diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2012-11-18 00:56:58 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2012-11-18 00:56:58 +0000 |
commit | eb5a0b4e1b3698be49ef8e570532ca19c23a9a63 (patch) | |
tree | 4cba264999b9c67d17a52322f1fd2ae45f912f82 /lib | |
parent | 7cedf303a515993e87302f8c042cb139586b890f (diff) | |
download | netpbm-mirror-eb5a0b4e1b3698be49ef8e570532ca19c23a9a63.tar.gz netpbm-mirror-eb5a0b4e1b3698be49ef8e570532ca19c23a9a63.tar.xz netpbm-mirror-eb5a0b4e1b3698be49ef8e570532ca19c23a9a63.zip |
Improve comments
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1764 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/shhopt.c | 2 | ||||
-rw-r--r-- | lib/util/shhopt.h | 17 |
2 files changed, 14 insertions, 5 deletions
diff --git a/lib/util/shhopt.c b/lib/util/shhopt.c index 4f7ce9c7..ccf2d1eb 100644 --- a/lib/util/shhopt.c +++ b/lib/util/shhopt.c @@ -77,7 +77,7 @@ optFatalFunc(const char *format, ...) | | RETURNS Number of options in the given array. | - | DESCRIPTION Count elements in an optStruct-array. The strcture must + | DESCRIPTION Count elements in an optStruct-array. The structure must | be ended using an element of type OPT_END. */ static int diff --git a/lib/util/shhopt.h b/lib/util/shhopt.h index 6be7f411..9a446290 100644 --- a/lib/util/shhopt.h +++ b/lib/util/shhopt.h @@ -22,7 +22,8 @@ main ( int argc, char **argv ) { optStruct3 opt; unsigned int option_def_index = 0; - optEntry *option_def = malloc(100*sizeof(option_def[0])); + optEntry * option_def; + MALLOCARRAY(option_def, 100); OPTENT3(0, "help", OPT_FLAG, &help_flag, &help_spec, 0); OPTENT3(0, "height", OPT_INT, &height, &height_spec, 0); @@ -69,6 +70,13 @@ Now run this program with something like myprog -v /etc/passwd -name=Bryan --hei=4 + If your program takes no options (so you have no OPTENT3 macro invocations), + you need an OPTENTINIT call to establish the empty option table: + + optEntry * option_def; + MALLOCARRAY(option_def, 1); + OPTENTINIT; + ======================================================================== #endif /* 0 */ @@ -190,9 +198,10 @@ typedef struct { } /* OPTENT3 is the same as OPTENTRY except that it also sets the "specified" - element of the table entry (so it assumes OPTION_DEF is a table of - optEntry instead of optStruct). It sets it to the number of times that - the option appears in the command line. + element of the table entry (so it assumes OPTION_DEF is a table of optEntry + instead of optStruct). This is a pointer to a variable that the parser + will set to the number of times that the option appears in the command + line. Here is an example: |