2004-09-12  Ulrich Drepper  <drepper@redhat.com>

	* nss/getent.c: Don't preconstruct help message.  Do it only when
	needed.

	* locale/programs/locale.c: Simplify help message printing.
This commit is contained in:
Ulrich Drepper 2004-09-13 05:30:21 +00:00
parent 9d9ab48728
commit f69425fa29
2 changed files with 59 additions and 36 deletions

View File

@ -1,3 +1,10 @@
2004-09-12 Ulrich Drepper <drepper@redhat.com>
* nss/getent.c: Don't preconstruct help message. Do it only when
needed.
* locale/programs/locale.c: Simplify help message printing.
2004-09-12 Roland McGrath <roland@frob.com>
* sysdeps/mach/hurd/i386/init-first.c (init1) [! SHARED]: Add decls

View File

@ -57,13 +57,21 @@ static const struct argp_option args_options[] =
{ NULL, 0, NULL, 0, NULL },
};
/* Short description of program. */
static const char doc[] = N_("Get entries from administrative database.\v\
For bug reporting instructions, please see:\n\
<http://www.gnu.org/software/libc/bugs.html>.\n");
/* Prototype for option handler. */
static error_t parse_option (int key, char *arg, struct argp_state *state);
/* Function to print some extra text in the help message. */
static char *more_help (int key, const char *text, void *input);
/* Data structure to communicate with argp functions. */
static struct argp argp =
{
args_options, parse_option, args_doc, NULL,
args_options, parse_option, args_doc, doc, NULL, more_help
};
/* Print the version information. */
@ -771,38 +779,42 @@ parse_option (int key, char *arg, struct argp_state *state)
return 0;
}
/* build doc */
static void
build_doc (void)
static char *
more_help (int key, const char *text, void *input)
{
int i, j, len;
char *short_doc, *long_doc, *doc, *p;
int len;
char *long_doc, *doc, *p;
short_doc = _("getent - get entries from administrative database.");
switch (key)
{
case ARGP_KEY_HELP_EXTRA:
/* We print some extra information. */
#if 0
return xstrdup (gettext ("\
For bug reporting instructions, please see:\n\
<http://www.gnu.org/software/libc/bugs.html>.\n"));
#endif
long_doc = _("Supported databases:");
len = strlen (short_doc) + strlen (long_doc) + 3;
len = strlen (long_doc) + 2;
for (i = 0; databases[i].name; ++i)
for (int i = 0; databases[i].name; ++i)
len += strlen (databases[i].name) + 1;
doc = (char *) malloc (len);
if (doc == NULL)
doc = short_doc;
else
if (doc != NULL)
{
p = stpcpy (doc, short_doc);
*p++ = '\v';
p = stpcpy (p, long_doc);
p = stpcpy (doc, long_doc);
*p++ = '\n';
for (i = 0, j = 0; databases[i].name; ++i)
for (int i = 0, col = 0; databases[i].name; ++i)
{
len = strlen (databases[i].name);
if (i != 0)
{
if (j + len > 72)
if (col + len > 72)
{
j = 0;
col = 0;
*p++ = '\n';
}
else
@ -810,13 +822,20 @@ build_doc (void)
}
p = mempcpy (p, databases[i].name, len);
j += len + 1;
}
col += len + 1;
}
argp.doc = doc;
return doc;
}
break;
default:
break;
}
return (char *) text;
}
/* the main function */
int
main (int argc, char *argv[])
@ -828,9 +847,6 @@ main (int argc, char *argv[])
/* Set the text message domain. */
textdomain (PACKAGE);
/* Build argp.doc. */
build_doc ();
/* Parse and process arguments. */
argp_parse (&argp, argc, argv, 0, &remaining, NULL);