ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/dynamicProps/DynamicPropsCmd.c
(Generate patch)

Comparing trunk/OOPSE-4/src/applications/dynamicProps/DynamicPropsCmd.c (file contents):
Revision 2671 by tim, Fri Mar 24 17:29:07 2006 UTC vs.
Revision 3084 by chuckv, Thu Dec 14 19:38:56 2006 UTC

# Line 1 | Line 1
1   /*
2 <  File autogenerated by gengetopt version 2.11
2 >  File autogenerated by gengetopt version 2.15
3    generated with the following command:
4 <  /home/maul/gezelter/tim/program/gengetopt-2.11/src/gengetopt -F DynamicPropsCmd
4 >  gengetopt -i DynamicProps.ggo --file-name=DynamicPropsCmd
5  
6    The developers of gengetopt consider the fixed text that goes in all
7    gengetopt output files to be in the public domain:
8    we make no copyright claims on it.
9   */
10  
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15
11   /* If we use autoconf.  */
12   #ifdef HAVE_CONFIG_H
13   #include "config.h"
14   #endif
15  
16 + #include <stdio.h>
17 + #include <stdlib.h>
18 + #include <string.h>
19 +
20   #include "getopt.h"
21  
22   #include "DynamicPropsCmd.h"
23  
24 + static
25 + void clear_given (struct gengetopt_args_info *args_info);
26 + static
27 + void clear_args (struct gengetopt_args_info *args_info);
28 +
29 + static int
30 + cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error);
31 +
32 + static int
33 + cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
34 +
35 + static char *
36 + gengetopt_strdup (const char *s);
37 +
38 + static
39 + void clear_given (struct gengetopt_args_info *args_info)
40 + {
41 +  args_info->help_given = 0 ;
42 +  args_info->version_given = 0 ;
43 +  args_info->input_given = 0 ;
44 +  args_info->output_given = 0 ;
45 +  args_info->sele1_given = 0 ;
46 +  args_info->sele2_given = 0 ;
47 +  args_info->order_given = 0 ;
48 +  args_info->rcorr_given = 0 ;
49 +  args_info->vcorr_given = 0 ;
50 +  args_info->dcorr_given = 0 ;
51 +  args_info->lcorr_given = 0 ;
52 +  args_info->r_rcorr_given = 0 ;
53 +  args_info->dynamicProps_group_counter = 0 ;
54 + }
55 +
56 + static
57 + void clear_args (struct gengetopt_args_info *args_info)
58 + {
59 +  args_info->input_arg = NULL;
60 +  args_info->input_orig = NULL;
61 +  args_info->output_arg = NULL;
62 +  args_info->output_orig = NULL;
63 +  args_info->sele1_arg = NULL;
64 +  args_info->sele1_orig = NULL;
65 +  args_info->sele2_arg = NULL;
66 +  args_info->sele2_orig = NULL;
67 +  args_info->order_orig = NULL;
68 +  
69 + }
70 +
71   void
72   cmdline_parser_print_version (void)
73   {
# Line 32 | Line 78 | cmdline_parser_print_help (void)
78   cmdline_parser_print_help (void)
79   {
80    cmdline_parser_print_version ();
81 <  printf("\n"
82 <  "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE);
83 <  printf("\n");
84 <  printf("  -h, --help                    Print help and exit\n");
85 <  printf("  -V, --version                 Print version and exit\n");
86 <  printf("  -i, --input=filename          input dump file\n");
87 <  printf("  -o, --output=filename         output file name\n");
88 <  printf("      --sele1=selection script  select first stuntdouble set\n");
89 <  printf("      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)\n");
90 <  printf("      --order=INT               Lengendre Polynomial Order\n");
91 <  printf("\n");
92 <  printf(" Group: dynamicProps  an option of this group is required\n");
93 <  printf("  -r, --rcorr                   rmsd\n");
94 <  printf("  -v, --vcorr                   velocity correlation function\n");
95 <  printf("  -d, --dcorr                   dipole correlation function\n");
50 <  printf("  -l, --lcorr                   Lengendre correlation function\n");
81 >  printf("\nUsage: DynamicProps [OPTIONS]...\n\n");
82 >  printf("%s\n","  -h, --help                    Print help and exit");
83 >  printf("%s\n","  -V, --version                 Print version and exit");
84 >  printf("%s\n","  -i, --input=filename          input dump file");
85 >  printf("%s\n","  -o, --output=filename         output file name");
86 >  printf("%s\n","      --sele1=selection script  select first stuntdouble set");
87 >  printf("%s\n","      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)");
88 >  printf("%s\n","      --order=INT               Lengendre Polynomial Order");
89 >  printf("%s\n","\n Group: dynamicProps\n   an option of this group is required");
90 >  printf("%s\n","  -r, --rcorr                   rmsd");
91 >  printf("%s\n","  -v, --vcorr                   velocity correlation function");
92 >  printf("%s\n","  -d, --dcorr                   dipole correlation function");
93 >  printf("%s\n","  -l, --lcorr                   Lengendre correlation function");
94 >  printf("%s\n","      --r_rcorr                 Radial rmsd");
95 >  
96   }
97  
98 + void
99 + cmdline_parser_init (struct gengetopt_args_info *args_info)
100 + {
101 +  clear_given (args_info);
102 +  clear_args (args_info);
103 + }
104  
105 < static char *gengetopt_strdup (const char *s);
105 > static void
106 > cmdline_parser_release (struct gengetopt_args_info *args_info)
107 > {
108 >  
109 >  if (args_info->input_arg)
110 >    {
111 >      free (args_info->input_arg); /* free previous argument */
112 >      args_info->input_arg = 0;
113 >    }
114 >  if (args_info->input_orig)
115 >    {
116 >      free (args_info->input_orig); /* free previous argument */
117 >      args_info->input_orig = 0;
118 >    }
119 >  if (args_info->output_arg)
120 >    {
121 >      free (args_info->output_arg); /* free previous argument */
122 >      args_info->output_arg = 0;
123 >    }
124 >  if (args_info->output_orig)
125 >    {
126 >      free (args_info->output_orig); /* free previous argument */
127 >      args_info->output_orig = 0;
128 >    }
129 >  if (args_info->sele1_arg)
130 >    {
131 >      free (args_info->sele1_arg); /* free previous argument */
132 >      args_info->sele1_arg = 0;
133 >    }
134 >  if (args_info->sele1_orig)
135 >    {
136 >      free (args_info->sele1_orig); /* free previous argument */
137 >      args_info->sele1_orig = 0;
138 >    }
139 >  if (args_info->sele2_arg)
140 >    {
141 >      free (args_info->sele2_arg); /* free previous argument */
142 >      args_info->sele2_arg = 0;
143 >    }
144 >  if (args_info->sele2_orig)
145 >    {
146 >      free (args_info->sele2_orig); /* free previous argument */
147 >      args_info->sele2_orig = 0;
148 >    }
149 >  if (args_info->order_orig)
150 >    {
151 >      free (args_info->order_orig); /* free previous argument */
152 >      args_info->order_orig = 0;
153 >    }
154 >  
155 >  clear_given (args_info);
156 > }
157  
158 + int
159 + cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
160 + {
161 +  FILE *outfile;
162 +  int i = 0;
163 +
164 +  outfile = fopen(filename, "w");
165 +
166 +  if (!outfile)
167 +    {
168 +      fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
169 +      return EXIT_FAILURE;
170 +    }
171 +
172 +  if (args_info->help_given) {
173 +    fprintf(outfile, "%s\n", "help");
174 +  }
175 +  if (args_info->version_given) {
176 +    fprintf(outfile, "%s\n", "version");
177 +  }
178 +  if (args_info->input_given) {
179 +    if (args_info->input_orig) {
180 +      fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig);
181 +    } else {
182 +      fprintf(outfile, "%s\n", "input");
183 +    }
184 +  }
185 +  if (args_info->output_given) {
186 +    if (args_info->output_orig) {
187 +      fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig);
188 +    } else {
189 +      fprintf(outfile, "%s\n", "output");
190 +    }
191 +  }
192 +  if (args_info->sele1_given) {
193 +    if (args_info->sele1_orig) {
194 +      fprintf(outfile, "%s=\"%s\"\n", "sele1", args_info->sele1_orig);
195 +    } else {
196 +      fprintf(outfile, "%s\n", "sele1");
197 +    }
198 +  }
199 +  if (args_info->sele2_given) {
200 +    if (args_info->sele2_orig) {
201 +      fprintf(outfile, "%s=\"%s\"\n", "sele2", args_info->sele2_orig);
202 +    } else {
203 +      fprintf(outfile, "%s\n", "sele2");
204 +    }
205 +  }
206 +  if (args_info->order_given) {
207 +    if (args_info->order_orig) {
208 +      fprintf(outfile, "%s=\"%s\"\n", "order", args_info->order_orig);
209 +    } else {
210 +      fprintf(outfile, "%s\n", "order");
211 +    }
212 +  }
213 +  if (args_info->rcorr_given) {
214 +    fprintf(outfile, "%s\n", "rcorr");
215 +  }
216 +  if (args_info->vcorr_given) {
217 +    fprintf(outfile, "%s\n", "vcorr");
218 +  }
219 +  if (args_info->dcorr_given) {
220 +    fprintf(outfile, "%s\n", "dcorr");
221 +  }
222 +  if (args_info->lcorr_given) {
223 +    fprintf(outfile, "%s\n", "lcorr");
224 +  }
225 +  if (args_info->r_rcorr_given) {
226 +    fprintf(outfile, "%s\n", "r_rcorr");
227 +  }
228 +  
229 +  fclose (outfile);
230 +
231 +  i = EXIT_SUCCESS;
232 +  return i;
233 + }
234 +
235 + void
236 + cmdline_parser_free (struct gengetopt_args_info *args_info)
237 + {
238 +  cmdline_parser_release (args_info);
239 + }
240 +
241 +
242   /* gengetopt_strdup() */
243   /* strdup.c replacement of strdup, which is not standard */
244   char *
245   gengetopt_strdup (const char *s)
246   {
247 <  char *result = (char*)malloc(strlen(s) + 1);
247 >  char *result = NULL;
248 >  if (!s)
249 >    return result;
250 >
251 >  result = (char*)malloc(strlen(s) + 1);
252    if (result == (char*)0)
253      return (char*)0;
254    strcpy(result, s);
255    return result;
256   }
257  
258 < int
259 < cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
258 > static void
259 > reset_group_dynamicProps(struct gengetopt_args_info *args_info);
260 >
261 > static void
262 > reset_group_dynamicProps(struct gengetopt_args_info *args_info)
263   {
264 <  int c;        /* Character of the parsed option.  */
265 <  int missing_required_options = 0;
73 <  int dynamicProps_group_counter = 0;
264 >  if (! args_info->dynamicProps_group_counter)
265 >    return;
266    
75
76  args_info->help_given = 0 ;
77  args_info->version_given = 0 ;
78  args_info->input_given = 0 ;
79  args_info->output_given = 0 ;
80  args_info->sele1_given = 0 ;
81  args_info->sele2_given = 0 ;
82  args_info->order_given = 0 ;
267    args_info->rcorr_given = 0 ;
268    args_info->vcorr_given = 0 ;
269    args_info->dcorr_given = 0 ;
270    args_info->lcorr_given = 0 ;
271 < #define clear_args() { \
272 <  args_info->input_arg = NULL; \
273 <  args_info->output_arg = NULL; \
90 <  args_info->sele1_arg = NULL; \
91 <  args_info->sele2_arg = NULL; \
271 >  args_info->r_rcorr_given = 0 ;
272 >
273 >  args_info->dynamicProps_group_counter = 0;
274   }
275  
276 <  clear_args();
276 > int
277 > cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
278 > {
279 >  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
280 > }
281 >
282 > int
283 > cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
284 > {
285 >  int result;
286 >
287 >  result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL);
288 >
289 >  if (result == EXIT_FAILURE)
290 >    {
291 >      cmdline_parser_free (args_info);
292 >      exit (EXIT_FAILURE);
293 >    }
294 >  
295 >  return result;
296 > }
297 >
298 > int
299 > cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
300 > {
301 >  int result = EXIT_SUCCESS;
302  
303 +  if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
304 +    result = EXIT_FAILURE;
305 +
306 +  if (result == EXIT_FAILURE)
307 +    {
308 +      cmdline_parser_free (args_info);
309 +      exit (EXIT_FAILURE);
310 +    }
311 +  
312 +  return result;
313 + }
314 +
315 + int
316 + cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
317 + {
318 +  int error = 0;
319 +
320 +  if (! args_info->input_given)
321 +    {
322 +      fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
323 +      error = 1;
324 +    }
325 +  if (args_info->dynamicProps_group_counter == 0)
326 +    {
327 +      fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required.%s\n", prog_name, args_info->dynamicProps_group_counter, (additional_error ? additional_error : ""));
328 +      error = 1;
329 +    }
330 +  
331 +
332 +  return error;
333 + }
334 +
335 + int
336 + cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error)
337 + {
338 +  int c;        /* Character of the parsed option.  */
339 +
340 +  int error = 0;
341 +  struct gengetopt_args_info local_args_info;
342 +
343 +  if (initialize)
344 +    cmdline_parser_init (args_info);
345 +
346 +  cmdline_parser_init (&local_args_info);
347 +
348    optarg = 0;
349    optind = 1;
350    opterr = 1;
# Line 115 | Line 367 | cmdline_parser (int argc, char * const *argv, struct g
367          { "vcorr",      0, NULL, 'v' },
368          { "dcorr",      0, NULL, 'd' },
369          { "lcorr",      0, NULL, 'l' },
370 +        { "r_rcorr",    0, NULL, 0 },
371          { NULL, 0, NULL, 0 }
372        };
373  
# Line 126 | Line 379 | cmdline_parser (int argc, char * const *argv, struct g
379        switch (c)
380          {
381          case 'h':       /* Print help and exit.  */
129          clear_args ();
382            cmdline_parser_print_help ();
383 +          cmdline_parser_free (&local_args_info);
384            exit (EXIT_SUCCESS);
385  
386          case 'V':       /* Print version and exit.  */
134          clear_args ();
387            cmdline_parser_print_version ();
388 +          cmdline_parser_free (&local_args_info);
389            exit (EXIT_SUCCESS);
390  
391          case 'i':       /* input dump file.  */
392 <          if (args_info->input_given)
392 >          if (local_args_info.input_given)
393              {
394 <              fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
395 <              clear_args ();
143 <              exit (EXIT_FAILURE);
394 >              fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
395 >              goto failure;
396              }
397 +          if (args_info->input_given && ! override)
398 +            continue;
399 +          local_args_info.input_given = 1;
400            args_info->input_given = 1;
401 +          if (args_info->input_arg)
402 +            free (args_info->input_arg); /* free previous string */
403            args_info->input_arg = gengetopt_strdup (optarg);
404 +          if (args_info->input_orig)
405 +            free (args_info->input_orig); /* free previous string */
406 +          args_info->input_orig = gengetopt_strdup (optarg);
407            break;
408  
409          case 'o':       /* output file name.  */
410 <          if (args_info->output_given)
410 >          if (local_args_info.output_given)
411              {
412 <              fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
413 <              clear_args ();
154 <              exit (EXIT_FAILURE);
412 >              fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
413 >              goto failure;
414              }
415 +          if (args_info->output_given && ! override)
416 +            continue;
417 +          local_args_info.output_given = 1;
418            args_info->output_given = 1;
419 +          if (args_info->output_arg)
420 +            free (args_info->output_arg); /* free previous string */
421            args_info->output_arg = gengetopt_strdup (optarg);
422 +          if (args_info->output_orig)
423 +            free (args_info->output_orig); /* free previous string */
424 +          args_info->output_orig = gengetopt_strdup (optarg);
425            break;
426  
427          case 'r':       /* rmsd.  */
428 <          if (args_info->rcorr_given)
428 >          if (local_args_info.rcorr_given)
429              {
430 <              fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE);
431 <              clear_args ();
165 <              exit (EXIT_FAILURE);
430 >              fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
431 >              goto failure;
432              }
433 +          if (args_info->rcorr_given && ! override)
434 +            continue;
435 +          local_args_info.rcorr_given = 1;
436            args_info->rcorr_given = 1;
437 <          dynamicProps_group_counter += 1;
438 <        break;
437 >          if (args_info->dynamicProps_group_counter && override)
438 >            reset_group_dynamicProps (args_info);
439 >          args_info->dynamicProps_group_counter += 1;
440 >          break;
441  
442          case 'v':       /* velocity correlation function.  */
443 <          if (args_info->vcorr_given)
443 >          if (local_args_info.vcorr_given)
444              {
445 <              fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once\n", CMDLINE_PARSER_PACKAGE);
446 <              clear_args ();
176 <              exit (EXIT_FAILURE);
445 >              fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
446 >              goto failure;
447              }
448 +          if (args_info->vcorr_given && ! override)
449 +            continue;
450 +          local_args_info.vcorr_given = 1;
451            args_info->vcorr_given = 1;
452 <          dynamicProps_group_counter += 1;
453 <        break;
452 >          if (args_info->dynamicProps_group_counter && override)
453 >            reset_group_dynamicProps (args_info);
454 >          args_info->dynamicProps_group_counter += 1;
455 >          break;
456  
457          case 'd':       /* dipole correlation function.  */
458 <          if (args_info->dcorr_given)
458 >          if (local_args_info.dcorr_given)
459              {
460 <              fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE);
461 <              clear_args ();
187 <              exit (EXIT_FAILURE);
460 >              fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
461 >              goto failure;
462              }
463 +          if (args_info->dcorr_given && ! override)
464 +            continue;
465 +          local_args_info.dcorr_given = 1;
466            args_info->dcorr_given = 1;
467 <          dynamicProps_group_counter += 1;
468 <        break;
467 >          if (args_info->dynamicProps_group_counter && override)
468 >            reset_group_dynamicProps (args_info);
469 >          args_info->dynamicProps_group_counter += 1;
470 >          break;
471  
472          case 'l':       /* Lengendre correlation function.  */
473 <          if (args_info->lcorr_given)
473 >          if (local_args_info.lcorr_given)
474              {
475 <              fprintf (stderr, "%s: `--lcorr' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE);
476 <              clear_args ();
198 <              exit (EXIT_FAILURE);
475 >              fprintf (stderr, "%s: `--lcorr' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
476 >              goto failure;
477              }
478 +          if (args_info->lcorr_given && ! override)
479 +            continue;
480 +          local_args_info.lcorr_given = 1;
481            args_info->lcorr_given = 1;
482 <          dynamicProps_group_counter += 1;
483 <        break;
482 >          if (args_info->dynamicProps_group_counter && override)
483 >            reset_group_dynamicProps (args_info);
484 >          args_info->dynamicProps_group_counter += 1;
485 >          break;
486  
487  
488          case 0: /* Long option with no short option */
489            /* select first stuntdouble set.  */
490            if (strcmp (long_options[option_index].name, "sele1") == 0)
491            {
492 <            if (args_info->sele1_given)
492 >            if (local_args_info.sele1_given)
493                {
494 <                fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE);
495 <                clear_args ();
213 <                exit (EXIT_FAILURE);
494 >                fprintf (stderr, "%s: `--sele1' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
495 >                goto failure;
496                }
497 +            if (args_info->sele1_given && ! override)
498 +              continue;
499 +            local_args_info.sele1_given = 1;
500              args_info->sele1_given = 1;
501 +            if (args_info->sele1_arg)
502 +              free (args_info->sele1_arg); /* free previous string */
503              args_info->sele1_arg = gengetopt_strdup (optarg);
504 <            break;
504 >            if (args_info->sele1_orig)
505 >              free (args_info->sele1_orig); /* free previous string */
506 >            args_info->sele1_orig = gengetopt_strdup (optarg);
507            }
219          
508            /* select second stuntdouble set (if sele2 is not set, use script from sele1).  */
509            else if (strcmp (long_options[option_index].name, "sele2") == 0)
510            {
511 <            if (args_info->sele2_given)
511 >            if (local_args_info.sele2_given)
512                {
513 <                fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE);
514 <                clear_args ();
227 <                exit (EXIT_FAILURE);
513 >                fprintf (stderr, "%s: `--sele2' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
514 >                goto failure;
515                }
516 +            if (args_info->sele2_given && ! override)
517 +              continue;
518 +            local_args_info.sele2_given = 1;
519              args_info->sele2_given = 1;
520 +            if (args_info->sele2_arg)
521 +              free (args_info->sele2_arg); /* free previous string */
522              args_info->sele2_arg = gengetopt_strdup (optarg);
523 <            break;
523 >            if (args_info->sele2_orig)
524 >              free (args_info->sele2_orig); /* free previous string */
525 >            args_info->sele2_orig = gengetopt_strdup (optarg);
526            }
233          
527            /* Lengendre Polynomial Order.  */
528            else if (strcmp (long_options[option_index].name, "order") == 0)
529            {
530 <            if (args_info->order_given)
530 >            if (local_args_info.order_given)
531                {
532 <                fprintf (stderr, "%s: `--order' option given more than once\n", CMDLINE_PARSER_PACKAGE);
533 <                clear_args ();
241 <                exit (EXIT_FAILURE);
532 >                fprintf (stderr, "%s: `--order' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
533 >                goto failure;
534                }
535 +            if (args_info->order_given && ! override)
536 +              continue;
537 +            local_args_info.order_given = 1;
538              args_info->order_given = 1;
539 <            args_info->order_arg = strtol (optarg,&stop_char,0);
539 >            args_info->order_arg = strtol (optarg, &stop_char, 0);
540 >            if (!(stop_char && *stop_char == '\0')) {
541 >              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
542 >              goto failure;
543 >            }
544 >            if (args_info->order_orig)
545 >              free (args_info->order_orig); /* free previous string */
546 >            args_info->order_orig = gengetopt_strdup (optarg);
547 >          }
548 >          /* Radial rmsd.  */
549 >          else if (strcmp (long_options[option_index].name, "r_rcorr") == 0)
550 >          {
551 >            if (local_args_info.r_rcorr_given)
552 >              {
553 >                fprintf (stderr, "%s: `--r_rcorr' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
554 >                goto failure;
555 >              }
556 >            if (args_info->r_rcorr_given && ! override)
557 >              continue;
558 >            local_args_info.r_rcorr_given = 1;
559 >            args_info->r_rcorr_given = 1;
560 >            if (args_info->dynamicProps_group_counter && override)
561 >              reset_group_dynamicProps (args_info);
562 >            args_info->dynamicProps_group_counter += 1;
563              break;
564            }
565            
566 <
566 >          break;
567          case '?':       /* Invalid option.  */
568            /* `getopt_long' already printed an error message.  */
569 <          exit (EXIT_FAILURE);
569 >          goto failure;
570  
571          default:        /* bug: option not considered.  */
572 <          fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
572 >          fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
573            abort ();
574          } /* switch */
575      } /* while */
576  
577 <  if ( dynamicProps_group_counter != 1)
577 >  if (args_info->dynamicProps_group_counter > 1)
578      {
579 <      fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, dynamicProps_group_counter);
580 <      missing_required_options = 1;
579 >      fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required.%s\n", argv[0], args_info->dynamicProps_group_counter, (additional_error ? additional_error : ""));
580 >      error = 1;
581      }
582    
583  
584 <  if (! args_info->input_given)
584 >
585 >  if (check_required)
586      {
587 <      fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE);
269 <      missing_required_options = 1;
587 >      error += cmdline_parser_required2 (args_info, argv[0], additional_error);
588      }
271  if ( missing_required_options )
272    exit (EXIT_FAILURE);
589  
590 +  cmdline_parser_release (&local_args_info);
591 +
592 +  if ( error )
593 +    return (EXIT_FAILURE);
594 +
595    return 0;
596 +
597 + failure:
598 +  
599 +  cmdline_parser_release (&local_args_info);
600 +  return (EXIT_FAILURE);
601   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines