diff options
author | Pádraig Brady <P@draigBrady.com> | 2016-10-15 23:10:35 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2016-10-16 12:23:55 +0100 |
commit | 492dcb2eb191b844a2fd5e51db3eed85289bea1f (patch) | |
tree | 910f93d88891b573520ebd5c812d61ddc7fbeed8 /src/printf.c | |
parent | d035eacfdeba2da0134e606c8a63b2f3c0bd05bb (diff) | |
download | coreutils-492dcb2eb191b844a2fd5e51db3eed85289bea1f.tar.xz |
all: use die() rather than error(EXIT_FAILURE)
die() has the advantage of being apparent to the compiler
that it doesn't return, which will avoid warnings in some cases,
and possibly generate better code.
* cfg.mk (sc_die_EXIT_FAILURE): A new syntax check rule to
catch any new uses of error (CONSTANT, ...);
Diffstat (limited to 'src/printf.c')
-rw-r--r-- | src/printf.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/printf.c b/src/printf.c index 0885f8ff6..a21529a50 100644 --- a/src/printf.c +++ b/src/printf.c @@ -56,6 +56,7 @@ #include "system.h" #include "c-strtod.h" +#include "die.h" #include "error.h" #include "quote.h" #include "unicodeio.h" @@ -250,7 +251,7 @@ print_esc (const char *escstart, bool octal_0) ++esc_length, ++p) esc_value = esc_value * 16 + hextobin (*p); if (esc_length == 0) - error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); + die (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); putchar (esc_value); } else if (isodigit (*p)) @@ -277,7 +278,7 @@ print_esc (const char *escstart, bool octal_0) --esc_length, ++p) { if (! isxdigit (to_uchar (*p))) - error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); + die (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); uni_value = uni_value * 16 + hextobin (*p); } @@ -289,8 +290,8 @@ print_esc (const char *escstart, bool octal_0) if ((uni_value <= 0x9f && uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60) || (uni_value >= 0xd800 && uni_value <= 0xdfff)) - error (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"), - esc_char, (esc_char == 'u' ? 4 : 8), uni_value); + die (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"), + esc_char, (esc_char == 'u' ? 4 : 8), uni_value); print_unicode_char (stdout, uni_value, 0); } @@ -562,8 +563,8 @@ print_formatted (const char *format, int argc, char **argv) if (INT_MIN <= width && width <= INT_MAX) field_width = width; else - error (EXIT_FAILURE, 0, _("invalid field width: %s"), - quote (*argv)); + die (EXIT_FAILURE, 0, _("invalid field width: %s"), + quote (*argv)); ++argv; --argc; } @@ -597,8 +598,8 @@ print_formatted (const char *format, int argc, char **argv) precision = -1; } else if (INT_MAX < prec) - error (EXIT_FAILURE, 0, _("invalid precision: %s"), - quote (*argv)); + die (EXIT_FAILURE, 0, _("invalid precision: %s"), + quote (*argv)); else precision = prec; ++argv; @@ -623,9 +624,9 @@ print_formatted (const char *format, int argc, char **argv) { unsigned char conversion = *f; if (! ok[conversion]) - error (EXIT_FAILURE, 0, - _("%.*s: invalid conversion specification"), - (int) (f + 1 - direc_start), direc_start); + die (EXIT_FAILURE, 0, + _("%.*s: invalid conversion specification"), + (int) (f + 1 - direc_start), direc_start); } print_direc (direc_start, direc_length, *f, |