diff options
-rw-r--r-- | numericx.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/numericx.c b/numericx.c index 2870b13..b8c0254 100644 --- a/numericx.c +++ b/numericx.c @@ -4,6 +4,8 @@ #include <stdbool.h> #include <errno.h> +#define PROG_NAME "numericx" + #ifndef DEBUG #define DEBUG false #endif @@ -39,8 +41,6 @@ typedef struct NumeralPtr struct NumeralPtr *previous; } numeral_ptr; -char* program_name = NULL; - /* * Creates new digit for numeral_ptr * Return pointer to new numeral_ptr @@ -52,7 +52,7 @@ new_digit(numeral_ptr* last_numeral, char const* to_first) numeral_ptr* starting_point = malloc(sizeof(numeral_ptr)); if(starting_point == NULL) { - fprintf(stderr, "error: %s: %s!", program_name, strerror(ENOMEM)); + fprintf(stderr, "error: %s: %s!", PROG_NAME, strerror(ENOMEM)); return NULL; } @@ -210,12 +210,10 @@ free_numeral(numeral_ptr* numeral) int main(int argc, char* argv[]) { - program_name = argv[0]; - /* argument processing */ if( !(argc == 2) ) { - fprintf(stderr, "usage: %s <number>\n", program_name); + fprintf(stderr, "usage: %s <number>\n", PROG_NAME); exit(EXIT_FAILURE); } @@ -234,7 +232,7 @@ main(int argc, char* argv[]) { free(from); free(to); - fprintf(stderr, "error: %s.\n", strerror(EDOM)); + fprintf(stderr, "error: %s: %s.\n", PROG_NAME, strerror(EDOM)); exit(EDOM); } @@ -272,7 +270,7 @@ main(int argc, char* argv[]) free(to); free_numeral(counting); free_numeral(result); - fprintf(stderr, "error: unrepresentable void number\n"); + fprintf(stderr, "error: %s: unrepresentable void number\n", PROG_NAME); exit(EXIT_FAILURE); } decrement_number_string(number, from_first, from_last, from_first); |