diff options
-rw-r--r-- | src/cat.c | 12 | ||||
-rw-r--r-- | src/cksum.c | 2 | ||||
-rw-r--r-- | src/csplit.c | 39 | ||||
-rw-r--r-- | src/cut.c | 2 | ||||
-rw-r--r-- | src/expand.c | 10 | ||||
-rw-r--r-- | src/fmt.c | 2 | ||||
-rw-r--r-- | src/fold.c | 7 | ||||
-rw-r--r-- | src/head.c | 10 | ||||
-rw-r--r-- | src/join.c | 14 | ||||
-rw-r--r-- | src/nl.c | 13 | ||||
-rw-r--r-- | src/paste.c | 8 | ||||
-rw-r--r-- | src/pr.c | 14 | ||||
-rw-r--r-- | src/split.c | 20 | ||||
-rw-r--r-- | src/sum.c | 2 | ||||
-rw-r--r-- | src/tac.c | 8 | ||||
-rw-r--r-- | src/tail.c | 8 | ||||
-rw-r--r-- | src/tr.c | 39 | ||||
-rw-r--r-- | src/unexpand.c | 10 | ||||
-rw-r--r-- | src/uniq.c | 20 | ||||
-rw-r--r-- | src/wc.c | 2 |
20 files changed, 128 insertions, 114 deletions
@@ -163,7 +163,7 @@ simple_cat ( /* Write this block out. */ if (full_write (output_desc, buf, n_read) < 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); } } @@ -244,7 +244,7 @@ cat ( do { if (full_write (output_desc, wp, outsize) < 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); wp += outsize; } while (bpout - wp >= outsize); @@ -297,7 +297,7 @@ cat ( int n_write = bpout - outbuf; if (full_write (output_desc, outbuf, n_write) < 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); bpout = outbuf; } @@ -591,7 +591,7 @@ main (int argc, char **argv) /* Get device, i-node number, and optimal blocksize of output. */ if (fstat (output_desc, &stat_buf) < 0) - error (1, errno, _("standard output")); + error (EXIT_FAILURE, errno, _("standard output")); outsize = ST_BLKSIZE (stat_buf); /* Input file can be output file for non-regular files. @@ -716,9 +716,9 @@ main (int argc, char **argv) while (++argind < argc); if (have_read_stdin && close (0) < 0) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); if (close (1) < 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/cksum.c b/src/cksum.c index 035b44f9c..6c2f053bf 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -326,7 +326,7 @@ main (int argc, char **argv) } if (have_read_stdin && fclose (stdin) == EOF) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/csplit.c b/src/csplit.c index 44096be2c..572a26d18 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -646,7 +646,7 @@ static unsigned int get_first_line_in_buffer (void) { if (head == NULL && !load_buffer ()) - error (1, errno, _("input disappeared")); + error (EXIT_FAILURE, errno, _("input disappeared")); return head->first_available; } @@ -747,7 +747,7 @@ set_input_file (const char *name) { input_desc = open (name, O_RDONLY); if (input_desc < 0) - error (1, errno, "%s", name); + error (EXIT_FAILURE, errno, "%s", name); } } @@ -1126,11 +1126,11 @@ check_for_offset (struct control *p, const char *str, const char *num) unsigned long val; if (*num != '-' && *num != '+') - error (1, 0, _("%s: `+' or `-' expected after delimeter"), str); + error (EXIT_FAILURE, 0, _("%s: `+' or `-' expected after delimeter"), str); if (xstrtoul (num + 1, NULL, 10, &val, NULL) != LONGINT_OK || val > UINT_MAX) - error (1, 0, _("%s: integer expected after `%c'"), str, *num); + error (EXIT_FAILURE, 0, _("%s: integer expected after `%c'"), str, *num); p->offset = (unsigned int) val; if (*num == '-') @@ -1150,7 +1150,7 @@ parse_repeat_count (int argnum, struct control *p, char *str) end = str + strlen (str) - 1; if (*end != '}') - error (1, 0, _("%s: `}' is required in repeat count"), str); + error (EXIT_FAILURE, 0, _("%s: `}' is required in repeat count"), str); *end = '\0'; if (str+1 == end-1 && *(str+1) == '*') @@ -1160,7 +1160,8 @@ parse_repeat_count (int argnum, struct control *p, char *str) if (xstrtoul (str + 1, NULL, 10, &val, NULL) != LONGINT_OK || val > UINT_MAX) { - error (1, 0, _("%s}: integer required between `{' and `}'"), + error (EXIT_FAILURE, 0, + _("%s}: integer required between `{' and `}'"), global_argv[argnum]); } p->repeat = (unsigned int) val; @@ -1186,7 +1187,8 @@ extract_regexp (int argnum, boolean ignore, char *str) closing_delim = strrchr (str + 1, delim); if (closing_delim == NULL) - error (1, 0, _("%s: closing delimeter `%c' missing"), str, delim); + error (EXIT_FAILURE, 0, + _("%s: closing delimeter `%c' missing"), str, delim); len = closing_delim - str - 1; p = new_control_record (); @@ -1239,12 +1241,13 @@ parse_patterns (int argc, int start, char **argv) if (xstrtoul (argv[i], NULL, 10, &val, NULL) != LONGINT_OK || val > INT_MAX) - error (1, 0, _("%s: invalid pattern"), argv[i]); + error (EXIT_FAILURE, 0, _("%s: invalid pattern"), argv[i]); if (val == 0) - error (1, 0, _("%s: line number must be greater than zero"), + error (EXIT_FAILURE, 0, + _("%s: line number must be greater than zero"), argv[i]); if (val < last_val) - error (1, 0, + error (EXIT_FAILURE, 0, _("line number `%s' is smaller than preceding line number, %lu"), argv[i], last_val); @@ -1373,14 +1376,16 @@ get_format_conv_type (char **format_ptr) break; case 0: - error (1, 0, _("missing conversion specifier in suffix")); + error (EXIT_FAILURE, 0, _("missing conversion specifier in suffix")); break; default: if (ISPRINT (ch)) - error (1, 0, _("invalid conversion specifier in suffix: %c"), ch); + error (EXIT_FAILURE, 0, + _("invalid conversion specifier in suffix: %c"), ch); else - error (1, 0, _("invalid conversion specifier in suffix: \\%.3o"), ch); + error (EXIT_FAILURE, 0, + _("invalid conversion specifier in suffix: \\%.3o"), ch); } } @@ -1411,9 +1416,11 @@ max_out (char *format) } if (percents == 0) - error (1, 0, _("missing %% conversion specification in suffix")); + error (EXIT_FAILURE, 0, + _("missing %% conversion specification in suffix")); else if (percents > 1) - error (1, 0, _("too many %% conversion specifications in suffix")); + error (EXIT_FAILURE, 0, + _("too many %% conversion specifications in suffix")); return out_count; } @@ -1492,7 +1499,7 @@ main (int argc, char **argv) case 'n': if (xstrtoul (optarg, NULL, 10, &val, NULL) != LONGINT_OK || val > INT_MAX) - error (1, 0, _("%s: invalid number"), optarg); + error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg); digits = (int) val; break; @@ -768,7 +768,7 @@ main (int argc, char **argv) exit_status = 1; } if (ferror (stdout) || fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/expand.c b/src/expand.c index de6aaa1c8..4103ea6c6 100644 --- a/src/expand.c +++ b/src/expand.c @@ -168,7 +168,7 @@ parse_tabstops (char *stops) tabval = tabval * 10 + *stops - '0'; } else - error (1, 0, _("tab size contains an invalid character")); + error (EXIT_FAILURE, 0, _("tab size contains an invalid character")); } add_tabstop (tabval); @@ -186,9 +186,9 @@ validate_tabstops (int *tabs, int entries) for (i = 0; i < entries; i++) { if (tabs[i] == 0) - error (1, 0, _("tab size cannot be 0")); + error (EXIT_FAILURE, 0, _("tab size cannot be 0")); if (tabs[i] <= prev_tab) - error (1, 0, _("tab sizes must be ascending")); + error (EXIT_FAILURE, 0, _("tab sizes must be ascending")); prev_tab = tabs[i]; } } @@ -393,9 +393,9 @@ main (int argc, char **argv) expand (); if (have_read_stdin && fclose (stdin) == EOF) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); if (ferror (stdout) || fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } @@ -383,7 +383,7 @@ main (register int argc, register char **argv) long int tmp_long; if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid line number increment: `%s'"), + error (EXIT_FAILURE, 0, _("invalid line number increment: `%s'"), optarg); max_width = (int) tmp_long; } diff --git a/src/fold.c b/src/fold.c index 548f4bbee..fb6405aa1 100644 --- a/src/fold.c +++ b/src/fold.c @@ -296,7 +296,8 @@ main (int argc, char **argv) long int tmp_long; if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid number of columns: `%s'"), optarg); + error (EXIT_FAILURE, 0, + _("invalid number of columns: `%s'"), optarg); width = (int) tmp_long; } break; @@ -322,9 +323,9 @@ main (int argc, char **argv) errs |= fold_file (argv[i], width); if (have_read_stdin && fclose (stdin) == EOF) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); if (fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (errs == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/head.c b/src/head.c index f3f8a9ee5..2ef9dea96 100644 --- a/src/head.c +++ b/src/head.c @@ -175,7 +175,7 @@ head_bytes (const char *filename, int fd, long int bytes_to_write) if (bytes_read > bytes_to_write) bytes_read = bytes_to_write; if (fwrite (buffer, 1, bytes_read, stdout) == 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); bytes_to_write -= bytes_read; } return 0; @@ -203,7 +203,7 @@ head_lines (const char *filename, int fd, long int lines_to_write) if (buffer[bytes_to_write++] == '\n' && --lines_to_write == 0) break; if (fwrite (buffer, 1, bytes_to_write, stdout) == 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); } return 0; } @@ -334,7 +334,7 @@ main (int argc, char **argv) /* FIXME: use xstrtoul instead. */ number = atou (optarg); if (number == -1) - error (1, 0, _("invalid number `%s'"), optarg); + error (EXIT_FAILURE, 0, _("invalid number `%s'"), optarg); break; case 'q': @@ -376,9 +376,9 @@ main (int argc, char **argv) exit_status |= head_file (argv[optind], number); if (have_read_stdin && close (0) < 0) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); if (fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/join.c b/src/join.c index 6e64cc172..1305fe9ce 100644 --- a/src/join.c +++ b/src/join.c @@ -888,22 +888,22 @@ main (int argc, char **argv) fp1 = strcmp (names[0], "-") ? fopen (names[0], "r") : stdin; if (!fp1) - error (1, errno, "%s", names[0]); + error (EXIT_FAILURE, errno, "%s", names[0]); fp2 = strcmp (names[1], "-") ? fopen (names[1], "r") : stdin; if (!fp2) - error (1, errno, "%s", names[1]); + error (EXIT_FAILURE, errno, "%s", names[1]); if (fp1 == fp2) - error (1, errno, _("both files cannot be standard input")); + error (EXIT_FAILURE, errno, _("both files cannot be standard input")); join (fp1, fp2); if (fp1 != stdin && fclose (fp1) == EOF) - error (1, errno, "%s", names[0]); + error (EXIT_FAILURE, errno, "%s", names[0]); if (fp2 != stdin && fclose (fp2) == EOF) - error (1, errno, "%s", names[1]); + error (EXIT_FAILURE, errno, "%s", names[1]); if ((fp1 == stdin || fp2 == stdin) && fclose (stdin) == EOF) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); if (ferror (stdout) || fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (EXIT_SUCCESS); } @@ -281,7 +281,7 @@ build_type_arg (char **typep, struct re_pattern_buffer *regexp) regexp->fastmap_accurate = 0; errmsg = re_compile_pattern (optarg, optlen, regexp); if (errmsg) - error (1, 0, "%s", errmsg); + error (EXIT_FAILURE, 0, "%s", errmsg); break; default: rval = FALSE; @@ -497,7 +497,7 @@ main (int argc, char **argv) if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK /* Allow it to be negative. */ || tmp_long > INT_MAX) - error (1, 0, _("invalid starting line number: `%s'"), + error (EXIT_FAILURE, 0, _("invalid starting line number: `%s'"), optarg); starting_line_number = (int) tmp_long; } @@ -507,7 +507,7 @@ main (int argc, char **argv) long int tmp_long; if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid line number increment: `%s'"), + error (EXIT_FAILURE, 0, _("invalid line number increment: `%s'"), optarg); page_incr = (int) tmp_long; } @@ -520,7 +520,7 @@ main (int argc, char **argv) long int tmp_long; if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid number of blank lines: `%s'"), + error (EXIT_FAILURE, 0, _("invalid number of blank lines: `%s'"), optarg); blank_join = (int) tmp_long; } @@ -533,7 +533,8 @@ main (int argc, char **argv) long int tmp_long; if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid line number field width: `%s'"), + error (EXIT_FAILURE, 0, + _("invalid line number field width: `%s'"), optarg); lineno_width = (int) tmp_long; } @@ -627,7 +628,7 @@ main (int argc, char **argv) exit_status = 1; } if (ferror (stdout) || fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/paste.c b/src/paste.c index 109f7b4f4..4a3d6a9b1 100644 --- a/src/paste.c +++ b/src/paste.c @@ -206,7 +206,7 @@ paste_parallel (int nfiles, char **fnamptr) { fileptr[files_open] = fopen (fnamptr[files_open], "r"); if (fileptr[files_open] == NULL) - error (1, errno, "%s", fnamptr[files_open]); + error (EXIT_FAILURE, errno, "%s", fnamptr[files_open]); else if (fileno (fileptr[files_open]) == 0) opened_stdin = 1; } @@ -215,7 +215,7 @@ paste_parallel (int nfiles, char **fnamptr) fileptr[files_open] = ENDLIST; if (opened_stdin && have_read_stdin) - error (1, 0, _("standard input is closed")); + error (EXIT_FAILURE, 0, _("standard input is closed")); /* Read a line from each file and output it to stdout separated by a delimiter, until we go through the loop without successfully @@ -489,8 +489,8 @@ main (int argc, char **argv) else exit_status = paste_serial (argc - optind, &argv[optind]); if (have_read_stdin && fclose (stdin) == EOF) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); if (ferror (stdout) || fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } @@ -624,11 +624,11 @@ main (int argc, char **argv) usage (0); if (parallel_files && explicit_columns) - error (1, 0, + error (EXIT_FAILURE, 0, _("Cannot specify number of columns when printing in parallel.")); if (parallel_files && print_across_flag) - error (1, 0, + error (EXIT_FAILURE, 0, _("Cannot specify both printing across and printing in parallel.")); for ( ; optind < argc; optind++) @@ -656,9 +656,9 @@ main (int argc, char **argv) cleanup (); if (have_read_stdin && fclose (stdin) == EOF) - error (1, errno, _("standard input")); + error (EXIT_FAILURE, errno, _("standard input")); if (ferror (stdout) || fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); if (failed_opens > 0) exit(1); exit (EXIT_SUCCESS); @@ -745,7 +745,7 @@ init_parameters (int number_of_files) (columns - 1) * chars_per_gutter) / columns; if (chars_per_column < 1) - error (1, 0, _("page width too narrow")); + error (EXIT_FAILURE, 0, _("page width too narrow")); if (numbered_lines) { @@ -957,9 +957,9 @@ close_file (COLUMN *p) if (p->status == CLOSED) return; if (ferror (p->fp)) - error (1, errno, "%s", p->name); + error (EXIT_FAILURE, errno, "%s", p->name); if (p->fp != stdin && fclose (p->fp) == EOF) - error (1, errno, "%s", p->name); + error (EXIT_FAILURE, errno, "%s", p->name); if (!parallel_files) { diff --git a/src/split.c b/src/split.c index 554dcf947..48316d1ff 100644 --- a/src/split.c +++ b/src/split.c @@ -176,17 +176,17 @@ cwrite (int new_file_flag, const char *bp, int bytes) if (new_file_flag) { if (output_desc >= 0 && close (output_desc) < 0) - error (1, errno, "%s", outfile); + error (EXIT_FAILURE, errno, "%s", outfile); next_file_name (); if (verbose) fprintf (stderr, _("creating file `%s'\n"), outfile); output_desc = open (outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output_desc < 0) - error (1, errno, "%s", outfile); + error (EXIT_FAILURE, errno, "%s", outfile); } if (full_write (output_desc, bp, bytes) < 0) - error (1, errno, "%s", outfile); + error (EXIT_FAILURE, errno, "%s", outfile); } /* Read NCHARS bytes from the input file into BUF. @@ -228,7 +228,7 @@ bytes_split (int nchars, char *buf, int bufsize) { n_read = stdread (buf, bufsize); if (n_read < 0) - error (1, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); bp_out = buf; to_read = n_read; for (;;) @@ -271,7 +271,7 @@ lines_split (int nlines, char *buf, int bufsize) { n_read = stdread (buf, bufsize); if (n_read < 0) - error (1, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); bp = bp_out = buf; eob = bp + n_read; *eob = '\n'; @@ -320,7 +320,7 @@ line_bytes_split (int nchars) n_read = stdread (buf + n_buffered, nchars - n_buffered); if (n_read < 0) - error (1, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); n_buffered += n_read; if (n_buffered != nchars) @@ -489,7 +489,7 @@ main (int argc, char **argv) { input_desc = open (infile, O_RDONLY); if (input_desc < 0) - error (1, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); } /* No output file is open now. */ @@ -509,7 +509,7 @@ main (int argc, char **argv) /* Get the optimal block size of input device and make a buffer. */ if (fstat (input_desc, &stat_buf) < 0) - error (1, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); in_blk_size = ST_BLKSIZE (stat_buf); buf = xmalloc (in_blk_size + 1); @@ -534,9 +534,9 @@ main (int argc, char **argv) } if (close (input_desc) < 0) - error (1, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); if (output_desc >= 0 && close (output_desc) < 0) - error (1, errno, "%s", outfile); + error (EXIT_FAILURE, errno, "%s", outfile); exit (EXIT_SUCCESS); } @@ -253,7 +253,7 @@ main (int argc, char **argv) errors = 1; if (have_read_stdin && fclose (stdin) == EOF) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } @@ -612,7 +612,7 @@ main (int argc, char **argv) case 's': separator = optarg; if (*separator == 0) - error (1, 0, _("separator cannot be empty")); + error (EXIT_FAILURE, 0, _("separator cannot be empty")); break; default: usage (1); @@ -638,7 +638,7 @@ main (int argc, char **argv) error_message = re_compile_pattern (separator, strlen (separator), &compiled_separator); if (error_message) - error (1, 0, "%s", error_message); + error (EXIT_FAILURE, 0, "%s", error_message); } else match_length = sentinel_length = strlen (separator); @@ -678,8 +678,8 @@ main (int argc, char **argv) output ((char *) NULL, (char *) NULL); if (have_read_stdin && close (0) < 0) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); if (close (1) < 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/tail.c b/src/tail.c index 3df500788..7246c5b79 100644 --- a/src/tail.c +++ b/src/tail.c @@ -63,7 +63,7 @@ assert ((fd) == 1); \ assert ((n_bytes) >= 0); \ if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \ - error (1, errno, _("write error")); \ + error (EXIT_FAILURE, errno, _("write error")); \ } \ while (0) @@ -537,7 +537,7 @@ output: total += bytes_read; } if (bytes_read == -1) - error (1, errno, "%s", filename); + error (EXIT_FAILURE, errno, "%s", filename); if (forever) { fflush (stdout); @@ -1012,8 +1012,8 @@ main (int argc, char **argv) tail_forever (argv + fileind, argc - fileind); if (have_read_stdin && close (0) < 0) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); if (fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } @@ -1516,7 +1516,8 @@ validate (struct Spec_list *s1, struct Spec_list *s2) get_s1_spec_stats (s1); if (s1->n_indefinite_repeats > 0) { - error (1, 0, _("the [c*] repeat construct may not appear in string1")); + error (EXIT_FAILURE, 0, + _("the [c*] repeat construct may not appear in string1")); } /* FIXME: it isn't clear from the POSIX spec that this is invalid, @@ -1524,7 +1525,7 @@ validate (struct Spec_list *s1, struct Spec_list *s2) with character classes, this seems a logical interpretation. */ if (complement && s1->has_upper_or_lower) { - error (1, 0, + error (EXIT_FAILURE, 0, _("character classes may not be used when translating \ and complementing")); } @@ -1534,14 +1535,14 @@ and complementing")); get_s2_spec_stats (s2, s1->length); if (s2->has_restricted_char_class) { - error (1, 0, + error (EXIT_FAILURE, 0, _("when translating, the only character classes that may \ appear in\n\tstring2 are `upper' and `lower'")); } if (s2->n_indefinite_repeats > 1) { - error (1, 0, + error (EXIT_FAILURE, 0, _("only one [c*] repeat construct may appear in string2")); } @@ -1549,7 +1550,7 @@ appear in\n\tstring2 are `upper' and `lower'")); { if (s2->has_equiv_class) { - error (1, 0, + error (EXIT_FAILURE, 0, _("[=c=] expressions may not appear in string2 \ when translating")); } @@ -1562,14 +1563,14 @@ when translating")); given or string1 is empty. */ if (s2->length == 0) - error (1, 0, + error (EXIT_FAILURE, 0, _("when not truncating set1, string2 must be non-empty")); string2_extend (s1, s2); } } if (complement && s2->has_upper_or_lower) - error (1, 0, + error (EXIT_FAILURE, 0, _("character classes may not be used when translating \ and complementing")); } @@ -1577,7 +1578,7 @@ and complementing")); /* Not translating. */ { if (s2->n_indefinite_repeats > 0) - error (1, 0, + error (EXIT_FAILURE, 0, _("the [c*] construct may appear in string2 only \ when translating")); } @@ -1611,7 +1612,7 @@ squeeze_filter (unsigned char *buf, long int size, PFI reader) nr = (*reader) (buf, size, NULL); if (nr < 0) - error (1, errno, _("read error")); + error (EXIT_FAILURE, errno, _("read error")); if (nr == 0) break; i = 0; @@ -1662,7 +1663,7 @@ squeeze_filter (unsigned char *buf, long int size, PFI reader) } if (out_len > 0 && fwrite ((char *) &buf[begin], 1, out_len, stdout) == 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); } if (char_to_squeeze != NOT_A_CHAR) @@ -1708,7 +1709,7 @@ read_and_delete (unsigned char *buf, long int size, PFI not_used) int nr = safe_read (0, (char *) buf, size); if (nr < 0) - error (1, errno, _("read error")); + error (EXIT_FAILURE, errno, _("read error")); if (nr == 0) { hit_eof = 1; @@ -1752,7 +1753,7 @@ read_and_xlate (unsigned char *buf, long int size, PFI not_used) chars_read = safe_read (0, (char *) buf, size); if (chars_read < 0) - error (1, errno, _("read error")); + error (EXIT_FAILURE, errno, _("read error")); if (chars_read == 0) { hit_eof = 1; @@ -1855,10 +1856,10 @@ main (int argc, char **argv) } if (!delete && !squeeze_repeats && non_option_args != 2) - error (1, 0, _("two strings must be given when translating")); + error (EXIT_FAILURE, 0, _("two strings must be given when translating")); if (delete && squeeze_repeats && non_option_args != 2) - error (1, 0, _("two strings must be given when both \ + error (EXIT_FAILURE, 0, _("two strings must be given when both \ deleting and squeezing repeats")); /* If --delete is given without --squeeze-repeats, then @@ -1871,13 +1872,13 @@ deleting and squeezing repeats")); if (posix_pedantic && non_option_args == 2) --non_option_args; else - error (1, 0, + error (EXIT_FAILURE, 0, _("only one string may be given when deleting \ without squeezing repeats")); } if (squeeze_repeats && non_option_args == 0) - error (1, 0, + error (EXIT_FAILURE, 0, _("at least one string must be given when squeezing repeats")); spec_init (s1); @@ -1909,7 +1910,7 @@ without squeezing repeats")); { nr = read_and_delete (io_buf, IO_BUF_SIZE, NULL); if (nr > 0 && fwrite ((char *) io_buf, 1, nr, stdout) == 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); } while (nr > 0); } @@ -1963,7 +1964,7 @@ without squeezing repeats")); c1 = get_next (s1, &class_s1); c2 = get_next (s2, &class_s2); if (!class_ok[(int) class_s1][(int) class_s2]) - error (1, 0, + error (EXIT_FAILURE, 0, _("misaligned or mismatched upper and/or lower classes")); /* The following should have been checked by validate... */ if (c2 == -1) @@ -1986,7 +1987,7 @@ without squeezing repeats")); chars_read = read_and_xlate (io_buf, IO_BUF_SIZE, NULL); if (chars_read > 0 && fwrite ((char *) io_buf, 1, chars_read, stdout) == 0) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); } while (chars_read > 0); } diff --git a/src/unexpand.c b/src/unexpand.c index 80e1de223..ea43e98a3 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -141,7 +141,7 @@ parse_tabstops (const char *stops) tabval = tabval * 10 + *stops - '0'; } else - error (1, 0, _("tab size contains an invalid character")); + error (EXIT_FAILURE, 0, _("tab size contains an invalid character")); } add_tabstop (tabval); @@ -159,9 +159,9 @@ validate_tabstops (const int *tabs, int entries) for (i = 0; i < entries; i++) { if (tabs[i] == 0) - error (1, 0, _("tab size cannot be 0")); + error (EXIT_FAILURE, 0, _("tab size cannot be 0")); if (tabs[i] <= prev_tab) - error (1, 0, _("tab sizes must be ascending")); + error (EXIT_FAILURE, 0, _("tab sizes must be ascending")); prev_tab = tabs[i]; } } @@ -450,8 +450,8 @@ main (int argc, char **argv) unexpand (); if (have_read_stdin && fclose (stdin) == EOF) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); if (fclose (stdout) == EOF) - error (1, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/uniq.c b/src/uniq.c index a696974bb..6d5a26468 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -218,14 +218,14 @@ check_file (const char *infile, const char *outfile) else istream = fopen (infile, "r"); if (istream == NULL) - error (1, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); if (!strcmp (outfile, "-")) ostream = stdout; else ostream = fopen (outfile, "w"); if (ostream == NULL) - error (1, errno, "%s", outfile); + error (EXIT_FAILURE, errno, "%s", outfile); thisline = &lb1; prevline = &lb2; @@ -263,10 +263,10 @@ check_file (const char *infile, const char *outfile) closefiles: if (ferror (istream) || fclose (istream) == EOF) - error (1, errno, _("error reading %s"), infile); + error (EXIT_FAILURE, errno, _("error reading %s"), infile); if (ferror (ostream) || fclose (ostream) == EOF) - error (1, errno, _("error writing %s"), outfile); + error (EXIT_FAILURE, errno, _("error writing %s"), outfile); free (lb1.buffer); free (lb2.buffer); @@ -323,7 +323,8 @@ main (int argc, char **argv) long int tmp_long; if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid number of fields to skip: `%s'"), + error (EXIT_FAILURE, 0, + _("invalid number of fields to skip: `%s'"), optarg); skip_fields = (int) tmp_long; } @@ -334,7 +335,8 @@ main (int argc, char **argv) long int tmp_long; if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid number of bytes to skip: `%s'"), + error (EXIT_FAILURE, 0, + _("invalid number of bytes to skip: `%s'"), optarg); skip_chars = (int) tmp_long; } @@ -349,7 +351,8 @@ main (int argc, char **argv) long int tmp_long; if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid number of bytes to compare: `%s'"), + error (EXIT_FAILURE, 0, + _("invalid number of bytes to compare: `%s'"), optarg); check_chars = (int) tmp_long; } @@ -379,7 +382,8 @@ main (int argc, char **argv) long int tmp_long; if (xstrtol (opt_str, NULL, 10, &tmp_long, NULL) != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid number of bytes to compare: `%s'"), + error (EXIT_FAILURE, 0, + _("invalid number of bytes to compare: `%s'"), opt_str); skip_chars = (int) tmp_long; } @@ -319,7 +319,7 @@ main (int argc, char **argv) } if (have_read_stdin && close (0)) - error (1, errno, "-"); + error (EXIT_FAILURE, errno, "-"); exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } |