From a334319f6530564d22e775935d9c91663623a1b4 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 22 Dec 2004 20:10:10 +0000 Subject: (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4. --- nss/getent.c | 86 +++++++++++++++++++++++++++--------------------------------- 1 file changed, 38 insertions(+), 48 deletions(-) (limited to 'nss/getent.c') diff --git a/nss/getent.c b/nss/getent.c index 14ec3c4..c0a2732 100644 --- a/nss/getent.c +++ b/nss/getent.c @@ -1,4 +1,4 @@ -/* Copyright (c) 1998-2003, 2004, 2005, 2006 Free Software Foundation, Inc. +/* Copyright (c) 1998-2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1998. @@ -21,23 +21,22 @@ #include #include +#include +#include +#include #include #include -#include #include #include -#include #include -#include -#include #include #include #include +#include +#include +#include #include #include -#include -#include -#include /* Get libc version number. */ #include @@ -84,7 +83,7 @@ print_version (FILE *stream, struct argp_state *state) Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2006"); +"), "2004"); fprintf (stream, gettext ("Written by %s.\n"), "Thorsten Kukuk"); } @@ -280,9 +279,9 @@ hosts_keys (int number, char *key[]) char addr[IN6ADDRSZ]; if (inet_pton (AF_INET6, key[i], &addr) > 0) - host = gethostbyaddr (addr, IN6ADDRSZ, AF_INET6); + host = gethostbyaddr (addr, sizeof (addr), AF_INET6); else if (inet_pton (AF_INET, key[i], &addr) > 0) - host = gethostbyaddr (addr, INADDRSZ, AF_INET); + host = gethostbyaddr (addr, sizeof (addr), AF_INET); else if ((host = gethostbyname2 (key[i], AF_INET6)) == NULL) host = gethostbyname2 (key[i], AF_INET); @@ -411,8 +410,6 @@ netgroup_keys (int number, char *key[]) } } - endnetgrent (); - return result; } @@ -760,27 +757,12 @@ D(shadow) static error_t parse_option (int key, char *arg, struct argp_state *state) { - char *endp; + int i; switch (key) { case 's': - endp = strchr (arg, ':'); - if (endp == NULL) - /* No specific database, change them all. */ - for (int i = 0; databases[i].name != NULL; ++i) - __nss_configure_lookup (databases[i].name, arg); - else - { - int i; - for (i = 0; databases[i].name != NULL; ++i) - if (strncmp (databases[i].name, arg, endp - arg) == 0) - { - __nss_configure_lookup (databases[i].name, endp + 1); - break; - } - if (databases[i].name == NULL) - error (EXIT_FAILURE, 0, gettext ("Unknown database name")); - } + for (i = 0; databases[i].name; ++i) + __nss_configure_lookup (databases[i].name, arg); break; default: @@ -794,20 +776,31 @@ parse_option (int key, char *arg, struct argp_state *state) static char * more_help (int key, const char *text, void *input) { + int len; + char *long_doc, *doc, *p; + switch (key) { - size_t len; - char *doc; - FILE *fp; - case ARGP_KEY_HELP_EXTRA: /* We print some extra information. */ - fp = open_memstream (&doc, &len); - if (fp != NULL) +#if 0 + return xstrdup (gettext ("\ +For bug reporting instructions, please see:\n\ +.\n")); +#endif + long_doc = _("Supported databases:"); + len = strlen (long_doc) + 2; + + for (int i = 0; databases[i].name; ++i) + len += strlen (databases[i].name) + 1; + + doc = (char *) malloc (len); + if (doc != NULL) { - fputs_unlocked (_("Supported databases:\n"), fp); + p = stpcpy (doc, long_doc); + *p++ = '\n'; - for (int i = 0, col = 0; databases[i].name != NULL; ++i) + for (int i = 0, col = 0; databases[i].name; ++i) { len = strlen (databases[i].name); if (i != 0) @@ -815,18 +808,17 @@ more_help (int key, const char *text, void *input) if (col + len > 72) { col = 0; - fputc_unlocked ('\n', fp); + *p++ = '\n'; } else - fputc_unlocked (' ', fp); + *p++ = ' '; } - fputs_unlocked (databases[i].name, fp); + p = mempcpy (p, databases[i].name, len); col += len + 1; } - if (fclose (fp) == 0) - return doc; + return doc; } break; @@ -841,8 +833,7 @@ more_help (int key, const char *text, void *input) int main (int argc, char *argv[]) { - /* Debugging support. */ - mtrace (); + int remaining, i; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); @@ -850,7 +841,6 @@ main (int argc, char *argv[]) textdomain (PACKAGE); /* Parse and process arguments. */ - int remaining; argp_parse (&argp, argc, argv, 0, &remaining, NULL); if ((argc - remaining) < 1) @@ -860,7 +850,7 @@ main (int argc, char *argv[]) return 1; } - for (int i = 0; databases[i].name; ++i) + for (i = 0; databases[i].name; ++i) if (argv[remaining][0] == databases[i].name[0] && !strcmp (argv[remaining], databases[i].name)) return databases[i].func (argc - remaining - 1, &argv[remaining + 1]); -- cgit v1.1