X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FErrCode.c;h=aaec2cc96d0c76e9c3cb604ae245517f32353c69;hp=5106885503a25e7b86a5e1767e30901d2aa33f91;hb=b72f18d024a942eca58a8109c60479d835ee7350;hpb=54d27b07aee6d293931ee274a3ede927f517f2cf diff --git a/sources/ErrCode.c b/sources/ErrCode.c index 5106885..aaec2cc 100644 --- a/sources/ErrCode.c +++ b/sources/ErrCode.c @@ -26,7 +26,7 @@ * * Usage: errcode -h give all info's * - * $Id: ErrCode.c,v 1.2 2001/09/09 22:45:34 piccardi Exp $ + * $Id: ErrCode.c,v 1.4 2001/10/14 15:05:33 piccardi Exp $ * ****************************************************************/ /* @@ -217,7 +217,17 @@ int main(int argc, char *argv[]) if (optind == argc) { usage(); } - err = atoi(argv[optind]); + /* convert string to number */ + err = strtol(argv[optind], NULL, 10); + /* testing error condition on conversion */ + if (err==LONG_MIN) { + perror("Underflow on error code"); + return 1; + } else if (err==LONG_MIN) { + perror("Overflow on error code"); + return 1; + } + /* conversion is fine */ if (message) { printf("Error message for %d is %s\n", err, strerror(err)); }