From aabf2e0f651292400d8683b41656cecab65033a5 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 14 Mar 2019 13:18:24 -0400 Subject: call setlocale() for localized perror() messages; cleaner return at end --- nice.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nice.c b/nice.c index 274191d..a103d0c 100644 --- a/nice.c +++ b/nice.c @@ -1,14 +1,20 @@ #define _XOPEN_SOURCE 700 #include +#include #include #include #include +#define NICE_UTILITY_NOT_FOUND 127 +#define NICE_UTILITY_NOT_INVOKED 126 + int main(int argc, char *argv[]) { int increment = 0; int c; + setlocale(LC_ALL, ""); + while ((c = getopt(argc, argv, "n:")) != -1) { switch (c) { case 'n': @@ -30,5 +36,10 @@ int main(int argc, char *argv[]) execvp(argv[0], argv); perror("nice"); - return errno == ENOENT ? 127 : 126; + + if (errno == ENOENT) { + return NICE_UTILITY_NOT_FOUND; + } + + return NICE_UTILITY_NOT_INVOKED; } -- cgit v1.2.1