X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetopt.c;h=8bcf5594571c22a8bcd3b44cbcc9938cb16fdfb7;hb=6aae241f16ed2dbe57475cb4c8b3a5b1ca1e9699;hp=de30ec79fec56abda44edbe0882096361c076b7a;hpb=b5da073416f93f9f145ac9eb44794775fbf6a752;p=gnulib.git diff --git a/lib/getopt.c b/lib/getopt.c index de30ec79f..8bcf55945 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -59,12 +59,15 @@ #include #endif /* GNU C library. */ +#ifndef _ /* This is for other GNU distributions with internationalized messages. - The GNU C Library itself does not yet support such messages. */ -#if HAVE_LIBINTL_H + When compiling libc, the _ macro is predefined. */ +#ifdef HAVE_LIBINTL_H # include +# define _(msgid) gettext (msgid) #else -# define gettext(msgid) (msgid) +# define _(msgid) (msgid) +#endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' @@ -476,7 +479,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (longopts != NULL && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + || (long_only && (argv[optind][2] + || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; @@ -489,6 +493,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; +#ifdef lint + indfound = 0; /* Avoid spurious compiler warning. */ +#endif + /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) @@ -516,7 +524,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (ambig && !exact) { if (opterr) - fprintf (stderr, gettext ("%s: option `%s' is ambiguous\n"), + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; @@ -539,12 +547,12 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, - gettext ("%s: option `--%s' doesn't allow an argument\n"), + _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, - gettext ("%s: option `%c%s' doesn't allow an argument\n"), + _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); nextchar += strlen (nextchar); @@ -559,7 +567,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (opterr) fprintf (stderr, - gettext ("%s: option `%s' requires an argument\n"), + _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; @@ -587,11 +595,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (argv[optind][1] == '-') /* --option */ - fprintf (stderr, gettext ("%s: unrecognized option `--%s'\n"), + fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ - fprintf (stderr, gettext ("%s: unrecognized option `%c%s'\n"), + fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; @@ -616,10 +624,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ - fprintf (stderr, gettext ("%s: illegal option -- %c\n"), + fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else - fprintf (stderr, gettext ("%s: invalid option -- %c\n"), + fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; @@ -655,7 +663,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, - gettext ("%s: option requires an argument -- %c\n"), + _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c;