~ubuntu-branches/ubuntu/intrepid/gengetopt/intrepid

« back to all changes in this revision

Viewing changes to tests/test_values_cmd.c.test

  • Committer: Bazaar Package Importer
  • Author(s): Bart Martens
  • Date: 2008-05-07 21:14:14 UTC
  • mfrom: (1.1.6 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080507211414-p2vy66i37h9csmxi
Tags: 2.22.1-1
* New upstream release.
* debian/copyright: Updated.
* debian/patches/02info.diff: Updated.
* debian/patches/03gcc43.diff: Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
  args_info->string_values_def_argopt_help = gengetopt_args_info_help[4] ;
156
156
  args_info->string_values_no_short_help = gengetopt_args_info_help[5] ;
157
157
  args_info->multistring_values_help = gengetopt_args_info_help[6] ;
158
 
  args_info->multistring_values_min = -1;
159
 
  args_info->multistring_values_max = -1;
 
158
  args_info->multistring_values_min = 0;
 
159
  args_info->multistring_values_max = 0;
160
160
  args_info->multistring_values_def_help = gengetopt_args_info_help[7] ;
161
 
  args_info->multistring_values_def_min = -1;
162
 
  args_info->multistring_values_def_max = -1;
 
161
  args_info->multistring_values_def_min = 0;
 
162
  args_info->multistring_values_def_max = 0;
163
163
  args_info->multistring_values_no_short_help = gengetopt_args_info_help[8] ;
164
 
  args_info->multistring_values_no_short_min = -1;
165
 
  args_info->multistring_values_no_short_max = -1;
 
164
  args_info->multistring_values_no_short_min = 0;
 
165
  args_info->multistring_values_no_short_max = 0;
166
166
  args_info->string_values_group_help = gengetopt_args_info_help[10] ;
167
167
  args_info->int_values_help = gengetopt_args_info_help[11] ;
168
168
  args_info->int_values_m_help = gengetopt_args_info_help[12] ;
169
 
  args_info->int_values_m_min = -1;
170
 
  args_info->int_values_m_max = -1;
 
169
  args_info->int_values_m_min = 0;
 
170
  args_info->int_values_m_max = 0;
171
171
  args_info->int_values_def_help = gengetopt_args_info_help[13] ;
172
172
  args_info->values_first_enums_help = gengetopt_args_info_help[14] ;
173
173
  args_info->values_second_enums_help = gengetopt_args_info_help[15] ;
174
174
  args_info->values_multiple_enums_help = gengetopt_args_info_help[16] ;
175
 
  args_info->values_multiple_enums_min = -1;
176
 
  args_info->values_multiple_enums_max = -1;
 
175
  args_info->values_multiple_enums_min = 0;
 
176
  args_info->values_multiple_enums_max = 0;
177
177
  args_info->file_save_help = gengetopt_args_info_help[17] ;
178
178
  
179
179
}
196
196
  printf("\n");
197
197
 
198
198
  if (strlen(gengetopt_args_info_description) > 0)
199
 
    printf("%s\n", gengetopt_args_info_description);
 
199
    printf("%s\n\n", gengetopt_args_info_description);
200
200
}
201
201
 
202
202
void
276
276
  new_node->orig = NULL;
277
277
}
278
278
 
 
279
/**
 
280
 * The passed arg parameter is NOT set to 0 from this function
 
281
 */
279
282
static void
280
 
free_multiple_field(unsigned int len, void **arg, char ***orig)
 
283
free_multiple_field(unsigned int len, void *arg, char ***orig)
281
284
{
282
285
  unsigned int i;
283
 
  if (*arg) {
 
286
  if (arg) {
284
287
    for (i = 0; i < len; ++i)
285
288
      {
286
289
        free_string_field(&((*orig)[i]));
287
290
      }
288
291
 
289
 
    free (*arg);
290
 
    *arg = 0;
 
292
    free (arg);
291
293
    free (*orig);
292
294
    *orig = 0;
293
295
  }
330
332
  free_string_field (&(args_info->string_values_group_arg));
331
333
  free_string_field (&(args_info->string_values_group_orig));
332
334
  free_string_field (&(args_info->int_values_orig));
333
 
  free_multiple_field (args_info->int_values_m_given, (void **)&(args_info->int_values_m_arg), &(args_info->int_values_m_orig));
 
335
  free_multiple_field (args_info->int_values_m_given, (void *)(args_info->int_values_m_arg), &(args_info->int_values_m_orig));
 
336
  args_info->int_values_m_arg = 0;
334
337
  free_string_field (&(args_info->int_values_def_orig));
335
338
  free_string_field (&(args_info->values_first_enums_orig));
336
339
  free_string_field (&(args_info->values_second_enums_orig));
337
 
  free_multiple_field (args_info->values_multiple_enums_given, (void **)&(args_info->values_multiple_enums_arg), &(args_info->values_multiple_enums_orig));
 
340
  free_multiple_field (args_info->values_multiple_enums_given, (void *)(args_info->values_multiple_enums_arg), &(args_info->values_multiple_enums_orig));
 
341
  args_info->values_multiple_enums_arg = 0;
338
342
  free_string_field (&(args_info->file_save_arg));
339
343
  free_string_field (&(args_info->file_save_orig));
340
344
  
501
505
get_multiple_arg_token(const char *arg)
502
506
{
503
507
  char *tok, *ret;
504
 
  size_t len, num_of_escape;
505
 
  int i, j;
 
508
  size_t len, num_of_escape, i, j;
506
509
 
507
510
  if (!arg)
508
511
    return NULL;
578
581
}
579
582
 
580
583
static int
581
 
check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc);
 
584
check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc);
582
585
 
583
586
int
584
 
check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc)
 
587
check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc)
585
588
{
586
589
  int error = 0;
587
590
 
588
 
  if (option_given && ! (min < 0 && max < 0))
 
591
  if (option_given && (min > 0 || max > 0))
589
592
    {
590
 
      if (min >= 0 && max >= 0)
 
593
      if (min > 0 && max > 0)
591
594
        {
592
595
          if (min == max)
593
596
            {
608
611
              error = 1;
609
612
            }
610
613
        }
611
 
      else if (min >= 0)
 
614
      else if (min > 0)
612
615
        {
613
616
          /* at least check */
614
617
          if (option_given < min)
618
621
              error = 1;
619
622
            }
620
623
        }
621
 
      else if (max >= 0)
 
624
      else if (max > 0)
622
625
        {
623
626
          /* at most check */
624
627
          if (option_given > max)
1272
1275
 
1273
1276
  if (args_info->group1_group_counter > 1)
1274
1277
    {
1275
 
      fprintf (stderr, "%s: %d options of group group1 were given. At most one is required.%s\n", argv[0], args_info->group1_group_counter, (additional_error ? additional_error : ""));
 
1278
      fprintf (stderr, "%s: %d options of group group1 were given. At most one is required%s.\n", argv[0], args_info->group1_group_counter, (additional_error ? additional_error : ""));
1276
1279
      error = 1;
1277
1280
    }
1278
1281