From fe07993e8f9894ec49330d833782a5ebade9d872 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 29 Dec 2007 19:12:47 +0000 Subject: cleanup git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@512 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/pgm/rawtopgm.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/converter/pgm/rawtopgm.c b/converter/pgm/rawtopgm.c index c91c6178..4eac91d2 100644 --- a/converter/pgm/rawtopgm.c +++ b/converter/pgm/rawtopgm.c @@ -18,13 +18,13 @@ struct cmdline_info { /* All the information the user supplied in the command line, in a form easy for the program to use. */ - const char *input_filespec; /* Filespec of input file */ + const char * inputFileName; unsigned int headerskip; float rowskip; int bottomfirst; /* the -bottomfirst/-bt option */ int autosize; /* User wants us to figure out the size */ - int width; - int height; + unsigned int width; + unsigned int height; int bpp; /* bytes per pixel in input format. 1 or 2 */ int littleendian; @@ -74,21 +74,21 @@ parse_command_line(int argc, char ** argv, /* Uses and sets argc, argv, and some of *cmdline_p and others. */ if (argc-1 == 0) { - cmdline_p->input_filespec = "-"; + cmdline_p->inputFileName = "-"; cmdline_p->autosize = TRUE; } else if (argc-1 == 1) { - cmdline_p->input_filespec = argv[1]; + cmdline_p->inputFileName = argv[1]; cmdline_p->autosize = TRUE; } else if (argc-1 == 2) { - cmdline_p->input_filespec = "-"; + cmdline_p->inputFileName = "-"; cmdline_p->autosize = FALSE; - cmdline_p->width = atoi(argv[1]); - cmdline_p->height = atoi(argv[2]); + cmdline_p->width = pm_parse_width(argv[1]); + cmdline_p->height = pm_parse_height(argv[2]); } else if (argc-1 == 3) { - cmdline_p->input_filespec = argv[3]; + cmdline_p->inputFileName = argv[3]; cmdline_p->autosize = FALSE; - cmdline_p->width = atoi(argv[1]); - cmdline_p->height = atoi(argv[2]); + cmdline_p->width = pm_parse_width(argv[1]); + cmdline_p->height = pm_parse_height(argv[2]); } else pm_error("Program takes zero, one, two, or three arguments. You " "specified %d", argc-1); @@ -107,11 +107,6 @@ parse_command_line(int argc, char ** argv, pm_error("Maxval must be less than 65536. You specified %d.", cmdline_p->maxval); - if (cmdline_p->width <= 0) - pm_error("Width must be a positive number."); - if (cmdline_p->height <= 0) - pm_error("Height must be a positive number."); - if (cmdline_p->rowskip && cmdline_p->autosize) pm_error("If you specify -rowskip, you must also give the image " "dimensions."); @@ -221,7 +216,7 @@ main(int argc, char *argv[] ) { parse_command_line(argc, argv, &cmdline); - ifp = pm_openr(cmdline.input_filespec); + ifp = pm_openr(cmdline.inputFileName); if (cmdline.autosize || cmdline.bottomfirst) { buf = pm_read_unknown_size( ifp, &nread ); -- cgit 1.4.1