diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-03-14 13:18:24 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-03-14 13:18:24 -0400 |
commit | aabf2e0f651292400d8683b41656cecab65033a5 (patch) | |
tree | ef32442e1bc3b811aa37628047b11e34088472ef | |
parent | 534e9a5d77adbcfe09d4ad6c643ea7bf3c824449 (diff) |
call setlocale() for localized perror() messages; cleaner return at end
-rw-r--r-- | nice.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,14 +1,20 @@ #define _XOPEN_SOURCE 700 #include <errno.h> +#include <locale.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#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; } |