OpenCoverage

readlink.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/readlink.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9static -
10 _Bool -
11 no_newline;-
12-
13-
14static -
15 _Bool -
16 verbose;-
17-
18static struct option const longopts[] =-
19{-
20 {"canonicalize", -
21 0-
22 , -
23 ((void *)0)-
24 , 'f'},-
25 {"canonicalize-existing", -
26 0-
27 , -
28 ((void *)0)-
29 , 'e'},-
30 {"canonicalize-missing", -
31 0-
32 , -
33 ((void *)0)-
34 , 'm'},-
35 {"no-newline", -
36 0-
37 , -
38 ((void *)0)-
39 , 'n'},-
40 {"quiet", -
41 0-
42 , -
43 ((void *)0)-
44 , 'q'},-
45 {"silent", -
46 0-
47 , -
48 ((void *)0)-
49 , 's'},-
50 {"verbose", -
51 0-
52 , -
53 ((void *)0)-
54 , 'v'},-
55 {"zero", -
56 0-
57 , -
58 ((void *)0)-
59 , 'z'},-
60 {"help", -
61 0-
62 , -
63 ((void *)0)-
64 , GETOPT_HELP_CHAR},-
65 {"version", -
66 0-
67 , -
68 ((void *)0)-
69 , GETOPT_VERSION_CHAR},-
70 {-
71 ((void *)0)-
72 , 0, -
73 ((void *)0)-
74 , 0}-
75};-
76-
77void-
78usage (int status)-
79{-
80 if (status !=
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 19 times by 1 test
Evaluated by:
  • readlink
3-19
81 0
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 19 times by 1 test
Evaluated by:
  • readlink
3-19
82 )-
83 do { fprintf (-
84 stderr-
85 , -
86 dcgettext (((void *)0), -
87 "Try '%s --help' for more information.\n"-
88 , 5)-
89 , program_name); }
executed 3 times by 1 test: end of block
Executed by:
  • readlink
while (0);
3
90 else-
91 {-
92 printf (-
93 dcgettext (((void *)0), -
94 "Usage: %s [OPTION]... FILE...\n"-
95 , 5)-
96 , program_name);-
97 fputs_unlocked (-
98 dcgettext (((void *)0), -
99 "Print value of a symbolic link or canonical file name\n\n"-
100 , 5)-
101 ,-
102 stdout-
103 )-
104 ;-
105 fputs_unlocked (-
106 dcgettext (((void *)0), -
107 " -f, --canonicalize canonicalize by following every symlink in\n every component of the given name recursively;\n all but the last component must exist\n -e, --canonicalize-existing canonicalize by following every symlink in\n every component of the given name recursively,\n all components must exist\n"-
108 , 5)-
109 ,-
110 stdout-
111 )-
112 ;-
113 fputs_unlocked (-
114 dcgettext (((void *)0), -
115 " -m, --canonicalize-missing canonicalize by following every symlink in\n every component of the given name recursively,\n without requirements on components existence\n -n, --no-newline do not output the trailing delimiter\n -q, --quiet\n -s, --silent suppress most error messages (on by default)\n -v, --verbose report error messages\n -z, --zero end each output line with NUL, not newline\n"-
116 , 5)-
117 ,-
118 stdout-
119 )-
120 ;-
121 fputs_unlocked (-
122 dcgettext (((void *)0), -
123 " --help display this help and exit\n"-
124 , 5)-
125 ,-
126 stdout-
127 );-
128 fputs_unlocked (-
129 dcgettext (((void *)0), -
130 " --version output version information and exit\n"-
131 , 5)-
132 ,-
133 stdout-
134 );-
135 emit_ancillary_info ("readlink");-
136 }
executed 19 times by 1 test: end of block
Executed by:
  • readlink
19
137 exit (status);
executed 22 times by 1 test: exit (status);
Executed by:
  • readlink
22
138}-
139-
140int-
141main (int argc, char **argv)-
142{-
143-
144 int can_mode = -1;-
145 int status = -
146 0-
147 ;-
148 int optc;-
149 -
150 _Bool -
151 use_nuls = -
152 0-
153 ;-
154-
155 ;-
156 set_program_name (argv[0]);-
157 setlocale (-
158 6-
159 , "");-
160 bindtextdomain ("coreutils", "/usr/local/share/locale");-
161 textdomain ("coreutils");-
162-
163 atexit (close_stdout);-
164-
165 while ((
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 256 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 216 times by 1 test
Evaluated by:
  • readlink
optc = getopt_long (argc, argv, "efmnqsvz", longopts,
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 256 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 216 times by 1 test
Evaluated by:
  • readlink
216-256
166 ((void *)0)
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 256 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 216 times by 1 test
Evaluated by:
  • readlink
216-256
167 )) != -1
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 256 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 216 times by 1 test
Evaluated by:
  • readlink
)
216-256
168 {-
169 switch (optc)-
170 {-
171 case
executed 63 times by 1 test: case 'e':
Executed by:
  • readlink
'e':
executed 63 times by 1 test: case 'e':
Executed by:
  • readlink
63
172 can_mode = CAN_EXISTING;-
173 break;
executed 63 times by 1 test: break;
Executed by:
  • readlink
63
174 case
executed 73 times by 1 test: case 'f':
Executed by:
  • readlink
'f':
executed 73 times by 1 test: case 'f':
Executed by:
  • readlink
73
175 can_mode = CAN_ALL_BUT_LAST;-
176 break;
executed 73 times by 1 test: break;
Executed by:
  • readlink
73
177 case
executed 67 times by 1 test: case 'm':
Executed by:
  • readlink
'm':
executed 67 times by 1 test: case 'm':
Executed by:
  • readlink
67
178 can_mode = CAN_MISSING;-
179 break;
executed 67 times by 1 test: break;
Executed by:
  • readlink
67
180 case
executed 5 times by 1 test: case 'n':
Executed by:
  • readlink
'n':
executed 5 times by 1 test: case 'n':
Executed by:
  • readlink
5
181 no_newline = -
182 1-
183 ;-
184 break;
executed 5 times by 1 test: break;
Executed by:
  • readlink
5
185 case
executed 2 times by 1 test: case 'q':
Executed by:
  • readlink
'q':
executed 2 times by 1 test: case 'q':
Executed by:
  • readlink
2
186 case
executed 2 times by 1 test: case 's':
Executed by:
  • readlink
's':
executed 2 times by 1 test: case 's':
Executed by:
  • readlink
2
187 verbose = -
188 0-
189 ;-
190 break;
executed 4 times by 1 test: break;
Executed by:
  • readlink
4
191 case
executed 6 times by 1 test: case 'v':
Executed by:
  • readlink
'v':
executed 6 times by 1 test: case 'v':
Executed by:
  • readlink
6
192 verbose = -
193 1-
194 ;-
195 break;
executed 6 times by 1 test: break;
Executed by:
  • readlink
6
196 case
executed 6 times by 1 test: case 'z':
Executed by:
  • readlink
'z':
executed 6 times by 1 test: case 'z':
Executed by:
  • readlink
6
197 use_nuls = -
198 1-
199 ;-
200 break;
executed 6 times by 1 test: break;
Executed by:
  • readlink
6
201 case
executed 19 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • readlink
GETOPT_HELP_CHAR:
executed 19 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • readlink
usage (
19
202 0-
203 ); break;
never executed: break;
;
0
204 case
executed 10 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • readlink
GETOPT_VERSION_CHAR:
executed 10 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • readlink
version_etc (
10
205 stdout-
206 , "readlink", "GNU coreutils", Version, ("Dmitry V. Levin"), (char *) -
207 ((void *)0)-
208 ); exit (
executed 10 times by 1 test: exit ( 0 );
Executed by:
  • readlink
10
209 0
executed 10 times by 1 test: exit ( 0 );
Executed by:
  • readlink
10
210 );
executed 10 times by 1 test: exit ( 0 );
Executed by:
  • readlink
break;
never executed: break;
;
0-10
211 default
executed 3 times by 1 test: default:
Executed by:
  • readlink
:
executed 3 times by 1 test: default:
Executed by:
  • readlink
3
212 usage (-
213 1-
214 );-
215 }
never executed: end of block
0
216 }-
217-
218 if (optind >= argc
optind >= argcDescription
TRUEnever evaluated
FALSEevaluated 216 times by 1 test
Evaluated by:
  • readlink
)
0-216
219 {-
220 error (0, 0, -
221 dcgettext (((void *)0), -
222 "missing operand"-
223 , 5)-
224 );-
225 usage (-
226 1-
227 );-
228 }
never executed: end of block
0
229-
230 if (argc - optind > 1
argc - optind > 1Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 209 times by 1 test
Evaluated by:
  • readlink
)
7-209
231 {-
232 if (no_newline
no_newlineDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 5 times by 1 test
Evaluated by:
  • readlink
)
2-5
233 error (0, 0,
executed 2 times by 1 test: error (0, 0, dcgettext (((void *)0), "ignoring --no-newline with multiple arguments" , 5) );
Executed by:
  • readlink
2
234 dcgettext (((void *)0),
executed 2 times by 1 test: error (0, 0, dcgettext (((void *)0), "ignoring --no-newline with multiple arguments" , 5) );
Executed by:
  • readlink
2
235 "ignoring --no-newline with multiple arguments"
executed 2 times by 1 test: error (0, 0, dcgettext (((void *)0), "ignoring --no-newline with multiple arguments" , 5) );
Executed by:
  • readlink
2
236 , 5)
executed 2 times by 1 test: error (0, 0, dcgettext (((void *)0), "ignoring --no-newline with multiple arguments" , 5) );
Executed by:
  • readlink
2
237 );
executed 2 times by 1 test: error (0, 0, dcgettext (((void *)0), "ignoring --no-newline with multiple arguments" , 5) );
Executed by:
  • readlink
2
238 no_newline = -
239 0-
240 ;-
241 }
executed 7 times by 1 test: end of block
Executed by:
  • readlink
7
242-
243 for (; optind < argc
optind < argcDescription
TRUEevaluated 224 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 216 times by 1 test
Evaluated by:
  • readlink
; ++optind)
216-224
244 {-
245 const char *fname = argv[optind];-
246 char *value = (can_mode != -1
can_mode != -1Description
TRUEevaluated 201 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 23 times by 1 test
Evaluated by:
  • readlink
23-201
247 ? canonicalize_filename_mode (fname, can_mode)-
248 : areadlink_with_size (fname, 63));-
249 if (value
valueDescription
TRUEevaluated 154 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 70 times by 1 test
Evaluated by:
  • readlink
)
70-154
250 {-
251 fputs_unlocked (value,-
252 stdout-
253 );-
254 if (! no_newline
! no_newlineDescription
TRUEevaluated 153 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 1 time by 1 test
Evaluated by:
  • readlink
)
1-153
255 putchar_unlocked (use_nuls ? '\0' : '\n');
executed 153 times by 1 test: putchar_unlocked (use_nuls ? '\0' : '\n');
Executed by:
  • readlink
153
256 free (value);-
257 }
executed 154 times by 1 test: end of block
Executed by:
  • readlink
154
258 else-
259 {-
260 status = -
261 1-
262 ;-
263 if (verbose
verboseDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • readlink
FALSEevaluated 68 times by 1 test
Evaluated by:
  • readlink
)
2-68
264 error (0,
executed 2 times by 1 test: error (0, (*__errno_location ()) , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, fname));
Executed by:
  • readlink
2
265 (*__errno_location ())
executed 2 times by 1 test: error (0, (*__errno_location ()) , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, fname));
Executed by:
  • readlink
2
266 , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, fname));
executed 2 times by 1 test: error (0, (*__errno_location ()) , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, fname));
Executed by:
  • readlink
2
267 }
executed 70 times by 1 test: end of block
Executed by:
  • readlink
70
268 }-
269-
270 return
executed 216 times by 1 test: return status;
Executed by:
  • readlink
status;
executed 216 times by 1 test: return status;
Executed by:
  • readlink
216
271}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2