OpenCoverage

stdbuf.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/stdbuf.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* stdbuf -- setup the standard streams for a command-
2 Copyright (C) 2009-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/* Written by Pádraig Brady. */-
18-
19#include <config.h>-
20#include <stdio.h>-
21#include <getopt.h>-
22#include <sys/types.h>-
23#include <assert.h>-
24-
25#include "system.h"-
26#include "die.h"-
27#include "error.h"-
28#include "filenamecat.h"-
29#include "quote.h"-
30#include "xreadlink.h"-
31#include "xstrtol.h"-
32#include "c-ctype.h"-
33-
34/* The official name of this program (e.g., no 'g' prefix). */-
35#define PROGRAM_NAME "stdbuf"-
36#define LIB_NAME "libstdbuf.so" /* FIXME: don't hardcode */-
37-
38#define AUTHORS proper_name ("Padraig Brady")-
39-
40static char *program_path;-
41-
42static struct-
43{-
44 size_t size;-
45 int optc;-
46 char *optarg;-
47} stdbuf[3];-
48-
49static struct option const longopts[] =-
50{-
51 {"input", required_argument, NULL, 'i'},-
52 {"output", required_argument, NULL, 'o'},-
53 {"error", required_argument, NULL, 'e'},-
54 {GETOPT_HELP_OPTION_DECL},-
55 {GETOPT_VERSION_OPTION_DECL},-
56 {NULL, 0, NULL, 0}-
57};-
58-
59/* Set size to the value of STR, interpreted as a decimal integer,-
60 optionally multiplied by various values.-
61 Return -1 on error, 0 on success.-
62-
63 This supports dd BLOCK size suffixes.-
64 Note we don't support dd's b=512, c=1, w=2 or 21x512MiB formats. */-
65static int-
66parse_size (char const *str, size_t *size)-
67{-
68 uintmax_t tmp_size;-
69 enum strtol_error e = xstrtoumax (str, NULL, 10, &tmp_size, "EGkKMPTYZ0");-
70 if (e == LONGINT_OK && SIZE_MAX < tmp_size)
e == LONGINT_OKDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 8 times by 1 test
Evaluated by:
  • stdbuf
(1844674407370...UL) < tmp_sizeDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-8
71 e = LONGINT_OVERFLOW;
never executed: e = LONGINT_OVERFLOW;
0
72-
73 if (e == LONGINT_OK)
e == LONGINT_OKDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 8 times by 1 test
Evaluated by:
  • stdbuf
2-8
74 {-
75 errno = 0;-
76 *size = tmp_size;-
77 return 0;
executed 2 times by 1 test: return 0;
Executed by:
  • stdbuf
2
78 }-
79-
80 errno = (e == LONGINT_OVERFLOW ? EOVERFLOW : errno);-
81 return -1;
executed 8 times by 1 test: return -1;
Executed by:
  • stdbuf
8
82}-
83-
84void-
85usage (int status)-
86{-
87 if (status != EXIT_SUCCESS)
status != 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 3 times by 1 test
Evaluated by:
  • stdbuf
3-5
88 emit_try_help ();
executed 5 times by 1 test: end of block
Executed by:
  • stdbuf
5
89 else-
90 {-
91 printf (_("Usage: %s OPTION... COMMAND\n"), program_name);-
92 fputs (_("\-
93Run COMMAND, with modified buffering operations for its standard streams.\n\-
94"), stdout);-
95-
96 emit_mandatory_arg_note ();-
97-
98 fputs (_("\-
99 -i, --input=MODE adjust standard input stream buffering\n\-
100 -o, --output=MODE adjust standard output stream buffering\n\-
101 -e, --error=MODE adjust standard error stream buffering\n\-
102"), stdout);-
103 fputs (HELP_OPTION_DESCRIPTION, stdout);-
104 fputs (VERSION_OPTION_DESCRIPTION, stdout);-
105 fputs (_("\n\-
106If MODE is 'L' the corresponding stream will be line buffered.\n\-
107This option is invalid with standard input.\n"), stdout);-
108 fputs (_("\n\-
109If MODE is '0' the corresponding stream will be unbuffered.\n\-
110"), stdout);-
111 fputs (_("\n\-
112Otherwise MODE is a number which may be followed by one of the following:\n\-
113KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\-
114In this case the corresponding stream will be fully buffered with the buffer\n\-
115size set to MODE bytes.\n\-
116"), stdout);-
117 fputs (_("\n\-
118NOTE: If COMMAND adjusts the buffering of its standard streams ('tee' does\n\-
119for example) then that will override corresponding changes by 'stdbuf'.\n\-
120Also some filters (like 'dd' and 'cat' etc.) don't use streams for I/O,\n\-
121and are thus unaffected by 'stdbuf' settings.\n\-
122"), stdout);-
123 emit_ancillary_info (PROGRAM_NAME);-
124 }
executed 3 times by 1 test: end of block
Executed by:
  • stdbuf
3
125 exit (status);
executed 8 times by 1 test: exit (status);
Executed by:
  • stdbuf
8
126}-
127-
128/* argv[0] can be anything really, but generally it contains-
129 the path to the executable or just a name if it was executed-
130 using $PATH. In the latter case to get the path we can:-
131 search getenv("PATH"), readlink("/prof/self/exe"), getenv("_"),-
132 dladdr(), pstat_getpathname(), etc. */-
133-
134static void-
135set_program_path (const char *arg)-
136{-
137 if (strchr (arg, '/')) /* Use absolute or relative paths directly. */
(__extension__... arg , '/' )))Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
__builtin_constant_p ( '/' )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
FALSEnever evaluated
!__builtin_constant_p ( arg )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
FALSEnever evaluated
( '/' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
138 {-
139 program_path = dir_name (arg);-
140 }
never executed: end of block
0
141 else-
142 {-
143 char *path = xreadlink ("/proc/self/exe");-
144 if (path)
pathDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
FALSEnever evaluated
0-2
145 program_path = dir_name (path);
executed 2 times by 1 test: program_path = dir_name (path);
Executed by:
  • stdbuf
2
146 else if ((path = getenv ("PATH")))
(path = getenv ("PATH"))Description
TRUEnever evaluated
FALSEnever evaluated
0
147 {-
148 char *dir;-
149 path = xstrdup (path);-
150 for (dir = strtok (path, ":"); dir != NULL; dir = strtok (NULL, ":"))
dir != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
151 {-
152 char *candidate = file_name_concat (dir, arg, NULL);-
153 if (access (candidate, X_OK) == 0)
access (candidate, 1 ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
154 {-
155 program_path = dir_name (candidate);-
156 free (candidate);-
157 break;
never executed: break;
0
158 }-
159 free (candidate);-
160 }
never executed: end of block
0
161 }
never executed: end of block
0
162 free (path);-
163 }
executed 2 times by 1 test: end of block
Executed by:
  • stdbuf
2
164}-
165-
166static int-
167optc_to_fileno (int c)-
168{-
169 int ret = -1;-
170-
171 switch (c)-
172 {-
173 case 'e':
executed 2 times by 1 test: case 'e':
Executed by:
  • stdbuf
2
174 ret = STDERR_FILENO;-
175 break;
executed 2 times by 1 test: break;
Executed by:
  • stdbuf
2
176 case 'i':
executed 3 times by 1 test: case 'i':
Executed by:
  • stdbuf
3
177 ret = STDIN_FILENO;-
178 break;
executed 3 times by 1 test: break;
Executed by:
  • stdbuf
3
179 case 'o':
executed 6 times by 1 test: case 'o':
Executed by:
  • stdbuf
6
180 ret = STDOUT_FILENO;-
181 break;
executed 6 times by 1 test: break;
Executed by:
  • stdbuf
6
182 }-
183-
184 return ret;
executed 11 times by 1 test: return ret;
Executed by:
  • stdbuf
11
185}-
186-
187static void-
188set_LD_PRELOAD (void)-
189{-
190 int ret;-
191#ifdef __APPLE__-
192 char const *preload_env = "DYLD_INSERT_LIBRARIES";-
193#else-
194 char const *preload_env = "LD_PRELOAD";-
195#endif-
196 char *old_libs = getenv (preload_env);-
197 char *LD_PRELOAD;-
198-
199 /* Note this would auto add the appropriate search path for "libstdbuf.so":-
200 gcc stdbuf.c -Wl,-rpath,'$ORIGIN' -Wl,-rpath,$PKGLIBEXECDIR-
201 However we want the lookup done for the exec'd command not stdbuf.-
202-
203 Since we don't link against libstdbuf.so add it to PKGLIBEXECDIR-
204 rather than to LIBDIR.-
205-
206 Note we could add "" as the penultimate item in the following list-
207 to enable searching for libstdbuf.so in the default system lib paths.-
208 However that would not indicate an error if libstdbuf.so was not found.-
209 Also while this could support auto selecting the right arch in a multilib-
210 environment, what we really want is to auto select based on the arch of the-
211 command being run, rather than that of stdbuf itself. This is currently-
212 not supported due to the unusual need for controlling the stdio buffering-
213 of programs that are a different architecture to the default on the-
214 system (and that of stdbuf itself). */-
215 char const *const search_path[] = {-
216 program_path,-
217 PKGLIBEXECDIR,-
218 NULL-
219 };-
220-
221 char const *const *path = search_path;-
222 char *libstdbuf;-
223-
224 while (true)-
225 {-
226 struct stat sb;-
227-
228 if (!**path) /* system default */
!**pathDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
229 {-
230 libstdbuf = xstrdup (LIB_NAME);-
231 break;
never executed: break;
0
232 }-
233 ret = asprintf (&libstdbuf, "%s/%s", *path, LIB_NAME);-
234 if (ret < 0)
ret < 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
235 xalloc_die ();
never executed: xalloc_die ();
0
236 if (stat (libstdbuf, &sb) == 0) /* file_exists */
stat (libstdbuf, &sb) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
FALSEnever evaluated
0-2
237 break;
executed 2 times by 1 test: break;
Executed by:
  • stdbuf
2
238 free (libstdbuf);-
239-
240 ++path;-
241 if ( ! *path)
! *pathDescription
TRUEnever evaluated
FALSEnever evaluated
0
242 die (EXIT_CANCELED, 0, _("failed to find %s"), quote (LIB_NAME));
never executed: ((!!sizeof (struct { _Static_assert (EXIT_CANCELED, "verify_expr (" "EXIT_CANCELED" ", " "(error (EXIT_CANCELED, 0, dcgettext (((void *)0), \"failed to find %s\", 5), quote (\"libstdbuf.so\")), assume (false))" ")"); int _gl_dummy; })) ? ((error (EXIT_CAN... "failed to find %s" , 5) , quote ("libstdbuf.so")), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error (EXIT_CANCELED, 0, dcgettext (((void *)0), "failed to find %s" , 5) , quote ("libstdbuf.so")), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
243 }
never executed: end of block
0
244-
245 /* FIXME: Do we need to support libstdbuf.dll, c:, '\' separators etc? */-
246-
247 if (old_libs)
old_libsDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
248 ret = asprintf (&LD_PRELOAD, "%s=%s:%s", preload_env, old_libs, libstdbuf);
never executed: ret = asprintf (&LD_PRELOAD, "%s=%s:%s", preload_env, old_libs, libstdbuf);
0
249 else-
250 ret = asprintf (&LD_PRELOAD, "%s=%s", preload_env, libstdbuf);
executed 2 times by 1 test: ret = asprintf (&LD_PRELOAD, "%s=%s", preload_env, libstdbuf);
Executed by:
  • stdbuf
2
251-
252 if (ret < 0)
ret < 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
253 xalloc_die ();
never executed: xalloc_die ();
0
254-
255 free (libstdbuf);-
256-
257 ret = putenv (LD_PRELOAD);-
258#ifdef __APPLE__-
259 if (ret == 0)-
260 ret = setenv ("DYLD_FORCE_FLAT_NAMESPACE", "y", 1);-
261#endif-
262-
263 if (ret != 0)
ret != 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
264 {-
265 die (EXIT_CANCELED, errno,-
266 _("failed to update the environment with %s"),-
267 quote (LD_PRELOAD));-
268 }
never executed: end of block
0
269}
executed 2 times by 1 test: end of block
Executed by:
  • stdbuf
2
270-
271/* Populate environ with _STDBUF_I=$MODE _STDBUF_O=$MODE _STDBUF_E=$MODE.-
272 Return TRUE if any environment variables set. */-
273-
274static bool-
275set_libstdbuf_options (void)-
276{-
277 bool env_set = false;-
278-
279 for (size_t i = 0; i < ARRAY_CARDINALITY (stdbuf); i++)
i < (sizeof (s...eof *(stdbuf))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 3 times by 1 test
Evaluated by:
  • stdbuf
3-9
280 {-
281 if (stdbuf[i].optarg)
stdbuf[i].optargDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 7 times by 1 test
Evaluated by:
  • stdbuf
2-7
282 {-
283 char *var;-
284 int ret;-
285-
286 if (*stdbuf[i].optarg == 'L')
*stdbuf[i].optarg == 'L'Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
287 ret = asprintf (&var, "%s%c=L", "_STDBUF_",
never executed: ret = asprintf (&var, "%s%c=L", "_STDBUF_", (__extension__ ({ int __res; if (sizeof ( stdbuf[i].optc ) > 1) { if (__builtin_constant_p ( stdbuf[i].optc )) { int __c = ( stdbuf[i].optc ); __res = __c < -128 || __c > 255 ? __c : (*__ctype_toupper_loc ())[__c]; } else __res = toupper ( stdbuf[i].optc ); } else __res = (*__ctype_toupper_loc ())[(int) ( stdbuf[i].optc )]; __res; })) );
0
288 toupper (stdbuf[i].optc));
never executed: ret = asprintf (&var, "%s%c=L", "_STDBUF_", (__extension__ ({ int __res; if (sizeof ( stdbuf[i].optc ) > 1) { if (__builtin_constant_p ( stdbuf[i].optc )) { int __c = ( stdbuf[i].optc ); __res = __c < -128 || __c > 255 ? __c : (*__ctype_toupper_loc ())[__c]; } else __res = toupper ( stdbuf[i].optc ); } else __res = (*__ctype_toupper_loc ())[(int) ( stdbuf[i].optc )]; __res; })) );
never executed: end of block
never executed: __res = toupper ( stdbuf[i].optc );
never executed: __res = (*__ctype_toupper_loc ())[(int) ( stdbuf[i].optc )];
sizeof ( stdbuf[i].optc ) > 1Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...dbuf[i].optc )Description
TRUEnever evaluated
FALSEnever evaluated
__c < -128Description
TRUEnever evaluated
FALSEnever evaluated
__c > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
289 else-
290 ret = asprintf (&var, "%s%c=%" PRIuMAX, "_STDBUF_",
executed 2 times by 1 test: ret = asprintf (&var, "%s%c=%" "l" "u" , "_STDBUF_", (__extension__ ({ int __res; if (sizeof ( stdbuf[i].optc ) > 1) { if (__builtin_constant_p ( stdbuf[i].optc )) { int __c = ( stdbuf[i].optc ); __res = __c < -128 || __c > 255 ? __c : (*__ctype_toupper_loc ())[__c]; } else __res = toupper ( stdbuf[i].optc ); } else __res = (*__ctype_toupper_loc ())[(int) ( stdbuf[i].optc )]; __res; })) , (uintmax_t) stdbuf[i].size);
Executed by:
  • stdbuf
2
291 toupper (stdbuf[i].optc),
executed 2 times by 1 test: ret = asprintf (&var, "%s%c=%" "l" "u" , "_STDBUF_", (__extension__ ({ int __res; if (sizeof ( stdbuf[i].optc ) > 1) { if (__builtin_constant_p ( stdbuf[i].optc )) { int __c = ( stdbuf[i].optc ); __res = __c < -128 || __c > 255 ? __c : (*__ctype_toupper_loc ())[__c]; } else __res = toupper ( stdbuf[i].optc ); } else __res = (*__ctype_toupper_loc ())[(int) ( stdbuf[i].optc )]; __res; })) , (uintmax_t) stdbuf[i].size);
Executed by:
  • stdbuf
never executed: end of block
executed 2 times by 1 test: __res = toupper ( stdbuf[i].optc );
Executed by:
  • stdbuf
never executed: __res = (*__ctype_toupper_loc ())[(int) ( stdbuf[i].optc )];
sizeof ( stdbuf[i].optc ) > 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
FALSEnever evaluated
__builtin_cons...dbuf[i].optc )Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
__c < -128Description
TRUEnever evaluated
FALSEnever evaluated
__c > 255Description
TRUEnever evaluated
FALSEnever evaluated
0-2
292 (uintmax_t) stdbuf[i].size);
executed 2 times by 1 test: ret = asprintf (&var, "%s%c=%" "l" "u" , "_STDBUF_", (__extension__ ({ int __res; if (sizeof ( stdbuf[i].optc ) > 1) { if (__builtin_constant_p ( stdbuf[i].optc )) { int __c = ( stdbuf[i].optc ); __res = __c < -128 || __c > 255 ? __c : (*__ctype_toupper_loc ())[__c]; } else __res = toupper ( stdbuf[i].optc ); } else __res = (*__ctype_toupper_loc ())[(int) ( stdbuf[i].optc )]; __res; })) , (uintmax_t) stdbuf[i].size);
Executed by:
  • stdbuf
2
293 if (ret < 0)
ret < 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
294 xalloc_die ();
never executed: xalloc_die ();
0
295-
296 if (putenv (var) != 0)
putenv (var) != 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
297 {-
298 die (EXIT_CANCELED, errno,-
299 _("failed to update the environment with %s"),-
300 quote (var));-
301 }
never executed: end of block
0
302-
303 env_set = true;-
304 }
executed 2 times by 1 test: end of block
Executed by:
  • stdbuf
2
305 }
executed 9 times by 1 test: end of block
Executed by:
  • stdbuf
9
306-
307 return env_set;
executed 3 times by 1 test: return env_set;
Executed by:
  • stdbuf
3
308}-
309-
310int-
311main (int argc, char **argv)-
312{-
313 int c;-
314-
315 initialize_main (&argc, &argv);-
316 set_program_name (argv[0]);-
317 setlocale (LC_ALL, "");-
318 bindtextdomain (PACKAGE, LOCALEDIR);-
319 textdomain (PACKAGE);-
320-
321 initialize_exit_failure (EXIT_CANCELED);-
322 atexit (close_stdout);-
323-
324 while ((c = getopt_long (argc, argv, "+i:o:e:", longopts, NULL)) != -1)
(c = getopt_lo... *)0) )) != -1Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 3 times by 1 test
Evaluated by:
  • stdbuf
3-21
325 {-
326 int opt_fileno;-
327-
328 switch (c)-
329 {-
330 /* Old McDonald had a farm ei... */-
331 case 'e':
executed 2 times by 1 test: case 'e':
Executed by:
  • stdbuf
2
332 case 'i':
executed 3 times by 1 test: case 'i':
Executed by:
  • stdbuf
3
333 case 'o':
executed 6 times by 1 test: case 'o':
Executed by:
  • stdbuf
6
334 opt_fileno = optc_to_fileno (c);-
335 assert (0 <= opt_fileno && opt_fileno < ARRAY_CARDINALITY (stdbuf));-
336 stdbuf[opt_fileno].optc = c;-
337 while (c_isspace (*optarg))
c_isspace (*optarg)Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • stdbuf
0-11
338 optarg++;
never executed: optarg++;
0
339 stdbuf[opt_fileno].optarg = optarg;-
340 if (c == 'i' && *optarg == 'L')
c == 'i'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 8 times by 1 test
Evaluated by:
  • stdbuf
*optarg == 'L'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
1-8
341 {-
342 /* -oL will be by far the most common use of this utility,-
343 but one could easily think -iL might have the same affect,-
344 so disallow it as it could be confusing. */-
345 error (0, 0, _("line buffering stdin is meaningless"));-
346 usage (EXIT_CANCELED);-
347 }
never executed: end of block
0
348-
349 if (!STREQ (optarg, "L")
never executed: __result = (((const unsigned char *) (const char *) ( optarg ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "L" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
!( __extension...)))); }) == 0)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • stdbuf
FALSEnever evaluated
__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 10 times by 1 test
Evaluated by:
  • stdbuf
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • stdbuf
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-10
350 && parse_size (optarg, &stdbuf[opt_fileno].size) == -1)
parse_size (op...o].size) == -1Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
2-8
351 die (EXIT_CANCELED, errno, _("invalid mode %s"), quote (optarg));
executed 8 times by 1 test: ((!!sizeof (struct { _Static_assert (EXIT_CANCELED, "verify_expr (" "EXIT_CANCELED" ", " "(error (EXIT_CANCELED, (*__errno_location ()), dcgettext (((void *)0), \"invalid mode %s\", 5), quote (optarg)), assume (false))" ")"); int _gl_dummy; })) ? ((error ...invalid mode %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error (EXIT_CANCELED, (*__errno_location ()) , dcgettext (((void *)0), "invalid mode %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
Executed by:
  • stdbuf
8
352-
353 break;
executed 2 times by 1 test: break;
Executed by:
  • stdbuf
2
354-
355 case_GETOPT_HELP_CHAR;
never executed: break;
executed 3 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • stdbuf
0-3
356-
357 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • stdbuf
never executed: break;
executed 4 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • stdbuf
0-4
358-
359 default:
executed 3 times by 1 test: default:
Executed by:
  • stdbuf
3
360 usage (EXIT_CANCELED);-
361 }
never executed: end of block
0
362 }-
363-
364 argv += optind;-
365 argc -= optind;-
366-
367 /* must specify at least 1 command. */-
368 if (argc < 1)
argc < 1Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • stdbuf
0-3
369 {-
370 error (0, 0, _("missing operand"));-
371 usage (EXIT_CANCELED);-
372 }
never executed: end of block
0
373-
374 if (! set_libstdbuf_options ())
! set_libstdbuf_options ()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
1-2
375 {-
376 error (0, 0, _("you must specify a buffering mode option"));-
377 usage (EXIT_CANCELED);-
378 }
never executed: end of block
0
379-
380 /* Try to preload libstdbuf first from the same path as-
381 stdbuf is running from. */-
382 set_program_path (program_name);-
383 if (!program_path)
!program_pathDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • stdbuf
0-2
384 program_path = xstrdup (PKGLIBDIR); /* Need to init to non-NULL. */
never executed: program_path = xstrdup ("/usr/local/lib/coreutils");
0
385 set_LD_PRELOAD ();-
386 free (program_path);-
387-
388 execvp (*argv, argv);-
389-
390 int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
(*__errno_location ()) == 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • stdbuf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • stdbuf
1
391 error (0, errno, _("failed to run command %s"), quote (argv[0]));-
392 return exit_status;
executed 2 times by 1 test: return exit_status;
Executed by:
  • stdbuf
2
393}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2