Re: gengetopt C example
Tong Sun <[email protected]> Tue, 22 Oct 2013 15:31:34 -0700 (PDT)
| Newsgroups | gmane.comp.gnu.gengetopt.general |
|---|---|
| Message-ID | <[email protected]> |
Further investigation:
> Here are the example files distributed from my Debian/Ubuntu package
>=A0
> /usr/share/doc/gengetopt/examples
> /usr/share/doc/gengetopt/examples/cmdline2.c.gz
> /usr/share/doc/gengetopt/examples/cmdline2.h.gz
Having expanded the=A0distributed=A0cmdline2.h/c, then compare them with my=
generated ones, I get:
$ diff -wU 1 /usr/share/doc/gengetopt/examples/cmdline2.h cmdline2.h
=A0 -- same=A0
$ diff -wU 1 /usr/share/doc/gengetopt/examples/cmdline2.c cmdline2.c
--- /usr/share/doc/gengetopt/examples/cmdline2.c =A0 =A0 =A0 =A02013-05-09 =
13:33:53.000000000 -0400
+++ cmdline2.c =A02013-10-22 17:33:42.380298444 -0400
@@ -3,3 +3,3 @@
=A0 =A0generated with the following command:
- =A0../src/gengetopt --input=3D./sample2.ggo --func-name=3Dmy_cmdline_pars=
er --file-name=3Dcmdline2 --unamed-opts --no-handle-help --no-handle-versio=
n=A0
+ =A0gengetopt --input=3Dsample2.ggo --func-name=3Dmy_cmdline_parser --file=
-name=3Dcmdline2 --unamed-opts=A0
=A0
@@ -664,29 +664,11 @@
=A0 =A0 =A0 =A0 =A0case 'h': =A0 =A0 =A0/* Print help and exit. =A0*/
- =A0 =A0 =A0 =A0
- =A0 =A0 =A0 =A0
- =A0 =A0 =A0 =A0 =A0if (update_arg( 0 ,=A0
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 , &(args_info->help_given),
- =A0 =A0 =A0 =A0 =A0 =A0 =A0&(local_args_info.help_given), optarg, 0, 0, A=
RG_NO,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0check_ambiguity, override, 0, 0,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0"help", 'h',
- =A0 =A0 =A0 =A0 =A0 =A0 =A0additional_error))
- =A0 =A0 =A0 =A0 =A0 =A0goto failure;
+ =A0 =A0 =A0 =A0 =A0my_cmdline_parser_print_help ();
=A0 =A0 =A0 =A0 =A0 =A0my_cmdline_parser_free (&local_args_info);
- =A0 =A0 =A0 =A0 =A0return 0;
+ =A0 =A0 =A0 =A0 =A0exit (EXIT_SUCCESS);
=A0 =A0 =A0 =A0 =A0
- =A0 =A0 =A0 =A0 =A0break;
=A0 =A0 =A0 =A0 =A0case 'V': =A0 =A0 =A0/* Print version and exit. =A0*/
- =A0 =A0 =A0 =A0
- =A0 =A0 =A0 =A0
- =A0 =A0 =A0 =A0 =A0if (update_arg( 0 ,=A0
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 , &(args_info->version_given),
- =A0 =A0 =A0 =A0 =A0 =A0 =A0&(local_args_info.version_given), optarg, 0, 0=
, ARG_NO,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0check_ambiguity, override, 0, 0,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0"version", 'V',
- =A0 =A0 =A0 =A0 =A0 =A0 =A0additional_error))
- =A0 =A0 =A0 =A0 =A0 =A0goto failure;
+ =A0 =A0 =A0 =A0 =A0my_cmdline_parser_print_version ();
=A0 =A0 =A0 =A0 =A0 =A0my_cmdline_parser_free (&local_args_info);
- =A0 =A0 =A0 =A0 =A0return 0;
+ =A0 =A0 =A0 =A0 =A0exit (EXIT_SUCCESS);
=A0 =A0 =A0 =A0 =A0
- =A0 =A0 =A0 =A0 =A0break;
=A0 =A0 =A0 =A0 =A0case 's': =A0 =A0 =A0/* A string option. =A0*/
@@ -823,20 +805,8 @@
=A0 =A0 =A0 =A0 =A0case 0: =A0 =A0 =A0 =A0/* Long option with no short opti=
on */
- =A0 =A0 =A0 =A0 =A0/* Print help, including hidden options, and exit. =A0=
*/
- =A0 =A0 =A0 =A0 =A0if (strcmp (long_options[option_index].name, "full-hel=
p") =3D=3D 0)
- =A0 =A0 =A0 =A0 =A0{
- =A0 =A0 =A0 =A0 =A0
- =A0 =A0 =A0 =A0 =A0
- =A0 =A0 =A0 =A0 =A0 =A0if (update_arg( 0 ,=A0
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 , &(args_info->full_help_given),
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&(local_args_info.full_help_given), optarg=
, 0, 0, ARG_NO,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0check_ambiguity, override, 0, 0,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"full-help", '-',
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0additional_error))
- =A0 =A0 =A0 =A0 =A0 =A0 =A0goto failure;
+ =A0 =A0 =A0 =A0 =A0if (strcmp (long_options[option_index].name, "full-hel=
p") =3D=3D 0) {
+ =A0 =A0 =A0 =A0 =A0 =A0my_cmdline_parser_print_full_help ();
=A0 =A0 =A0 =A0 =A0 =A0 =A0my_cmdline_parser_free (&local_args_info);
- =A0 =A0 =A0 =A0 =A0 =A0return 0;
- =A0 =A0 =A0 =A0 =A0
+ =A0 =A0 =A0 =A0 =A0 =A0exit (EXIT_SUCCESS);
=A0 =A0 =A0 =A0 =A0 =A0}
=A0 =A0 =A0 =A0 =A0 =A0
- =A0 =A0 =A0 =A0 =A0break;
=A0 =A0 =A0 =A0 =A0case '?': =A0 =A0 =A0/* Invalid option. =A0*/
Looks to me that the gengetopt is behaving as always, since the generated f=
iles are (almost) the same.=A0
So the error is caused by the new gcc?=A0
Any easy fix?=A0
PS.=A0
$ apt-cache policy gcc
gcc:
=A0 Installed: 4:4.8.0-0ubuntu13
=A0 Candidate: 4:4.8.1-2ubuntu3
=A0 Version table:
=A0 =A0 =A04:4.8.1-2ubuntu3 0
=A0 =A0 =A0 =A0 500 http://us.archive.ubuntu.com/ubuntu/ saucy/main i386 Pa=
ckages
=A0*** 4:4.8.0-0ubuntu13 0
=A0 =A0 =A0 =A0 100 /var/lib/dpkg/status
Thanks