OpenCoverage

expand-common.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/expand-common.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* expand-common - common functionality for expand/unexapnd-
2 Copyright (C) 1989-2018 Free Software Foundation, Inc.-
3-
4 This program is free software: you can redistribute it and/or modify-
5 it under the terms of the GNU General Public License as published by-
6 the Free Software Foundation, either version 3 of the License, or-
7 (at your option) any later version.-
8-
9 This program is distributed in the hope that it will be useful,-
10 but WITHOUT ANY WARRANTY; without even the implied warranty of-
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
12 GNU General Public License for more details.-
13-
14 You should have received a copy of the GNU General Public License-
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */-
16-
17#include <config.h>-
18-
19#include <assert.h>-
20#include <stdio.h>-
21#include <sys/types.h>-
22#include "system.h"-
23#include "die.h"-
24#include "error.h"-
25#include "fadvise.h"-
26#include "quote.h"-
27#include "xstrndup.h"-
28-
29#include "expand-common.h"-
30-
31/* If true, convert blanks even after nonblank characters have been-
32 read on the line. */-
33bool convert_entire_line = false;-
34-
35/* If nonzero, the size of all tab stops. If zero, use 'tab_list' instead. */-
36static uintmax_t tab_size = 0;-
37-
38/* If nonzero, the size of all tab stops after the last specifed. */-
39static uintmax_t extend_size = 0;-
40-
41/* If nonzero, an increment for additional tab stops after the last specified.*/-
42static uintmax_t increment_size = 0;-
43-
44/* The maximum distance between tab stops. */-
45size_t max_column_width;-
46-
47/* Array of the explicit column numbers of the tab stops;-
48 after 'tab_list' is exhausted, each additional tab is replaced-
49 by a space. The first column is column 0. */-
50static uintmax_t *tab_list = NULL;-
51-
52/* The number of allocated entries in 'tab_list'. */-
53static size_t n_tabs_allocated = 0;-
54-
55/* The index of the first invalid element of 'tab_list',-
56 where the next element can be added. */-
57static size_t first_free_tab = 0;-
58-
59/* Null-terminated array of input filenames. */-
60static char **file_list = NULL;-
61-
62/* Default for 'file_list' if no files are given on the command line. */-
63static char *stdin_argv[] =-
64{-
65 (char *) "-", NULL-
66};-
67-
68/* True if we have ever read standard input. */-
69static bool have_read_stdin = false;-
70-
71/* The desired exit status. */-
72int exit_status = EXIT_SUCCESS;-
73-
74-
75-
76/* Add tab stop TABVAL to the end of 'tab_list'. */-
77extern void-
78add_tab_stop (uintmax_t tabval)-
79{-
80 uintmax_t prev_column = first_free_tab ? tab_list[first_free_tab - 1] : 0;
first_free_tabDescription
TRUEevaluated 39 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 68 times by 2 tests
Evaluated by:
  • expand
  • unexpand
39-68
81 uintmax_t column_width = prev_column <= tabval ? tabval - prev_column : 0;
prev_column <= tabvalDescription
TRUEevaluated 107 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEnever evaluated
0-107
82-
83 if (first_free_tab == n_tabs_allocated)
first_free_tab...tabs_allocatedDescription
TRUEevaluated 68 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 39 times by 2 tests
Evaluated by:
  • expand
  • unexpand
39-68
84 tab_list = X2NREALLOC (tab_list, &n_tabs_allocated);
executed 68 times by 2 tests: tab_list = ((void) (!!sizeof (struct { _Static_assert (sizeof *(tab_list) != 1, "verify_true (" "sizeof *(tab_list) != 1" ")"); int _gl_dummy; })), x2nrealloc (tab_list, &n_tabs_allocated, sizeof *(tab_list)));
Executed by:
  • expand
  • unexpand
68
85 tab_list[first_free_tab++] = tabval;-
86-
87 if (max_column_width < column_width)
max_column_wid...< column_widthDescription
TRUEevaluated 76 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 31 times by 2 tests
Evaluated by:
  • expand
  • unexpand
31-76
88 {-
89 if (SIZE_MAX < column_width)
(1844674407370...< column_widthDescription
TRUEnever evaluated
FALSEevaluated 76 times by 2 tests
Evaluated by:
  • expand
  • unexpand
0-76
90 die (EXIT_FAILURE, 0, _("tabs are too far apart"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"tabs are too far apart\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "tabs are too far apart" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "tabs are too far apart" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
91 max_column_width = column_width;-
92 }
executed 76 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
76
93}
executed 107 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
107
94-
95static bool-
96set_extend_size (uintmax_t tabval)-
97{-
98 bool ok = true;-
99-
100 if (extend_size)
extend_sizeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 12 times by 1 test
Evaluated by:
  • expand
2-12
101 {-
102 error (0, 0,-
103 _("'/' specifier only allowed"-
104 " with the last value"));-
105 ok = false;-
106 }
executed 2 times by 1 test: end of block
Executed by:
  • expand
2
107 extend_size = tabval;-
108-
109 return ok;
executed 14 times by 1 test: return ok;
Executed by:
  • expand
14
110}-
111-
112static bool-
113set_increment_size (uintmax_t tabval)-
114{-
115 bool ok = true;-
116-
117 if (increment_size)
increment_sizeDescription
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • expand
0-11
118 {-
119 error (0,0,-
120 _("'+' specifier only allowed"-
121 " with the last value"));-
122 ok = false;-
123 }
never executed: end of block
0
124 increment_size = tabval;-
125-
126 return ok;
executed 11 times by 1 test: return ok;
Executed by:
  • expand
11
127}-
128-
129/* Add the comma or blank separated list of tab stops STOPS-
130 to the list of tab stops. */-
131extern void-
132parse_tab_stops (char const *stops)-
133{-
134 bool have_tabval = false;-
135 uintmax_t tabval = 0;-
136 bool extend_tabval = false;-
137 bool increment_tabval = false;-
138 char const *num_start = NULL;-
139 bool ok = true;-
140-
141 for (; *stops; stops++)
*stopsDescription
TRUEevaluated 238 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 84 times by 2 tests
Evaluated by:
  • expand
  • unexpand
84-238
142 {-
143 if (*stops == ',' || isblank (to_uchar (*stops)))
*stops == ','Description
TRUEevaluated 46 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 192 times by 2 tests
Evaluated by:
  • expand
  • unexpand
((*__ctype_b_l...int) _ISblank)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 187 times by 2 tests
Evaluated by:
  • expand
  • unexpand
5-192
144 {-
145 if (have_tabval)
have_tabvalDescription
TRUEevaluated 43 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 8 times by 1 test
Evaluated by:
  • expand
8-43
146 {-
147 if (extend_tabval)
extend_tabvalDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 41 times by 2 tests
Evaluated by:
  • expand
  • unexpand
2-41
148 {-
149 if (! set_extend_size (tabval))
! set_extend_size (tabval)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • expand
FALSEevaluated 1 time by 1 test
Evaluated by:
  • expand
1
150 {-
151 ok = false;-
152 break;
executed 1 time by 1 test: break;
Executed by:
  • expand
1
153 }-
154 }
executed 1 time by 1 test: end of block
Executed by:
  • expand
1
155 else if (increment_tabval)
increment_tabvalDescription
TRUEnever evaluated
FALSEevaluated 41 times by 2 tests
Evaluated by:
  • expand
  • unexpand
0-41
156 {-
157 if (! set_increment_size (tabval))
! set_increment_size (tabval)Description
TRUEnever evaluated
FALSEnever evaluated
0
158 {-
159 ok = false;-
160 break;
never executed: break;
0
161 }-
162 }
never executed: end of block
0
163 else-
164 add_tab_stop (tabval);
executed 41 times by 2 tests: add_tab_stop (tabval);
Executed by:
  • expand
  • unexpand
41
165 }-
166 have_tabval = false;-
167 }
executed 50 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
50
168 else if (*stops == '/')
*stops == '/'Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 169 times by 2 tests
Evaluated by:
  • expand
  • unexpand
18-169
169 {-
170 if (have_tabval)
have_tabvalDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • expand
FALSEevaluated 17 times by 1 test
Evaluated by:
  • expand
1-17
171 {-
172 error (0, 0, _("'/' specifier not at start of number: %s"),-
173 quote (stops));-
174 ok = false;-
175 }
executed 1 time by 1 test: end of block
Executed by:
  • expand
1
176 extend_tabval = true;-
177 increment_tabval = false;-
178 }
executed 18 times by 1 test: end of block
Executed by:
  • expand
18
179 else if (*stops == '+')
*stops == '+'Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 155 times by 2 tests
Evaluated by:
  • expand
  • unexpand
14-155
180 {-
181 if (have_tabval)
have_tabvalDescription
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • expand
0-14
182 {-
183 error (0, 0, _("'+' specifier not at start of number: %s"),-
184 quote (stops));-
185 ok = false;-
186 }
never executed: end of block
0
187 increment_tabval = true;-
188 extend_tabval = false;-
189 }
executed 14 times by 1 test: end of block
Executed by:
  • expand
14
190 else if (ISDIGIT (*stops))
((unsigned int...s) - '0' <= 9)Description
TRUEevaluated 146 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • expand
  • unexpand
9-146
191 {-
192 if (!have_tabval)
!have_tabvalDescription
TRUEevaluated 123 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 23 times by 1 test
Evaluated by:
  • expand
23-123
193 {-
194 tabval = 0;-
195 have_tabval = true;-
196 num_start = stops;-
197 }
executed 123 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
123
198-
199 /* Detect overflow. */-
200 if (!DECIMAL_DIGIT_ACCUMULATE (tabval, *stops - '0', uintmax_t))
!( (void) (&(t... '0')), 1 )) )Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • expand
FALSEevaluated 145 times by 2 tests
Evaluated by:
  • expand
  • unexpand
(uintmax_t) -1 / 10 < (tabval)Description
TRUEnever evaluated
FALSEevaluated 146 times by 2 tests
Evaluated by:
  • expand
  • unexpand
(uintmax_t) ((...')) < (tabval)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • expand
FALSEevaluated 145 times by 2 tests
Evaluated by:
  • expand
  • unexpand
0-146
201 {-
202 size_t len = strspn (num_start, "0123456789");-
203 char *bad_num = xstrndup (num_start, len);-
204 error (0, 0, _("tab stop is too large %s"), quote (bad_num));-
205 free (bad_num);-
206 ok = false;-
207 stops = num_start + len - 1;-
208 }
executed 1 time by 1 test: end of block
Executed by:
  • expand
1
209 }
executed 146 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
146
210 else-
211 {-
212 error (0, 0, _("tab size contains invalid character(s): %s"),-
213 quote (stops));-
214 ok = false;-
215 break;
executed 9 times by 2 tests: break;
Executed by:
  • expand
  • unexpand
9
216 }-
217 }-
218-
219 if (ok && have_tabval)
okDescription
TRUEevaluated 82 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • expand
  • unexpand
have_tabvalDescription
TRUEevaluated 78 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 4 times by 1 test
Evaluated by:
  • expand
4-82
220 {-
221 if (extend_tabval)
extend_tabvalDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 66 times by 2 tests
Evaluated by:
  • expand
  • unexpand
12-66
222 ok &= set_extend_size (tabval);
executed 12 times by 1 test: ok &= set_extend_size (tabval);
Executed by:
  • expand
12
223 else if (increment_tabval)
increment_tabvalDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 55 times by 2 tests
Evaluated by:
  • expand
  • unexpand
11-55
224 ok &= set_increment_size (tabval);
executed 11 times by 1 test: ok &= set_increment_size (tabval);
Executed by:
  • expand
11
225 else-
226 add_tab_stop (tabval);
executed 55 times by 2 tests: add_tab_stop (tabval);
Executed by:
  • expand
  • unexpand
55
227 }-
228-
229 if (! ok)
! okDescription
TRUEevaluated 13 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 81 times by 2 tests
Evaluated by:
  • expand
  • unexpand
13-81
230 exit (EXIT_FAILURE);
executed 13 times by 2 tests: exit ( 1 );
Executed by:
  • expand
  • unexpand
13
231}
executed 81 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
81
232-
233/* Check that the list of tab stops TABS, with ENTRIES entries,-
234 contains only nonzero, ascending values. */-
235-
236static void-
237validate_tab_stops (uintmax_t const *tabs, size_t entries)-
238{-
239 uintmax_t prev_tab = 0;-
240-
241 for (size_t i = 0; i < entries; i++)
i < entriesDescription
TRUEevaluated 107 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 108 times by 2 tests
Evaluated by:
  • expand
  • unexpand
107-108
242 {-
243 if (tabs[i] == 0)
tabs[i] == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • expand
FALSEevaluated 106 times by 2 tests
Evaluated by:
  • expand
  • unexpand
1-106
244 die (EXIT_FAILURE, 0, _("tab size cannot be 0"));
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"tab size cannot be 0\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "tab size cannot be 0" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "tab size cannot be 0" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
Executed by:
  • expand
1
245 if (tabs[i] <= prev_tab)
tabs[i] <= prev_tabDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • expand
FALSEevaluated 105 times by 2 tests
Evaluated by:
  • expand
  • unexpand
1-105
246 die (EXIT_FAILURE, 0, _("tab sizes must be ascending"));
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"tab sizes must be ascending\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "tab sizes must be ascending" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "tab sizes must be ascending" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
Executed by:
  • expand
1
247 prev_tab = tabs[i];-
248 }
executed 105 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
105
249-
250 if (increment_size && extend_size)
increment_sizeDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 97 times by 2 tests
Evaluated by:
  • expand
  • unexpand
extend_sizeDescription
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • expand
0-97
251 die (EXIT_FAILURE, 0, _("'/' specifier is mutually exclusive with '+'"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"'/' specifier is mutually exclusive with '+'\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "'/' specifier is mutually exclusive with '+'" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "'/' specifier is mutually exclusive with '+'" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
252}
executed 108 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
108
253-
254/* Called after all command-line options have been parsed,-
255 and add_tab_stop/parse_tab_stops have been called.-
256 Will validate the tab-stop values,-
257 and set the final values to:-
258 tab-stops = 8 (if no tab-stops given on command line)-
259 tab-stops = N (if value N specified as the only value).-
260 tab-stops = distinct values given on command line (if multiple values given).-
261*/-
262extern void-
263finalize_tab_stops (void)-
264{-
265 validate_tab_stops (tab_list, first_free_tab);-
266-
267 if (first_free_tab == 0)
first_free_tab == 0Description
TRUEevaluated 42 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 66 times by 2 tests
Evaluated by:
  • expand
  • unexpand
42-66
268 tab_size = max_column_width = extend_size
executed 42 times by 2 tests: tab_size = max_column_width = extend_size ? extend_size : increment_size ? increment_size : 8;
Executed by:
  • expand
  • unexpand
extend_sizeDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 37 times by 2 tests
Evaluated by:
  • expand
  • unexpand
5-42
269 ? extend_size : increment_size
executed 42 times by 2 tests: tab_size = max_column_width = extend_size ? extend_size : increment_size ? increment_size : 8;
Executed by:
  • expand
  • unexpand
increment_sizeDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • expand
  • unexpand
5-42
270 ? increment_size : 8;
executed 42 times by 2 tests: tab_size = max_column_width = extend_size ? extend_size : increment_size ? increment_size : 8;
Executed by:
  • expand
  • unexpand
42
271 else if (first_free_tab == 1 && ! extend_size && ! increment_size)
first_free_tab == 1Description
TRUEevaluated 37 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • expand
  • unexpand
! extend_sizeDescription
TRUEevaluated 34 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 3 times by 1 test
Evaluated by:
  • expand
! increment_sizeDescription
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 4 times by 1 test
Evaluated by:
  • expand
3-37
272 tab_size = tab_list[0];
executed 30 times by 2 tests: tab_size = tab_list[0];
Executed by:
  • expand
  • unexpand
30
273 else-
274 tab_size = 0;
executed 36 times by 2 tests: tab_size = 0;
Executed by:
  • expand
  • unexpand
36
275}-
276-
277-
278extern uintmax_t-
279get_next_tab_column (const uintmax_t column, size_t* tab_index,-
280 bool* last_tab)-
281{-
282 *last_tab = false;-
283-
284 /* single tab-size - return multiples of it */-
285 if (tab_size)
tab_sizeDescription
TRUEevaluated 204 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 136 times by 2 tests
Evaluated by:
  • expand
  • unexpand
136-204
286 return column + (tab_size - column % tab_size);
executed 204 times by 2 tests: return column + (tab_size - column % tab_size);
Executed by:
  • expand
  • unexpand
204
287-
288 /* multiple tab-sizes - iterate them until the tab position is beyond-
289 the current input column. */-
290 for ( ; *tab_index < first_free_tab ; (*tab_index)++ )
*tab_index < first_free_tabDescription
TRUEevaluated 171 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 37 times by 2 tests
Evaluated by:
  • expand
  • unexpand
37-171
291 {-
292 uintmax_t tab = tab_list[*tab_index];-
293 if (column < tab)
column < tabDescription
TRUEevaluated 99 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • expand
  • unexpand
72-99
294 return tab;
executed 99 times by 2 tests: return tab;
Executed by:
  • expand
  • unexpand
99
295 }
executed 72 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
72
296-
297 /* relative last tab - return multiples of it */-
298 if (extend_size)
extend_sizeDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 27 times by 2 tests
Evaluated by:
  • expand
  • unexpand
10-27
299 return column + (extend_size - column % extend_size);
executed 10 times by 1 test: return column + (extend_size - column % extend_size);
Executed by:
  • expand
10
300-
301 /* incremental last tab - add increment_size to the previous tab stop */-
302 if (increment_size)
increment_sizeDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • expand
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • expand
  • unexpand
13-14
303 {-
304 uintmax_t end_tab = tab_list[first_free_tab - 1];-
305-
306 return column + (increment_size - ((column - end_tab) % increment_size));
executed 13 times by 1 test: return column + (increment_size - ((column - end_tab) % increment_size));
Executed by:
  • expand
13
307 }-
308-
309 *last_tab = true;-
310 return 0;
executed 14 times by 2 tests: return 0;
Executed by:
  • expand
  • unexpand
14
311}-
312-
313-
314-
315-
316/* Sets new file-list */-
317extern void-
318set_file_list (char **list)-
319{-
320 have_read_stdin = false;-
321-
322 if (!list)
!listDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 104 times by 2 tests
Evaluated by:
  • expand
  • unexpand
4-104
323 file_list = stdin_argv;
executed 4 times by 2 tests: file_list = stdin_argv;
Executed by:
  • expand
  • unexpand
4
324 else-
325 file_list = list;
executed 104 times by 2 tests: file_list = list;
Executed by:
  • expand
  • unexpand
104
326}-
327-
328/* Close the old stream pointer FP if it is non-NULL,-
329 and return a new one opened to read the next input file.-
330 Open a filename of '-' as the standard input.-
331 Return NULL if there are no more input files. */-
332-
333extern FILE *-
334next_file (FILE *fp)-
335{-
336 static char *prev_file;-
337 char *file;-
338-
339 if (fp)
fpDescription
TRUEevaluated 111 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 108 times by 2 tests
Evaluated by:
  • expand
  • unexpand
108-111
340 {-
341 assert (prev_file);-
342 if (ferror (fp))
ferror_unlocked (fp)Description
TRUEnever evaluated
FALSEevaluated 111 times by 2 tests
Evaluated by:
  • expand
  • unexpand
0-111
343 {-
344 error (0, errno, "%s", quotef (prev_file));-
345 exit_status = EXIT_FAILURE;-
346 }
never executed: end of block
0
347 if (STREQ (prev_file, "-"))
never executed: __result = (((const unsigned char *) (const char *) ( prev_file ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]);
never executed: end of block
executed 4 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
( __extension_...)))); }) == 0)Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 107 times by 2 tests
Evaluated by:
  • expand
  • unexpand
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEevaluated 111 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEnever evaluated
__result == 0Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 107 times by 2 tests
Evaluated by:
  • expand
  • unexpand
__s2_len > 1Description
TRUEnever evaluated
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • expand
  • unexpand
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-111
348 clearerr (fp); /* Also clear EOF. */
executed 4 times by 2 tests: clearerr_unlocked (fp);
Executed by:
  • expand
  • unexpand
4
349 else if (fclose (fp) != 0)
rpl_fclose (fp) != 0Description
TRUEnever evaluated
FALSEevaluated 107 times by 2 tests
Evaluated by:
  • expand
  • unexpand
0-107
350 {-
351 error (0, errno, "%s", quotef (prev_file));-
352 exit_status = EXIT_FAILURE;-
353 }
never executed: end of block
0
354 }
executed 111 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
111
355-
356 while ((file = *file_list++) != NULL)
(file = *file_...!= ((void *)0)Description
TRUEevaluated 111 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 108 times by 2 tests
Evaluated by:
  • expand
  • unexpand
108-111
357 {-
358 if (STREQ (file, "-"))
never executed: __result = (((const unsigned char *) (const char *) ( file ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]);
never executed: end of block
executed 4 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
( __extension_...)))); }) == 0)Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 107 times by 2 tests
Evaluated by:
  • expand
  • unexpand
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEevaluated 111 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEnever evaluated
__result == 0Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 107 times by 2 tests
Evaluated by:
  • expand
  • unexpand
__s2_len > 1Description
TRUEnever evaluated
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • expand
  • unexpand
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-111
359 {-
360 have_read_stdin = true;-
361 fp = stdin;-
362 }
executed 4 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
4
363 else-
364 fp = fopen (file, "r");
executed 107 times by 2 tests: fp = fopen (file, "r");
Executed by:
  • expand
  • unexpand
107
365 if (fp)
fpDescription
TRUEevaluated 111 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEnever evaluated
0-111
366 {-
367 prev_file = file;-
368 fadvise (fp, FADVISE_SEQUENTIAL);-
369 return fp;
executed 111 times by 2 tests: return fp;
Executed by:
  • expand
  • unexpand
111
370 }-
371 error (0, errno, "%s", quotef (file));-
372 exit_status = EXIT_FAILURE;-
373 }
never executed: end of block
0
374 return NULL;
executed 108 times by 2 tests: return ((void *)0) ;
Executed by:
  • expand
  • unexpand
108
375}-
376-
377/* */-
378extern void-
379cleanup_file_list_stdin (void)-
380{-
381 if (have_read_stdin && fclose (stdin) != 0)
have_read_stdinDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • expand
  • unexpand
FALSEevaluated 104 times by 2 tests
Evaluated by:
  • expand
  • unexpand
rpl_fclose ( stdin ) != 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • expand
  • unexpand
0-104
382 die (EXIT_FAILURE, errno, "-");
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
383}
executed 108 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
108
384-
385-
386extern void-
387emit_tab_list_info (void)-
388{-
389 /* suppress syntax check for emit_mandatory_arg_note() */-
390 fputs (_("\-
391 -t, --tabs=LIST use comma separated list of tab positions\n\-
392"), stdout);-
393 fputs (_("\-
394 The last specified position can be prefixed with '/'\n\-
395 to specify a tab size to use after the last\n\-
396 explicitly specified tab stop. Also a prefix of '+'\n\-
397 can be used to align remaining tab stops relative to\n\-
398 the last specified tab stop instead of the first column\n\-
399"), stdout);-
400}
executed 11 times by 2 tests: end of block
Executed by:
  • expand
  • unexpand
11
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2