OpenCoverage

mapfile.def

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/mapfile.def
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17static int run_callback (const char *, unsigned int, const char *);-
18static int delim;-
19-
20static int-
21run_callback (callback, curindex, curline)-
22 const char *callback;-
23 unsigned int curindex;-
24 const char *curline;-
25{-
26 unsigned int execlen;-
27 char *execstr, *qline;-
28 int flags;-
29-
30 qline = sh_single_quote (curline);-
31 execlen = strlen (callback) + strlen (qline) + 10;-
32-
33-
34 execlen += 3;-
35 execstr = sh_xmalloc((execlen), "./mapfile.def", 123);-
36-
37 flags = 0x004;-
38-
39-
40-
41-
42 snprintf (execstr, execlen, "%s %d %s", callback, curindex, qline);-
43 sh_xfree((qline), "./mapfile.def", 131);-
44 return
executed 31 times by 1 test: return evalstring (execstr, ((void *)0) , flags);
Executed by:
  • Self test
evalstring (execstr,
executed 31 times by 1 test: return evalstring (execstr, ((void *)0) , flags);
Executed by:
  • Self test
31
45 ((void *)0)
executed 31 times by 1 test: return evalstring (execstr, ((void *)0) , flags);
Executed by:
  • Self test
31
46 , flags);
executed 31 times by 1 test: return evalstring (execstr, ((void *)0) , flags);
Executed by:
  • Self test
31
47}-
48-
49static void-
50do_chop(line, delim)-
51 char *line;-
52 unsigned char delim;-
53{-
54 int length;-
55-
56 length = strlen (line);-
57 if (length
lengthDescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& line[length-1] == delim
line[length-1] == delimDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
0-59
58 line[length-1] = '\0';
executed 56 times by 1 test: line[length-1] = '\0';
Executed by:
  • Self test
56
59}
executed 59 times by 1 test: end of block
Executed by:
  • Self test
59
60-
61static int-
62mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_name, delim, flags)-
63 int fd;-
64 long line_count_goal, origin, nskip, callback_quantum;-
65 char *callback, *array_name;-
66 int delim;-
67 int flags;-
68{-
69 char *line;-
70 size_t line_length;-
71 unsigned int array_index, line_count;-
72 SHELL_VAR *entry;-
73 int unbuffered_read;-
74-
75 line = -
76 ((void *)0)-
77 ;-
78 line_length = 0;-
79 unbuffered_read = 0;-
80-
81-
82-
83-
84 entry = find_or_make_array_variable (array_name, 1);-
85 if (entry == 0
entry == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
|| ((((
((((entry)->at... (0x0000002)))Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
entry)->attributes) & (0x0000002)))
((((entry)->at... (0x0000002)))Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
|| ((((
((((entry)->at... (0x0004000)))Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
entry)->attributes) & (0x0004000)))
((((entry)->at... (0x0004000)))Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
)
0-23
86 {-
87 if (entry
entryDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
&& ((((
((((entry)->at... (0x0000002)))Description
TRUEnever evaluated
FALSEnever evaluated
entry)->attributes) & (0x0000002)))
((((entry)->at... (0x0000002)))Description
TRUEnever evaluated
FALSEnever evaluated
)
0-2
88 err_readonly (array_name);
never executed: err_readonly (array_name);
0
89-
90 return
executed 2 times by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 2 times by 1 test: return (1);
Executed by:
  • Self test
2
91 }-
92 else if (((((
((((entry)->at...000004))) == 0Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
entry)->attributes) & (0x0000004))) == 0
((((entry)->at...000004))) == 0Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
)
0-23
93 {-
94 builtin_error (-
95 dcgettext (((void *)0), -
96 "%s: not an indexed array"-
97 , 5)-
98 , array_name);-
99 return
never executed: return (1);
(1);
never executed: return (1);
0
100 }-
101 else if (((((
((((entry)->at... (0x0001000)))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
entry)->attributes) & (0x0001000)))
((((entry)->at... (0x0001000)))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
)
4-19
102 ((
executed 4 times by 1 test: ((entry)->attributes &= ~(0x0001000));
Executed by:
  • Self test
entry)->attributes &= ~(0x0001000));
executed 4 times by 1 test: ((entry)->attributes &= ~(0x0001000));
Executed by:
  • Self test
4
103-
104 if (flags & 0x01
flags & 0x01Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
2-21
105 array_flush ((ARRAY *)((entry)->value));
executed 21 times by 1 test: array_flush ((ARRAY *)((entry)->value));
Executed by:
  • Self test
21
106-
107-
108 unbuffered_read = (
(lseek (fd, 0L, 1 ) < 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
lseek (fd, 0L,
(lseek (fd, 0L, 1 ) < 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
2-21
109 1
(lseek (fd, 0L, 1 ) < 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
2-21
110 ) < 0)
(lseek (fd, 0L, 1 ) < 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
&& (
( (*__errno_lo...on ()) == 29 )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-21
111 (*__errno_location ())
( (*__errno_lo...on ()) == 29 )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
112 ==
( (*__errno_lo...on ()) == 29 )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
113 29
( (*__errno_lo...on ()) == 29 )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
114 )
( (*__errno_lo...on ()) == 29 )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
;
0-2
115-
116-
117-
118-
119 if (delim != '\n'
delim != '\n'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
)
1-22
120 unbuffered_read = 1;
executed 1 time by 1 test: unbuffered_read = 1;
Executed by:
  • Self test
1
121-
122 zreset ();-
123-
124-
125 for (line_count = 0; line_count < nskip
line_count < nskipDescription
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
; line_count++)
0-23
126 if (zgetline (fd, &line, &line_length, delim, unbuffered_read) < 0
zgetline (fd, ...ered_read) < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
127 break;
never executed: break;
0
128-
129 line = 0;-
130 line_length = 0;-
131-
132-
133 for (array_index = origin, line_count = 1;-
134 zgetline (fd, &line, &line_length, delim, unbuffered_read) != -1
zgetline (fd, ...ed_read) != -1Description
TRUEevaluated 141 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
;
20-141
135 array_index++)-
136 {-
137-
138 if (flags & 0x02
flags & 0x02Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 82 times by 1 test
Evaluated by:
  • Self test
)
59-82
139 do_chop (line, delim);
executed 59 times by 1 test: do_chop (line, delim);
Executed by:
  • Self test
59
140-
141-
142 if (callback
callbackDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 81 times by 1 test
Evaluated by:
  • Self test
&& line_count
line_countDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& (
(line_count % ..._quantum) == 0Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test
line_count % callback_quantum) == 0
(line_count % ..._quantum) == 0Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test
)
0-81
143 {-
144 run_callback (callback, array_index, line);-
145-
146-
147 if (unbuffered_read == 0
unbuffered_read == 0Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
)
4-27
148 zsyncfd (fd);
executed 27 times by 1 test: zsyncfd (fd);
Executed by:
  • Self test
27
149 }
executed 31 times by 1 test: end of block
Executed by:
  • Self test
31
150-
151-
152-
153 bind_array_element (entry, array_index, line, 0);-
154-
155-
156 line_count++;-
157 if (line_count_goal != 0
line_count_goal != 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 126 times by 1 test
Evaluated by:
  • Self test
&& line_count > line_count_goal
line_count > line_count_goalDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
)
3-126
158 break;
executed 3 times by 1 test: break;
Executed by:
  • Self test
3
159 }
executed 138 times by 1 test: end of block
Executed by:
  • Self test
138
160-
161 sh_xfree((line), "./mapfile.def", 235);-
162-
163 if (unbuffered_read == 0
unbuffered_read == 0Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
2-21
164 zsyncfd (fd);
executed 21 times by 1 test: zsyncfd (fd);
Executed by:
  • Self test
21
165-
166 return
executed 23 times by 1 test: return 0;
Executed by:
  • Self test
0;
executed 23 times by 1 test: return 0;
Executed by:
  • Self test
23
167}-
168-
169int-
170mapfile_builtin (list)-
171 WORD_LIST *list;-
172{-
173 int opt, code, fd, flags;-
174 intmax_t intval;-
175 long lines, origin, nskip, callback_quantum;-
176 char *array_name, *callback;-
177-
178 fd = 0;-
179 lines = origin = nskip = 0;-
180 flags = 0x01;-
181 callback_quantum = 5000;-
182 callback = 0;-
183 delim = '\n';-
184-
185 reset_internal_getopt ();-
186 while ((
(opt = interna...:c:s:")) != -1Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
opt = internal_getopt (list, "d:u:n:O:tC:c:s:")) != -1
(opt = interna...:c:s:")) != -1Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
)
25
187 {-
188 switch (opt)-
189 {-
190 case
executed 1 time by 1 test: case 'd':
Executed by:
  • Self test
'd':
executed 1 time by 1 test: case 'd':
Executed by:
  • Self test
1
191 delim = *list_optarg;-
192 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test
1
193 case
executed 1 time by 1 test: case 'u':
Executed by:
  • Self test
'u':
executed 1 time by 1 test: case 'u':
Executed by:
  • Self test
1
194 code = legal_number (list_optarg, &intval);-
195 if (code == 0
code == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
|| intval < 0
intval < 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
|| intval != (int)intval
intval != (int)intvalDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
0-1
196 {-
197 builtin_error (-
198 dcgettext (((void *)0), -
199 "%s: invalid file descriptor specification"-
200 , 5)-
201 , list_optarg);-
202 return
never executed: return (1);
(1);
never executed: return (1);
0
203 }-
204 else-
205 fd = intval;
executed 1 time by 1 test: fd = intval;
Executed by:
  • Self test
1
206-
207 if (sh_validfd (fd) == 0
sh_validfd (fd) == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
0-1
208 {-
209 builtin_error (-
210 dcgettext (((void *)0), -
211 "%d: invalid file descriptor: %s"-
212 , 5)-
213 , fd, strerror (-
214 (*__errno_location ())-
215 ));-
216 return
never executed: return (1);
(1);
never executed: return (1);
0
217 }-
218 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test
1
219-
220 case
executed 4 times by 1 test: case 'n':
Executed by:
  • Self test
'n':
executed 4 times by 1 test: case 'n':
Executed by:
  • Self test
4
221 code = legal_number (list_optarg, &intval);-
222 if (code == 0
code == 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
|| intval < 0
intval < 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
|| intval != (unsigned)intval
intval != (unsigned)intvalDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
)
0-4
223 {-
224 builtin_error (-
225 dcgettext (((void *)0), -
226 "%s: invalid line count"-
227 , 5)-
228 , list_optarg);-
229 return
never executed: return (1);
(1);
never executed: return (1);
0
230 }-
231 else-
232 lines = intval;
executed 4 times by 1 test: lines = intval;
Executed by:
  • Self test
4
233 break;
executed 4 times by 1 test: break;
Executed by:
  • Self test
4
234-
235 case
executed 2 times by 1 test: case 'O':
Executed by:
  • Self test
'O':
executed 2 times by 1 test: case 'O':
Executed by:
  • Self test
2
236 code = legal_number (list_optarg, &intval);-
237 if (code == 0
code == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
|| intval < 0
intval < 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
|| intval != (unsigned)intval
intval != (unsigned)intvalDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
238 {-
239 builtin_error (-
240 dcgettext (((void *)0), -
241 "%s: invalid array origin"-
242 , 5)-
243 , list_optarg);-
244 return
never executed: return (1);
(1);
never executed: return (1);
0
245 }-
246 else-
247 origin = intval;
executed 2 times by 1 test: origin = intval;
Executed by:
  • Self test
2
248 flags &= ~0x01;-
249 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
2
250 case
executed 5 times by 1 test: case 't':
Executed by:
  • Self test
't':
executed 5 times by 1 test: case 't':
Executed by:
  • Self test
5
251 flags |= 0x02;-
252 break;
executed 5 times by 1 test: break;
Executed by:
  • Self test
5
253 case
executed 6 times by 1 test: case 'C':
Executed by:
  • Self test
'C':
executed 6 times by 1 test: case 'C':
Executed by:
  • Self test
6
254 callback = list_optarg;-
255 break;
executed 6 times by 1 test: break;
Executed by:
  • Self test
6
256 case
executed 6 times by 1 test: case 'c':
Executed by:
  • Self test
'c':
executed 6 times by 1 test: case 'c':
Executed by:
  • Self test
6
257 code = legal_number (list_optarg, &intval);-
258 if (code == 0
code == 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
|| intval <= 0
intval <= 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
|| intval != (unsigned)intval
intval != (unsigned)intvalDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
)
0-6
259 {-
260 builtin_error (-
261 dcgettext (((void *)0), -
262 "%s: invalid callback quantum"-
263 , 5)-
264 , list_optarg);-
265 return
never executed: return (1);
(1);
never executed: return (1);
0
266 }-
267 else-
268 callback_quantum = intval;
executed 6 times by 1 test: callback_quantum = intval;
Executed by:
  • Self test
6
269 break;
executed 6 times by 1 test: break;
Executed by:
  • Self test
6
270 case
never executed: case 's':
's':
never executed: case 's':
0
271 code = legal_number (list_optarg, &intval);-
272 if (code == 0
code == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| intval < 0
intval < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| intval != (unsigned)intval
intval != (unsigned)intvalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
273 {-
274 builtin_error (-
275 dcgettext (((void *)0), -
276 "%s: invalid line count"-
277 , 5)-
278 , list_optarg);-
279 return
never executed: return (1);
(1);
never executed: return (1);
0
280 }-
281 else-
282 nskip = intval;
never executed: nskip = intval;
0
283 break;
never executed: break;
0
284 case
never executed: case -99:
-99:
never executed: case -99:
builtin_help (); return
never executed: return (258);
(258);
never executed: return (258);
0
285 default
never executed: default:
:
never executed: default:
0
286 builtin_usage ();-
287 return
never executed: return (258);
(258);
never executed: return (258);
0
288 }-
289 }-
290 list = loptend;-
291-
292 if (list == 0
list == 0Description
TRUEnever evaluated
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
)
0-25
293 array_name = "MAPFILE";
never executed: array_name = "MAPFILE";
0
294 else if (list->word == 0
list->word == 0Description
TRUEnever evaluated
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
|| list->word->word == 0
list->word->word == 0Description
TRUEnever evaluated
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
)
0-25
295 {-
296 builtin_error ("internal error: getting variable name");-
297 return
never executed: return (1);
(1);
never executed: return (1);
0
298 }-
299 else if (list->word->word[0] == '\0'
list->word->word[0] == '\0'Description
TRUEnever evaluated
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
)
0-25
300 {-
301 builtin_error (-
302 dcgettext (((void *)0), -
303 "empty array variable name"-
304 , 5)-
305 );-
306 return
never executed: return (258);
(258);
never executed: return (258);
0
307 }-
308 else-
309 array_name = list->word->word;
executed 25 times by 1 test: array_name = list->word->word;
Executed by:
  • Self test
25
310-
311 if (legal_identifier (array_name) == 0
legal_identifi...ray_name) == 0Description
TRUEnever evaluated
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
)
0-25
312 {-
313 sh_invalidid (array_name);-
314 return
never executed: return (1);
(1);
never executed: return (1);
0
315 }-
316-
317 return
executed 25 times by 1 test: return mapfile (fd, lines, origin, nskip, callback_quantum, callback, array_name, delim, flags);
Executed by:
  • Self test
mapfile (fd, lines, origin, nskip, callback_quantum, callback, array_name, delim, flags);
executed 25 times by 1 test: return mapfile (fd, lines, origin, nskip, callback_quantum, callback, array_name, delim, flags);
Executed by:
  • Self test
25
318}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2