diff subopt-helper.c @ 28827:2b021e3e1000

Get rid of the "set" member of the subopt-parser struct, it made it impossible to make the those struct variables const. Also it is not really useful, and wastes space.
author reimar
date Fri, 06 Mar 2009 20:41:02 +0000
parents bc9e95184521
children 3b9429f763e2
line wrap: on
line diff
--- a/subopt-helper.c	Fri Mar 06 20:20:12 2009 +0000
+++ b/subopt-helper.c	Fri Mar 06 20:41:02 2009 +0000
@@ -45,18 +45,11 @@
  *         else a non-zero value is returned.
  *
  */
-int subopt_parse( char const * const str, opt_t * opts )
+int subopt_parse( char const * const str, const opt_t * opts )
 {
   int parse_err = 0, idx;
   unsigned int parse_pos = 0;
 
-  /* Initialize set member to false.          *
-   * It is set to true if it was found in str */
-  for ( idx=0; opts[idx].name; ++idx )
-  {
-    opts[idx].set = 0;
-  }
-
   if ( str )
   {
     while ( str[parse_pos] && !parse_err )
@@ -101,7 +94,7 @@
         if( strncmp( &str[parse_pos], opts[idx].name, opt_len ) == 0 )
         {
           /* option was found */
-          opts[idx].set = 1; next = 1;
+          next = 1;
 
           assert( opts[idx].valp && "Need a pointer to store the arg!" );
 
@@ -196,7 +189,7 @@
                   strncmp( &str[parse_pos+2], opts[idx].name, opt_len ) == 0 )
         {
           /* option was found but negated */
-          opts[idx].set = 1; next = 1;
+          next = 1;
 
           /* set arg to false */
           *((int *)(opts[idx].valp)) = 0;