Fix warnings under BSD
[tinc] / lib / getopt.c
index 5f74dee..a6782ed 100644 (file)
@@ -44,6 +44,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include <stdio.h>
 
+#ifdef HAVE_STRING_H
+#include <string.h>
+#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,8 +89,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #define getpid() GetCurrentProcessId()
 #endif
 
-#include "gettext.h"
-
 /* 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.
@@ -669,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++;
@@ -690,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);
 
@@ -715,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;
@@ -744,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 *) "";
@@ -774,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;
@@ -807,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;
@@ -854,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++;
@@ -872,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);
@@ -888,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] == ':' ? ':' : '?';
@@ -937,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;