Standard Error Exit
Halt program when an error occurs.
Notes
Since the key behavior is to halt the program
on an error, only exit call intrinsicly belongs
to ErrorExit.
The calls to error() and cleanup() are extensions
to some ErrorExit sites.
- Import exit()
- Imported declaration
- Segment Source
- 22: #include <config.h>
- Import error()
-
Imported declaration
- Notes
-
When error() is called with a non-zero first
argument, it executes a exit() call.
Thus it needs to be viewed as an alternate form
of the exit() call, similar to usage().
- Segment Source
- 36: #include "error.h"
- Define usage()
- Function definition
- Notes
-
Most of the apparent body of the usage() function
is actually supplied by the UsageMsg concern.
- Segment Source
- 205: static void
206: usage (int status)
207: {
208: if (status != 0)
209: fprintf (stderr, _("Try `%s --help' for more information.\n"),
210: program_name);
211: else
212: {
213: printf (_("\
214: Usage: %s [OPTION]... [FILE]...\n\
215: "),
216: program_name);
217: printf (_("\
218: Write sorted concatenation of all FILE(s) to standard output.\n\
219: \n\
220: +POS1 [-POS2] start a key at POS1, end it before POS2\n\
221: -b ignore leading blanks in sort fields or keys\n\
222: -c check if given files already sorted, do not sort\n\
223: -d consider only [a-zA-Z0-9 ] characters in keys\n\
224: -f fold lower case to upper case characters in keys\n\
225: -g compare according to general numerical value, imply -b\n\
226: -i consider only [\\040-\\0176] characters in keys\n\
227: -k POS1[,POS2] same as +POS1 [-POS2], but all positions counted from 1\n\
228: -m merge already sorted files, do not sort\n\
229: -M compare (unknown) < `JAN' < ... < `DEC', imply -b\n\
230: -n compare according to string numerical value, imply -b\n\
231: -o FILE write result on FILE instead of standard output\n\
232: -r reverse the result of comparisons\n\
233: -s stabilize sort by disabling last resort comparison\n\
234: -t SEP use SEParator instead of non- to whitespace transition\n\
235: -T DIRECT use DIRECT for temporary files, not $TMPDIR or %s\n\
236: -u with -c, check for strict ordering;\n\
237: with -m, only output the first of an equal sequence\n\
238: -z end lines with 0 byte, not newline, for find -print0\n\
239: --help display this help and exit\n\
240: --version output version information and exit\n\
241: \n\
242: POS is F[.C][OPTS], where F is the field number and C the character\n\
243: position in the field, both counted from zero. OPTS is made up of one\n\
244: or more of Mbdfinr, this effectively disable global -Mbdfinr settings\n\
245: for that key. If no key given, use the entire line as key. With no\n\
246: FILE, or when FILE is -, read standard input.\n\
247: ")
248: , DEFAULT_TMPDIR);
249: puts (_("\nReport bugs to textutils-bugs@gnu.ai.mit.edu"));
250: }
251: /* Don't use EXIT_FAILURE here in case it is defined to be 1.
252: POSIX requires that sort return 1 IFF invoked with -c and
253: the input is not properly sorted. */
254: assert (status == 0 || status == SORT_FAILURE);
255: exit (status);
256: }
257:
- Error exit in WrapMem
-
Code insertion
- Segment Source
-
286: error (0, 0, _("virtual memory exhausted"));
287: cleanup ();
288: exit (SORT_FAILURE);
- Error exit in WrapMem
-
Code insertion
- Segment Source
-
311: error (0, 0, _("virtual memory exhausted"));
312: cleanup ();
313: exit (SORT_FAILURE);
- Error exit in TempMngr
-
Code insertion
- Segment Source
-
327: error (0, errno, "%s", file);
328: cleanup ();
329: exit (SORT_FAILURE);
- Error exit in WrapIO
-
Code insertion
- Segment Source
-
348: error (0, errno, "%s", file);
349: cleanup ();
350: exit (SORT_FAILURE);
- Error exits in WrapIO
-
Code insertion
Segment Element
Code insertion
-
372: error (0, errno, _("flushing file"));
373: cleanup ();
374: exit (SORT_FAILURE);
Segment Element
Code insertion
-
381: error (0, errno, _("error closing file"));
382: cleanup ();
383: exit (SORT_FAILURE);
- Error exit in OutputBytes
-
Code insertion
- Segment Source
-
393: error (0, errno, _("write error"));
394: cleanup ();
395: exit (SORT_FAILURE);
- Error exit in Input
- Code insertion
- Segment Source
-
503: error (0, errno, _("read error"));
504: cleanup ();
505: exit (SORT_FAILURE);
- Define badfieldspec()
-
Function definition
- Segment Source
- 1635: static void
1636: badfieldspec (const char *s)
1637: {
1638: error (SORT_FAILURE, 0, _("invalid field specification `%s'"), s);
1639: }
1640:
- Error exits in OldFields option parsing
Segment Element
Code modification
-
1788: badfieldspec (argv[i]);
Segment Element
Code modification
-
1804: badfieldspec (argv[i]);
Segment Element
Code insertion
-
1814: error (0, 0, _("when using the old-style +POS and -POS \
1815: key specifiers,\nthe +POS specifier must come first"));
1816: usage (SORT_FAILURE);
Segment Element
Code modification
-
1828: badfieldspec (argv[i]);
- Error exits in POSIX option parsing (-k)
Segment Element
Code modification
-
1849: error (SORT_FAILURE, 0,
1850: _("option `-k' requires an argument"));
Segment Element
Code modification
-
1861: badfieldspec (argv[i]);
Segment Element
Code insertion
-
1866: /* Provoke with `sort -k0' */
1867: error (0, 0, _("the starting field number argument \
1868: to the `-k' option must be positive"));
1869: badfieldspec (argv[i]);
Segment Element
Code insertion
-
1877: /* Provoke with `sort -k1.' */
1878: error (0, 0, _("starting field spec has `.' but \
1879: lacks following character offset"));
1880: badfieldspec (argv[i]);
Segment Element
Code insertion
-
1886: /* Provoke with `sort -k1.0' */
1887: error (0, 0, _("starting field character offset \
1888: argument to the `-k' option\nmust be positive"));
1889: badfieldspec (argv[i]);
Segment Element
Code modification
-
1907: badfieldspec (argv[i]);
Segment Element
Code insertion
-
1914: /* Provoke with `sort -k1,' */
1915: error (0, 0, _("field specification has `,' but \
1916: lacks following field spec"));
1917: badfieldspec (argv[i]);
Segment Element
Code insertion
-
1924: /* Provoke with `sort -k1,0' */
1925: error (0, 0, _("ending field number argument \
1926: to the `-k' option must be positive"));
1927: badfieldspec (argv[i]);
Segment Element
Code insertion
-
1935: /* Provoke with `sort -k1,1.' */
1936: error (0, 0, _("ending field spec has `.' \
1937: but lacks following character offset"));
1938: badfieldspec (argv[i]);
Segment Element
Code modification
-
1952: badfieldspec (argv[i]);
- Error exits in OutSpec option parsing (-o)
- Code modification
- Segment Source
-
1966: error (SORT_FAILURE, 0,
1967: _("option `-o' requires an argument"));
- Error exit in TabSep option parsing (-t)
- Code modification
- Segment Source
-
1984: error (SORT_FAILURE, 0,
1985: _("option `-t' requires an argument"));
- Error exit in TempSpace option parsing (-T)
- Code modification
- Segment Source
-
1995: error (SORT_FAILURE, 0,
1996: _("option `-T' requires an argument"));
- Error exit due to unrecognized options
-
Code insertion
- Segment Source
-
2011: fprintf (stderr, _("%s: unrecognized option `-%c'\n"),
2012: argv[0], *s);
2013: usage (SORT_FAILURE);
- Error exits in Protect
Segment Element
Code insertion
-
2091: error (0, errno, "%s", files[i]);
2092: cleanup ();
2093: exit (SORT_FAILURE);
Segment Element
Code insertion
-
2111: error (0, errno, "%s", files[i]);
2112: cleanup ();
2113: exit (SORT_FAILURE);
- Error exits due to shut down problems
Segment Element
Code modification
-
2137: error (SORT_FAILURE, errno, _("%s: write error"), outfile);
Segment Element
Code modification
-
2140: error (SORT_FAILURE, errno, outfile);
Segment Element
Code modification
-
2142: error (SORT_FAILURE, errno, _("%s: write error"), outfile);