[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [help-gengetopt] gengetopt C example
From: |
Tong Sun |
Subject: |
Re: [help-gengetopt] gengetopt C example |
Date: |
Tue, 22 Oct 2013 15:31:34 -0700 (PDT) |
Further investigation:
> Here are the example files distributed from my Debian/Ubuntu package
>
> /usr/share/doc/gengetopt/examples
> /usr/share/doc/gengetopt/examples/cmdline2.c.gz
> /usr/share/doc/gengetopt/examples/cmdline2.h.gz
Having expanded the distributed cmdline2.h/c, then compare them with my
generated ones, I get:
$ diff -wU 1 /usr/share/doc/gengetopt/examples/cmdline2.h cmdline2.h
-- same
$ diff -wU 1 /usr/share/doc/gengetopt/examples/cmdline2.c cmdline2.c
--- /usr/share/doc/gengetopt/examples/cmdline2.c 2013-05-09
13:33:53.000000000 -0400
+++ cmdline2.c 2013-10-22 17:33:42.380298444 -0400
@@ -3,3 +3,3 @@
generated with the following command:
- ../src/gengetopt --input=./sample2.ggo --func-name=my_cmdline_parser
--file-name=cmdline2 --unamed-opts --no-handle-help --no-handle-version
+ gengetopt --input=sample2.ggo --func-name=my_cmdline_parser
--file-name=cmdline2 --unamed-opts
@@ -664,29 +664,11 @@
case 'h': /* Print help and exit. */
-
-
- if (update_arg( 0 ,
- 0 , &(args_info->help_given),
- &(local_args_info.help_given), optarg, 0, 0, ARG_NO,
- check_ambiguity, override, 0, 0,
- "help", 'h',
- additional_error))
- goto failure;
+ my_cmdline_parser_print_help ();
my_cmdline_parser_free (&local_args_info);
- return 0;
+ exit (EXIT_SUCCESS);
- break;
case 'V': /* Print version and exit. */
-
-
- if (update_arg( 0 ,
- 0 , &(args_info->version_given),
- &(local_args_info.version_given), optarg, 0, 0, ARG_NO,
- check_ambiguity, override, 0, 0,
- "version", 'V',
- additional_error))
- goto failure;
+ my_cmdline_parser_print_version ();
my_cmdline_parser_free (&local_args_info);
- return 0;
+ exit (EXIT_SUCCESS);
- break;
case 's': /* A string option. */
@@ -823,20 +805,8 @@
case 0: /* Long option with no short option */
- /* Print help, including hidden options, and exit. */
- if (strcmp (long_options[option_index].name, "full-help") == 0)
- {
-
-
- if (update_arg( 0 ,
- 0 , &(args_info->full_help_given),
- &(local_args_info.full_help_given), optarg, 0, 0, ARG_NO,
- check_ambiguity, override, 0, 0,
- "full-help", '-',
- additional_error))
- goto failure;
+ if (strcmp (long_options[option_index].name, "full-help") == 0) {
+ my_cmdline_parser_print_full_help ();
my_cmdline_parser_free (&local_args_info);
- return 0;
-
+ exit (EXIT_SUCCESS);
}
- break;
case '?': /* Invalid option. */
Looks to me that the gengetopt is behaving as always, since the generated files
are (almost) the same.
So the error is caused by the new gcc?
Any easy fix?
PS.
$ apt-cache policy gcc
gcc:
Installed: 4:4.8.0-0ubuntu13
Candidate: 4:4.8.1-2ubuntu3
Version table:
4:4.8.1-2ubuntu3 0
500 http://us.archive.ubuntu.com/ubuntu/ saucy/main i386 Packages
*** 4:4.8.0-0ubuntu13 0
100 /var/lib/dpkg/status
Thanks