"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
before changing it!
- Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94
+ Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
#include <stdlib.h>
#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 <libintl.h>
+# 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'
optarg = NULL;
if (optind == 0)
- optstring = _getopt_initialize (optstring);
+ {
+ optstring = _getopt_initialize (optstring);
+ optind = 1; /* Don't scan ARGV[0], the program name. */
+ }
if (nextchar == NULL || *nextchar == '\0')
{
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;
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++)
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++;
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);
{
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] == ':' ? ':' : '?';
{
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 *) "";
{
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;
{
/* 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;