OpenCoverage

dirname.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/dirname.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2static struct option const longopts[] =-
3{-
4 {"zero", -
5 0-
6 , -
7 ((void *)0)-
8 , 'z'},-
9 {"help", -
10 0-
11 , -
12 ((void *)0)-
13 , GETOPT_HELP_CHAR},-
14 {"version", -
15 0-
16 , -
17 ((void *)0)-
18 , GETOPT_VERSION_CHAR},-
19 {-
20 ((void *)0)-
21 , 0, -
22 ((void *)0)-
23 , 0}-
24};-
25-
26void-
27usage (int status)-
28{-
29 if (status !=
status != 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • dirname
FALSEevaluated 5 times by 1 test
Evaluated by:
  • dirname
4-5
30 0
status != 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • dirname
FALSEevaluated 5 times by 1 test
Evaluated by:
  • dirname
4-5
31 )-
32 do { fprintf (-
33 stderr-
34 , -
35 dcgettext (((void *)0), -
36 "Try '%s --help' for more information.\n"-
37 , 5)-
38 , program_name); }
executed 4 times by 1 test: end of block
Executed by:
  • dirname
while (0);
4
39 else-
40 {-
41 printf (-
42 dcgettext (((void *)0), -
43 "Usage: %s [OPTION] NAME...\n"-
44 , 5)-
45-
46 -
47 ,-
48 program_name);-
49 fputs_unlocked (-
50 dcgettext (((void *)0), -
51 "Output each NAME with its last non-slash component and trailing slashes\nremoved; if NAME contains no /'s, output '.' (meaning the current directory).\n\n"-
52 , 5)-
53 ,-
54 stdout-
55 )-
56-
57-
58-
59 ;-
60 fputs_unlocked (-
61 dcgettext (((void *)0), -
62 " -z, --zero end each output line with NUL, not newline\n"-
63 , 5)-
64 ,-
65 stdout-
66 )-
67-
68 ;-
69 fputs_unlocked (-
70 dcgettext (((void *)0), -
71 " --help display this help and exit\n"-
72 , 5)-
73 ,-
74 stdout-
75 );-
76 fputs_unlocked (-
77 dcgettext (((void *)0), -
78 " --version output version information and exit\n"-
79 , 5)-
80 ,-
81 stdout-
82 );-
83 printf (-
84 dcgettext (((void *)0), -
85 "\nExamples:\n %s /usr/bin/ -> \"/usr\"\n %s dir1/str dir2/str -> \"dir1\" followed by \"dir2\"\n %s stdio.h -> \".\"\n"-
86 , 5)-
87-
88-
89-
90-
91-
92 -
93 ,-
94 program_name, program_name, program_name);-
95 emit_ancillary_info ("dirname");-
96 }
executed 5 times by 1 test: end of block
Executed by:
  • dirname
5
97 exit (status);
executed 9 times by 1 test: exit (status);
Executed by:
  • dirname
9
98}-
99-
100int-
101main (int argc, char **argv)-
102{-
103 static char const dot = '.';-
104 -
105 _Bool -
106 use_nuls = -
107 0-
108 ;-
109 char const *result;-
110 size_t len;-
111-
112 ;-
113 set_program_name (argv[0]);-
114 setlocale (-
115 6-
116 , "");-
117 bindtextdomain ("coreutils", "/usr/local/share/locale");-
118 textdomain ("coreutils");-
119-
120 atexit (close_stdout);-
121-
122 while (-
123 1-
124 )-
125 {-
126 int c = getopt_long (argc, argv, "z", longopts, -
127 ((void *)0)-
128 );-
129-
130 if (c == -1
c == -1Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • dirname
FALSEevaluated 14 times by 1 test
Evaluated by:
  • dirname
)
14-22
131 break;
executed 22 times by 1 test: break;
Executed by:
  • dirname
22
132-
133 switch (c)-
134 {-
135 case
executed 2 times by 1 test: case 'z':
Executed by:
  • dirname
'z':
executed 2 times by 1 test: case 'z':
Executed by:
  • dirname
2
136 use_nuls = -
137 1-
138 ;-
139 break;
executed 2 times by 1 test: break;
Executed by:
  • dirname
2
140-
141 case
executed 5 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • dirname
GETOPT_HELP_CHAR:
executed 5 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • dirname
usage (
5
142 0-
143 ); break;
never executed: break;
;
0
144 case
executed 4 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • dirname
GETOPT_VERSION_CHAR:
executed 4 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • dirname
version_etc (
4
145 stdout-
146 , "dirname", "GNU coreutils", Version, ("David MacKenzie"), ("Jim Meyering"), (char *) -
147 ((void *)0)-
148 ); exit (
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • dirname
4
149 0
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • dirname
4
150 );
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • dirname
break;
never executed: break;
;
0-4
151-
152 default
executed 3 times by 1 test: default:
Executed by:
  • dirname
:
executed 3 times by 1 test: default:
Executed by:
  • dirname
3
153 usage (-
154 1-
155 );-
156 }
never executed: end of block
0
157 }-
158-
159 if (argc < optind + 1
argc < optind + 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • dirname
FALSEevaluated 21 times by 1 test
Evaluated by:
  • dirname
)
1-21
160 {-
161 error (0, 0, -
162 dcgettext (((void *)0), -
163 "missing operand"-
164 , 5)-
165 );-
166 usage (-
167 1-
168 );-
169 }
never executed: end of block
0
170-
171 for (; optind < argc
optind < argcDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • dirname
FALSEevaluated 21 times by 1 test
Evaluated by:
  • dirname
; optind++)
21-22
172 {-
173 result = argv[optind];-
174 len = dir_len (result);-
175-
176 if (! len
! lenDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • dirname
FALSEevaluated 19 times by 1 test
Evaluated by:
  • dirname
)
3-19
177 {-
178 result = &dot;-
179 len = 1;-
180 }
executed 3 times by 1 test: end of block
Executed by:
  • dirname
3
181-
182 -
183 (__extension__ ((__builtin_constant_p (-
184 1-
185 ) && __builtin_constant_p (-
186 len-
187 ) && (size_t) (-
188 1-
189 ) * (size_t) (-
190 len-
191 ) <= 8 && (size_t) (-
192 1-
193 ) != 0) ? ({ const char *__ptr = (const char *) (-
194 result-
195 ); FILE *__stream = (stdout); size_t __cnt; for (__cnt = (size_t) (-
196 1-
197 ) * (size_t) (-
198 len-
199 ); __cnt > 0
__cnt > 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • dirname
FALSEevaluated 3 times by 1 test
Evaluated by:
  • dirname
; --__cnt) if ((
(__builtin_exp...r++))) == (-1)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • dirname
__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0)
__builtin_expe...write_end), 0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • dirname
FALSEnever evaluated
? __overflow (__stream, (unsigned char) (*__ptr++)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (*__ptr++))) == (-1)
(__builtin_exp...r++))) == (-1)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • dirname
) break;
never executed: break;
((size_t) (
0-3
200 1-
201 ) * (size_t) (-
202 len-
203 ) - __cnt) / (size_t) (-
204 1-
205 ); }) : (((__builtin_constant_p (-
206 1-
207 ) && (size_t) (-
208 1-
209 ) == 0) || (__builtin_constant_p (-
210 len-
211 ) && (size_t) (-
212 len-
213 ) == 0)) ? ((void) (-
214 result-
215 ), (void) (stdout), (void) (-
216 1-
217 ), (void) (-
218 len-
219 ), (size_t) 0) : fwrite_unlocked (-
220 result-
221 , -
222 1-
223 , -
224 len-
225 , stdout))))-
226 ;-
227 putchar_unlocked (use_nuls ? '\0' :'\n');-
228 }
executed 22 times by 1 test: end of block
Executed by:
  • dirname
22
229-
230 return
executed 21 times by 1 test: return 0 ;
Executed by:
  • dirname
executed 21 times by 1 test: return 0 ;
Executed by:
  • dirname
21
231 0
executed 21 times by 1 test: return 0 ;
Executed by:
  • dirname
21
232 ;
executed 21 times by 1 test: return 0 ;
Executed by:
  • dirname
21
233}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2