diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-12-28 19:53:34 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-12-28 19:53:34 +0000 |
commit | 5d16663331afd0bc2edaeb2e49042dc219ce9c2f (patch) | |
tree | 476fbb2ab4311d4bb6d65b250825e254a7a2c1ef /generator/pgmkernel.c | |
parent | 42f0bf8e7f1ff88000a3584c265e6f1631662ec4 (diff) | |
download | netpbm-mirror-5d16663331afd0bc2edaeb2e49042dc219ce9c2f.tar.gz netpbm-mirror-5d16663331afd0bc2edaeb2e49042dc219ce9c2f.tar.xz netpbm-mirror-5d16663331afd0bc2edaeb2e49042dc219ce9c2f.zip |
promote Development to Advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4827 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'generator/pgmkernel.c')
-rw-r--r-- | generator/pgmkernel.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/generator/pgmkernel.c b/generator/pgmkernel.c index cbae0882..8d99a76d 100644 --- a/generator/pgmkernel.c +++ b/generator/pgmkernel.c @@ -20,7 +20,7 @@ #include "shhopt.h" #include "mallocvar.h" #include "pgm.h" - +#include "nstring.h" struct CmdlineInfo { @@ -89,20 +89,30 @@ parseCommandLine(int argc, const char ** argv, if (argc-1 < 1) pm_error("Need at least one argument: size of (square) kernel"); else if (argc-1 == 1) { - if (atoi(argv[1]) <= 0) + unsigned int dimension; + const char * error; + + pm_string_to_uint(argv[1], &dimension, &error); + if (error) { + pm_error("'%s' is invalid as an image width/height. %s", argv[1], error); + pm_strfree(error); + } + if (dimension <= 0) pm_error("Dimension must be a positive number. " "You specified '%s'", argv[1]); - cmdlineP->cols = atoi(argv[1]); - cmdlineP->rows = atoi(argv[1]); + cmdlineP->cols = cmdlineP->rows = dimension; + } else if (argc-1 == 2) { - if (atoi(argv[1]) <= 0) + unsigned int const width = pm_parse_width(argv[1]); + unsigned int const height = pm_parse_height(argv[2]); + if (width <= 0) pm_error("Width must be a positive number. " "You specified '%s'", argv[1]); - if (atoi(argv[2]) <= 0) + if (height <= 0) pm_error("Height must be a positive number. " "You specified '%s'", argv[2]); - cmdlineP->cols = atoi(argv[1]); - cmdlineP->rows = atoi(argv[2]); + cmdlineP->cols = width; + cmdlineP->rows = height; } else pm_error("At most two arguments allowed. " "You specified %u", argc-1); @@ -243,3 +253,6 @@ main(int argc, const char * argv[]) { return 0; } + + + |