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.2 and 1.3

version 1.2, 2001/10/23 00:05:18 version 1.3, 2001/10/23 15:41:32
Line 35  static int cfg_cmdline_get_next_opt(cons
Line 35  static int cfg_cmdline_get_next_opt(cons
   
         register int opt_idx;          register int opt_idx;
   
         char cur_opt_types[][10] = { "NONE", "SHORT", "SHORTS", "LONG" };  
   
         while (con->argv[con->cur_idx] != NULL) {          while (con->argv[con->cur_idx] != NULL) {
   
                 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_OPTION;                                  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]);                                  con->cur_arg = strdup(con->argv[con->cur_idx + 1]);
                         }                          }
Line 58  static int cfg_cmdline_get_next_opt(cons
Line 56  static int cfg_cmdline_get_next_opt(cons
   
                 opt_idx = search_cur_opt(con);                  opt_idx = search_cur_opt(con);
   
                 fprintf(stderr, "DEBUG|%d|%s|%s|%s|%s|%d|\n",  #if defined(DEBUG) && DEBUG
                   fprintf(stderr, "DEBUG|%d|%s|%s|%s|%d|flags=%x(",
                                                                 con->cur_idx, con->argv[con->cur_idx],                                                                  con->cur_idx, con->argv[con->cur_idx],
                                                                 cur_opt_types[con->cur_opt_type],  
                                                                 con->cur_opt == NULL ? "[NULL]" : con->cur_opt,                                                                  con->cur_opt == NULL ? "[NULL]" : con->cur_opt,
                                                                 con->cur_arg == NULL ? "[NULL]" : con->cur_arg,                                                                  con->cur_arg == NULL ? "[NULL]" : con->cur_arg,
                                                                 opt_idx);                                                                  opt_idx, con->cur_opt_type);
   
                   if (con->cur_opt_type & CFG_LONG_OPTION)
                           fputs("-LONG-", stderr);
                   if (con->cur_opt_type & CFG_SHORT_OPTION)
                           fputs("-SHORT-", stderr);
                   if (con->cur_opt_type & CFG_SHORT_OPTIONS)
                           fputs("-SHORTS-", stderr);
                   if (con->cur_opt_type & CFG_LONG_SEPINIT)
                           fputs("-SEPINIT-", stderr);
   
                   fputs(")\n", stderr);
   #endif
   
                 if (opt_idx < 0)                  if (opt_idx < 0)
                         return CFG_ERROR_UNKNOWN;                          return CFG_ERROR_UNKNOWN;
Line 142  static int cfg_cmdline_get_next_opt(cons
Line 152  static int cfg_cmdline_get_next_opt(cons
                                                         *((int *)con->options[opt_idx].value) = value;                                                          *((int *)con->options[opt_idx].value) = value;
                                         }                                          }
   
                                         if (! (con->cur_opt_type & CFG_LONG_SEPINIT)) {                                          if (! (con->cur_opt_type & CFG_LONG_SEPINIT)
                                                 puts("not sepinit");                                                                                          && ! (con->cur_opt_type
                                                                                                   & CFG_SHORT_OPTIONS)) {
                                                   puts("[1] moving cur_idx");
                                                 con->cur_idx++;                                                  con->cur_idx++;
                                         }                                          }
                                 }                                  }
   
                                   if (con->cur_opt_type & CFG_SHORT_OPTIONS)
                                           con->cur_opt_type -= CFG_SHORT_OPTIONS;
   
                                 break;                                  break;
   
                         case CFG_UNSIGNED_LONG:                          case CFG_UNSIGNED_LONG:
Line 194  return POPT_ERROR_OVERFLOW;
Line 209  return POPT_ERROR_OVERFLOW;
                                 break;                                  break;
                 }                  }
   
                 if (con->cur_opt_type != CFG_SHORT_OPTIONS)                  printf("%d vs. %d\n", con->cur_opt_type, CFG_SHORT_OPTIONS);
   
                   if (! (con->cur_opt_type & CFG_SHORT_OPTIONS)) {
                           puts("[2] moving cur_idx");
                         con->cur_idx++;                          con->cur_idx++;
                   }
   
                 if (con->options[opt_idx].val != 0)                  if (con->options[opt_idx].val != 0)
                         return con->options[opt_idx].val;                          return con->options[opt_idx].val;
Line 254  static int set_currents(const CFG_CONTEX
Line 273  static int set_currents(const CFG_CONTEX
                 s_sep = s + 1;                  s_sep = s + 1;
   
                 if (strlen(s_sep) > 0) {                  if (strlen(s_sep) > 0) {
                         con->cur_opt_type = CFG_SHORT_OPTIONS;                          con->cur_opt_type = CFG_SHORT_OPTION + CFG_SHORT_OPTIONS;
   
                         if ((con->cur_arg = strdup(s_sep)) == NULL)                          if ((con->cur_arg = strdup(s_sep)) == NULL)
                                 return 0;                                  return 0;
Line 262  static int set_currents(const CFG_CONTEX
Line 281  static int set_currents(const CFG_CONTEX
                 else {                  else {
                         con->cur_opt_type = CFG_SHORT_OPTION;                          con->cur_opt_type = CFG_SHORT_OPTION;
   
                         if ((con->cur_arg = strdup(con->argv[con->cur_idx])) == NULL)                          if (con->argv[con->cur_idx + 1] != NULL) {
                                 return 0;                                  con->cur_arg = strdup(con->argv[con->cur_idx + 1]);
                                   if (con->cur_arg == NULL)
                                           return 0;
                           }
                           else
                                   con->cur_arg = NULL;
                 }                  }
         }          }
         else {          else {
Line 329  static int search_cur_opt(const CFG_CONT
Line 353  static int search_cur_opt(const CFG_CONT
                    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))
                                                                 || (con->cur_opt_type == CFG_SHORT_OPTION &&                                                                  || (con->cur_opt_type & CFG_SHORT_OPTION &&
                                                                         con->cur_opt[0] ==                                                                          con->cur_opt[0] ==
                                                                         con->options[i].cmdline_short_name)                                                                          con->options[i].cmdline_short_name)
                                                                 || (con->cur_opt_type == CFG_NONE_OPTION &&                                                                  || (con->cur_opt_type == CFG_NONE_OPTION &&

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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