Index: trunk/src/emx/include/emx/getopt.h
===================================================================
--- trunk/src/emx/include/emx/getopt.h	(revision 929)
+++ trunk/src/emx/include/emx/getopt.h	(revision 930)
@@ -8,9 +8,9 @@
 #endif
 
-extern char *optarg;       /* argument of current option                    */
-extern int optind;         /* index of next argument; default=0: initialize */
-extern int opterr;         /* 0=disable error messages; default=1: enable   */
-extern int optopt;         /* option character which caused the error       */
-extern char *optswchar;    /* characters introducing options; default="-"   */
+extern char *_emx_optarg;       /* argument of current option                    */
+extern int _emx_optind;         /* index of next argument; default=0: initialize */
+extern int _emx_opterr;         /* 0=disable error messages; default=1: enable   */
+extern int _emx_optopt;         /* option character which caused the error       */
+extern char *_emx_optswchar;    /* characters introducing options; default="-"   */
 
 extern enum _optmode
@@ -19,5 +19,5 @@
   GETOPT_ANY,              /* move non-options to the end                   */
   GETOPT_KEEP              /* return options in order                       */
-} optmode;
+} _emx_optmode;
 
 
@@ -25,5 +25,5 @@
    array pointed to. */
 
-int getopt (int, char **, __const__ char *);
+int _emx_getopt (int, char **, __const__ char *);
 
 #if defined (__cplusplus)
Index: trunk/src/emx/src/lib/misc/getopt.c
===================================================================
--- trunk/src/emx/src/lib/misc/getopt.c	(revision 929)
+++ trunk/src/emx/src/lib/misc/getopt.c	(revision 930)
@@ -8,10 +8,10 @@
 #include <emx/umalloc.h>
 
-char *optarg          = NULL;
-int optind            = 1;              /* Default: first call             */
-int opterr            = 1;              /* Default: error messages enabled */
-char *optswchar       = "-";            /* Default: '-' starts options     */
-enum _optmode optmode = GETOPT_UNIX;
-int optopt;
+char *_emx_optarg          = NULL;
+int _emx_optind            = 1;              /* Default: first call             */
+int _emx_opterr            = 1;              /* Default: error messages enabled */
+char *_emx_optswchar       = "-";            /* Default: '-' starts options     */
+enum _optmode _emx_optmode = GETOPT_UNIX;
+int _emx_optopt;
 
 static char * next_opt;             /* Next character in cluster of options */
@@ -30,21 +30,21 @@
 
 #define PUT(dst) BEGIN \
-                  if (optmode == GETOPT_ANY) \
-                    dst[dst##_count++] = argv[optind]; \
+                  if (_emx_optmode == GETOPT_ANY) \
+                    dst[dst##_count++] = argv[_emx_optind]; \
                  END
 
 /* Note: `argv' is not const as GETOPT_ANY reorders argv[]. */
 
-int _STD(getopt) (int argc, char * argv[], const char *opt_str)
+int _emx_getopt (int argc, char * argv[], const char *opt_str)
 {
   char c, *q;
   int i, j;
 
-  if (!init || optind == 0)
+  if (!init || _emx_optind == 0)
     {
-      if (optind == 0) optind = 1;
+      if (_emx_optind == 0) _emx_optind = 1;
       done = 0; init = 1;
       next_opt = "";
-      if (optmode == GETOPT_ANY)
+      if (_emx_optmode == GETOPT_ANY)
         {
           options = (char **)_hmalloc (argc * sizeof (char *));
@@ -61,10 +61,10 @@
     return -1;
 restart:
-  optarg = NULL;
+  _emx_optarg = NULL;
   if (*next_opt == 0)
     {
-      if (optind >= argc)
+      if (_emx_optind >= argc)
         {
-          if (optmode == GETOPT_ANY)
+          if (_emx_optmode == GETOPT_ANY)
             {
               j = 1;
@@ -73,5 +73,5 @@
               for (i = 0; i < non_options_count; ++i)
                 argv[j++] = non_options[i];
-              optind = options_count+1;
+              _emx_optind = options_count+1;
               free (options); free (non_options);
             }
@@ -79,7 +79,7 @@
           return -1;
         }
-      else if (!strchr (optswchar, argv[optind][0]) || argv[optind][1] == 0)
+      else if (!strchr (_emx_optswchar, argv[_emx_optind][0]) || argv[_emx_optind][1] == 0)
         {
-          if (optmode == GETOPT_UNIX)
+          if (_emx_optmode == GETOPT_UNIX)
             {
               done = 1;
@@ -87,26 +87,26 @@
             }
           PUT (non_options);
-          optarg = argv[optind++];
-          if (optmode == GETOPT_ANY)
+          _emx_optarg = argv[_emx_optind++];
+          if (_emx_optmode == GETOPT_ANY)
             goto restart;
-          /* optmode==GETOPT_KEEP */
+          /* _emx_optmode==GETOPT_KEEP */
           return 0;
         }
-      else if (argv[optind][0] == argv[optind][1] && argv[optind][2] == 0)
+      else if (argv[_emx_optind][0] == argv[_emx_optind][1] && argv[_emx_optind][2] == 0)
         {
-          if (optmode == GETOPT_ANY)
+          if (_emx_optmode == GETOPT_ANY)
             {
               j = 1;
               for (i = 0; i < options_count; ++i)
                 argv[j++] = options[i];
-              argv[j++] = argv[optind];
+              argv[j++] = argv[_emx_optind];
               for (i = 0; i < non_options_count; ++i)
                 argv[j++] = non_options[i];
-              for (i = optind+1; i < argc; ++i)
+              for (i = _emx_optind+1; i < argc; ++i)
                 argv[j++] = argv[i];
-              optind = options_count+2;
+              _emx_optind = options_count+2;
               free (options); free (non_options);
             }
-          ++optind;
+          ++_emx_optind;
           done = 1;
           return -1;
@@ -115,14 +115,14 @@
         {
           PUT (options);
-          sw_char = argv[optind][0];
-          next_opt = argv[optind]+1;
+          sw_char = argv[_emx_optind][0];
+          next_opt = argv[_emx_optind]+1;
         }
     }
   c = *next_opt++;
   if (*next_opt == 0)  /* Move to next argument if end of argument reached */
-    ++optind;
+    ++_emx_optind;
   if (c == ':' || (q = strchr (opt_str, c)) == NULL)
     {
-      if (opterr && opt_str[0] != ':')
+      if (_emx_opterr && opt_str[0] != ':')
         {
           if (c < ' ' || c >= 127)
@@ -133,5 +133,5 @@
                      argv[0], sw_char, c);
         }
-      optopt = c;
+      _emx_optopt = c;
       return '?';
     }
@@ -140,16 +140,16 @@
       if (*next_opt != 0)         /* Argument given */
         {
-          optarg = next_opt;
+          _emx_optarg = next_opt;
           next_opt = "";
-          ++optind;
+          ++_emx_optind;
         }
       else if (q[2] == ':')
-        optarg = NULL;            /* Optional argument missing */
-      else if (optind >= argc)
+        _emx_optarg = NULL;            /* Optional argument missing */
+      else if (_emx_optind >= argc)
         {                         /* Required argument missing */
-          if (opterr && opt_str[0] != ':')
+          if (_emx_opterr && opt_str[0] != ':')
             fprintf (stderr, "%s: no argument for `%c%c' option\n",
                      argv[0], sw_char, c);
-          optopt = c;
+          _emx_optopt = c;
           return (opt_str[0] == ':' ? ':' : '?');
         }
@@ -157,5 +157,5 @@
         {
           PUT (options);
-          optarg = argv[optind++];
+          _emx_optarg = argv[_emx_optind++];
         }
     }
