[BACK]Return to getarg.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / asn1_compile

Diff for /src/usr.bin/asn1_compile/Attic/getarg.c between version 1.4 and 1.5

version 1.4, 2004/06/08 16:49:00 version 1.5, 2005/10/16 18:56:35
Line 33 
Line 33 
   
 #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
 #include <config.h>  #include <config.h>
 RCSID("$KTH: getarg.c,v 1.46 2002/08/20 16:23:07 joda Exp $");  RCSID("$KTH: getarg.c,v 1.48 2005/04/12 11:28:43 lha Exp $");
 #endif  #endif
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <err.h>  #include <errno.h>
 #include "getarg.h"  #include "getarg.h"
   
 #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)  #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
Line 202 
Line 202 
     return col;      return col;
 }  }
   
 void  void ROKEN_LIB_FUNCTION
 arg_printusage (struct getargs *args,  arg_printusage (struct getargs *args,
                 size_t num_args,                  size_t num_args,
                 const char *progname,                  const char *progname,
Line 322 
Line 322 
     }      }
 }  }
   
 static void  static int
 add_string(getarg_strings *s, char *value)  add_string(getarg_strings *s, char *value)
 {  {
     if ((s->strings = realloc(s->strings, (s->num_strings + 1) *      char **strings;
       sizeof(*s->strings))) == NULL)  
         err(1, "realloc");      strings = realloc(s->strings, (s->num_strings + 1) * sizeof(*s->strings));
       if (strings == NULL) {
           free(s->strings);
           s->strings = NULL;
           s->num_strings = 0;
           return ENOMEM;
       }
       s->strings = strings;
     s->strings[s->num_strings] = value;      s->strings[s->num_strings] = value;
     s->num_strings++;      s->num_strings++;
       return 0;
 }  }
   
 static int  static int
Line 407 
Line 415 
     }      }
     case arg_strings:      case arg_strings:
     {      {
         add_string((getarg_strings*)current->value, goptarg + 1);          return add_string((getarg_strings*)current->value, goptarg + 1);
         return 0;  
     }      }
     case arg_flag:      case arg_flag:
     case arg_negative_flag:      case arg_negative_flag:
Line 516 
Line 523 
                     *(char**)args[k].value = goptarg;                      *(char**)args[k].value = goptarg;
                     return 0;                      return 0;
                 } else if(args[k].type == arg_strings) {                  } else if(args[k].type == arg_strings) {
                     add_string((getarg_strings*)args[k].value, goptarg);                      return add_string((getarg_strings*)args[k].value, goptarg);
                     return 0;  
                 } else if(args[k].type == arg_double) {                  } else if(args[k].type == arg_double) {
                     double tmp;                      double tmp;
                     if(sscanf(goptarg, "%lf", &tmp) != 1)                      if(sscanf(goptarg, "%lf", &tmp) != 1)
Line 534 
Line 540 
     return 0;      return 0;
 }  }
   
 int  int ROKEN_LIB_FUNCTION
 getarg(struct getargs *args, size_t num_args,  getarg(struct getargs *args, size_t num_args,
        int argc, char **argv, int *goptind)         int argc, char **argv, int *goptind)
 {  {
Line 575 
Line 581 
     return ret;      return ret;
 }  }
   
 void  void ROKEN_LIB_FUNCTION
 free_getarg_strings (getarg_strings *s)  free_getarg_strings (getarg_strings *s)
 {  {
     free (s->strings);      free (s->strings);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5