OpenCoverage

join.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/join.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* join - join lines of two files on a common field-
2 Copyright (C) 1991-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 Mike Haertel, mike@gnu.ai.mit.edu. */-
18-
19#include <config.h>-
20-
21#include <assert.h>-
22#include <sys/types.h>-
23#include <getopt.h>-
24-
25#include "system.h"-
26#include "die.h"-
27#include "error.h"-
28#include "fadvise.h"-
29#include "hard-locale.h"-
30#include "linebuffer.h"-
31#include "memcasecmp.h"-
32#include "quote.h"-
33#include "stdio--.h"-
34#include "xmemcoll.h"-
35#include "xstrtol.h"-
36#include "argmatch.h"-
37-
38/* The official name of this program (e.g., no 'g' prefix). */-
39#define PROGRAM_NAME "join"-
40-
41#define AUTHORS proper_name ("Mike Haertel")-
42-
43#define join system_join-
44-
45#define SWAPLINES(a, b) do { \-
46 struct line *tmp = a; \-
47 a = b; \-
48 b = tmp; \-
49} while (0);-
50-
51/* An element of the list identifying which fields to print for each-
52 output line. */-
53struct outlist-
54 {-
55 /* File number: 0, 1, or 2. 0 means use the join field.-
56 1 means use the first file argument, 2 the second. */-
57 int file;-
58-
59 /* Field index (zero-based), specified only when FILE is 1 or 2. */-
60 size_t field;-
61-
62 struct outlist *next;-
63 };-
64-
65/* A field of a line. */-
66struct field-
67 {-
68 char *beg; /* First character in field. */-
69 size_t len; /* The length of the field. */-
70 };-
71-
72/* A line read from an input file. */-
73struct line-
74 {-
75 struct linebuffer buf; /* The line itself. */-
76 size_t nfields; /* Number of elements in 'fields'. */-
77 size_t nfields_allocated; /* Number of elements allocated for 'fields'. */-
78 struct field *fields;-
79 };-
80-
81/* One or more consecutive lines read from a file that all have the-
82 same join field value. */-
83struct seq-
84 {-
85 size_t count; /* Elements used in 'lines'. */-
86 size_t alloc; /* Elements allocated in 'lines'. */-
87 struct line **lines;-
88 };-
89-
90/* The previous line read from each file. */-
91static struct line *prevline[2] = {NULL, NULL};-
92-
93/* The number of lines read from each file. */-
94static uintmax_t line_no[2] = {0, 0};-
95-
96/* The input file names. */-
97static char *g_names[2];-
98-
99/* This provides an extra line buffer for each file. We need these if we-
100 try to read two consecutive lines into the same buffer, since we don't-
101 want to overwrite the previous buffer before we check order. */-
102static struct line *spareline[2] = {NULL, NULL};-
103-
104/* True if the LC_COLLATE locale is hard. */-
105static bool hard_LC_COLLATE;-
106-
107/* If nonzero, print unpairable lines in file 1 or 2. */-
108static bool print_unpairables_1, print_unpairables_2;-
109-
110/* If nonzero, print pairable lines. */-
111static bool print_pairables;-
112-
113/* If nonzero, we have seen at least one unpairable line. */-
114static bool seen_unpairable;-
115-
116/* If nonzero, we have warned about disorder in that file. */-
117static bool issued_disorder_warning[2];-
118-
119/* Empty output field filler. */-
120static char const *empty_filler;-
121-
122/* Whether to ensure the same number of fields are output from each line. */-
123static bool autoformat;-
124/* The number of fields to output for each line.-
125 Only significant when autoformat is true. */-
126static size_t autocount_1;-
127static size_t autocount_2;-
128-
129/* Field to join on; SIZE_MAX means they haven't been determined yet. */-
130static size_t join_field_1 = SIZE_MAX;-
131static size_t join_field_2 = SIZE_MAX;-
132-
133/* List of fields to print. */-
134static struct outlist outlist_head;-
135-
136/* Last element in 'outlist', where a new element can be added. */-
137static struct outlist *outlist_end = &outlist_head;-
138-
139/* Tab character separating fields. If negative, fields are separated-
140 by any nonempty string of blanks, otherwise by exactly one-
141 tab character whose value (when cast to unsigned char) equals TAB. */-
142static int tab = -1;-
143-
144/* If nonzero, check that the input is correctly ordered. */-
145static enum-
146 {-
147 CHECK_ORDER_DEFAULT,-
148 CHECK_ORDER_ENABLED,-
149 CHECK_ORDER_DISABLED-
150 } check_input_order;-
151-
152enum-
153{-
154 CHECK_ORDER_OPTION = CHAR_MAX + 1,-
155 NOCHECK_ORDER_OPTION,-
156 HEADER_LINE_OPTION-
157};-
158-
159-
160static struct option const longopts[] =-
161{-
162 {"ignore-case", no_argument, NULL, 'i'},-
163 {"check-order", no_argument, NULL, CHECK_ORDER_OPTION},-
164 {"nocheck-order", no_argument, NULL, NOCHECK_ORDER_OPTION},-
165 {"zero-terminated", no_argument, NULL, 'z'},-
166 {"header", no_argument, NULL, HEADER_LINE_OPTION},-
167 {GETOPT_HELP_OPTION_DECL},-
168 {GETOPT_VERSION_OPTION_DECL},-
169 {NULL, 0, NULL, 0}-
170};-
171-
172/* Used to print non-joining lines */-
173static struct line uni_blank;-
174-
175/* If nonzero, ignore case when comparing join fields. */-
176static bool ignore_case;-
177-
178/* If nonzero, treat the first line of each file as column headers ---
179 join them without checking for ordering */-
180static bool join_header_lines;-
181-
182/* The character marking end of line. Default to \n. */-
183static char eolchar = '\n';-
184-
185void-
186usage (int status)-
187{-
188 if (status != EXIT_SUCCESS)
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • join
FALSEevaluated 11 times by 1 test
Evaluated by:
  • join
3-11
189 emit_try_help ();
executed 3 times by 1 test: end of block
Executed by:
  • join
3
190 else-
191 {-
192 printf (_("\-
193Usage: %s [OPTION]... FILE1 FILE2\n\-
194"),-
195 program_name);-
196 fputs (_("\-
197For each pair of input lines with identical join fields, write a line to\n\-
198standard output. The default join field is the first, delimited by blanks.\-
199\n\-
200"), stdout);-
201 fputs (_("\-
202\n\-
203When FILE1 or FILE2 (not both) is -, read standard input.\n\-
204"), stdout);-
205 fputs (_("\-
206\n\-
207 -a FILENUM also print unpairable lines from file FILENUM, where\n\-
208 FILENUM is 1 or 2, corresponding to FILE1 or FILE2\n\-
209 -e EMPTY replace missing input fields with EMPTY\n\-
210"), stdout);-
211 fputs (_("\-
212 -i, --ignore-case ignore differences in case when comparing fields\n\-
213 -j FIELD equivalent to '-1 FIELD -2 FIELD'\n\-
214 -o FORMAT obey FORMAT while constructing output line\n\-
215 -t CHAR use CHAR as input and output field separator\n\-
216"), stdout);-
217 fputs (_("\-
218 -v FILENUM like -a FILENUM, but suppress joined output lines\n\-
219 -1 FIELD join on this FIELD of file 1\n\-
220 -2 FIELD join on this FIELD of file 2\n\-
221 --check-order check that the input is correctly sorted, even\n\-
222 if all input lines are pairable\n\-
223 --nocheck-order do not check that the input is correctly sorted\n\-
224 --header treat the first line in each file as field headers,\n\-
225 print them without trying to pair them\n\-
226"), stdout);-
227 fputs (_("\-
228 -z, --zero-terminated line delimiter is NUL, not newline\n\-
229"), stdout);-
230 fputs (HELP_OPTION_DESCRIPTION, stdout);-
231 fputs (VERSION_OPTION_DESCRIPTION, stdout);-
232 fputs (_("\-
233\n\-
234Unless -t CHAR is given, leading blanks separate fields and are ignored,\n\-
235else fields are separated by CHAR. Any FIELD is a field number counted\n\-
236from 1. FORMAT is one or more comma or blank separated specifications,\n\-
237each being 'FILENUM.FIELD' or '0'. Default FORMAT outputs the join field,\n\-
238the remaining fields from FILE1, the remaining fields from FILE2, all\n\-
239separated by CHAR. If FORMAT is the keyword 'auto', then the first\n\-
240line of each file determines the number of fields output for each line.\n\-
241\n\-
242Important: FILE1 and FILE2 must be sorted on the join fields.\n\-
243E.g., use \"sort -k 1b,1\" if 'join' has no options,\n\-
244or use \"join -t ''\" if 'sort' has no options.\n\-
245Note, comparisons honor the rules specified by 'LC_COLLATE'.\n\-
246If the input is not sorted and some lines cannot be joined, a\n\-
247warning message will be given.\n\-
248"), stdout);-
249 emit_ancillary_info (PROGRAM_NAME);-
250 }
executed 11 times by 1 test: end of block
Executed by:
  • join
11
251 exit (status);
executed 14 times by 1 test: exit (status);
Executed by:
  • join
14
252}-
253-
254/* Record a field in LINE, with location FIELD and size LEN. */-
255-
256static void-
257extract_field (struct line *line, char *field, size_t len)-
258{-
259 if (line->nfields >= line->nfields_allocated)
line->nfields ...elds_allocatedDescription
TRUEevaluated 275 times by 1 test
Evaluated by:
  • join
FALSEevaluated 340 times by 1 test
Evaluated by:
  • join
275-340
260 {-
261 line->fields = X2NREALLOC (line->fields, &line->nfields_allocated);-
262 }
executed 275 times by 1 test: end of block
Executed by:
  • join
275
263 line->fields[line->nfields].beg = field;-
264 line->fields[line->nfields].len = len;-
265 ++(line->nfields);-
266}
executed 615 times by 1 test: end of block
Executed by:
  • join
615
267-
268/* Fill in the 'fields' structure in LINE. */-
269-
270static void-
271xfields (struct line *line)-
272{-
273 char *ptr = line->buf.buffer;-
274 char const *lim = ptr + line->buf.length - 1;-
275-
276 if (ptr == lim)
ptr == limDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • join
FALSEevaluated 339 times by 1 test
Evaluated by:
  • join
3-339
277 return;
executed 3 times by 1 test: return;
Executed by:
  • join
3
278-
279 if (0 <= tab && tab != '\n')
0 <= tabDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • join
FALSEevaluated 317 times by 1 test
Evaluated by:
  • join
tab != '\n'Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • join
FALSEevaluated 6 times by 1 test
Evaluated by:
  • join
6-317
280 {-
281 char *sep;-
282 for (; (sep = memchr (ptr, tab, lim - ptr)) != NULL; ptr = sep + 1)
(sep = memchr ...!= ((void *)0)Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • join
FALSEevaluated 16 times by 1 test
Evaluated by:
  • join
16-25
283 extract_field (line, ptr, sep - ptr);
executed 25 times by 1 test: extract_field (line, ptr, sep - ptr);
Executed by:
  • join
25
284 }
executed 16 times by 1 test: end of block
Executed by:
  • join
16
285 else if (tab < 0)
tab < 0Description
TRUEevaluated 317 times by 1 test
Evaluated by:
  • join
FALSEevaluated 6 times by 1 test
Evaluated by:
  • join
6-317
286 {-
287 /* Skip leading blanks before the first field. */-
288 while (field_sep (*ptr))
field_sep (*ptr)Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • join
FALSEevaluated 317 times by 1 test
Evaluated by:
  • join
34-317
289 if (++ptr == lim)
++ptr == limDescription
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • join
0-34
290 return;
never executed: return;
0
291-
292 do-
293 {-
294 char *sep;-
295 for (sep = ptr + 1; sep != lim && ! field_sep (*sep); sep++)
sep != limDescription
TRUEevaluated 608 times by 1 test
Evaluated by:
  • join
FALSEevaluated 317 times by 1 test
Evaluated by:
  • join
! field_sep (*sep)Description
TRUEevaluated 357 times by 1 test
Evaluated by:
  • join
FALSEevaluated 251 times by 1 test
Evaluated by:
  • join
251-608
296 continue;
executed 357 times by 1 test: continue;
Executed by:
  • join
357
297 extract_field (line, ptr, sep - ptr);-
298 if (sep == lim)
sep == limDescription
TRUEevaluated 317 times by 1 test
Evaluated by:
  • join
FALSEevaluated 251 times by 1 test
Evaluated by:
  • join
251-317
299 return;
executed 317 times by 1 test: return;
Executed by:
  • join
317
300 for (ptr = sep + 1; ptr != lim && field_sep (*ptr); ptr++)
ptr != limDescription
TRUEevaluated 252 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
field_sep (*ptr)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • join
FALSEevaluated 251 times by 1 test
Evaluated by:
  • join
0-252
301 continue;
executed 1 time by 1 test: continue;
Executed by:
  • join
1
302 }
executed 251 times by 1 test: end of block
Executed by:
  • join
251
303 while (ptr != lim);
ptr != limDescription
TRUEevaluated 251 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
0-251
304 }
never executed: end of block
0
305-
306 extract_field (line, ptr, lim - ptr);-
307}
executed 22 times by 1 test: end of block
Executed by:
  • join
22
308-
309static void-
310freeline (struct line *line)-
311{-
312 if (line == NULL)
line == ((void *)0)Description
TRUEevaluated 2024 times by 1 test
Evaluated by:
  • join
FALSEevaluated 491 times by 1 test
Evaluated by:
  • join
491-2024
313 return;
executed 2024 times by 1 test: return;
Executed by:
  • join
2024
314 free (line->fields);-
315 line->fields = NULL;-
316 free (line->buf.buffer);-
317 line->buf.buffer = NULL;-
318}
executed 491 times by 1 test: end of block
Executed by:
  • join
491
319-
320/* Return <0 if the join field in LINE1 compares less than the one in LINE2;-
321 >0 if it compares greater; 0 if it compares equal.-
322 Report an error and exit if the comparison fails.-
323 Use join fields JF_1 and JF_2 respectively. */-
324-
325static int-
326keycmp (struct line const *line1, struct line const *line2,-
327 size_t jf_1, size_t jf_2)-
328{-
329 /* Start of field to compare in each file. */-
330 char *beg1;-
331 char *beg2;-
332-
333 size_t len1;-
334 size_t len2; /* Length of fields to compare. */-
335 int diff;-
336-
337 if (jf_1 < line1->nfields)
jf_1 < line1->nfieldsDescription
TRUEevaluated 329 times by 1 test
Evaluated by:
  • join
FALSEevaluated 7 times by 1 test
Evaluated by:
  • join
7-329
338 {-
339 beg1 = line1->fields[jf_1].beg;-
340 len1 = line1->fields[jf_1].len;-
341 }
executed 329 times by 1 test: end of block
Executed by:
  • join
329
342 else-
343 {-
344 beg1 = NULL;-
345 len1 = 0;-
346 }
executed 7 times by 1 test: end of block
Executed by:
  • join
7
347-
348 if (jf_2 < line2->nfields)
jf_2 < line2->nfieldsDescription
TRUEevaluated 323 times by 1 test
Evaluated by:
  • join
FALSEevaluated 13 times by 1 test
Evaluated by:
  • join
13-323
349 {-
350 beg2 = line2->fields[jf_2].beg;-
351 len2 = line2->fields[jf_2].len;-
352 }
executed 323 times by 1 test: end of block
Executed by:
  • join
323
353 else-
354 {-
355 beg2 = NULL;-
356 len2 = 0;-
357 }
executed 13 times by 1 test: end of block
Executed by:
  • join
13
358-
359 if (len1 == 0)
len1 == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • join
FALSEevaluated 329 times by 1 test
Evaluated by:
  • join
7-329
360 return len2 == 0 ? 0 : -1;
executed 7 times by 1 test: return len2 == 0 ? 0 : -1;
Executed by:
  • join
7
361 if (len2 == 0)
len2 == 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • join
FALSEevaluated 320 times by 1 test
Evaluated by:
  • join
9-320
362 return 1;
executed 9 times by 1 test: return 1;
Executed by:
  • join
9
363-
364 if (ignore_case)
ignore_caseDescription
TRUEnever evaluated
FALSEevaluated 320 times by 1 test
Evaluated by:
  • join
0-320
365 {-
366 /* FIXME: ignore_case does not work with NLS (in particular,-
367 with multibyte chars). */-
368 diff = memcasecmp (beg1, beg2, MIN (len1, len2));-
369 }
never executed: end of block
0
370 else-
371 {-
372 if (hard_LC_COLLATE)
hard_LC_COLLATEDescription
TRUEnever evaluated
FALSEevaluated 320 times by 1 test
Evaluated by:
  • join
0-320
373 return xmemcoll (beg1, len1, beg2, len2);
never executed: return xmemcoll (beg1, len1, beg2, len2);
0
374 diff = memcmp (beg1, beg2, MIN (len1, len2));-
375 }
executed 320 times by 1 test: end of block
Executed by:
  • join
320
376-
377 if (diff)
diffDescription
TRUEevaluated 216 times by 1 test
Evaluated by:
  • join
FALSEevaluated 104 times by 1 test
Evaluated by:
  • join
104-216
378 return diff;
executed 216 times by 1 test: return diff;
Executed by:
  • join
216
379 return len1 < len2 ? -1 : len1 != len2;
executed 104 times by 1 test: return len1 < len2 ? -1 : len1 != len2;
Executed by:
  • join
104
380}-
381-
382/* Check that successive input lines PREV and CURRENT from input file-
383 WHATFILE are presented in order, unless the user may be relying on-
384 the GNU extension that input lines may be out of order if no input-
385 lines are unpairable.-
386-
387 If the user specified --nocheck-order, the check is not made.-
388 If the user specified --check-order, the problem is fatal.-
389 Otherwise (the default), the message is simply a warning.-
390-
391 A message is printed at most once per input file. */-
392-
393static void-
394check_order (const struct line *prev,-
395 const struct line *current,-
396 int whatfile)-
397{-
398 if (check_input_order != CHECK_ORDER_DISABLED
check_input_or...ORDER_DISABLEDDescription
TRUEevaluated 181 times by 1 test
Evaluated by:
  • join
FALSEevaluated 6 times by 1 test
Evaluated by:
  • join
6-181
399 && ((check_input_order == CHECK_ORDER_ENABLED) || seen_unpairable))
(check_input_o...ORDER_ENABLED)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • join
FALSEevaluated 172 times by 1 test
Evaluated by:
  • join
seen_unpairableDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • join
FALSEevaluated 144 times by 1 test
Evaluated by:
  • join
9-172
400 {-
401 if (!issued_disorder_warning[whatfile-1])
!issued_disord...ng[whatfile-1]Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
0-37
402 {-
403 size_t join_field = whatfile == 1 ? join_field_1 : join_field_2;
whatfile == 1Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • join
FALSEevaluated 11 times by 1 test
Evaluated by:
  • join
11-26
404 if (keycmp (prev, current, join_field, join_field) > 0)
keycmp (prev, ...oin_field) > 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • join
FALSEevaluated 29 times by 1 test
Evaluated by:
  • join
8-29
405 {-
406 /* Exclude any trailing newline. */-
407 size_t len = current->buf.length;-
408 if (0 < len && current->buf.buffer[len - 1] == '\n')
0 < lenDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
current->buf.b...n - 1] == '\n'Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
0-8
409 --len;
executed 8 times by 1 test: --len;
Executed by:
  • join
8
410-
411 /* If the offending line is longer than INT_MAX, output-
412 only the first INT_MAX bytes in this diagnostic. */-
413 len = MIN (INT_MAX, len);
((0x7fffffff)<( len ))Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • join
0-8
414-
415 error ((check_input_order == CHECK_ORDER_ENABLED-
416 ? EXIT_FAILURE : 0),-
417 0, _("%s:%"PRIuMAX": is not sorted: %.*s"),-
418 g_names[whatfile - 1], line_no[whatfile - 1],-
419 (int) len, current->buf.buffer);-
420-
421 /* If we get to here, the message was merely a warning.-
422 Arrange to issue it only once per file. */-
423 issued_disorder_warning[whatfile-1] = true;-
424 }
executed 4 times by 1 test: end of block
Executed by:
  • join
4
425 }
executed 33 times by 1 test: end of block
Executed by:
  • join
33
426 }
executed 33 times by 1 test: end of block
Executed by:
  • join
33
427}
executed 183 times by 1 test: end of block
Executed by:
  • join
183
428-
429static inline void-
430reset_line (struct line *line)-
431{-
432 line->nfields = 0;-
433}
executed 115 times by 1 test: end of block
Executed by:
  • join
115
434-
435static struct line *-
436init_linep (struct line **linep)-
437{-
438 struct line *line = xcalloc (1, sizeof *line);-
439 *linep = line;-
440 return line;
executed 366 times by 1 test: return line;
Executed by:
  • join
366
441}-
442-
443/* Read a line from FP into LINE and split it into fields.-
444 Return true if successful. */-
445-
446static bool-
447get_line (FILE *fp, struct line **linep, int which)-
448{-
449 struct line *line = *linep;-
450-
451 if (line == prevline[which - 1])
line == prevline[which - 1]Description
TRUEevaluated 228 times by 1 test
Evaluated by:
  • join
FALSEevaluated 253 times by 1 test
Evaluated by:
  • join
228-253
452 {-
453 SWAPLINES (line, spareline[which - 1]);-
454 *linep = line;-
455 }
executed 228 times by 1 test: end of block
Executed by:
  • join
228
456-
457 if (line)
lineDescription
TRUEevaluated 115 times by 1 test
Evaluated by:
  • join
FALSEevaluated 366 times by 1 test
Evaluated by:
  • join
115-366
458 reset_line (line);
executed 115 times by 1 test: reset_line (line);
Executed by:
  • join
115
459 else-
460 line = init_linep (linep);
executed 366 times by 1 test: line = init_linep (linep);
Executed by:
  • join
366
461-
462 if (! readlinebuffer_delim (&line->buf, fp, eolchar))
! readlinebuff..., fp, eolchar)Description
TRUEevaluated 139 times by 1 test
Evaluated by:
  • join
FALSEevaluated 342 times by 1 test
Evaluated by:
  • join
139-342
463 {-
464 if (ferror (fp))
ferror_unlocked (fp)Description
TRUEnever evaluated
FALSEevaluated 139 times by 1 test
Evaluated by:
  • join
0-139
465 die (EXIT_FAILURE, errno, _("read error"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"read error\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "read error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "read error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
466 freeline (line);-
467 return false;
executed 139 times by 1 test: return 0 ;
Executed by:
  • join
139
468 }-
469 ++line_no[which - 1];-
470-
471 xfields (line);-
472-
473 if (prevline[which - 1])
prevline[which - 1]Description
TRUEevaluated 187 times by 1 test
Evaluated by:
  • join
FALSEevaluated 155 times by 1 test
Evaluated by:
  • join
155-187
474 check_order (prevline[which - 1], line, which);
executed 187 times by 1 test: check_order (prevline[which - 1], line, which);
Executed by:
  • join
187
475-
476 prevline[which - 1] = line;-
477 return true;
executed 338 times by 1 test: return 1 ;
Executed by:
  • join
338
478}-
479-
480static void-
481free_spareline (void)-
482{-
483 for (size_t i = 0; i < ARRAY_CARDINALITY (spareline); i++)
i < (sizeof (s... *(spareline))Description
TRUEevaluated 200 times by 1 test
Evaluated by:
  • join
FALSEevaluated 100 times by 1 test
Evaluated by:
  • join
100-200
484 {-
485 if (spareline[i])
spareline[i]Description
TRUEevaluated 66 times by 1 test
Evaluated by:
  • join
FALSEevaluated 134 times by 1 test
Evaluated by:
  • join
66-134
486 {-
487 freeline (spareline[i]);-
488 free (spareline[i]);-
489 }
executed 66 times by 1 test: end of block
Executed by:
  • join
66
490 }
executed 200 times by 1 test: end of block
Executed by:
  • join
200
491}
executed 100 times by 1 test: end of block
Executed by:
  • join
100
492-
493static void-
494initseq (struct seq *seq)-
495{-
496 seq->count = 0;-
497 seq->alloc = 0;-
498 seq->lines = NULL;-
499}
executed 148 times by 1 test: end of block
Executed by:
  • join
148
500-
501/* Read a line from FP and add it to SEQ. Return true if successful. */-
502-
503static bool-
504getseq (FILE *fp, struct seq *seq, int whichfile)-
505{-
506 if (seq->count == seq->alloc)
seq->count == seq->allocDescription
TRUEevaluated 148 times by 1 test
Evaluated by:
  • join
FALSEevaluated 285 times by 1 test
Evaluated by:
  • join
148-285
507 {-
508 seq->lines = X2NREALLOC (seq->lines, &seq->alloc);-
509 for (size_t i = seq->count; i < seq->alloc; i++)
i < seq->allocDescription
TRUEevaluated 2368 times by 1 test
Evaluated by:
  • join
FALSEevaluated 148 times by 1 test
Evaluated by:
  • join
148-2368
510 seq->lines[i] = NULL;
executed 2368 times by 1 test: seq->lines[i] = ((void *)0) ;
Executed by:
  • join
2368
511 }
executed 148 times by 1 test: end of block
Executed by:
  • join
148
512-
513 if (get_line (fp, &seq->lines[seq->count], whichfile))
get_line (fp, ...t], whichfile)Description
TRUEevaluated 324 times by 1 test
Evaluated by:
  • join
FALSEevaluated 105 times by 1 test
Evaluated by:
  • join
105-324
514 {-
515 ++seq->count;-
516 return true;
executed 324 times by 1 test: return 1 ;
Executed by:
  • join
324
517 }-
518 return false;
executed 105 times by 1 test: return 0 ;
Executed by:
  • join
105
519}-
520-
521/* Read a line from FP and add it to SEQ, as the first item if FIRST is-
522 true, else as the next. */-
523static bool-
524advance_seq (FILE *fp, struct seq *seq, bool first, int whichfile)-
525{-
526 if (first)
firstDescription
TRUEevaluated 79 times by 1 test
Evaluated by:
  • join
FALSEevaluated 206 times by 1 test
Evaluated by:
  • join
79-206
527 seq->count = 0;
executed 79 times by 1 test: seq->count = 0;
Executed by:
  • join
79
528-
529 return getseq (fp, seq, whichfile);
executed 285 times by 1 test: return getseq (fp, seq, whichfile);
Executed by:
  • join
285
530}-
531-
532static void-
533delseq (struct seq *seq)-
534{-
535 for (size_t i = 0; i < seq->alloc; i++)
i < seq->allocDescription
TRUEevaluated 2240 times by 1 test
Evaluated by:
  • join
FALSEevaluated 140 times by 1 test
Evaluated by:
  • join
140-2240
536 {-
537 freeline (seq->lines[i]);-
538 free (seq->lines[i]);-
539 }
executed 2240 times by 1 test: end of block
Executed by:
  • join
2240
540 free (seq->lines);-
541}
executed 140 times by 1 test: end of block
Executed by:
  • join
140
542-
543-
544/* Print field N of LINE if it exists and is nonempty, otherwise-
545 'empty_filler' if it is nonempty. */-
546-
547static void-
548prfield (size_t n, struct line const *line)-
549{-
550 size_t len;-
551-
552 if (n < line->nfields)
n < line->nfieldsDescription
TRUEevaluated 318 times by 1 test
Evaluated by:
  • join
FALSEevaluated 82 times by 1 test
Evaluated by:
  • join
82-318
553 {-
554 len = line->fields[n].len;-
555 if (len)
lenDescription
TRUEevaluated 313 times by 1 test
Evaluated by:
  • join
FALSEevaluated 5 times by 1 test
Evaluated by:
  • join
5-313
556 fwrite (line->fields[n].beg, 1, len, stdout);
executed 313 times by 1 test: (__extension__ ((__builtin_constant_p ( 1 ) && __builtin_constant_p ( len ) && (size_t) ( 1 ) * (size_t) ( len ) <= 8 && (size_t) ( 1 ) != 0) ? ({ const char *__ptr = (const char *) ( line->fields[n].beg ); FILE *__stream = (stdout); size_t __cnt; for (__...tant_p ( 1 ) && (size_t) ( 1 ) == 0) || (__builtin_constant_p ( len ) && (size_t) ( len ) == 0)) ? ((void) ( line->fields[n].beg ), (void) (stdout), (void) ( 1 ), (void) ( len ), (size_t) 0) : fwrite_unlocked ( line->fields[n].beg , 1 , len , stdout)))) ;
Executed by:
  • join
never executed: break;
(__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
0-313
557 else if (empty_filler)
empty_fillerDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • join
0-5
558 fputs (empty_filler, stdout);
never executed: fputs_unlocked (empty_filler, stdout );
0
559 }
executed 318 times by 1 test: end of block
Executed by:
  • join
318
560 else if (empty_filler)
empty_fillerDescription
TRUEevaluated 79 times by 1 test
Evaluated by:
  • join
FALSEevaluated 3 times by 1 test
Evaluated by:
  • join
3-79
561 fputs (empty_filler, stdout);
executed 79 times by 1 test: fputs_unlocked (empty_filler, stdout );
Executed by:
  • join
79
562}
executed 400 times by 1 test: end of block
Executed by:
  • join
400
563-
564/* Output all the fields in line, other than the join field. */-
565-
566static void-
567prfields (struct line const *line, size_t join_field, size_t autocount)-
568{-
569 size_t i;-
570 size_t nfields = autoformat ? autocount : line->nfields;
autoformatDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • join
FALSEevaluated 138 times by 1 test
Evaluated by:
  • join
40-138
571 char output_separator = tab < 0 ? ' ' : tab;
tab < 0Description
TRUEevaluated 158 times by 1 test
Evaluated by:
  • join
FALSEevaluated 20 times by 1 test
Evaluated by:
  • join
20-158
572-
573 for (i = 0; i < join_field && i < nfields; ++i)
i < join_fieldDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • join
FALSEevaluated 176 times by 1 test
Evaluated by:
  • join
i < nfieldsDescription
TRUEevaluated 47 times by 1 test
Evaluated by:
  • join
FALSEevaluated 2 times by 1 test
Evaluated by:
  • join
2-176
574 {-
575 putchar (output_separator);-
576 prfield (i, line);-
577 }
executed 47 times by 1 test: end of block
Executed by:
  • join
47
578 for (i = join_field + 1; i < nfields; ++i)
i < nfieldsDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • join
FALSEevaluated 178 times by 1 test
Evaluated by:
  • join
132-178
579 {-
580 putchar (output_separator);-
581 prfield (i, line);-
582 }
executed 132 times by 1 test: end of block
Executed by:
  • join
132
583}
executed 178 times by 1 test: end of block
Executed by:
  • join
178
584-
585/* Print the join of LINE1 and LINE2. */-
586-
587static void-
588prjoin (struct line const *line1, struct line const *line2)-
589{-
590 const struct outlist *outlist;-
591 char output_separator = tab < 0 ? ' ' : tab;
tab < 0Description
TRUEevaluated 142 times by 1 test
Evaluated by:
  • join
FALSEevaluated 10 times by 1 test
Evaluated by:
  • join
10-142
592 size_t field;-
593 struct line const *line;-
594-
595 outlist = outlist_head.next;-
596 if (outlist)
outlistDescription
TRUEevaluated 63 times by 1 test
Evaluated by:
  • join
FALSEevaluated 89 times by 1 test
Evaluated by:
  • join
63-89
597 {-
598 const struct outlist *o;-
599-
600 o = outlist;-
601 while (1)-
602 {-
603 if (o->file == 0)
o->file == 0Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • join
FALSEevaluated 121 times by 1 test
Evaluated by:
  • join
11-121
604 {-
605 if (line1 == &uni_blank)
line1 == &uni_blankDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • join
FALSEevaluated 10 times by 1 test
Evaluated by:
  • join
1-10
606 {-
607 line = line2;-
608 field = join_field_2;-
609 }
executed 1 time by 1 test: end of block
Executed by:
  • join
1
610 else-
611 {-
612 line = line1;-
613 field = join_field_1;-
614 }
executed 10 times by 1 test: end of block
Executed by:
  • join
10
615 }-
616 else-
617 {-
618 line = (o->file == 1 ? line1 : line2);
o->file == 1Description
TRUEevaluated 53 times by 1 test
Evaluated by:
  • join
FALSEevaluated 68 times by 1 test
Evaluated by:
  • join
53-68
619 field = o->field;-
620 }
executed 121 times by 1 test: end of block
Executed by:
  • join
121
621 prfield (field, line);-
622 o = o->next;-
623 if (o == NULL)
o == ((void *)0)Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • join
FALSEevaluated 69 times by 1 test
Evaluated by:
  • join
63-69
624 break;
executed 63 times by 1 test: break;
Executed by:
  • join
63
625 putchar (output_separator);-
626 }
executed 69 times by 1 test: end of block
Executed by:
  • join
69
627 putchar (eolchar);-
628 }
executed 63 times by 1 test: end of block
Executed by:
  • join
63
629 else-
630 {-
631 if (line1 == &uni_blank)
line1 == &uni_blankDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • join
FALSEevaluated 75 times by 1 test
Evaluated by:
  • join
14-75
632 {-
633 line = line2;-
634 field = join_field_2;-
635 }
executed 14 times by 1 test: end of block
Executed by:
  • join
14
636 else-
637 {-
638 line = line1;-
639 field = join_field_1;-
640 }
executed 75 times by 1 test: end of block
Executed by:
  • join
75
641-
642 /* Output the join field. */-
643 prfield (field, line);-
644-
645 /* Output other fields. */-
646 prfields (line1, join_field_1, autocount_1);-
647 prfields (line2, join_field_2, autocount_2);-
648-
649 putchar (eolchar);-
650 }
executed 89 times by 1 test: end of block
Executed by:
  • join
89
651}-
652-
653/* Print the join of the files in FP1 and FP2. */-
654-
655static void-
656join (FILE *fp1, FILE *fp2)-
657{-
658 struct seq seq1, seq2;-
659 int diff;-
660 bool eof1, eof2;-
661-
662 fadvise (fp1, FADVISE_SEQUENTIAL);-
663 fadvise (fp2, FADVISE_SEQUENTIAL);-
664-
665 /* Read the first line of each file. */-
666 initseq (&seq1);-
667 getseq (fp1, &seq1, 1);-
668 initseq (&seq2);-
669 getseq (fp2, &seq2, 2);-
670-
671 if (autoformat)
autoformatDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • join
FALSEevaluated 68 times by 1 test
Evaluated by:
  • join
6-68
672 {-
673 autocount_1 = seq1.count ? seq1.lines[0]->nfields : 0;
seq1.countDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
0-6
674 autocount_2 = seq2.count ? seq2.lines[0]->nfields : 0;
seq2.countDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
0-6
675 }
executed 6 times by 1 test: end of block
Executed by:
  • join
6
676-
677 if (join_header_lines && (seq1.count || seq2.count))
join_header_linesDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • join
FALSEevaluated 68 times by 1 test
Evaluated by:
  • join
seq1.countDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
seq2.countDescription
TRUEnever evaluated
FALSEnever evaluated
0-68
678 {-
679 struct line const *hline1 = seq1.count ? seq1.lines[0] : &uni_blank;
seq1.countDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
0-6
680 struct line const *hline2 = seq2.count ? seq2.lines[0] : &uni_blank;
seq2.countDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • join
FALSEevaluated 1 time by 1 test
Evaluated by:
  • join
1-5
681 prjoin (hline1, hline2);-
682 prevline[0] = NULL;-
683 prevline[1] = NULL;-
684 if (seq1.count)
seq1.countDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
0-6
685 advance_seq (fp1, &seq1, true, 1);
executed 6 times by 1 test: advance_seq (fp1, &seq1, 1 , 1);
Executed by:
  • join
6
686 if (seq2.count)
seq2.countDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • join
FALSEevaluated 1 time by 1 test
Evaluated by:
  • join
1-5
687 advance_seq (fp2, &seq2, true, 2);
executed 5 times by 1 test: advance_seq (fp2, &seq2, 1 , 2);
Executed by:
  • join
5
688 }
executed 6 times by 1 test: end of block
Executed by:
  • join
6
689-
690 while (seq1.count && seq2.count)
seq1.countDescription
TRUEevaluated 191 times by 1 test
Evaluated by:
  • join
FALSEevaluated 51 times by 1 test
Evaluated by:
  • join
seq2.countDescription
TRUEevaluated 172 times by 1 test
Evaluated by:
  • join
FALSEevaluated 19 times by 1 test
Evaluated by:
  • join
19-191
691 {-
692 diff = keycmp (seq1.lines[0], seq2.lines[0],-
693 join_field_1, join_field_2);-
694 if (diff < 0)
diff < 0Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • join
FALSEevaluated 136 times by 1 test
Evaluated by:
  • join
36-136
695 {-
696 if (print_unpairables_1)
print_unpairables_1Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • join
FALSEevaluated 20 times by 1 test
Evaluated by:
  • join
16-20
697 prjoin (seq1.lines[0], &uni_blank);
executed 16 times by 1 test: prjoin (seq1.lines[0], &uni_blank);
Executed by:
  • join
16
698 advance_seq (fp1, &seq1, true, 1);-
699 seen_unpairable = true;-
700 continue;
executed 36 times by 1 test: continue;
Executed by:
  • join
36
701 }-
702 if (diff > 0)
diff > 0Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • join
FALSEevaluated 104 times by 1 test
Evaluated by:
  • join
32-104
703 {-
704 if (print_unpairables_2)
print_unpairables_2Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • join
FALSEevaluated 20 times by 1 test
Evaluated by:
  • join
12-20
705 prjoin (&uni_blank, seq2.lines[0]);
executed 12 times by 1 test: prjoin (&uni_blank, seq2.lines[0]);
Executed by:
  • join
12
706 advance_seq (fp2, &seq2, true, 2);-
707 seen_unpairable = true;-
708 continue;
executed 32 times by 1 test: continue;
Executed by:
  • join
32
709 }-
710-
711 /* Keep reading lines from file1 as long as they continue to-
712 match the current line from file2. */-
713 eof1 = false;-
714 do-
715 if (!advance_seq (fp1, &seq1, false, 1))
!advance_seq (... &seq1, 0 , 1)Description
TRUEevaluated 35 times by 1 test
Evaluated by:
  • join
FALSEevaluated 67 times by 1 test
Evaluated by:
  • join
35-67
716 {-
717 eof1 = true;-
718 ++seq1.count;-
719 break;
executed 35 times by 1 test: break;
Executed by:
  • join
35
720 }-
721 while (!keycmp (seq1.lines[seq1.count - 1], seq2.lines[0],
!keycmp (seq1.... join_field_2)Description
TRUEnever evaluated
FALSEevaluated 67 times by 1 test
Evaluated by:
  • join
0-67
722 join_field_1, join_field_2));
!keycmp (seq1.... join_field_2)Description
TRUEnever evaluated
FALSEevaluated 67 times by 1 test
Evaluated by:
  • join
0-67
723-
724 /* Keep reading lines from file2 as long as they continue to-
725 match the current line from file1. */-
726 eof2 = false;-
727 do-
728 if (!advance_seq (fp2, &seq2, false, 2))
!advance_seq (... &seq2, 0 , 2)Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • join
FALSEevaluated 60 times by 1 test
Evaluated by:
  • join
40-60
729 {-
730 eof2 = true;-
731 ++seq2.count;-
732 break;
executed 40 times by 1 test: break;
Executed by:
  • join
40
733 }-
734 while (!keycmp (seq1.lines[0], seq2.lines[seq2.count - 1],
!keycmp (seq1.... join_field_2)Description
TRUEnever evaluated
FALSEevaluated 60 times by 1 test
Evaluated by:
  • join
0-60
735 join_field_1, join_field_2));
!keycmp (seq1.... join_field_2)Description
TRUEnever evaluated
FALSEevaluated 60 times by 1 test
Evaluated by:
  • join
0-60
736-
737 if (print_pairables)
print_pairablesDescription
TRUEevaluated 97 times by 1 test
Evaluated by:
  • join
FALSEevaluated 3 times by 1 test
Evaluated by:
  • join
3-97
738 {-
739 for (size_t i = 0; i < seq1.count - 1; ++i)
i < seq1.count - 1Description
TRUEevaluated 97 times by 1 test
Evaluated by:
  • join
FALSEevaluated 97 times by 1 test
Evaluated by:
  • join
97
740 {-
741 size_t j;-
742 for (j = 0; j < seq2.count - 1; ++j)
j < seq2.count - 1Description
TRUEevaluated 97 times by 1 test
Evaluated by:
  • join
FALSEevaluated 97 times by 1 test
Evaluated by:
  • join
97
743 prjoin (seq1.lines[i], seq2.lines[j]);
executed 97 times by 1 test: prjoin (seq1.lines[i], seq2.lines[j]);
Executed by:
  • join
97
744 }
executed 97 times by 1 test: end of block
Executed by:
  • join
97
745 }
executed 97 times by 1 test: end of block
Executed by:
  • join
97
746-
747 if (!eof1)
!eof1Description
TRUEevaluated 67 times by 1 test
Evaluated by:
  • join
FALSEevaluated 33 times by 1 test
Evaluated by:
  • join
33-67
748 {-
749 SWAPLINES (seq1.lines[0], seq1.lines[seq1.count - 1]);-
750 seq1.count = 1;-
751 }
executed 67 times by 1 test: end of block
Executed by:
  • join
67
752 else-
753 seq1.count = 0;
executed 33 times by 1 test: seq1.count = 0;
Executed by:
  • join
33
754-
755 if (!eof2)
!eof2Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • join
FALSEevaluated 40 times by 1 test
Evaluated by:
  • join
40-60
756 {-
757 SWAPLINES (seq2.lines[0], seq2.lines[seq2.count - 1]);-
758 seq2.count = 1;-
759 }
executed 60 times by 1 test: end of block
Executed by:
  • join
60
760 else-
761 seq2.count = 0;
executed 40 times by 1 test: seq2.count = 0;
Executed by:
  • join
40
762 }-
763-
764 /* If the user did not specify --nocheck-order, then we read the-
765 tail ends of both inputs to verify that they are in order. We-
766 skip the rest of the tail once we have issued a warning for that-
767 file, unless we actually need to print the unpairable lines. */-
768 struct line *line = NULL;-
769 bool checktail = false;-
770-
771 if (check_input_order != CHECK_ORDER_DISABLED
check_input_or...ORDER_DISABLEDDescription
TRUEevaluated 67 times by 1 test
Evaluated by:
  • join
FALSEevaluated 3 times by 1 test
Evaluated by:
  • join
3-67
772 && !(issued_disorder_warning[0] && issued_disorder_warning[1]))
issued_disorder_warning[0]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • join
FALSEevaluated 65 times by 1 test
Evaluated by:
  • join
issued_disorder_warning[1]Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • join
0-65
773 checktail = true;
executed 67 times by 1 test: checktail = 1 ;
Executed by:
  • join
67
774-
775 if ((print_unpairables_1 || checktail) && seq1.count)
print_unpairables_1Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • join
FALSEevaluated 44 times by 1 test
Evaluated by:
  • join
checktailDescription
TRUEevaluated 41 times by 1 test
Evaluated by:
  • join
FALSEevaluated 3 times by 1 test
Evaluated by:
  • join
seq1.countDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • join
FALSEevaluated 48 times by 1 test
Evaluated by:
  • join
3-48
776 {-
777 if (print_unpairables_1)
print_unpairables_1Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • join
FALSEevaluated 11 times by 1 test
Evaluated by:
  • join
8-11
778 prjoin (seq1.lines[0], &uni_blank);
executed 8 times by 1 test: prjoin (seq1.lines[0], &uni_blank);
Executed by:
  • join
8
779 if (seq2.count)
seq2.countDescription
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • join
0-19
780 seen_unpairable = true;
never executed: seen_unpairable = 1 ;
0
781 while (get_line (fp1, &line, 1))
get_line (fp1, &line, 1)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • join
FALSEevaluated 19 times by 1 test
Evaluated by:
  • join
10-19
782 {-
783 if (print_unpairables_1)
print_unpairables_1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • join
FALSEevaluated 6 times by 1 test
Evaluated by:
  • join
4-6
784 prjoin (line, &uni_blank);
executed 4 times by 1 test: prjoin (line, &uni_blank);
Executed by:
  • join
4
785 if (issued_disorder_warning[0] && !print_unpairables_1)
issued_disorder_warning[0]Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • join
!print_unpairables_1Description
TRUEnever evaluated
FALSEnever evaluated
0-10
786 break;
never executed: break;
0
787 }
executed 10 times by 1 test: end of block
Executed by:
  • join
10
788 }
executed 19 times by 1 test: end of block
Executed by:
  • join
19
789-
790 if ((print_unpairables_2 || checktail) && seq2.count)
print_unpairables_2Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • join
FALSEevaluated 52 times by 1 test
Evaluated by:
  • join
checktailDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • join
FALSEevaluated 3 times by 1 test
Evaluated by:
  • join
seq2.countDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • join
FALSEevaluated 50 times by 1 test
Evaluated by:
  • join
3-52
791 {-
792 if (print_unpairables_2)
print_unpairables_2Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • join
FALSEevaluated 10 times by 1 test
Evaluated by:
  • join
7-10
793 prjoin (&uni_blank, seq2.lines[0]);
executed 7 times by 1 test: prjoin (&uni_blank, seq2.lines[0]);
Executed by:
  • join
7
794 if (seq1.count)
seq1.countDescription
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • join
0-17
795 seen_unpairable = true;
never executed: seen_unpairable = 1 ;
0
796 while (get_line (fp2, &line, 2))
get_line (fp2, &line, 2)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • join
FALSEevaluated 15 times by 1 test
Evaluated by:
  • join
4-15
797 {-
798 if (print_unpairables_2)
print_unpairables_2Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • join
FALSEevaluated 2 times by 1 test
Evaluated by:
  • join
2
799 prjoin (&uni_blank, line);
executed 2 times by 1 test: prjoin (&uni_blank, line);
Executed by:
  • join
2
800 if (issued_disorder_warning[1] && !print_unpairables_2)
issued_disorder_warning[1]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • join
FALSEevaluated 2 times by 1 test
Evaluated by:
  • join
!print_unpairables_2Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
0-2
801 break;
executed 2 times by 1 test: break;
Executed by:
  • join
2
802 }
executed 2 times by 1 test: end of block
Executed by:
  • join
2
803 }
executed 17 times by 1 test: end of block
Executed by:
  • join
17
804-
805 freeline (line);-
806 free (line);-
807-
808 delseq (&seq1);-
809 delseq (&seq2);-
810}
executed 70 times by 1 test: end of block
Executed by:
  • join
70
811-
812/* Add a field spec for field FIELD of file FILE to 'outlist'. */-
813-
814static void-
815add_field (int file, size_t field)-
816{-
817 struct outlist *o;-
818-
819 assert (file == 0 || file == 1 || file == 2);-
820 assert (file != 0 || field == 0);-
821-
822 o = xmalloc (sizeof *o);-
823 o->file = file;-
824 o->field = field;-
825 o->next = NULL;-
826-
827 /* Add to the end of the list so the fields are in the right order. */-
828 outlist_end->next = o;-
829 outlist_end = o;-
830}
executed 40 times by 1 test: end of block
Executed by:
  • join
40
831-
832/* Convert a string of decimal digits, STR (the 1-based join field number),-
833 to an integral value. Upon successful conversion, return one less-
834 (the zero-based field number). Silently convert too-large values-
835 to SIZE_MAX - 1. Otherwise, if a value cannot be converted, give a-
836 diagnostic and exit. */-
837-
838static size_t-
839string_to_join_field (char const *str)-
840{-
841 size_t result;-
842 unsigned long int val;-
843 verify (SIZE_MAX <= ULONG_MAX);-
844-
845 strtol_error s_err = xstrtoul (str, NULL, 10, &val, "");-
846 if (s_err == LONGINT_OVERFLOW || (s_err == LONGINT_OK && SIZE_MAX < val))
s_err == LONGINT_OVERFLOWDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • join
FALSEevaluated 52 times by 1 test
Evaluated by:
  • join
s_err == LONGINT_OKDescription
TRUEevaluated 48 times by 1 test
Evaluated by:
  • join
FALSEevaluated 4 times by 1 test
Evaluated by:
  • join
(18446744073709551615UL) < valDescription
TRUEnever evaluated
FALSEevaluated 48 times by 1 test
Evaluated by:
  • join
0-52
847 val = SIZE_MAX;
executed 2 times by 1 test: val = (18446744073709551615UL) ;
Executed by:
  • join
2
848 else if (s_err != LONGINT_OK || val == 0)
s_err != LONGINT_OKDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • join
FALSEevaluated 48 times by 1 test
Evaluated by:
  • join
val == 0Description
TRUEnever evaluated
FALSEevaluated 48 times by 1 test
Evaluated by:
  • join
0-48
849 die (EXIT_FAILURE, 0, _("invalid field number: %s"), quote (str));
executed 4 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid field number: %s\", 5), quote (str)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "invalid field number: %s" , 5) , quote (str)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid field number: %s" , 5) , quote (str)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
Executed by:
  • join
4
850-
851 result = val - 1;-
852-
853 return result;
executed 50 times by 1 test: return result;
Executed by:
  • join
50
854}-
855-
856/* Convert a single field specifier string, S, to a *FILE_INDEX, *FIELD_INDEX-
857 pair. In S, the field index string is 1-based; *FIELD_INDEX is zero-based.-
858 If S is valid, return true. Otherwise, give a diagnostic and exit. */-
859-
860static void-
861decode_field_spec (const char *s, int *file_index, size_t *field_index)-
862{-
863 /* The first character must be 0, 1, or 2. */-
864 switch (s[0])-
865 {-
866 case '0':
executed 3 times by 1 test: case '0':
Executed by:
  • join
3
867 if (s[1])
s[1]Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • join
0-3
868 {-
869 /* '0' must be all alone -- no '.FIELD'. */-
870 die (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));-
871 }
never executed: end of block
0
872 *file_index = 0;-
873 *field_index = 0;-
874 break;
executed 3 times by 1 test: break;
Executed by:
  • join
3
875-
876 case '1':
executed 16 times by 1 test: case '1':
Executed by:
  • join
16
877 case '2':
executed 21 times by 1 test: case '2':
Executed by:
  • join
21
878 if (s[1] != '.')
s[1] != '.'Description
TRUEnever evaluated
FALSEevaluated 37 times by 1 test
Evaluated by:
  • join
0-37
879 die (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid field specifier: %s\", 5), quote (s)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "invalid field specifier: %s" , 5) , quote (s)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid field specifier: %s" , 5) , quote (s)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
880 *file_index = s[0] - '0';-
881 *field_index = string_to_join_field (s + 2);-
882 break;
executed 37 times by 1 test: break;
Executed by:
  • join
37
883-
884 default:
executed 1 time by 1 test: default:
Executed by:
  • join
1
885 die (EXIT_FAILURE, 0,-
886 _("invalid file number in field spec: %s"), quote (s));-
887-
888 /* Tell gcc -W -Wall that we can't get beyond this point.-
889 This avoids a warning (otherwise legit) that the caller's copies-
890 of *file_index and *field_index might be used uninitialized. */-
891 abort ();
never executed: abort ();
0
892-
893 break;
never executed: break;
0
894 }-
895}-
896-
897/* Add the comma or blank separated field spec(s) in STR to 'outlist'. */-
898-
899static void-
900add_field_list (char *str)-
901{-
902 char *p = str;-
903-
904 do-
905 {-
906 int file_index;-
907 size_t field_index;-
908 char const *spec_item = p;-
909-
910 p = strpbrk (p, ", \t");-
911 if (p)
pDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • join
FALSEevaluated 19 times by 1 test
Evaluated by:
  • join
19-22
912 *p++ = '\0';
executed 22 times by 1 test: *p++ = '\0';
Executed by:
  • join
22
913 decode_field_spec (spec_item, &file_index, &field_index);-
914 add_field (file_index, field_index);-
915 }
executed 40 times by 1 test: end of block
Executed by:
  • join
40
916 while (p);
pDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • join
FALSEevaluated 19 times by 1 test
Evaluated by:
  • join
19-21
917}
executed 19 times by 1 test: end of block
Executed by:
  • join
19
918-
919/* Set the join field *VAR to VAL, but report an error if *VAR is set-
920 more than once to incompatible values. */-
921-
922static void-
923set_join_field (size_t *var, size_t val)-
924{-
925 if (*var != SIZE_MAX && *var != val)
*var != (18446...73709551615UL)Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • join
*var != valDescription
TRUEnever evaluated
FALSEnever evaluated
0-14
926 {-
927 unsigned long int var1 = *var + 1;-
928 unsigned long int val1 = val + 1;-
929 die (EXIT_FAILURE, 0,-
930 _("incompatible join fields %lu, %lu"), var1, val1);-
931 }
never executed: end of block
0
932 *var = val;-
933}
executed 14 times by 1 test: end of block
Executed by:
  • join
14
934-
935/* Status of command-line arguments. */-
936-
937enum operand_status-
938 {-
939 /* This argument must be an operand, i.e., one of the files to be-
940 joined. */-
941 MUST_BE_OPERAND,-
942-
943 /* This might be the argument of the preceding -j1 or -j2 option,-
944 or it might be an operand. */-
945 MIGHT_BE_J1_ARG,-
946 MIGHT_BE_J2_ARG,-
947-
948 /* This might be the argument of the preceding -o option, or it might be-
949 an operand. */-
950 MIGHT_BE_O_ARG-
951 };-
952-
953/* Add NAME to the array of input file NAMES with operand statuses-
954 OPERAND_STATUS; currently there are NFILES names in the list. */-
955-
956static void-
957add_file_name (char *name, char *names[2],-
958 int operand_status[2], int joption_count[2], int *nfiles,-
959 int *prev_optc_status, int *optc_status)-
960{-
961 int n = *nfiles;-
962-
963 if (n == 2)
n == 2Description
TRUEnever evaluated
FALSEevaluated 148 times by 1 test
Evaluated by:
  • join
0-148
964 {-
965 bool op0 = (operand_status[0] == MUST_BE_OPERAND);-
966 char *arg = names[op0];-
967 switch (operand_status[op0])-
968 {-
969 case MUST_BE_OPERAND:
never executed: case MUST_BE_OPERAND:
0
970 error (0, 0, _("extra operand %s"), quoteaf (name));-
971 usage (EXIT_FAILURE);-
972-
973 case MIGHT_BE_J1_ARG:
code before this statement never executed: case MIGHT_BE_J1_ARG:
never executed: case MIGHT_BE_J1_ARG:
0
974 joption_count[0]--;-
975 set_join_field (&join_field_1, string_to_join_field (arg));-
976 break;
never executed: break;
0
977-
978 case MIGHT_BE_J2_ARG:
never executed: case MIGHT_BE_J2_ARG:
0
979 joption_count[1]--;-
980 set_join_field (&join_field_2, string_to_join_field (arg));-
981 break;
never executed: break;
0
982-
983 case MIGHT_BE_O_ARG:
never executed: case MIGHT_BE_O_ARG:
0
984 add_field_list (arg);-
985 break;
never executed: break;
0
986 }-
987 if (!op0)
!op0Description
TRUEnever evaluated
FALSEnever evaluated
0
988 {-
989 operand_status[0] = operand_status[1];-
990 names[0] = names[1];-
991 }
never executed: end of block
0
992 n = 1;-
993 }
never executed: end of block
0
994-
995 operand_status[n] = *prev_optc_status;-
996 names[n] = name;-
997 *nfiles = n + 1;-
998 if (*prev_optc_status == MIGHT_BE_O_ARG)
*prev_optc_sta...MIGHT_BE_O_ARGDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • join
FALSEevaluated 110 times by 1 test
Evaluated by:
  • join
38-110
999 *optc_status = MIGHT_BE_O_ARG;
executed 38 times by 1 test: *optc_status = MIGHT_BE_O_ARG;
Executed by:
  • join
38
1000}
executed 148 times by 1 test: end of block
Executed by:
  • join
148
1001-
1002int-
1003main (int argc, char **argv)-
1004{-
1005 int optc_status;-
1006 int prev_optc_status = MUST_BE_OPERAND;-
1007 int operand_status[2];-
1008 int joption_count[2] = { 0, 0 };-
1009 FILE *fp1, *fp2;-
1010 int optc;-
1011 int nfiles = 0;-
1012 int i;-
1013-
1014 initialize_main (&argc, &argv);-
1015 set_program_name (argv[0]);-
1016 setlocale (LC_ALL, "");-
1017 bindtextdomain (PACKAGE, LOCALEDIR);-
1018 textdomain (PACKAGE);-
1019 hard_LC_COLLATE = hard_locale (LC_COLLATE);-
1020-
1021 atexit (close_stdout);-
1022 atexit (free_spareline);-
1023-
1024 print_pairables = true;-
1025 seen_unpairable = false;-
1026 issued_disorder_warning[0] = issued_disorder_warning[1] = false;-
1027 check_input_order = CHECK_ORDER_DEFAULT;-
1028-
1029 while ((optc = getopt_long (argc, argv, "-a:e:i1:2:j:o:t:v:z",
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 316 times by 1 test
Evaluated by:
  • join
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
74-316
1030 longopts, NULL))
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 316 times by 1 test
Evaluated by:
  • join
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
74-316
1031 != -1)
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 316 times by 1 test
Evaluated by:
  • join
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
74-316
1032 {-
1033 optc_status = MUST_BE_OPERAND;-
1034-
1035 switch (optc)-
1036 {-
1037 case 'v':
executed 7 times by 1 test: case 'v':
Executed by:
  • join
7
1038 print_pairables = false;-
1039 FALLTHROUGH;-
1040-
1041 case 'a':
code before this statement executed 7 times by 1 test: case 'a':
Executed by:
  • join
executed 39 times by 1 test: case 'a':
Executed by:
  • join
7-39
1042 {-
1043 unsigned long int val;-
1044 if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK
xstrtoul (opta... != LONGINT_OKDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • join
FALSEevaluated 44 times by 1 test
Evaluated by:
  • join
2-44
1045 || (val != 1 && val != 2))
val != 1Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • join
FALSEevaluated 26 times by 1 test
Evaluated by:
  • join
val != 2Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • join
0-26
1046 die (EXIT_FAILURE, 0,
executed 2 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid field number: %s\", 5), quote (optarg)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "invalid field number: %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid field number: %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • join
2
1047 _("invalid field number: %s"), quote (optarg));
executed 2 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid field number: %s\", 5), quote (optarg)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "invalid field number: %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid field number: %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • join
2
1048 if (val == 1)
val == 1Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • join
FALSEevaluated 18 times by 1 test
Evaluated by:
  • join
18-26
1049 print_unpairables_1 = true;
executed 26 times by 1 test: print_unpairables_1 = 1 ;
Executed by:
  • join
26
1050 else-
1051 print_unpairables_2 = true;
executed 18 times by 1 test: print_unpairables_2 = 1 ;
Executed by:
  • join
18
1052 }-
1053 break;
executed 44 times by 1 test: break;
Executed by:
  • join
44
1054-
1055 case 'e':
executed 27 times by 1 test: case 'e':
Executed by:
  • join
27
1056 if (empty_filler && ! STREQ (empty_filler, optarg))
never executed: __result = (((const unsigned char *) (const char *) ( empty_filler ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( optarg ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
empty_fillerDescription
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • join
! ( __extensio...)))); }) == 0)Description
TRUEnever evaluated
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
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-27
1057 die (EXIT_FAILURE, 0,
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"conflicting empty-field replacement strings\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "conflicting empty-field replacement strings" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "conflicting empty-field replacement strings" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
0
1058 _("conflicting empty-field replacement strings"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"conflicting empty-field replacement strings\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "conflicting empty-field replacement strings" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "conflicting empty-field replacement strings" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
0
1059 empty_filler = optarg;-
1060 break;
executed 27 times by 1 test: break;
Executed by:
  • join
27
1061-
1062 case 'i':
executed 2 times by 1 test: case 'i':
Executed by:
  • join
2
1063 ignore_case = true;-
1064 break;
executed 2 times by 1 test: break;
Executed by:
  • join
2
1065-
1066 case '1':
executed 7 times by 1 test: case '1':
Executed by:
  • join
7
1067 set_join_field (&join_field_1, string_to_join_field (optarg));-
1068 break;
executed 6 times by 1 test: break;
Executed by:
  • join
6
1069-
1070 case '2':
executed 7 times by 1 test: case '2':
Executed by:
  • join
7
1071 set_join_field (&join_field_2, string_to_join_field (optarg));-
1072 break;
executed 6 times by 1 test: break;
Executed by:
  • join
6
1073-
1074 case 'j':
executed 3 times by 1 test: case 'j':
Executed by:
  • join
3
1075 if ((optarg[0] == '1' || optarg[0] == '2') && !optarg[1]
optarg[0] == '1'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • join
optarg[0] == '2'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • join
!optarg[1]Description
TRUEnever evaluated
FALSEnever evaluated
0-3
1076 && optarg == argv[optind - 1] + 2)
optarg == argv[optind - 1] + 2Description
TRUEnever evaluated
FALSEnever evaluated
0
1077 {-
1078 /* The argument was either "-j1" or "-j2". */-
1079 bool is_j2 = (optarg[0] == '2');-
1080 joption_count[is_j2]++;-
1081 optc_status = MIGHT_BE_J1_ARG + is_j2;-
1082 }
never executed: end of block
0
1083 else-
1084 {-
1085 set_join_field (&join_field_1, string_to_join_field (optarg));-
1086 set_join_field (&join_field_2, join_field_1);-
1087 }
executed 1 time by 1 test: end of block
Executed by:
  • join
1
1088 break;
executed 1 time by 1 test: break;
Executed by:
  • join
1
1089-
1090 case 'o':
executed 26 times by 1 test: case 'o':
Executed by:
  • join
26
1091 if (STREQ (optarg, "auto"))
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 *) ( "auto" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • join
FALSEevaluated 20 times by 1 test
Evaluated by:
  • join
__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-20
1092 autoformat = true;
executed 6 times by 1 test: autoformat = 1 ;
Executed by:
  • join
6
1093 else-
1094 {-
1095 add_field_list (optarg);-
1096 optc_status = MIGHT_BE_O_ARG;-
1097 }
executed 19 times by 1 test: end of block
Executed by:
  • join
19
1098 break;
executed 25 times by 1 test: break;
Executed by:
  • join
25
1099-
1100 case 't':
executed 8 times by 1 test: case 't':
Executed by:
  • join
8
1101 {-
1102 unsigned char newtab = optarg[0];-
1103 if (! newtab)
! newtabDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • join
FALSEevaluated 6 times by 1 test
Evaluated by:
  • join
2-6
1104 newtab = '\n'; /* '' => process the whole line. */
executed 2 times by 1 test: newtab = '\n';
Executed by:
  • join
2
1105 else if (optarg[1])
optarg[1]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • join
FALSEevaluated 4 times by 1 test
Evaluated by:
  • join
2-4
1106 {-
1107 if (STREQ (optarg, "\\0"))
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 *) ( "\\0" ))[3] - __s2[3]);
executed 1 time by 1 test: end of block
Executed by:
  • join
executed 1 time by 1 test: end of block
Executed by:
  • join
( __extension_...)))); }) == 0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • join
FALSEevaluated 1 time by 1 test
Evaluated by:
  • join
__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 2 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
__result == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • join
FALSEevaluated 1 time by 1 test
Evaluated by:
  • join
__s2_len > 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • join
FALSEnever evaluated
__result == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • join
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • join
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-2
1108 newtab = '\0';
executed 1 time by 1 test: newtab = '\0';
Executed by:
  • join
1
1109 else-
1110 die (EXIT_FAILURE, 0, _("multi-character tab %s"),
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"multi-character tab %s\", 5), quote (optarg)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "multi-character tab %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "multi-character tab %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • join
1
1111 quote (optarg));
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"multi-character tab %s\", 5), quote (optarg)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "multi-character tab %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "multi-character tab %s" , 5) , quote (optarg)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • join
1
1112 }-
1113 if (0 <= tab && tab != newtab)
0 <= tabDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • join
tab != newtabDescription
TRUEnever evaluated
FALSEnever evaluated
0-7
1114 die (EXIT_FAILURE, 0, _("incompatible tabs"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"incompatible tabs\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "incompatible tabs" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "incompatible tabs" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1115 tab = newtab;-
1116 }-
1117 break;
executed 7 times by 1 test: break;
Executed by:
  • join
7
1118-
1119 case 'z':
executed 6 times by 1 test: case 'z':
Executed by:
  • join
6
1120 eolchar = 0;-
1121 break;
executed 6 times by 1 test: break;
Executed by:
  • join
6
1122-
1123 case NOCHECK_ORDER_OPTION:
executed 4 times by 1 test: case NOCHECK_ORDER_OPTION:
Executed by:
  • join
4
1124 check_input_order = CHECK_ORDER_DISABLED;-
1125 break;
executed 4 times by 1 test: break;
Executed by:
  • join
4
1126-
1127 case CHECK_ORDER_OPTION:
executed 7 times by 1 test: case CHECK_ORDER_OPTION:
Executed by:
  • join
7
1128 check_input_order = CHECK_ORDER_ENABLED;-
1129 break;
executed 7 times by 1 test: break;
Executed by:
  • join
7
1130-
1131 case 1: /* Non-option argument. */
executed 148 times by 1 test: case 1:
Executed by:
  • join
148
1132 add_file_name (optarg, g_names, operand_status, joption_count,-
1133 &nfiles, &prev_optc_status, &optc_status);-
1134 break;
executed 148 times by 1 test: break;
Executed by:
  • join
148
1135-
1136 case HEADER_LINE_OPTION:
executed 7 times by 1 test: case HEADER_LINE_OPTION:
Executed by:
  • join
7
1137 join_header_lines = true;-
1138 break;
executed 7 times by 1 test: break;
Executed by:
  • join
7
1139-
1140 case_GETOPT_HELP_CHAR;
never executed: break;
executed 11 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • join
0-11
1141-
1142 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • join
never executed: break;
executed 4 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • join
0-4
1143-
1144 default:
executed 3 times by 1 test: default:
Executed by:
  • join
3
1145 usage (EXIT_FAILURE);-
1146 }
never executed: end of block
0
1147-
1148 prev_optc_status = optc_status;-
1149 }
executed 290 times by 1 test: end of block
Executed by:
  • join
290
1150-
1151 /* Process any operands after "--". */-
1152 prev_optc_status = MUST_BE_OPERAND;-
1153 while (optind < argc)
optind < argcDescription
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
0-74
1154 add_file_name (argv[optind++], g_names, operand_status, joption_count,
never executed: add_file_name (argv[optind++], g_names, operand_status, joption_count, &nfiles, &prev_optc_status, &optc_status);
0
1155 &nfiles, &prev_optc_status, &optc_status);
never executed: add_file_name (argv[optind++], g_names, operand_status, joption_count, &nfiles, &prev_optc_status, &optc_status);
0
1156-
1157 if (nfiles != 2)
nfiles != 2Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
0-74
1158 {-
1159 if (nfiles == 0)
nfiles == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1160 error (0, 0, _("missing operand"));
never executed: error (0, 0, dcgettext (((void *)0), "missing operand" , 5) );
0
1161 else-
1162 error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
never executed: error (0, 0, dcgettext (((void *)0), "missing operand after %s" , 5) , quote (argv[argc - 1]));
0
1163 usage (EXIT_FAILURE);-
1164 }
never executed: end of block
0
1165-
1166 /* If "-j1" was specified and it turns out not to have had an argument,-
1167 treat it as "-j 1". Likewise for -j2. */-
1168 for (i = 0; i < 2; i++)
i < 2Description
TRUEevaluated 148 times by 1 test
Evaluated by:
  • join
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
74-148
1169 if (joption_count[i] != 0)
joption_count[i] != 0Description
TRUEnever evaluated
FALSEevaluated 148 times by 1 test
Evaluated by:
  • join
0-148
1170 {-
1171 set_join_field (&join_field_1, i);-
1172 set_join_field (&join_field_2, i);-
1173 }
never executed: end of block
0
1174-
1175 if (join_field_1 == SIZE_MAX)
join_field_1 =...73709551615UL)Description
TRUEevaluated 67 times by 1 test
Evaluated by:
  • join
FALSEevaluated 7 times by 1 test
Evaluated by:
  • join
7-67
1176 join_field_1 = 0;
executed 67 times by 1 test: join_field_1 = 0;
Executed by:
  • join
67
1177 if (join_field_2 == SIZE_MAX)
join_field_2 =...73709551615UL)Description
TRUEevaluated 67 times by 1 test
Evaluated by:
  • join
FALSEevaluated 7 times by 1 test
Evaluated by:
  • join
7-67
1178 join_field_2 = 0;
executed 67 times by 1 test: join_field_2 = 0;
Executed by:
  • join
67
1179-
1180 fp1 = STREQ (g_names[0], "-") ? stdin : fopen (g_names[0], "r");
never executed: __result = (((const unsigned char *) (const char *) ( g_names[0] ))[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
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
__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 74 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
__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-74
1181 if (!fp1)
!fp1Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
0-74
1182 die (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon (0, shell_escape_quoting_style, g_names[0])), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_locatio...shell_escape_quoting_style, g_names[0])), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, g_names[0])), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1183 fp2 = STREQ (g_names[1], "-") ? stdin : fopen (g_names[1], "r");
never executed: __result = (((const unsigned char *) (const char *) ( g_names[1] ))[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
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
__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 74 times by 1 test
Evaluated by:
  • join
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
__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-74
1184 if (!fp2)
!fp2Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
0-74
1185 die (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon (0, shell_escape_quoting_style, g_names[1])), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_locatio...shell_escape_quoting_style, g_names[1])), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, g_names[1])), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1186 if (fp1 == fp2)
fp1 == fp2Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • join
0-74
1187 die (EXIT_FAILURE, errno, _("both files cannot be standard input"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"both files cannot be standard input\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) ,... "both files cannot be standard input" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "both files cannot be standard input" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1188 join (fp1, fp2);-
1189-
1190 if (fclose (fp1) != 0)
rpl_fclose (fp1) != 0Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • join
0-70
1191 die (EXIT_FAILURE, errno, "%s", quotef (g_names[0]));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon (0, shell_escape_quoting_style, g_names[0])), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_locatio...shell_escape_quoting_style, g_names[0])), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, g_names[0])), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1192 if (fclose (fp2) != 0)
rpl_fclose (fp2) != 0Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • join
0-70
1193 die (EXIT_FAILURE, errno, "%s", quotef (g_names[1]));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon (0, shell_escape_quoting_style, g_names[1])), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_locatio...shell_escape_quoting_style, g_names[1])), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, g_names[1])), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1194-
1195 if (issued_disorder_warning[0] || issued_disorder_warning[1])
issued_disorder_warning[0]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • join
FALSEevaluated 68 times by 1 test
Evaluated by:
  • join
issued_disorder_warning[1]Description
TRUEnever evaluated
FALSEevaluated 68 times by 1 test
Evaluated by:
  • join
0-68
1196 return EXIT_FAILURE;
executed 2 times by 1 test: return 1 ;
Executed by:
  • join
2
1197 else-
1198 return EXIT_SUCCESS;
executed 68 times by 1 test: return 0 ;
Executed by:
  • join
68
1199}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2