OpenCoverage

cd.def

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/cd.def
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18-
19-
20extern const char * const bash_getcwd_errstr;-
21-
22static int bindpwd (int);-
23static int setpwd (char *);-
24static char *resetpwd (char *);-
25static int change_to_directory (char *, int, int);-
26-
27static int cdxattr (char *, char **);-
28static void resetxattr (void);-
29-
30-
31int cdspelling = 0;-
32-
33int cdable_vars;-
34-
35static int eflag;-
36static int xattrflag;-
37static int xattrfd = -1;-
38-
39-
40static int-
41setpwd (dirname)-
42 char *dirname;-
43{-
44 int old_anm;-
45 SHELL_VAR *tvar;-
46-
47 old_anm = array_needs_making;-
48 tvar = bind_variable ("PWD", dirname ? dirname : "", 0);-
49 if (tvar
tvarDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& ((((
((((tvar)->att... (0x0000002)))Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
tvar)->attributes) & (0x0000002)))
((((tvar)->att... (0x0000002)))Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
)
0-66
50 return
never executed: return 1;
1;
never executed: return 1;
0
51 if (tvar
tvarDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& old_anm == 0
old_anm == 0Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
&& array_needs_making
array_needs_makingDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& ((((
((((tvar)->att... (0x0000001)))Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tvar)->attributes) & (0x0000001)))
((((tvar)->att... (0x0000001)))Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-66
52 {-
53 update_export_env_inplace ("PWD=", 4, dirname ? dirname : "");-
54 array_needs_making = 0;-
55 }
executed 44 times by 1 test: end of block
Executed by:
  • Self test
44
56 return
executed 66 times by 1 test: return 0;
Executed by:
  • Self test
0;
executed 66 times by 1 test: return 0;
Executed by:
  • Self test
66
57}-
58-
59static int-
60bindpwd (no_symlinks)-
61 int no_symlinks;-
62{-
63 char *dirname, *pwdvar;-
64 int old_anm, r;-
65 SHELL_VAR *tvar;-
66-
67 r = sh_chkwrite (0);-
68-
69-
70 dirname = the_current_working_directory
the_current_working_directoryDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
? (no_symlinks
no_symlinksDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 65 times by 1 test
Evaluated by:
  • Self test
? sh_physpath (the_current_working_directory, 0) : the_current_working_directory)
0-66
71 : get_working_directory ("cd");-
72-
73-
74 old_anm = array_needs_making;-
75 pwdvar = get_string_value ("PWD");-
76-
77 tvar = bind_variable ("OLDPWD", pwdvar, 0);-
78 if (tvar
tvarDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& ((((
((((tvar)->att... (0x0000002)))Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
tvar)->attributes) & (0x0000002)))
((((tvar)->att... (0x0000002)))Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
)
0-66
79 r = 1;
never executed: r = 1;
0
80-
81 if (old_anm == 0
old_anm == 0Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
&& array_needs_making
array_needs_makingDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& ((((
((((tvar)->att... (0x0000001)))Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tvar)->attributes) & (0x0000001)))
((((tvar)->att... (0x0000001)))Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-44
82 {-
83 update_export_env_inplace ("OLDPWD=", 7, pwdvar);-
84 array_needs_making = 0;-
85 }
executed 44 times by 1 test: end of block
Executed by:
  • Self test
44
86-
87 if (setpwd (dirname) == 1
setpwd (dirname) == 1Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
)
0-66
88 r = 1;
never executed: r = 1;
0
89 if (dirname == 0
dirname == 0Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
&& eflag
eflagDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-66
90 r = 1;
never executed: r = 1;
0
91-
92 if (dirname
dirnameDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& dirname != the_current_working_directory
dirname != the...king_directoryDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 65 times by 1 test
Evaluated by:
  • Self test
)
0-66
93 sh_xfree((dirname), "./cd.def", 170);
executed 1 time by 1 test: sh_xfree((dirname), "./cd.def", 170);
Executed by:
  • Self test
1
94-
95 return
executed 66 times by 1 test: return (r);
Executed by:
  • Self test
(r);
executed 66 times by 1 test: return (r);
Executed by:
  • Self test
66
96}-
97-
98-
99-
100static char *-
101resetpwd (caller)-
102 char *caller;-
103{-
104 char *tdir;-
105-
106 do { if (the_current_working_directory
the_current_working_directoryDescription
TRUEnever evaluated
FALSEnever evaluated
) sh_xfree((the_current_working_directory), "./cd.def", 183);
never executed: sh_xfree((the_current_working_directory), "./cd.def", 183);
} while (0);
0
107 the_current_working_directory = (char *)-
108 ((void *)0)-
109 ;-
110 tdir = get_working_directory (caller);-
111 return
never executed: return (tdir);
(tdir);
never executed: return (tdir);
0
112}-
113-
114static int-
115cdxattr (dir, ndirp)-
116 char *dir;-
117 char **ndirp;-
118{-
119 return
never executed: return -1;
-1;
never executed: return -1;
0
120-
121}-
122-
123-
124static void-
125resetxattr ()-
126{-
127-
128-
129-
130-
131-
132-
133-
134 xattrfd = -1;-
135-
136}
executed 66 times by 1 test: end of block
Executed by:
  • Self test
66
137int-
138cd_builtin (list)-
139 WORD_LIST *list;-
140{-
141 char *dirname, *cdpath, *path, *temp;-
142 int path_index, no_symlinks, opt, lflag, e;-
143-
144-
145 if (restricted
restrictedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73 times by 1 test
Evaluated by:
  • Self test
)
1-73
146 {-
147 sh_restricted ((char *)-
148 ((void *)0)-
149 );-
150 return
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
1
151 }-
152-
153-
154 eflag = 0;-
155 no_symlinks = no_symbolic_links;-
156 xattrflag = 0;-
157 reset_internal_getopt ();-
158-
159-
160-
161 while ((
(opt = interna... "eLP")) != -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73 times by 1 test
Evaluated by:
  • Self test
opt = internal_getopt (list, "eLP")) != -1
(opt = interna... "eLP")) != -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73 times by 1 test
Evaluated by:
  • Self test
)
1-73
162-
163 {-
164 switch (opt)-
165 {-
166 case
executed 1 time by 1 test: case 'P':
Executed by:
  • Self test
'P':
executed 1 time by 1 test: case 'P':
Executed by:
  • Self test
1
167 no_symlinks = 1;-
168 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test
1
169 case
never executed: case 'L':
'L':
never executed: case 'L':
0
170 no_symlinks = 0;-
171 break;
never executed: break;
0
172 case
never executed: case 'e':
'e':
never executed: case 'e':
0
173 eflag = 1;-
174 break;
never executed: break;
0
175-
176-
177-
178-
179-
180 case
never executed: case -99:
-99:
never executed: case -99:
builtin_help (); return
never executed: return (258);
(258);
never executed: return (258);
0
181 default
never executed: default:
:
never executed: default:
0
182 builtin_usage ();-
183 return
never executed: return (258);
(258);
never executed: return (258);
0
184 }-
185 }-
186 list = loptend;-
187-
188 lflag = (cdable_vars
cdable_varsDescription
TRUEnever evaluated
FALSEevaluated 73 times by 1 test
Evaluated by:
  • Self test
? 0x001 : 0) |
0-73
189 ((interactive && cdspelling) ? 0x002 : 0);-
190 if (eflag
eflagDescription
TRUEnever evaluated
FALSEevaluated 73 times by 1 test
Evaluated by:
  • Self test
&& no_symlinks == 0
no_symlinks == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0-73
191 eflag = 0;
never executed: eflag = 0;
0
192-
193 if (list == 0
list == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 71 times by 1 test
Evaluated by:
  • Self test
)
2-71
194 {-
195-
196 dirname = get_string_value ("HOME");-
197-
198 if (dirname == 0
dirname == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1
199 {-
200 builtin_error (-
201 dcgettext (((void *)0), -
202 "HOME not set"-
203 , 5)-
204 );-
205 return
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
1
206 }-
207 lflag = 0;-
208 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
209-
210 else if (list->next
list->nextDescription
TRUEnever evaluated
FALSEevaluated 71 times by 1 test
Evaluated by:
  • Self test
)
0-71
211 {-
212 builtin_error (-
213 dcgettext (((void *)0), -
214 "too many arguments"-
215 , 5)-
216 );-
217 return
never executed: return (1);
(1);
never executed: return (1);
0
218 }-
219 else if (list->word->word[0] == '-'
list->word->word[0] == '-'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69 times by 1 test
Evaluated by:
  • Self test
&& list->word->word[1] == '\0'
list->word->word[1] == '\0'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-69
220 {-
221-
222 dirname = get_string_value ("OLDPWD");-
223-
224 if (dirname == 0
dirname == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1
225 {-
226 builtin_error (-
227 dcgettext (((void *)0), -
228 "OLDPWD not set"-
229 , 5)-
230 );-
231 return
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
1
232 }-
233-
234-
235-
236 lflag = 0x004;-
237-
238 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
239 else if (absolute_pathname (list->word->word)
absolute_pathn...t->word->word)Description
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
2-67
240 dirname = list->word->word;
executed 67 times by 1 test: dirname = list->word->word;
Executed by:
  • Self test
67
241 else if (privileged_mode == 0
privileged_mode == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& (
(cdpath = get_...ue ("CDPATH"))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
cdpath = get_string_value ("CDPATH"))
(cdpath = get_...ue ("CDPATH"))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
0-2
242 {-
243 dirname = list->word->word;-
244-
245-
246 path_index = 0;-
247 while (path = extract_colon_unit (cdpath, &path_index)
path = extract..., &path_index)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-2
248 {-
249-
250 opt = path[0] != '\0';-
251 temp = sh_makepath (path, dirname, 0x01);-
252 sh_xfree((path), "./cd.def", 367);-
253-
254 if (change_to_directory (temp, no_symlinks, xattrflag)
change_to_dire...ks, xattrflag)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1
255 {-
256-
257-
258-
259-
260 if (opt
optDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& (
(path = no_sym...ing_directory)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
path = no_symlinks ? temp : the_current_working_directory)
(path = no_sym...ing_directory)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-1
261 printf ("%s\n", path);
executed 1 time by 1 test: printf ("%s\n", path);
Executed by:
  • Self test
1
262-
263 sh_xfree((temp), "./cd.def", 378);-
264-
265-
266-
267-
268-
269 return
executed 1 time by 1 test: return (bindpwd (no_symlinks));
Executed by:
  • Self test
(bindpwd (no_symlinks));
executed 1 time by 1 test: return (bindpwd (no_symlinks));
Executed by:
  • Self test
1
270-
271 }-
272 else-
273 sh_xfree((temp), "./cd.def", 388);
executed 1 time by 1 test: sh_xfree((temp), "./cd.def", 388);
Executed by:
  • Self test
1
274 }-
275 }
never executed: end of block
0
276 else-
277 dirname = list->word->word;
executed 1 time by 1 test: dirname = list->word->word;
Executed by:
  • Self test
1
278-
279-
280-
281 if (change_to_directory (dirname, no_symlinks, xattrflag)
change_to_dire...ks, xattrflag)Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
)
5-65
282 {-
283 if (lflag & 0x004
lflag & 0x004Description
TRUEnever evaluated
FALSEevaluated 65 times by 1 test
Evaluated by:
  • Self test
)
0-65
284 printf ("%s\n", dirname);
never executed: printf ("%s\n", dirname);
0
285 return
executed 65 times by 1 test: return (bindpwd (no_symlinks));
Executed by:
  • Self test
(bindpwd (no_symlinks));
executed 65 times by 1 test: return (bindpwd (no_symlinks));
Executed by:
  • Self test
65
286 }-
287-
288-
289-
290-
291 if (lflag & 0x001
lflag & 0x001Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
)
0-5
292 {-
293 temp = get_string_value (dirname);-
294 if (temp
tempDescription
TRUEnever evaluated
FALSEnever evaluated
&& change_to_directory (temp, no_symlinks, xattrflag)
change_to_dire...ks, xattrflag)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
295 {-
296 printf ("%s\n", temp);-
297 return
never executed: return (bindpwd (no_symlinks));
(bindpwd (no_symlinks));
never executed: return (bindpwd (no_symlinks));
0
298 }-
299 }
never executed: end of block
0
300-
301-
302-
303-
304 if (lflag & 0x002
lflag & 0x002Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
)
0-5
305 {-
306 temp = dirspell (dirname);-
307 if (temp
tempDescription
TRUEnever evaluated
FALSEnever evaluated
&& change_to_directory (temp, no_symlinks, xattrflag)
change_to_dire...ks, xattrflag)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
308 {-
309 printf ("%s\n", temp);-
310 sh_xfree((temp), "./cd.def", 439);-
311 return
never executed: return (bindpwd (no_symlinks));
(bindpwd (no_symlinks));
never executed: return (bindpwd (no_symlinks));
0
312 }-
313 else-
314 do { if (temp
tempDescription
TRUEnever evaluated
FALSEnever evaluated
) sh_xfree((temp), "./cd.def", 443);
never executed: sh_xfree((temp), "./cd.def", 443);
}
never executed: end of block
while (0);
0
315 }-
316-
317 e = -
318 (*__errno_location ())-
319 ;-
320 temp = printable_filename (dirname, 0);-
321 builtin_error ("%s: %s", temp, strerror (e));-
322 if (temp != dirname
temp != dirnameDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
)
1-4
323 sh_xfree((temp), "./cd.def", 450);
executed 1 time by 1 test: sh_xfree((temp), "./cd.def", 450);
Executed by:
  • Self test
1
324 return
executed 5 times by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 5 times by 1 test: return (1);
Executed by:
  • Self test
5
325}-
326-
327-
328-
329static int verbatim_pwd;-
330-
331-
332int-
333pwd_builtin (list)-
334 WORD_LIST *list;-
335{-
336 char *directory;-
337 int opt, pflag;-
338-
339 verbatim_pwd = no_symbolic_links;-
340 pflag = 0;-
341 reset_internal_getopt ();-
342 while ((
(opt = interna..., "LP")) != -1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
opt = internal_getopt (list, "LP")) != -1
(opt = interna..., "LP")) != -1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
)
3-9
343 {-
344 switch (opt)-
345 {-
346 case
executed 2 times by 1 test: case 'P':
Executed by:
  • Self test
'P':
executed 2 times by 1 test: case 'P':
Executed by:
  • Self test
2
347 verbatim_pwd = pflag = 1;-
348 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
2
349 case
executed 1 time by 1 test: case 'L':
Executed by:
  • Self test
'L':
executed 1 time by 1 test: case 'L':
Executed by:
  • Self test
1
350 verbatim_pwd = 0;-
351 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test
1
352 case
never executed: case -99:
-99:
never executed: case -99:
builtin_help (); return
never executed: return (258);
(258);
never executed: return (258);
0
353 default
never executed: default:
:
never executed: default:
0
354 builtin_usage ();-
355 return
never executed: return (258);
(258);
never executed: return (258);
0
356 }-
357 }-
358 list = loptend;-
359-
360-
361-
362 directory = the_current_working_directory
the_current_working_directoryDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
? (verbatim_pwd
verbatim_pwdDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
? sh_physpath (the_current_working_directory, 0) : the_current_working_directory)
0-9
363 : get_working_directory ("pwd");-
364-
365-
366-
367 if ((the_current_working_directory
the_current_working_directoryDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& directory == 0
directory == 0Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
) ||
0-9
368 (posixly_correct
posixly_correctDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
&& same_file (".", the_current_working_directory, (struct stat *)0, (struct stat *)0) == 0
same_file ("."...stat *)0) == 0Description
TRUEnever evaluated
FALSEnever evaluated
))
0-9
369 {-
370 if (directory
directoryDescription
TRUEnever evaluated
FALSEnever evaluated
&& directory != the_current_working_directory
directory != t...king_directoryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
371 sh_xfree((directory), "./cd.def", 515);
never executed: sh_xfree((directory), "./cd.def", 515);
0
372 directory = resetpwd ("pwd");-
373 }
never executed: end of block
0
374-
375-
376-
377 if (directory
directoryDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-9
378 {-
379 opt = 0;-
380 printf ("%s\n", directory);-
381-
382 if (posixly_correct
posixly_correctDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
&& pflag
pflagDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-9
383 opt = setpwd (directory);
never executed: opt = setpwd (directory);
0
384 if (directory != the_current_working_directory
directory != t...king_directoryDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
2-7
385 sh_xfree((directory), "./cd.def", 529);
executed 2 times by 1 test: sh_xfree((directory), "./cd.def", 529);
Executed by:
  • Self test
2
386 return
executed 9 times by 1 test: return (sh_chkwrite (opt));
Executed by:
  • Self test
(sh_chkwrite (opt));
executed 9 times by 1 test: return (sh_chkwrite (opt));
Executed by:
  • Self test
9
387 }-
388 else-
389 return
never executed: return (1);
(1);
never executed: return (1);
0
390}-
391-
392-
393-
394-
395-
396-
397-
398static int-
399change_to_directory (newdir, nolinks, xattr)-
400 char *newdir;-
401 int nolinks, xattr;-
402{-
403 char *t, *tdir, *ndir;-
404 int err, canon_failed, r, ndlen;-
405-
406 tdir = (char *)-
407 ((void *)0)-
408 ;-
409-
410 if (the_current_working_directory == 0
the_current_wo...directory == 0Description
TRUEnever evaluated
FALSEevaluated 72 times by 1 test
Evaluated by:
  • Self test
)
0-72
411 {-
412 t = get_working_directory ("chdir");-
413 do { if (t
tDescription
TRUEnever evaluated
FALSEnever evaluated
) sh_xfree((t), "./cd.def", 555);
never executed: sh_xfree((t), "./cd.def", 555);
} while (0);
0
414 }
never executed: end of block
0
415-
416 t = make_absolute (newdir, the_current_working_directory);-
417-
418-
419-
420-
421 tdir = nolinks
nolinksDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 71 times by 1 test
Evaluated by:
  • Self test
? sh_physpath (t, 0)
1-71
422 : sh_canonpath (t, 0x0001|0x0002);-
423-
424 ndlen = strlen (newdir);-
425-
426-
427-
428 canon_failed = 0;-
429 if (tdir
tdirDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
&& *
*tdirDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tdir
*tdirDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-66
430 sh_xfree((t), "./cd.def", 572);
executed 66 times by 1 test: sh_xfree((t), "./cd.def", 572);
Executed by:
  • Self test
66
431 else-
432 {-
433 do { if (tdir
tdirDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
) sh_xfree((tdir), "./cd.def", 575);
never executed: sh_xfree((tdir), "./cd.def", 575);
} while (0);
0-6
434 tdir = t;-
435 canon_failed = 1;-
436 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
437-
438-
439-
440-
441 if (posixly_correct
posixly_correctDescription
TRUEnever evaluated
FALSEevaluated 72 times by 1 test
Evaluated by:
  • Self test
&& nolinks == 0
nolinks == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& canon_failed
canon_failedDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
0-72
442 (*
(*__errno_location ()) != 36Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) != 36Description
TRUEnever evaluated
FALSEnever evaluated
0
443 !=
(*__errno_location ()) != 36Description
TRUEnever evaluated
FALSEnever evaluated
0
444 36
(*__errno_location ()) != 36Description
TRUEnever evaluated
FALSEnever evaluated
0
445 || ndlen >
ndlen > 4096Description
TRUEnever evaluated
FALSEnever evaluated
0
446 4096
ndlen > 4096Description
TRUEnever evaluated
FALSEnever evaluated
0
447 ))-
448 {-
449-
450 if (-
451 (*
(*__errno_location ()) != 2Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) != 2Description
TRUEnever evaluated
FALSEnever evaluated
0
452 !=
(*__errno_location ()) != 2Description
TRUEnever evaluated
FALSEnever evaluated
0
453 2
(*__errno_location ()) != 2Description
TRUEnever evaluated
FALSEnever evaluated
0
454 && -
455 (*
(*__errno_location ()) != 36Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) != 36Description
TRUEnever evaluated
FALSEnever evaluated
0
456 !=
(*__errno_location ()) != 36Description
TRUEnever evaluated
FALSEnever evaluated
0
457 36
(*__errno_location ()) != 36Description
TRUEnever evaluated
FALSEnever evaluated
0
458 )-
459-
460-
461-
462 -
463(*
never executed: (*__errno_location ()) = 20 ;
never executed: (*__errno_location ()) = 20 ;
__errno_location ())
never executed: (*__errno_location ()) = 20 ;
0
464 =
never executed: (*__errno_location ()) = 20 ;
0
465 20
never executed: (*__errno_location ()) = 20 ;
0
466 ;
never executed: (*__errno_location ()) = 20 ;
0
467 sh_xfree((tdir), "./cd.def", 591);-
468 return
never executed: return (0);
(0);
never executed: return (0);
0
469 }-
470 {-
471 r = chdir (nolinks ? newdir : tdir);-
472 if (r >= 0
r >= 0Description
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
)
6-66
473 resetxattr ();
executed 66 times by 1 test: resetxattr ();
Executed by:
  • Self test
66
474 }-
475-
476-
477 if (r == 0
r == 0Description
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
)
6-66
478 {-
479-
480-
481 if (canon_failed
canon_failedDescription
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
)
0-66
482 {-
483 t = resetpwd ("cd");-
484 if (t == 0
t == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
485 set_working_directory (tdir);
never executed: set_working_directory (tdir);
0
486 else-
487 sh_xfree((t), "./cd.def", 632);
never executed: sh_xfree((t), "./cd.def", 632);
0
488 }-
489 else-
490 set_working_directory (tdir);
executed 66 times by 1 test: set_working_directory (tdir);
Executed by:
  • Self test
66
491-
492 sh_xfree((tdir), "./cd.def", 637);-
493 return
executed 66 times by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 66 times by 1 test: return (1);
Executed by:
  • Self test
66
494 }-
495-
496-
497-
498 if (nolinks
nolinksDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
)
0-6
499 {-
500 sh_xfree((tdir), "./cd.def", 645);-
501 return
never executed: return (0);
(0);
never executed: return (0);
0
502 }-
503-
504 err = -
505 (*__errno_location ())-
506 ;-
507-
508-
509-
510-
511 if (chdir (newdir) == 0
chdir (newdir) == 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
)
0-6
512 {-
513 t = resetpwd ("cd");-
514 if (t == 0
t == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
515 set_working_directory (tdir);
never executed: set_working_directory (tdir);
0
516 else-
517 sh_xfree((t), "./cd.def", 660);
never executed: sh_xfree((t), "./cd.def", 660);
0
518-
519 r = 1;-
520 }
never executed: end of block
0
521 else-
522 {-
523 -
524 (*__errno_location ()) -
525 = err;-
526 r = 0;-
527 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
528-
529 sh_xfree((tdir), "./cd.def", 670);-
530 return
executed 6 times by 1 test: return r;
Executed by:
  • Self test
r;
executed 6 times by 1 test: return r;
Executed by:
  • Self test
6
531}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2