OpenCoverage

hash.def

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/hash.def
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11extern int dot_found_in_search;-
12-
13static int add_hashed_command (char *, int);-
14static int print_hash_info (BUCKET_CONTENTS *);-
15static int print_portable_hash_info (BUCKET_CONTENTS *);-
16static int print_hashed_commands (int);-
17static int list_hashed_filename_targets (WORD_LIST *, int);-
18-
19-
20-
21-
22int-
23hash_builtin (list)-
24 WORD_LIST *list;-
25{-
26 int expunge_hash_table, list_targets, list_portably, delete, opt;-
27 char *w, *pathname;-
28-
29 if (hashing_enabled == 0
hashing_enabled == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 46 times by 1 test
Evaluated by:
  • Self test
)
5-46
30 {-
31 builtin_error (-
32 dcgettext (((void *)0), -
33 "hashing disabled"-
34 , 5)-
35 );-
36 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
37 }-
38-
39 expunge_hash_table = list_targets = list_portably = delete = 0;-
40 pathname = (char *)-
41 ((void *)0)-
42 ;-
43 reset_internal_getopt ();-
44 while ((
(opt = interna...lp:rt")) != -1Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 41 times by 1 test
Evaluated by:
  • Self test
opt = internal_getopt (list, "dlp:rt")) != -1
(opt = interna...lp:rt")) != -1Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 41 times by 1 test
Evaluated by:
  • Self test
)
23-41
45 {-
46 switch (opt)-
47 {-
48 case
never executed: case 'd':
'd':
never executed: case 'd':
0
49 delete = 1;-
50 break;
never executed: break;
0
51 case
never executed: case 'l':
'l':
never executed: case 'l':
0
52 list_portably = 1;-
53 break;
never executed: break;
0
54 case
executed 6 times by 1 test: case 'p':
Executed by:
  • Self test
'p':
executed 6 times by 1 test: case 'p':
Executed by:
  • Self test
6
55 pathname = list_optarg;-
56 break;
executed 6 times by 1 test: break;
Executed by:
  • Self test
6
57 case
executed 12 times by 1 test: case 'r':
Executed by:
  • Self test
'r':
executed 12 times by 1 test: case 'r':
Executed by:
  • Self test
12
58 expunge_hash_table = 1;-
59 break;
executed 12 times by 1 test: break;
Executed by:
  • Self test
12
60 case
never executed: case 't':
't':
never executed: case 't':
0
61 list_targets = 1;-
62 break;
never executed: break;
0
63 case
never executed: case -99:
-99:
never executed: case -99:
builtin_help (); return
never executed: return (258);
(258);
never executed: return (258);
0
64 default
executed 5 times by 1 test: default:
Executed by:
  • Self test
:
executed 5 times by 1 test: default:
Executed by:
  • Self test
5
65 builtin_usage ();-
66 return
executed 5 times by 1 test: return (258);
Executed by:
  • Self test
(258);
executed 5 times by 1 test: return (258);
Executed by:
  • Self test
5
67 }-
68 }-
69 list = loptend;-
70-
71-
72 if (list == 0
list == 0Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
&& list_targets
list_targetsDescription
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
)
0-22
73 {-
74 sh_needarg ("-t");-
75 return
never executed: return (1);
(1);
never executed: return (1);
0
76 }-
77-
78-
79-
80 if (list == 0
list == 0Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
&& expunge_hash_table == 0
expunge_hash_table == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
)
10-22
81 {-
82 opt = print_hashed_commands (list_portably);-
83 if (opt == 0
opt == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
&& posixly_correct == 0
posixly_correct == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-7
84 printf (
executed 7 times by 1 test: printf ( dcgettext (((void *)0), "%s: hash table empty\n" , 5) , this_command_name);
Executed by:
  • Self test
7
85 dcgettext (((void *)0),
executed 7 times by 1 test: printf ( dcgettext (((void *)0), "%s: hash table empty\n" , 5) , this_command_name);
Executed by:
  • Self test
7
86 "%s: hash table empty\n"
executed 7 times by 1 test: printf ( dcgettext (((void *)0), "%s: hash table empty\n" , 5) , this_command_name);
Executed by:
  • Self test
7
87 , 5)
executed 7 times by 1 test: printf ( dcgettext (((void *)0), "%s: hash table empty\n" , 5) , this_command_name);
Executed by:
  • Self test
7
88 , this_command_name);
executed 7 times by 1 test: printf ( dcgettext (((void *)0), "%s: hash table empty\n" , 5) , this_command_name);
Executed by:
  • Self test
7
89-
90 return
executed 10 times by 1 test: return (0);
Executed by:
  • Self test
(0);
executed 10 times by 1 test: return (0);
Executed by:
  • Self test
10
91 }-
92-
93 if (expunge_hash_table
expunge_hash_tableDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
)
12-19
94 phash_flush ();
executed 12 times by 1 test: phash_flush ();
Executed by:
  • Self test
12
95-
96-
97 if (list_targets
list_targetsDescription
TRUEnever evaluated
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
)
0-31
98 return
never executed: return (list_hashed_filename_targets (list, list_portably));
(list_hashed_filename_targets (list, list_portably));
never executed: return (list_hashed_filename_targets (list, list_portably));
0
99-
100-
101 if (restricted
restrictedDescription
TRUEnever evaluated
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
&& pathname
pathnameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-31
102 {-
103 if (-
104 (
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
__extension__ (__builtin_constant_p (
__builtin_constant_p ( '/' )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
105 '/'
__builtin_constant_p ( '/' )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
106 )
__builtin_constant_p ( '/' )Description
TRUEnever evaluated
FALSEnever evaluated
&& !__builtin_constant_p (
!__builtin_con...p ( pathname )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
107 pathname
!__builtin_con...p ( pathname )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
108 )
!__builtin_con...p ( pathname )Description
TRUEnever evaluated
FALSEnever evaluated
&& (
( '/' ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
109 '/'
( '/' ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
110 ) == '\0'
( '/' ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
? (char *) __rawmemchr (
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
111 pathname
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
112 ,
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
113 '/'
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
114 ) : __builtin_strchr (
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
115 pathname
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
116 ,
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
117 '/'
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
118 )))
(__extension__...name , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
0
119 )-
120 {-
121 sh_restricted (pathname);-
122 return
never executed: return (1);
(1);
never executed: return (1);
0
123 }-
124-
125-
126 w = find_user_command (pathname);-
127 if (w == 0
w == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| *
*w == 0Description
TRUEnever evaluated
FALSEnever evaluated
w == 0
*w == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| executable_file (w) == 0
executable_file (w) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
128 {-
129 sh_notfound (pathname);-
130 sh_xfree((w), "./hash.def", 164);-
131 return
never executed: return (1);
(1);
never executed: return (1);
0
132 }-
133 sh_xfree((w), "./hash.def", 167);-
134 }
never executed: end of block
0
135-
136-
137 for (opt = 0; list
listDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
; list = list->next)
19-31
138 {-
139-
140 w = list->word->word;-
141 if (absolute_program (w)
absolute_program (w)Description
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
)
0-19
142 continue;
never executed: continue;
0
143 else if (pathname
pathnameDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
)
6-13
144 {-
145 if (is_directory (pathname)
is_directory (pathname)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
)
0-6
146 {-
147-
148 builtin_error ("%s: %s", pathname, strerror (-
149 21-
150 ));-
151-
152-
153-
154 opt = 1;-
155 }
never executed: end of block
0
156 else-
157 phash_insert (w, pathname, 0, 0);
executed 6 times by 1 test: phash_insert (w, pathname, 0, 0);
Executed by:
  • Self test
6
158 }-
159 else if (delete
deleteDescription
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
)
0-13
160 {-
161 if (phash_remove (w)
phash_remove (w)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
162 {-
163 sh_notfound (w);-
164 opt = 1;-
165 }
never executed: end of block
0
166 }
never executed: end of block
0
167 else if (add_hashed_command (w, 0)
add_hashed_command (w, 0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
)
5-8
168 opt = 1;
executed 5 times by 1 test: opt = 1;
Executed by:
  • Self test
5
169 }
executed 19 times by 1 test: end of block
Executed by:
  • Self test
19
170-
171 fflush (-
172 stdout-
173 );-
174 return
executed 31 times by 1 test: return (opt);
Executed by:
  • Self test
(opt);
executed 31 times by 1 test: return (opt);
Executed by:
  • Self test
31
175}-
176-
177static int-
178add_hashed_command (w, quiet)-
179 char *w;-
180 int quiet;-
181{-
182 int rv;-
183 char *full_path;-
184-
185 rv = 0;-
186 if (find_function (w) == 0
find_function (w) == 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& find_shell_builtin (w) == 0
find_shell_builtin (w) == 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-13
187 {-
188 phash_remove (w);-
189 full_path = find_user_command (w);-
190 if (full_path
full_pathDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
&& executable_file (full_path)
executable_file (full_path)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-8
191 phash_insert (w, full_path, dot_found_in_search, 0);
executed 8 times by 1 test: phash_insert (w, full_path, dot_found_in_search, 0);
Executed by:
  • Self test
8
192 else-
193 {-
194 if (quiet == 0
quiet == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-5
195 sh_notfound (w);
executed 5 times by 1 test: sh_notfound (w);
Executed by:
  • Self test
5
196 rv++;-
197 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test
5
198 do { if (full_path
full_pathDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
) sh_xfree((full_path), "./hash.def", 228);
executed 8 times by 1 test: sh_xfree((full_path), "./hash.def", 228);
Executed by:
  • Self test
} while (0);
5-8
199 }
executed 13 times by 1 test: end of block
Executed by:
  • Self test
13
200 return
executed 13 times by 1 test: return (rv);
Executed by:
  • Self test
(rv);
executed 13 times by 1 test: return (rv);
Executed by:
  • Self test
13
201}-
202-
203-
204static int-
205print_hash_info (item)-
206 BUCKET_CONTENTS *item;-
207{-
208 printf ("%4d\t%s\n", item->times_found, ((PATH_DATA *)(item)->data)->path);-
209 return
executed 8 times by 1 test: return 0;
Executed by:
  • Self test
0;
executed 8 times by 1 test: return 0;
Executed by:
  • Self test
8
210}-
211-
212static int-
213print_portable_hash_info (item)-
214 BUCKET_CONTENTS *item;-
215{-
216 char *fp, *fn;-
217-
218 fp = printable_filename (((PATH_DATA *)(item)->data)->path, 1);-
219 fn = printable_filename (item->key, 1);-
220 printf ("builtin hash -p %s %s\n", fp, fn);-
221 if (fp != ((PATH_DATA *)(item)->data)->path
fp != ((PATH_D...)->data)->pathDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
222 sh_xfree((fp), "./hash.def", 252);
never executed: sh_xfree((fp), "./hash.def", 252);
0
223 if (fn != item->key
fn != item->keyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
224 sh_xfree((fn), "./hash.def", 254);
never executed: sh_xfree((fn), "./hash.def", 254);
0
225 return
never executed: return 0;
0;
never executed: return 0;
0
226}-
227-
228static int-
229print_hashed_commands (fmt)-
230 int fmt;-
231{-
232 if (hashed_filenames == 0
hashed_filenames == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
|| ((
((hashed_filen...ries : 0) == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
hashed_filenames) ? (hashed_filenames)->nentries : 0) == 0
((hashed_filen...ries : 0) == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
0-7
233 return
executed 7 times by 1 test: return (0);
Executed by:
  • Self test
(0);
executed 7 times by 1 test: return (0);
Executed by:
  • Self test
7
234-
235 if (fmt == 0
fmt == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-3
236 printf (
executed 3 times by 1 test: printf ( dcgettext (((void *)0), "hits\tcommand\n" , 5) );
Executed by:
  • Self test
3
237 dcgettext (((void *)0),
executed 3 times by 1 test: printf ( dcgettext (((void *)0), "hits\tcommand\n" , 5) );
Executed by:
  • Self test
3
238 "hits\tcommand\n"
executed 3 times by 1 test: printf ( dcgettext (((void *)0), "hits\tcommand\n" , 5) );
Executed by:
  • Self test
3
239 , 5)
executed 3 times by 1 test: printf ( dcgettext (((void *)0), "hits\tcommand\n" , 5) );
Executed by:
  • Self test
3
240 );
executed 3 times by 1 test: printf ( dcgettext (((void *)0), "hits\tcommand\n" , 5) );
Executed by:
  • Self test
3
241 hash_walk (hashed_filenames, fmt ? print_portable_hash_info : print_hash_info);-
242 return
executed 3 times by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 3 times by 1 test: return (1);
Executed by:
  • Self test
3
243}-
244-
245static int-
246list_hashed_filename_targets (list, fmt)-
247 WORD_LIST *list;-
248 int fmt;-
249{-
250 int all_found, multiple;-
251 char *target;-
252 WORD_LIST *l;-
253-
254 all_found = 1;-
255 multiple = list->next != 0;-
256-
257 for (l = list; l
lDescription
TRUEnever evaluated
FALSEnever evaluated
; l = l->next)
0
258 {-
259 target = phash_search (l->word->word);-
260 if (target == 0
target == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
261 {-
262 all_found = 0;-
263 sh_notfound (l->word->word);-
264 continue;
never executed: continue;
0
265 }-
266 if (fmt
fmtDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
267 printf ("builtin hash -p %s %s\n", target, l->word->word);
never executed: printf ("builtin hash -p %s %s\n", target, l->word->word);
0
268 else-
269 {-
270 if (multiple
multipleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
271 printf ("%s\t", l->word->word);
never executed: printf ("%s\t", l->word->word);
0
272 printf ("%s\n", target);-
273 }
never executed: end of block
0
274 sh_xfree((target), "./hash.def", 300);-
275 }
never executed: end of block
0
276-
277 return
never executed: return (all_found ? 0 : 1);
(all_found ? 0 : 1);
never executed: return (all_found ? 0 : 1);
0
278}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2