help-gengetopt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[help-gengetopt] non hidden option strings are doubled


From: Gyozo, PAPP (VBuster)
Subject: [help-gengetopt] non hidden option strings are doubled
Date: Wed, 17 May 2006 17:09:34 +0200

Hi there!

I'm using gengetopt-2.17rc3? and have found an interesting thing.
Help strings are doubled for public (not hidden) options into two dedicated 
const array: *_options_help and *_options_full_help and *_print_help() and 
*_print_full_help() now iterates on these arrays, respectively.

It would be easy to define a struct including the help string and a hidden flag 
and that's way only one array would suffice our needs.
My approach would be:

struct options_desc {
        char *help
        ,int  hidden
        /* open for further extension */
};

void
getoptions_print_help (void)
{
        getoptions_print_help_internal ( 0 );
}

void
getoptions_print_full_help (void)
{
        getoptions_print_help_internal ( 1 );
}

void
getoptions_print_help_internal (int all)
{
  int i = 0;
  getoptions_print_version ();

  if (strlen(cmdline_options_purpose) > 0)
    printf("\n%s\n", cmdline_options_purpose);

  printf("\n%s\n\n", cmdline_options_usage);

  for ( i = 0; cmdline_options[i].help; i++ )
    {
      if ( all || !cmdline_options[i].hidden )
        printf("%s\n", cmdline_options[i].help);
    }
}


--
Papp, Győző 
VirusBuster Kft




reply via email to

[Prev in Thread] Current Thread [Next in Thread]