X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=lib%2Fgetopt.c;h=a6782ed667b46fccfb2a01b76ed18b5d4dcff591;hp=300f86de3ebd98045ee611d537a84387df4c10fd;hb=eda71798749e8b0abf5e8b3cbc11da82aa607f00;hpb=88a8826cf72297a784d597ba5a2b47058e1faf72 diff --git a/lib/getopt.c b/lib/getopt.c index 300f86de..a6782ed6 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -19,10 +19,10 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -USA. */ +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ @@ -44,6 +44,10 @@ USA. */ #include +#ifdef HAVE_STRING_H +#include +#endif + /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling @@ -85,17 +89,6 @@ USA. */ #define getpid() GetCurrentProcessId() #endif -#ifndef _ -/* This is for other GNU distributions with internationalized messages. - When compiling libc, the _ macro is predefined. */ -#ifdef HAVE_LIBINTL_H -# include -# define _(msgid) gettext (msgid) -#else -# define _(msgid) (msgid) -#endif -#endif - /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. @@ -268,7 +261,7 @@ extern pid_t __libc_pid; is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void -__attribute__ ((unused)) +__attribute__ ((__unused__)) store_args_and_env (int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so @@ -678,7 +671,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (ambig && !exact) { if (opterr) - fprintf (stderr, _("%s: option `%s' is ambiguous\n"), + fprintf (stderr, "%s: option `%s' is ambiguous\n", argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; @@ -699,16 +692,18 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) else { if (opterr) - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - _("%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - _("%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[optind - 1][0], pfound->name); + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + "%s: option `--%s' doesn't allow an argument\n", + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[optind - 1][0], pfound->name); + } nextchar += strlen (nextchar); @@ -724,7 +719,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (opterr) fprintf (stderr, - _("%s: option `%s' requires an argument\n"), + "%s: option `%s' requires an argument\n", argv[0], argv[optind - 1]); nextchar += strlen (nextchar); optopt = pfound->val; @@ -753,11 +748,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (argv[optind][1] == '-') /* --option */ - fprintf (stderr, _("%s: unrecognized option `--%s'\n"), + fprintf (stderr, "%s: unrecognized option `--%s'\n", argv[0], nextchar); else /* +option or -option */ - fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), + fprintf (stderr, "%s: unrecognized option `%c%s'\n", argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; @@ -783,10 +778,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: illegal option -- %c\n"), + fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); else - fprintf (stderr, _("%s: invalid option -- %c\n"), + fprintf (stderr, "%s: invalid option -- %c\n", argv[0], c); } optopt = c; @@ -816,7 +811,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (opterr) { /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: option requires an argument -- %c\n"), + fprintf (stderr, "%s: option requires an argument -- %c\n", argv[0], c); } optopt = c; @@ -863,7 +858,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (ambig && !exact) { if (opterr) - fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), + fprintf (stderr, "%s: option `-W %s' is ambiguous\n", argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; @@ -881,8 +876,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) else { if (opterr) - fprintf (stderr, _("\ -%s: option `-W %s' doesn't allow an argument\n"), + fprintf (stderr, + "%s: option `-W %s' doesn't allow an argument\n", argv[0], pfound->name); nextchar += strlen (nextchar); @@ -897,7 +892,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (opterr) fprintf (stderr, - _("%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] == ':' ? ':' : '?'; @@ -946,7 +941,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, - _("%s: option requires an argument -- %c\n"), + "%s: option requires an argument -- %c\n", argv[0], c); } optopt = c;