Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for libcfg+/src/cmdline.c between version 1.6 and 1.7

version 1.6, 2001/11/27 17:11:30 version 1.7, 2001/11/28 20:46:51
Line 1 
Line 1 
 /* TODO: ./configure check HAVE_FLOAT_H je dolezity!!! */  
 /* no uz ani nie, ked mam limits.h :P */  
   
 #include <math.h>  #include <math.h>
 #include <limits.h>  #include <limits.h>
 #include <float.h>  #include <float.h>
Line 37  static int cfg_cmdline_get_next_opt(cons
Line 34  static int cfg_cmdline_get_next_opt(cons
            }             }
   
            return 0;             return 0;
            */           */
   
         register int opt_idx;          register int opt_idx;
         register int arg_used;          register int arg_used;
   
         while (con->argv[con->cur_idx] != NULL) {          while (1) {
   
                 arg_used = 0;                  arg_used = 0;
   
                   /* Updating cur_idx step by step and testing for NULL in argv. */
                   for (; con->cur_idx_tmp > 0; con->cur_idx_tmp--, con->cur_idx++)
                           if (con->argv[con->cur_idx] == NULL)
                                   break;
   
                   /* Finished? */
                   if (con->argv[con->cur_idx] == NULL)
                           break;
   
                 if (con->cur_opt_type & CFG_SHORT_OPTIONS) {                  if (con->cur_opt_type & CFG_SHORT_OPTIONS) {
   
                         con->cur_opt[0] = con->cur_arg[0];                          con->cur_opt[0] = con->cur_arg[0];
                         strdel(con->cur_arg);                          strdel(con->cur_arg);
   
                         if (strlen(con->cur_arg) == 0) {                          if (strlen(con->cur_arg) == 0) {
                                 con->cur_opt_type -= CFG_SHORT_OPTIONS;                                  con->cur_opt_type -= CFG_SHORT_OPTIONS;
                                 free(con->cur_arg);                                  free(con->cur_arg);
                                 con->cur_arg = strdup(con->argv[con->cur_idx + 1]);  
                                   /* strdup() doesn't accept NULL as parameter */
                                   con->cur_arg = con->argv[con->cur_idx + 1] != NULL
                                           ? strdup(con->argv[con->cur_idx + 1]) : NULL;
                         }                          }
                 }                  }
                 else {                  else {
Line 139  static int cfg_cmdline_get_next_opt(cons
Line 149  static int cfg_cmdline_get_next_opt(cons
                                                    value,                                                     value,
                                                    INT_MAX,                                                     INT_MAX,
                                                    LONG_MAX);                                                     LONG_MAX);
                                                    */                                                   */
   
                                                 if (value >= INT_MAX || value <= INT_MIN)                                                  if (value >= INT_MAX || value <= INT_MIN)
                                                         return CFG_ERROR_OVERFLOW;                                                          return CFG_ERROR_OVERFLOW;
Line 232  static int cfg_cmdline_get_next_opt(cons
Line 242  static int cfg_cmdline_get_next_opt(cons
                                                                         && !(con->cur_opt_type & CFG_SHORT_OPTIONS))                                                                          && !(con->cur_opt_type & CFG_SHORT_OPTIONS))
                         {                          {
                                 puts("[1] argument used, moving cur_idx");                                  puts("[1] argument used, moving cur_idx");
                                 con->cur_idx++;                                  con->cur_idx_tmp++;
                         }                          }
   
                         if (con->cur_opt_type & CFG_SHORT_OPTIONS)                          if (con->cur_opt_type & CFG_SHORT_OPTIONS)
Line 241  static int cfg_cmdline_get_next_opt(cons
Line 251  static int cfg_cmdline_get_next_opt(cons
   
                 if (! (con->cur_opt_type & CFG_SHORT_OPTIONS)) {                  if (! (con->cur_opt_type & CFG_SHORT_OPTIONS)) {
                         puts("[2] moving cur_idx");                          puts("[2] moving cur_idx");
                         con->cur_idx++;                          con->cur_idx_tmp++;
                 }                  }
   
                 if (con->options[opt_idx].val != 0)                  if (con->options[opt_idx].val != 0)
Line 379  static int search_cur_opt(const CFG_CONT
Line 389  static int search_cur_opt(const CFG_CONT
                    con->cur_opt,                     con->cur_opt,
                    con->options[i].cmdline_long_name,                     con->options[i].cmdline_long_name,
                    con->options[i].cmdline_short_name);                     con->options[i].cmdline_short_name);
                    */                   */
   
                 if ((con->cur_opt_type & CFG_LONG_OPTION && ! strcmp(con->cur_opt,                  if ((con->cur_opt_type & CFG_LONG_OPTION && ! strcmp(con->cur_opt,
                                                                                 con->options[i].cmdline_long_name))                                                                                  con->options[i].cmdline_long_name))

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top