diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-02-20 17:09:42 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-02-20 17:09:42 +0000 |
commit | 435cf27a61980d986c9feecdb024368237455aba (patch) | |
tree | 6fed7ba415691e8b911d19cc21623fc79c336ef5 /editor | |
parent | 73109d82230bf5768d6aa7b27cd565914dbe2a1e (diff) | |
download | netpbm-mirror-435cf27a61980d986c9feecdb024368237455aba.tar.gz netpbm-mirror-435cf27a61980d986c9feecdb024368237455aba.tar.xz netpbm-mirror-435cf27a61980d986c9feecdb024368237455aba.zip |
Add -offset option
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@228 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor')
-rw-r--r-- | editor/ppm3d.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/editor/ppm3d.c b/editor/ppm3d.c index 79ece022..24e58fac 100644 --- a/editor/ppm3d.c +++ b/editor/ppm3d.c @@ -46,12 +46,16 @@ parseCommandLine(int argc, char ** argv, optStruct3 opt; unsigned int option_def_index; + unsigned int offsetSpec; + const char * offsetArg; MALLOCARRAY_NOFAIL(option_def, 100); option_def_index = 0; /* incremented by OPTENT3 */ OPTENT3(0, "color", OPT_FLAG, NULL, - &cmdlineP->color, 0 ); + &cmdlineP->color, 0); + OPTENT3(0, "offset", OPT_UINT, &cmdlineP->offset, + &offsetSpec, 0); opt.opt_table = option_def; opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ @@ -68,21 +72,31 @@ parseCommandLine(int argc, char ** argv, cmdlineP->rghtInputFileName = argv[2]; if (argc-1 > 2) { - int const offsetnum = atoi(argv[3]); - - if (offsetnum <= 0) - pm_error("Offset must be a positive number. You specified " - "'%s'", argv[3]); - else - cmdlineP->offset = offsetnum; + offsetArg = argv[3]; if (argc-1 > 3) pm_error("Program takes at most 3 arguments: left and " "right input file names and offset. " "You specified %u", argc-1); } else - cmdlineP->offset = 30; + offsetArg = NULL; } + + if (offsetArg && offsetSpec) + pm_error("You cannot specify both -offset and the offset " + "argument (i.e. with -offset, there is at most " + "two arguments: left and right input file names"); + else if (!offsetArg && !offsetSpec) + cmdlineP->offset = 30; + else if (offsetArg) { + int const offsetnum = atoi(offsetArg); + + if (offsetnum <= 0) + pm_error("Offset must be a positive number. You specified " + "'%s'", offsetArg); + else + cmdlineP->offset = offsetnum; + } } |