diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-11-18 15:53:17 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-11-18 15:53:17 +0000 |
commit | 28119ad57a22536240fbdf2e6dbce92005a0e5d1 (patch) | |
tree | 91a5d4d448f403678de4399fb95b32b51bf37dd8 | |
parent | 6f82b1b8932ffab2e2fc33dfc0eb0bc621a668a4 (diff) |
Delete useless call to setlocale(3).
While the C library function printf(3) is used here and is
locale-dependent, the printf(1) utility does not use the locale
dependent parts %lc and %ls. While POSIX requires LC_NUMERIC
support, we intentionally don't implement that in printf(3).
In summary, no functional change.
While here, sort headers and use the usual __dead usage() idiom.
Based on a patch from Jan Stary <hans at stare dot cz>.
OK bentley@
-rw-r--r-- | usr.bin/printf/printf.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index c0a76f04859..30feac0559a 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printf.c,v 1.25 2016/07/27 01:52:03 tedu Exp $ */ +/* $OpenBSD: printf.c,v 1.26 2016/11/18 15:53:16 schwarze Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -30,14 +30,13 @@ */ #include <ctype.h> +#include <err.h> +#include <errno.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <string.h> -#include <limits.h> -#include <locale.h> -#include <errno.h> -#include <err.h> +#include <unistd.h> static int print_escape_str(const char *); static int print_escape(const char *); @@ -50,7 +49,7 @@ static unsigned long getulong(void); static char *getstr(void); static char *mklong(const char *, int); static void check_conversion(const char *, const char *); -static void usage(void); +static void __dead usage(void); static int rval; static char **gargv; @@ -80,8 +79,6 @@ main(int argc, char *argv[]) char convch, nextch; char *format; - setlocale (LC_ALL, ""); - if (pledge("stdio", NULL) == -1) err(1, "pledge"); @@ -91,10 +88,8 @@ main(int argc, char *argv[]) argv++; } - if (argc < 2) { + if (argc < 2) usage(); - return (1); - } format = *++argv; gargv = ++argv; @@ -498,8 +493,9 @@ check_conversion(const char *s, const char *ep) } } -static void +static void __dead usage(void) { (void)fprintf(stderr, "usage: printf format [argument ...]\n"); + exit(1); } |