OpenCoverage

seq.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/seq.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* seq - print sequence of numbers to standard output.-
2 Copyright (C) 1994-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 Ulrich Drepper. */-
18-
19#include <config.h>-
20#include <getopt.h>-
21#include <stdio.h>-
22#include <sys/types.h>-
23-
24#include "system.h"-
25#include "die.h"-
26#include "c-strtod.h"-
27#include "error.h"-
28#include "quote.h"-
29#include "xstrtod.h"-
30-
31/* Roll our own isfinite/isnan rather than using <math.h>, so that we don't-
32 have to worry about linking -lm just for isfinite. */-
33#ifndef isfinite-
34# define isfinite(x) ((x) * 0 == 0)-
35#endif-
36#ifndef isnan-
37# define isnan(x) ((x) != (x))-
38#endif-
39-
40/* The official name of this program (e.g., no 'g' prefix). */-
41#define PROGRAM_NAME "seq"-
42-
43#define AUTHORS proper_name ("Ulrich Drepper")-
44-
45/* If true print all number with equal width. */-
46static bool equal_width;-
47-
48/* The string used to separate two numbers. */-
49static char const *separator;-
50-
51/* The string output after all numbers have been output.-
52 Usually "\n" or "\0". */-
53static char const terminator[] = "\n";-
54-
55static struct option const long_options[] =-
56{-
57 { "equal-width", no_argument, NULL, 'w'},-
58 { "format", required_argument, NULL, 'f'},-
59 { "separator", required_argument, NULL, 's'},-
60 {GETOPT_HELP_OPTION_DECL},-
61 {GETOPT_VERSION_OPTION_DECL},-
62 { NULL, 0, NULL, 0}-
63};-
64-
65void-
66usage (int status)-
67{-
68 if (status != EXIT_SUCCESS)
status != 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 9 times by 1 test
Evaluated by:
  • seq
9-16
69 emit_try_help ();
executed 16 times by 1 test: end of block
Executed by:
  • seq
16
70 else-
71 {-
72 printf (_("\-
73Usage: %s [OPTION]... LAST\n\-
74 or: %s [OPTION]... FIRST LAST\n\-
75 or: %s [OPTION]... FIRST INCREMENT LAST\n\-
76"), program_name, program_name, program_name);-
77 fputs (_("\-
78Print numbers from FIRST to LAST, in steps of INCREMENT.\n\-
79"), stdout);-
80-
81 emit_mandatory_arg_note ();-
82-
83 fputs (_("\-
84 -f, --format=FORMAT use printf style floating-point FORMAT\n\-
85 -s, --separator=STRING use STRING to separate numbers (default: \\n)\n\-
86 -w, --equal-width equalize width by padding with leading zeroes\n\-
87"), stdout);-
88 fputs (HELP_OPTION_DESCRIPTION, stdout);-
89 fputs (VERSION_OPTION_DESCRIPTION, stdout);-
90 fputs (_("\-
91\n\-
92If FIRST or INCREMENT is omitted, it defaults to 1. That is, an\n\-
93omitted INCREMENT defaults to 1 even when LAST is smaller than FIRST.\n\-
94The sequence of numbers ends when the sum of the current number and\n\-
95INCREMENT would become greater than LAST.\n\-
96FIRST, INCREMENT, and LAST are interpreted as floating point values.\n\-
97INCREMENT is usually positive if FIRST is smaller than LAST, and\n\-
98INCREMENT is usually negative if FIRST is greater than LAST.\n\-
99INCREMENT must not be 0; none of FIRST, INCREMENT and LAST may be NaN.\n\-
100"), stdout);-
101 fputs (_("\-
102FORMAT must be suitable for printing one argument of type 'double';\n\-
103it defaults to %.PRECf if FIRST, INCREMENT, and LAST are all fixed point\n\-
104decimal numbers with maximum precision PREC, and to %g otherwise.\n\-
105"), stdout);-
106 emit_ancillary_info (PROGRAM_NAME);-
107 }
executed 9 times by 1 test: end of block
Executed by:
  • seq
9
108 exit (status);
executed 25 times by 1 test: exit (status);
Executed by:
  • seq
25
109}-
110-
111/* A command-line operand. */-
112struct operand-
113{-
114 /* Its value, converted to 'long double'. */-
115 long double value;-
116-
117 /* Its print width, if it were printed out in a form similar to its-
118 input form. An input like "-.1" is treated like "-0.1", and an-
119 input like "1." is treated like "1", but otherwise widths are-
120 left alone. */-
121 size_t width;-
122-
123 /* Number of digits after the decimal point, or INT_MAX if the-
124 number can't easily be expressed as a fixed-point number. */-
125 int precision;-
126};-
127typedef struct operand operand;-
128-
129/* Description of what a number-generating format will generate. */-
130struct layout-
131{-
132 /* Number of bytes before and after the number. */-
133 size_t prefix_len;-
134 size_t suffix_len;-
135};-
136-
137/* Read a long double value from the command line.-
138 Return if the string is correct else signal error. */-
139-
140static operand-
141scan_arg (const char *arg)-
142{-
143 operand ret;-
144-
145 if (! xstrtold (arg, NULL, &ret.value, c_strtold))
! xstrtold (ar...ue, c_strtold)Description
TRUEnever evaluated
FALSEevaluated 247 times by 1 test
Evaluated by:
  • seq
0-247
146 {-
147 error (0, 0, _("invalid floating point argument: %s"), quote (arg));-
148 usage (EXIT_FAILURE);-
149 }
never executed: end of block
0
150-
151 if (isnan (ret.value))
((ret.value) != (ret.value))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 238 times by 1 test
Evaluated by:
  • seq
9-238
152 {-
153 error (0, 0, _("invalid %s argument: %s"), quote_n (0, "not-a-number"),-
154 quote_n (1, arg));-
155 usage (EXIT_FAILURE);-
156 }
never executed: end of block
0
157-
158 /* We don't output spaces or '+' so don't include in width */-
159 while (isspace (to_uchar (*arg)) || *arg == '+')
((*__ctype_b_l...int) _ISspace)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 239 times by 1 test
Evaluated by:
  • seq
*arg == '+'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • seq
FALSEevaluated 238 times by 1 test
Evaluated by:
  • seq
1-239
160 arg++;
executed 3 times by 1 test: arg++;
Executed by:
  • seq
3
161-
162 /* Default to auto width and precision. */-
163 ret.width = 0;-
164 ret.precision = INT_MAX;-
165-
166 /* Use no precision (and possibly fast generation) for integers. */-
167 char const *decimal_point = strchr (arg, '.');
__builtin_constant_p ( '.' )Description
TRUEevaluated 238 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
!__builtin_constant_p ( arg )Description
TRUEevaluated 238 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
( '.' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 238 times by 1 test
Evaluated by:
  • seq
0-238
168 if (! decimal_point && ! strchr (arg, 'p') /* not a hex float */)
! decimal_pointDescription
TRUEevaluated 180 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 58 times by 1 test
Evaluated by:
  • seq
! (__extension... arg , 'p' )))Description
TRUEevaluated 179 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1 time by 1 test
Evaluated by:
  • seq
__builtin_constant_p ( 'p' )Description
TRUEevaluated 180 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
!__builtin_constant_p ( arg )Description
TRUEevaluated 180 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
( 'p' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 180 times by 1 test
Evaluated by:
  • seq
0-180
169 ret.precision = 0;
executed 179 times by 1 test: ret.precision = 0;
Executed by:
  • seq
179
170-
171 /* auto set width and precision for decimal inputs. */-
172 if (! arg[strcspn (arg, "xX")] && isfinite (ret.value))
! arg[ __built...arg , "xX" ) ]Description
TRUEevaluated 234 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 4 times by 1 test
Evaluated by:
  • seq
((ret.value) * 0 == 0)Description
TRUEevaluated 227 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 7 times by 1 test
Evaluated by:
  • seq
4-234
173 {-
174 size_t fraction_len = 0;-
175 ret.width = strlen (arg);-
176-
177 if (decimal_point)
decimal_pointDescription
TRUEevaluated 58 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 169 times by 1 test
Evaluated by:
  • seq
58-169
178 {-
179 fraction_len = strcspn (decimal_point + 1, "eE");-
180 if (fraction_len <= INT_MAX)
fraction_len <= 0x7fffffffDescription
TRUEevaluated 58 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
0-58
181 ret.precision = fraction_len;
executed 58 times by 1 test: ret.precision = fraction_len;
Executed by:
  • seq
58
182 ret.width += (fraction_len == 0 /* #. -> # */
fraction_len == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • seq
FALSEevaluated 57 times by 1 test
Evaluated by:
  • seq
1-57
183 ? -1-
184 : (decimal_point == arg /* .# -> 0.# */
decimal_point == argDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 39 times by 1 test
Evaluated by:
  • seq
18-39
185 || ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */
! ((unsigned i...]) - '0' <= 9)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 37 times by 1 test
Evaluated by:
  • seq
2-37
186 }
executed 58 times by 1 test: end of block
Executed by:
  • seq
58
187 char const *e = strchr (arg, 'e');
__builtin_constant_p ( 'e' )Description
TRUEevaluated 227 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
!__builtin_constant_p ( arg )Description
TRUEevaluated 227 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
( 'e' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 227 times by 1 test
Evaluated by:
  • seq
0-227
188 if (! e)
! eDescription
TRUEevaluated 211 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 16 times by 1 test
Evaluated by:
  • seq
16-211
189 e = strchr (arg, 'E');
executed 211 times by 1 test: e = (__extension__ (__builtin_constant_p ( 'E' ) && !__builtin_constant_p ( arg ) && ( 'E' ) == '\0' ? (char *) __rawmemchr ( arg , 'E' ) : __builtin_strchr ( arg , 'E' ))) ;
Executed by:
  • seq
__builtin_constant_p ( 'E' )Description
TRUEevaluated 211 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
!__builtin_constant_p ( arg )Description
TRUEevaluated 211 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
( 'E' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 211 times by 1 test
Evaluated by:
  • seq
0-211
190 if (e)
eDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 211 times by 1 test
Evaluated by:
  • seq
16-211
191 {-
192 long exponent = strtol (e + 1, NULL, 10);-
193 ret.precision += exponent < 0 ? -exponent
exponent < 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 7 times by 1 test
Evaluated by:
  • seq
7-9
194 : - MIN (ret.precision, exponent);-
195 /* Don't account for e.... in the width since this is not output. */-
196 ret.width -= strlen (arg) - (e - arg);-
197 /* Adjust the width as per the exponent. */-
198 if (exponent < 0)
exponent < 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 7 times by 1 test
Evaluated by:
  • seq
7-9
199 {-
200 if (decimal_point)
decimal_pointDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 6 times by 1 test
Evaluated by:
  • seq
3-6
201 {-
202 if (e == decimal_point + 1) /* undo #. -> # above */
e == decimal_point + 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • seq
FALSEevaluated 2 times by 1 test
Evaluated by:
  • seq
1-2
203 ret.width++;
executed 1 time by 1 test: ret.width++;
Executed by:
  • seq
1
204 }
executed 3 times by 1 test: end of block
Executed by:
  • seq
3
205 else-
206 ret.width++;
executed 6 times by 1 test: ret.width++;
Executed by:
  • seq
6
207 exponent = -exponent;-
208 }
executed 9 times by 1 test: end of block
Executed by:
  • seq
9
209 else-
210 {-
211 if (decimal_point && ret.precision == 0 && fraction_len)
decimal_pointDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 2 times by 1 test
Evaluated by:
  • seq
ret.precision == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
fraction_lenDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
0-5
212 ret.width--; /* discount space for '.' */
executed 5 times by 1 test: ret.width--;
Executed by:
  • seq
5
213 exponent -= MIN (fraction_len, exponent);
(( fraction_le...<( exponent ))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 4 times by 1 test
Evaluated by:
  • seq
3-4
214 }
executed 7 times by 1 test: end of block
Executed by:
  • seq
7
215 ret.width += exponent;-
216 }
executed 16 times by 1 test: end of block
Executed by:
  • seq
16
217 }
executed 227 times by 1 test: end of block
Executed by:
  • seq
227
218-
219 return ret;
executed 238 times by 1 test: return ret;
Executed by:
  • seq
238
220}-
221-
222/* If FORMAT is a valid printf format for a double argument, return-
223 its long double equivalent, allocated from dynamic storage, and-
224 store into *LAYOUT a description of the output layout; otherwise,-
225 report an error and exit. */-
226-
227static char const *-
228long_double_format (char const *fmt, struct layout *layout)-
229{-
230 size_t i;-
231 size_t prefix_len = 0;-
232 size_t suffix_len = 0;-
233 size_t length_modifier_offset;-
234 bool has_L;-
235-
236 for (i = 0; ! (fmt[i] == '%' && fmt[i + 1] != '%'); i += (fmt[i] == '%') + 1)
fmt[i] == '%'Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 77 times by 1 test
Evaluated by:
  • seq
fmt[i + 1] != '%'Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 2 times by 1 test
Evaluated by:
  • seq
2-77
237 {-
238 if (!fmt[i])
!fmt[i]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 77 times by 1 test
Evaluated by:
  • seq
2-77
239 die (EXIT_FAILURE, 0,
executed 2 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"format %s has no %% directive\", 5), quote (fmt)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "format %s has no %% directive" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "format %s has no %% directive" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • seq
2
240 _("format %s has no %% directive"), quote (fmt));
executed 2 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"format %s has no %% directive\", 5), quote (fmt)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "format %s has no %% directive" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "format %s has no %% directive" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • seq
2
241 prefix_len++;-
242 }
executed 77 times by 1 test: end of block
Executed by:
  • seq
77
243-
244 i++;-
245 i += strspn (fmt + i, "-+#0 '");-
246 i += strspn (fmt + i, "0123456789");-
247 if (fmt[i] == '.')
fmt[i] == '.'Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 8 times by 1 test
Evaluated by:
  • seq
8-11
248 {-
249 i++;-
250 i += strspn (fmt + i, "0123456789");-
251 }
executed 11 times by 1 test: end of block
Executed by:
  • seq
11
252-
253 length_modifier_offset = i;-
254 has_L = (fmt[i] == 'L');-
255 i += has_L;-
256 if (fmt[i] == '\0')
fmt[i] == '\0'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • seq
FALSEevaluated 18 times by 1 test
Evaluated by:
  • seq
1-18
257 die (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt));
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"format %s ends in %%\", 5), quote (fmt)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "format %s ends in %%" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "format %s ends in %%" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
Executed by:
  • seq
1
258 if (! strchr ("efgaEFGA", fmt[i]))
! (__extension..." , fmt[i] )))Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • seq
__builtin_cons...t_p ( fmt[i] )Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • seq
!__builtin_con...( "efgaEFGA" )Description
TRUEnever evaluated
FALSEnever evaluated
( fmt[i] ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-18
259 die (EXIT_FAILURE, 0,
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"format %s has unknown %%%c directive\", 5), quote (fmt), fmt[i]), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)... %%%c directive" , 5) , quote (fmt), fmt[i]), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "format %s has unknown %%%c directive" , 5) , quote (fmt), fmt[i]), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
0
260 _("format %s has unknown %%%c directive"), quote (fmt), fmt[i]);
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"format %s has unknown %%%c directive\", 5), quote (fmt), fmt[i]), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)... %%%c directive" , 5) , quote (fmt), fmt[i]), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "format %s has unknown %%%c directive" , 5) , quote (fmt), fmt[i]), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
0
261-
262 for (i++; ; i += (fmt[i] == '%') + 1)-
263 if (fmt[i] == '%' && fmt[i + 1] != '%')
fmt[i] == '%'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 16 times by 1 test
Evaluated by:
  • seq
fmt[i + 1] != '%'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1 time by 1 test
Evaluated by:
  • seq
1-16
264 die (EXIT_FAILURE, 0, _("format %s has too many %% directives"),
executed 2 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"format %s has too many %% directives\", 5), quote (fmt)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "format %s has too many %% directives" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "format %s has too many %% directives" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • seq
2
265 quote (fmt));
executed 2 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"format %s has too many %% directives\", 5), quote (fmt)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "format %s has too many %% directives" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "format %s has too many %% directives" , 5) , quote (fmt)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • seq
2
266 else if (fmt[i])
fmt[i]Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • seq
FALSEevaluated 16 times by 1 test
Evaluated by:
  • seq
1-16
267 suffix_len++;
executed 1 time by 1 test: suffix_len++;
Executed by:
  • seq
1
268 else-
269 {-
270 size_t format_size = i + 1;-
271 char *ldfmt = xmalloc (format_size + 1);-
272 memcpy (ldfmt, fmt, length_modifier_offset);-
273 ldfmt[length_modifier_offset] = 'L';-
274 strcpy (ldfmt + length_modifier_offset + 1,-
275 fmt + length_modifier_offset + has_L);-
276 layout->prefix_len = prefix_len;-
277 layout->suffix_len = suffix_len;-
278 return ldfmt;
executed 16 times by 1 test: return ldfmt;
Executed by:
  • seq
16
279 }-
280}
never executed: end of block
0
281-
282static void ATTRIBUTE_NORETURN-
283io_error (void)-
284{-
285 /* FIXME: consider option to silently ignore errno=EPIPE */-
286 clearerr (stdout);-
287 die (EXIT_FAILURE, errno, _("write error"));-
288}
never executed: end of block
0
289-
290/* Actually print the sequence of numbers in the specified range, with the-
291 given or default stepping and format. */-
292-
293static void-
294print_numbers (char const *fmt, struct layout layout,-
295 long double first, long double step, long double last)-
296{-
297 bool out_of_range = (step < 0 ? first < last : last < first);
step < 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 69 times by 1 test
Evaluated by:
  • seq
16-69
298-
299 if (! out_of_range)
! out_of_rangeDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 5 times by 1 test
Evaluated by:
  • seq
5-80
300 {-
301 long double x = first;-
302 long double i;-
303-
304 for (i = 1; ; i++)-
305 {-
306 long double x0 = x;-
307 if (printf (fmt, x) < 0)
printf (fmt, x) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 268932 times by 1 test
Evaluated by:
  • seq
5-268932
308 io_error ();
executed 5 times by 1 test: io_error ();
Executed by:
  • seq
5
309 if (out_of_range)
out_of_rangeDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 268927 times by 1 test
Evaluated by:
  • seq
5-268927
310 break;
executed 5 times by 1 test: break;
Executed by:
  • seq
5
311 x = first + i * step;-
312 out_of_range = (step < 0 ? x < last : last < x);
step < 0Description
TRUEevaluated 113 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 268814 times by 1 test
Evaluated by:
  • seq
113-268814
313-
314 if (out_of_range)
out_of_rangeDescription
TRUEevaluated 75 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 268852 times by 1 test
Evaluated by:
  • seq
75-268852
315 {-
316 /* If the number just past LAST prints as a value equal-
317 to LAST, and prints differently from the previous-
318 number, then print the number. This avoids problems-
319 with rounding. For example, with the x86 it causes-
320 "seq 0 0.000001 0.000003" to print 0.000003 instead-
321 of stopping at 0.000002. */-
322-
323 bool print_extra_number = false;-
324 long double x_val;-
325 char *x_str;-
326 int x_strlen;-
327 setlocale (LC_NUMERIC, "C");-
328 x_strlen = asprintf (&x_str, fmt, x);-
329 setlocale (LC_NUMERIC, "");-
330 if (x_strlen < 0)
x_strlen < 0Description
TRUEnever evaluated
FALSEevaluated 75 times by 1 test
Evaluated by:
  • seq
0-75
331 xalloc_die ();
never executed: xalloc_die ();
0
332 x_str[x_strlen - layout.suffix_len] = '\0';-
333-
334 if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, c_strtold)
xstrtold (x_st...al, c_strtold)Description
TRUEevaluated 73 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 2 times by 1 test
Evaluated by:
  • seq
2-73
335 && x_val == last)
x_val == lastDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 68 times by 1 test
Evaluated by:
  • seq
5-68
336 {-
337 char *x0_str = NULL;-
338 if (asprintf (&x0_str, fmt, x0) < 0)
asprintf (&x0_..., fmt, x0) < 0Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • seq
0-5
339 xalloc_die ();
never executed: xalloc_die ();
0
340 print_extra_number = !STREQ (x0_str, x_str);
never executed: __result = (((const unsigned char *) (const char *) ( x0_str ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( x_str ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__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
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__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
341 free (x0_str);-
342 }
executed 5 times by 1 test: end of block
Executed by:
  • seq
5
343-
344 free (x_str);-
345 if (! print_extra_number)
! print_extra_numberDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 5 times by 1 test
Evaluated by:
  • seq
5-70
346 break;
executed 70 times by 1 test: break;
Executed by:
  • seq
70
347 }
executed 5 times by 1 test: end of block
Executed by:
  • seq
5
348-
349 if (fputs (separator, stdout) == EOF)
fputs_unlocked...dout ) == (-1)Description
TRUEnever evaluated
FALSEevaluated 268857 times by 1 test
Evaluated by:
  • seq
0-268857
350 io_error ();
never executed: io_error ();
0
351 }
executed 268857 times by 1 test: end of block
Executed by:
  • seq
268857
352-
353 if (fputs (terminator, stdout) == EOF)
fputs_unlocked...dout ) == (-1)Description
TRUEnever evaluated
FALSEevaluated 75 times by 1 test
Evaluated by:
  • seq
0-75
354 io_error ();
never executed: io_error ();
0
355 }
executed 75 times by 1 test: end of block
Executed by:
  • seq
75
356}
executed 80 times by 1 test: end of block
Executed by:
  • seq
80
357-
358/* Return the default format given FIRST, STEP, and LAST. */-
359static char const *-
360get_default_format (operand first, operand step, operand last)-
361{-
362 static char format_buf[sizeof "%0.Lf" + 2 * INT_STRLEN_BOUND (int)];-
363-
364 int prec = MAX (first.precision, step.precision);
(( first.preci...p.precision ))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 64 times by 1 test
Evaluated by:
  • seq
5-64
365-
366 if (prec != INT_MAX && last.precision != INT_MAX)
prec != 0x7fffffffDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1 time by 1 test
Evaluated by:
  • seq
last.precision != 0x7fffffffDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
0-68
367 {-
368 if (equal_width)
equal_widthDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 48 times by 1 test
Evaluated by:
  • seq
20-48
369 {-
370 /* increase first_width by any increased precision in step */-
371 size_t first_width = first.width + (prec - first.precision);-
372 /* adjust last_width to use precision from first/step */-
373 size_t last_width = last.width + (prec - last.precision);-
374 if (last.precision && prec == 0)
last.precisionDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 15 times by 1 test
Evaluated by:
  • seq
prec == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • seq
FALSEevaluated 4 times by 1 test
Evaluated by:
  • seq
1-15
375 last_width--; /* don't include space for '.' */
executed 1 time by 1 test: last_width--;
Executed by:
  • seq
1
376 if (last.precision == 0 && prec)
last.precision == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 5 times by 1 test
Evaluated by:
  • seq
precDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 8 times by 1 test
Evaluated by:
  • seq
5-15
377 last_width++; /* include space for '.' */
executed 7 times by 1 test: last_width++;
Executed by:
  • seq
7
378 if (first.precision == 0 && prec)
first.precision == 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 7 times by 1 test
Evaluated by:
  • seq
precDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 9 times by 1 test
Evaluated by:
  • seq
4-13
379 first_width++; /* include space for '.' */
executed 4 times by 1 test: first_width++;
Executed by:
  • seq
4
380 size_t width = MAX (first_width, last_width);
(( first_width... last_width ))Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 13 times by 1 test
Evaluated by:
  • seq
7-13
381 if (width <= INT_MAX)
width <= 0x7fffffffDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
0-20
382 {-
383 int w = width;-
384 sprintf (format_buf, "%%0%d.%dLf", w, prec);-
385 return format_buf;
executed 20 times by 1 test: return format_buf;
Executed by:
  • seq
20
386 }-
387 }
never executed: end of block
0
388 else-
389 {-
390 sprintf (format_buf, "%%.%dLf", prec);-
391 return format_buf;
executed 48 times by 1 test: return format_buf;
Executed by:
  • seq
48
392 }-
393 }-
394-
395 return "%Lg";
executed 1 time by 1 test: return "%Lg";
Executed by:
  • seq
1
396}-
397-
398/* The NUL-terminated string S0 of length S_LEN represents a valid-
399 non-negative decimal integer. Adjust the string and length so-
400 that the pair describe the next-larger value. */-
401static void-
402incr (char **s0, size_t *s_len)-
403{-
404 char *s = *s0;-
405 char *endp = s + *s_len - 1;-
406-
407 do-
408 {-
409 if ((*endp)++ < '9')
(*endp)++ < '9'Description
TRUEevaluated 1144312 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 132274 times by 1 test
Evaluated by:
  • seq
132274-1144312
410 return;
executed 1144312 times by 1 test: return;
Executed by:
  • seq
1144312
411 *endp-- = '0';-
412 }
executed 132274 times by 1 test: end of block
Executed by:
  • seq
132274
413 while (endp >= s);
endp >= sDescription
TRUEevaluated 132066 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 208 times by 1 test
Evaluated by:
  • seq
208-132066
414 *--(*s0) = '1';-
415 ++*s_len;-
416}
executed 208 times by 1 test: end of block
Executed by:
  • seq
208
417-
418/* Compare A and B (each a NUL-terminated digit string), with lengths-
419 given by A_LEN and B_LEN. Return +1 if A < B, -1 if B < A, else 0. */-
420static int-
421cmp (char const *a, size_t a_len, char const *b, size_t b_len)-
422{-
423 if (a_len < b_len)
a_len < b_lenDescription
TRUEevaluated 1039799 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 85614 times by 1 test
Evaluated by:
  • seq
85614-1039799
424 return -1;
executed 1039799 times by 1 test: return -1;
Executed by:
  • seq
1039799
425 if (b_len < a_len)
b_len < a_lenDescription
TRUEnever evaluated
FALSEevaluated 85614 times by 1 test
Evaluated by:
  • seq
0-85614
426 return 1;
never executed: return 1;
0
427 return (strcmp (a, b));
executed 85614 times by 1 test: return ( __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( a ) && __builtin_constant_p ( b ) && (__s1_len = __builtin_strlen ( a ), __s2_len = __builtin_strlen ( b ), (!((size_t)(const void *)(( a ) + 1) - (size_t)(const void *)( a ) == ...result == 0) { __result = (((const unsigned char *) (const char *) ( b ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( b ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( a , b )))); }) );
Executed by:
  • seq
never executed: __result = (((const unsigned char *) (const char *) ( a ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( b ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__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
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__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-85614
428}-
429-
430/* Trim leading 0's from S, but if S is all 0's, leave one.-
431 Return a pointer to the trimmed string. */-
432static char const * _GL_ATTRIBUTE_PURE-
433trim_leading_zeros (char const *s)-
434{-
435 char const *p = s;-
436 while (*s == '0')
*s == '0'Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 388 times by 1 test
Evaluated by:
  • seq
20-388
437 ++s;
executed 20 times by 1 test: ++s;
Executed by:
  • seq
20
438-
439 /* If there were only 0's, back up, to leave one. */-
440 if (!*s && s != p)
!*sDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 376 times by 1 test
Evaluated by:
  • seq
s != pDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
0-376
441 --s;
executed 12 times by 1 test: --s;
Executed by:
  • seq
12
442 return s;
executed 388 times by 1 test: return s;
Executed by:
  • seq
388
443}-
444-
445/* Print all whole numbers from A to B, inclusive -- to stdout, each-
446 followed by a newline. If B < A, return false and print nothing.-
447 Otherwise, return true. */-
448static bool-
449seq_fast (char const *a, char const *b)-
450{-
451 bool inf = STREQ (b, "inf");
never executed: __result = (((const unsigned char *) (const char *) ( b ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
executed 3 times by 1 test: __result = (((const unsigned char *) (const char *) ( "inf" ))[3] - __s2[3]);
Executed by:
  • seq
executed 3 times by 1 test: end of block
Executed by:
  • seq
executed 3 times by 1 test: end of block
Executed by:
  • seq
__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 194 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
__result == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 191 times by 1 test
Evaluated by:
  • seq
__s2_len > 1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
__result == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
__s2_len > 2Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
__result == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
0-194
452-
453 /* Skip past any leading 0's. Without this, our naive cmp-
454 function would declare 000 to be larger than 99. */-
455 a = trim_leading_zeros (a);-
456 b = trim_leading_zeros (b);-
457-
458 size_t p_len = strlen (a);-
459 size_t q_len = inf ? 0 : strlen (b);
infDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 191 times by 1 test
Evaluated by:
  • seq
3-191
460-
461 /* Allow for at least 31 digits without realloc.-
462 1 more than p_len is needed for the inf case. */-
463 size_t inc_size = MAX (MAX (p_len + 1, q_len), 31);
((((( p_len + ...en )))>( 31 ))Description
TRUEevaluated 71 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 123 times by 1 test
Evaluated by:
  • seq
(( p_len + 1 )>( q_len ))Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 158 times by 1 test
Evaluated by:
  • seq
(( p_len + 1 )>( q_len ))Description
TRUEnever evaluated
FALSEevaluated 71 times by 1 test
Evaluated by:
  • seq
0-158
464-
465 /* Copy input strings (incl NUL) to end of new buffers. */-
466 char *p0 = xmalloc (inc_size + 1);-
467 char *p = memcpy (p0 + inc_size - p_len, a, p_len + 1);-
468 char *q;-
469 char *q0;-
470 if (! inf)
! infDescription
TRUEevaluated 191 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 3 times by 1 test
Evaluated by:
  • seq
3-191
471 {-
472 q0 = xmalloc (inc_size + 1);-
473 q = memcpy (q0 + inc_size - q_len, b, q_len + 1);-
474 }
executed 191 times by 1 test: end of block
Executed by:
  • seq
191
475 else-
476 q = q0 = NULL;
executed 3 times by 1 test: q = q0 = ((void *)0) ;
Executed by:
  • seq
3
477-
478 bool ok = inf || cmp (p, p_len, q, q_len) <= 0;
infDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 191 times by 1 test
Evaluated by:
  • seq
cmp (p, p_len, q, q_len) <= 0Description
TRUEevaluated 187 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 4 times by 1 test
Evaluated by:
  • seq
3-191
479 if (ok)
okDescription
TRUEevaluated 190 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 4 times by 1 test
Evaluated by:
  • seq
4-190
480 {-
481 /* Reduce number of fwrite calls which is seen to-
482 give a speed-up of more than 2x over the unbuffered code-
483 when printing the first 10^9 integers. */-
484 size_t buf_size = MAX (BUFSIZ, (inc_size + 1) * 2);
((8192)>( (inc...ze + 1) * 2 ))Description
TRUEevaluated 190 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
0-190
485 char *buf = xmalloc (buf_size);-
486 char const *buf_end = buf + buf_size;-
487-
488 char *bufp = buf;-
489-
490 /* Write first number to buffer. */-
491 bufp = mempcpy (bufp, p, p_len);-
492-
493 /* Append separator then number. */-
494 while (inf || cmp (p, p_len, q, q_len) < 0)
infDescription
TRUEevaluated 19485 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1125222 times by 1 test
Evaluated by:
  • seq
cmp (p, p_len, q, q_len) < 0Description
TRUEevaluated 1125035 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 187 times by 1 test
Evaluated by:
  • seq
187-1125222
495 {-
496 *bufp++ = *separator;-
497 incr (&p, &p_len);-
498-
499 /* Double up the buffers when needed for the inf case. */-
500 if (p_len == inc_size)
p_len == inc_sizeDescription
TRUEevaluated 72 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1144448 times by 1 test
Evaluated by:
  • seq
72-1144448
501 {-
502 inc_size *= 2;-
503 p0 = xrealloc (p0, inc_size + 1);-
504 p = memmove (p0 + p_len, p0, p_len + 1);-
505-
506 if (buf_size < (inc_size + 1) * 2)
buf_size < (inc_size + 1) * 2Description
TRUEnever evaluated
FALSEevaluated 72 times by 1 test
Evaluated by:
  • seq
0-72
507 {-
508 size_t buf_offset = bufp - buf;-
509 buf_size = (inc_size + 1) * 2;-
510 buf = xrealloc (buf, buf_size);-
511 buf_end = buf + buf_size;-
512 bufp = buf + buf_offset;-
513 }
never executed: end of block
0
514 }
executed 72 times by 1 test: end of block
Executed by:
  • seq
72
515-
516 bufp = mempcpy (bufp, p, p_len);-
517 /* If no place for another separator + number then-
518 output buffer so far, and reset to start of buffer. */-
519 if (buf_end - (p_len + 1) < bufp)
buf_end - (p_len + 1) < bufpDescription
TRUEevaluated 933 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1143587 times by 1 test
Evaluated by:
  • seq
933-1143587
520 {-
521 if (fwrite (buf, bufp - buf, 1, stdout) != 1)
never executed: break;
(__extension__...tdout)))) != 1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 930 times by 1 test
Evaluated by:
  • seq
(__builtin_exp...r++))) == (-1)Description
TRUEnever evaluated
FALSEnever evaluated
__cnt > 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_expe...write_end), 0)Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...( bufp - buf )Description
TRUEnever evaluated
FALSEevaluated 933 times by 1 test
Evaluated by:
  • seq
__builtin_constant_p ( 1 )Description
TRUEnever evaluated
FALSEnever evaluated
(size_t) ( buf..._t) ( 1 ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
(size_t) ( bufp - buf ) != 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...( bufp - buf )Description
TRUEnever evaluated
FALSEevaluated 933 times by 1 test
Evaluated by:
  • seq
(size_t) ( bufp - buf ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( 1 )Description
TRUEevaluated 933 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
(size_t) ( 1 ) == 0Description
TRUEnever evaluated
FALSEevaluated 933 times by 1 test
Evaluated by:
  • seq
0-933
522 io_error ();
executed 3 times by 1 test: io_error ();
Executed by:
  • seq
3
523 bufp = buf;-
524 }
executed 930 times by 1 test: end of block
Executed by:
  • seq
930
525 }
executed 1144517 times by 1 test: end of block
Executed by:
  • seq
1144517
526-
527 /* Write any remaining buffered output, and the terminator. */-
528 *bufp++ = *terminator;-
529 if (fwrite (buf, bufp - buf, 1, stdout) != 1)
never executed: break;
(__extension__...tdout)))) != 1Description
TRUEnever evaluated
FALSEevaluated 187 times by 1 test
Evaluated by:
  • seq
(__builtin_exp...r++))) == (-1)Description
TRUEnever evaluated
FALSEnever evaluated
__cnt > 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_expe...write_end), 0)Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...( bufp - buf )Description
TRUEnever evaluated
FALSEevaluated 187 times by 1 test
Evaluated by:
  • seq
__builtin_constant_p ( 1 )Description
TRUEnever evaluated
FALSEnever evaluated
(size_t) ( buf..._t) ( 1 ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
(size_t) ( bufp - buf ) != 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...( bufp - buf )Description
TRUEnever evaluated
FALSEevaluated 187 times by 1 test
Evaluated by:
  • seq
(size_t) ( bufp - buf ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( 1 )Description
TRUEevaluated 187 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
(size_t) ( 1 ) == 0Description
TRUEnever evaluated
FALSEevaluated 187 times by 1 test
Evaluated by:
  • seq
0-187
530 io_error ();
never executed: io_error ();
0
531-
532 IF_LINT (free (buf));-
533 }
executed 187 times by 1 test: end of block
Executed by:
  • seq
187
534-
535 free (p0);-
536 free (q0);-
537 return ok;
executed 191 times by 1 test: return ok;
Executed by:
  • seq
191
538}-
539-
540/* Return true if S consists of at least one digit and no non-digits. */-
541static bool _GL_ATTRIBUTE_PURE-
542all_digits_p (char const *s)-
543{-
544 size_t n = strlen (s);-
545 return ISDIGIT (s[0]) && n == strspn (s, "0123456789");
executed 472 times by 1 test: return ((unsigned int) (s[0]) - '0' <= 9) && n == __builtin_strspn ( s , "0123456789" ) ;
Executed by:
  • seq
472
546}-
547-
548int-
549main (int argc, char **argv)-
550{-
551 int optc;-
552 operand first = { 1, 1, 0 };-
553 operand step = { 1, 1, 0 };-
554 operand last;-
555 struct layout layout = { 0, 0 };-
556-
557 /* The printf(3) format used for output. */-
558 char const *format_str = NULL;-
559-
560 initialize_main (&argc, &argv);-
561 set_program_name (argv[0]);-
562 setlocale (LC_ALL, "");-
563 bindtextdomain (PACKAGE, LOCALEDIR);-
564 textdomain (PACKAGE);-
565-
566 atexit (close_stdout);-
567-
568 equal_width = false;-
569 separator = "\n";-
570-
571 /* We have to handle negative numbers in the command line but this-
572 conflicts with the command line arguments. So explicitly check first-
573 whether the next argument looks like a negative number. */-
574 while (optind < argc)
optind < argcDescription
TRUEevaluated 363 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
0-363
575 {-
576 if (argv[optind][0] == '-'
argv[optind][0] == '-'Description
TRUEevaluated 84 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 279 times by 1 test
Evaluated by:
  • seq
84-279
577 && ((optc = argv[optind][1]) == '.' || ISDIGIT (optc)))
(optc = argv[o...nd][1]) == '.'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • seq
FALSEevaluated 83 times by 1 test
Evaluated by:
  • seq
((unsigned int...c) - '0' <= 9)Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 72 times by 1 test
Evaluated by:
  • seq
1-83
578 {-
579 /* means negative number */-
580 break;
executed 12 times by 1 test: break;
Executed by:
  • seq
12
581 }-
582-
583 optc = getopt_long (argc, argv, "+f:s:w", long_options, NULL);-
584 if (optc == -1)
optc == -1Description
TRUEevaluated 281 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 70 times by 1 test
Evaluated by:
  • seq
70-281
585 break;
executed 281 times by 1 test: break;
Executed by:
  • seq
281
586-
587 switch (optc)-
588 {-
589 case 'f':
executed 23 times by 1 test: case 'f':
Executed by:
  • seq
23
590 format_str = optarg;-
591 break;
executed 23 times by 1 test: break;
Executed by:
  • seq
23
592-
593 case 's':
executed 5 times by 1 test: case 's':
Executed by:
  • seq
5
594 separator = optarg;-
595 break;
executed 5 times by 1 test: break;
Executed by:
  • seq
5
596-
597 case 'w':
executed 22 times by 1 test: case 'w':
Executed by:
  • seq
22
598 equal_width = true;-
599 break;
executed 22 times by 1 test: break;
Executed by:
  • seq
22
600-
601 case_GETOPT_HELP_CHAR;
never executed: break;
executed 9 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • seq
0-9
602-
603 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
executed 8 times by 1 test: exit ( 0 );
Executed by:
  • seq
never executed: break;
executed 8 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • seq
0-8
604-
605 default:
executed 3 times by 1 test: default:
Executed by:
  • seq
3
606 usage (EXIT_FAILURE);-
607 }
never executed: end of block
0
608 }-
609-
610 unsigned int n_args = argc - optind;-
611 if (n_args < 1)
n_args < 1Description
TRUEnever evaluated
FALSEevaluated 293 times by 1 test
Evaluated by:
  • seq
0-293
612 {-
613 error (0, 0, _("missing operand"));-
614 usage (EXIT_FAILURE);-
615 }
never executed: end of block
0
616-
617 if (3 < n_args)
3 < n_argsDescription
TRUEnever evaluated
FALSEevaluated 293 times by 1 test
Evaluated by:
  • seq
0-293
618 {-
619 error (0, 0, _("extra operand %s"), quote (argv[optind + 3]));-
620 usage (EXIT_FAILURE);-
621 }
never executed: end of block
0
622-
623 if (format_str)
format_strDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 272 times by 1 test
Evaluated by:
  • seq
21-272
624 format_str = long_double_format (format_str, &layout);
executed 21 times by 1 test: format_str = long_double_format (format_str, &layout);
Executed by:
  • seq
21
625-
626 if (format_str != NULL && equal_width)
format_str != ((void *)0)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 272 times by 1 test
Evaluated by:
  • seq
equal_widthDescription
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • seq
0-272
627 {-
628 error (0, 0, _("format string may not be specified"-
629 " when printing equal width strings"));-
630 usage (EXIT_FAILURE);-
631 }
never executed: end of block
0
632-
633 /* If the following hold:-
634 - no format string, [FIXME: relax this, eventually]-
635 - integer start (or no start)-
636 - integer end-
637 - increment == 1 or not specified [FIXME: relax this, eventually]-
638 then use the much more efficient integer-only code. */-
639 if (all_digits_p (argv[optind])
all_digits_p (argv[optind])Description
TRUEevaluated 249 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 39 times by 1 test
Evaluated by:
  • seq
39-249
640 && (n_args == 1 || all_digits_p (argv[optind + 1]))
n_args == 1Description
TRUEevaluated 69 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 180 times by 1 test
Evaluated by:
  • seq
all_digits_p (...v[optind + 1])Description
TRUEevaluated 146 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 34 times by 1 test
Evaluated by:
  • seq
34-180
641 && (n_args < 3 || (STREQ ("1", argv[optind + 1])
never executed: __result = (((const unsigned char *) (const char *) ( "1" ))[3] - __s2[3]);
never executed: end of block
executed 4 times by 1 test: end of block
Executed by:
  • seq
never executed: __result = (((const unsigned char *) (const char *) ( argv[optind + 1] ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
n_args < 3Description
TRUEevaluated 198 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 17 times by 1 test
Evaluated by:
  • seq
( __extension_...)))); }) == 0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 13 times by 1 test
Evaluated by:
  • seq
__s1_len > 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • seq
FALSEnever evaluated
__result == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 13 times by 1 test
Evaluated by:
  • seq
__s1_len > 1Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • seq
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__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-198
642 && all_digits_p (argv[optind + 2])))
all_digits_p (...v[optind + 2])Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 2 times by 1 test
Evaluated by:
  • seq
2
643 && !equal_width && !format_str && strlen (separator) == 1)
!equal_widthDescription
TRUEevaluated 197 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 3 times by 1 test
Evaluated by:
  • seq
!format_strDescription
TRUEevaluated 186 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 11 times by 1 test
Evaluated by:
  • seq
strlen (separator) == 1Description
TRUEevaluated 185 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1 time by 1 test
Evaluated by:
  • seq
1-197
644 {-
645 char const *s1 = n_args == 1 ? "1" : argv[optind];
n_args == 1Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 125 times by 1 test
Evaluated by:
  • seq
60-125
646 char const *s2 = argv[optind + (n_args - 1)];-
647 if (seq_fast (s1, s2))
seq_fast (s1, s2)Description
TRUEevaluated 183 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 2 times by 1 test
Evaluated by:
  • seq
2-183
648 return EXIT_SUCCESS;
executed 183 times by 1 test: return 0 ;
Executed by:
  • seq
183
649-
650 /* Upon any failure, let the more general code deal with it. */-
651 }
executed 2 times by 1 test: end of block
Executed by:
  • seq
2
652-
653 last = scan_arg (argv[optind++]);-
654-
655 if (optind < argc)
optind < argcDescription
TRUEevaluated 87 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 14 times by 1 test
Evaluated by:
  • seq
14-87
656 {-
657 first = last;-
658 last = scan_arg (argv[optind++]);-
659-
660 if (optind < argc)
optind < argcDescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 25 times by 1 test
Evaluated by:
  • seq
25-59
661 {-
662 step = last;-
663 if (step.value == 0)
step.value == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 55 times by 1 test
Evaluated by:
  • seq
4-55
664 {-
665 error (0, 0, _("invalid Zero increment value: %s"),-
666 quote (argv[optind-1]));-
667 usage (EXIT_FAILURE);-
668 }
never executed: end of block
0
669-
670 last = scan_arg (argv[optind++]);-
671 }
executed 53 times by 1 test: end of block
Executed by:
  • seq
53
672 }
executed 78 times by 1 test: end of block
Executed by:
  • seq
78
673-
674 if ((isfinite (first.value) && first.precision == 0)
((first.value) * 0 == 0)Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1 time by 1 test
Evaluated by:
  • seq
first.precision == 0Description
TRUEevaluated 71 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 20 times by 1 test
Evaluated by:
  • seq
1-91
675 && step.precision == 0 && last.precision == 0
step.precision == 0Description
TRUEevaluated 62 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 9 times by 1 test
Evaluated by:
  • seq
last.precision == 0Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 2 times by 1 test
Evaluated by:
  • seq
2-62
676 && 0 <= first.value && step.value == 1 && 0 <= last.value
0 <= first.valueDescription
TRUEevaluated 57 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 3 times by 1 test
Evaluated by:
  • seq
step.value == 1Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 26 times by 1 test
Evaluated by:
  • seq
0 <= last.valueDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1 time by 1 test
Evaluated by:
  • seq
1-57
677 && !equal_width && !format_str && strlen (separator) == 1)
!equal_widthDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 7 times by 1 test
Evaluated by:
  • seq
!format_strDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 11 times by 1 test
Evaluated by:
  • seq
strlen (separator) == 1Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1 time by 1 test
Evaluated by:
  • seq
1-23
678 {-
679 char *s1;-
680 char *s2;-
681 if (asprintf (&s1, "%0.Lf", first.value) < 0)
asprintf (&s1,...rst.value) < 0Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • seq
0-11
682 xalloc_die ();
never executed: xalloc_die ();
0
683 if (! isfinite (last.value))
! ((last.value) * 0 == 0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 8 times by 1 test
Evaluated by:
  • seq
3-8
684 s2 = xstrdup ("inf"); /* Ensure "inf" is used. */
executed 3 times by 1 test: s2 = xstrdup ("inf");
Executed by:
  • seq
3
685 else if (asprintf (&s2, "%0.Lf", last.value) < 0)
asprintf (&s2,...ast.value) < 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • seq
0-8
686 xalloc_die ();
never executed: xalloc_die ();
0
687-
688 if (*s1 != '-' && *s2 != '-' && seq_fast (s1, s2))
*s1 != '-'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1 time by 1 test
Evaluated by:
  • seq
*s2 != '-'Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 1 time by 1 test
Evaluated by:
  • seq
seq_fast (s1, s2)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 2 times by 1 test
Evaluated by:
  • seq
1-10
689 {-
690 IF_LINT (free (s1));-
691 IF_LINT (free (s2));-
692 return EXIT_SUCCESS;
executed 4 times by 1 test: return 0 ;
Executed by:
  • seq
4
693 }-
694-
695 free (s1);-
696 free (s2);-
697 /* Upon any failure, let the more general code deal with it. */-
698 }
executed 4 times by 1 test: end of block
Executed by:
  • seq
4
699-
700 if (format_str == NULL)
format_str == ((void *)0)Description
TRUEevaluated 69 times by 1 test
Evaluated by:
  • seq
FALSEevaluated 16 times by 1 test
Evaluated by:
  • seq
16-69
701 format_str = get_default_format (first, step, last);
executed 69 times by 1 test: format_str = get_default_format (first, step, last);
Executed by:
  • seq
69
702-
703 print_numbers (format_str, layout, first.value, step.value, last.value);-
704-
705 return EXIT_SUCCESS;
executed 80 times by 1 test: return 0 ;
Executed by:
  • seq
80
706}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2