Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/dirname.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | static 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 | - | |||||||||||||||||||||||||
26 | void | - | ||||||||||||||||||||||||
27 | usage (int status) | - | ||||||||||||||||||||||||
28 | { | - | ||||||||||||||||||||||||
29 | if (status !=
| 4-5 | ||||||||||||||||||||||||
30 | 0
| 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: while (0);end of block Executed by:
| 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:
| 5 | ||||||||||||||||||||||||
97 | exit (status); executed 9 times by 1 test: exit (status); Executed by:
| 9 | ||||||||||||||||||||||||
98 | } | - | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | int | - | ||||||||||||||||||||||||
101 | main (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
| 14-22 | ||||||||||||||||||||||||
131 | break; executed 22 times by 1 test: break; Executed by:
| 22 | ||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||
133 | switch (c) | - | ||||||||||||||||||||||||
134 | { | - | ||||||||||||||||||||||||
135 | case executed 2 times by 1 test: 'z':case 'z': Executed by:
executed 2 times by 1 test: case 'z': Executed by:
| 2 | ||||||||||||||||||||||||
136 | use_nuls = | - | ||||||||||||||||||||||||
137 | 1 | - | ||||||||||||||||||||||||
138 | ; | - | ||||||||||||||||||||||||
139 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||
141 | case executed 5 times by 1 test: GETOPT_HELP_CHAR:case GETOPT_HELP_CHAR: Executed by:
executed 5 times by 1 test: usage (case GETOPT_HELP_CHAR: Executed by:
| 5 | ||||||||||||||||||||||||
142 | 0 | - | ||||||||||||||||||||||||
143 | ); break; never executed: ;break; | 0 | ||||||||||||||||||||||||
144 | case executed 4 times by 1 test: GETOPT_VERSION_CHAR:case GETOPT_VERSION_CHAR: Executed by:
executed 4 times by 1 test: version_etc (case GETOPT_VERSION_CHAR: Executed by:
| 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:
| 4 | ||||||||||||||||||||||||
149 | 0 executed 4 times by 1 test: exit ( 0 ); Executed by:
| 4 | ||||||||||||||||||||||||
150 | ); executed 4 times by 1 test: break;exit ( 0 ); Executed by:
never executed: ;break; | 0-4 | ||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||
152 | default executed 3 times by 1 test: :default: Executed by:
executed 3 times by 1 test: default: Executed by:
| 3 | ||||||||||||||||||||||||
153 | usage ( | - | ||||||||||||||||||||||||
154 | 1 | - | ||||||||||||||||||||||||
155 | ); | - | ||||||||||||||||||||||||
156 | } never executed: end of block | 0 | ||||||||||||||||||||||||
157 | } | - | ||||||||||||||||||||||||
158 | - | |||||||||||||||||||||||||
159 | if (argc < optind + 1
| 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
| 21-22 | ||||||||||||||||||||||||
172 | { | - | ||||||||||||||||||||||||
173 | result = argv[optind]; | - | ||||||||||||||||||||||||
174 | len = dir_len (result); | - | ||||||||||||||||||||||||
175 | - | |||||||||||||||||||||||||
176 | if (! len
| 3-19 | ||||||||||||||||||||||||
177 | { | - | ||||||||||||||||||||||||
178 | result = ˙ | - | ||||||||||||||||||||||||
179 | len = 1; | - | ||||||||||||||||||||||||
180 | } executed 3 times by 1 test: end of block Executed by:
| 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
never executed: ((size_t) (break; | 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:
| 22 | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | return executed 21 times by 1 test: return 0 ; Executed by:
executed 21 times by 1 test: return 0 ; Executed by:
| 21 | ||||||||||||||||||||||||
231 | 0 executed 21 times by 1 test: return 0 ; Executed by:
| 21 | ||||||||||||||||||||||||
232 | ; executed 21 times by 1 test: return 0 ; Executed by:
| 21 | ||||||||||||||||||||||||
233 | } | - | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |