OSDN Git Service

Make floating point environment more robust.
[mingw/mingw-org-wsl.git] / mingwrt / setargv.c
index 09e543c..1b57f85 100644 (file)
@@ -8,7 +8,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2014, MinGW.org Project
+ * Copyright (C) 2014, 2017, MinGW.org Project
  *
  * ---------------------------------------------------------------------------
  *
@@ -33,6 +33,8 @@
  * ---------------------------------------------------------------------------
  *
  */
+#define _ISOC99_SOURCE
+
 #include <glob.h>
 #include <string.h>
 #include <ctype.h>
@@ -99,9 +101,7 @@ void __mingw32_setargv( const char *cmdline )
   /* Capture any non-default globbing options, which the user may have
    * specified via a custom setting for _CRT_glob.
    */
-  int gl_opts = GLOB_NOCHECK;
-  if( _CRT_glob & __CRT_GLOB_CASE_SENSITIVE__ )
-    gl_opts |= GLOB_CASEMATCH;
+  int gl_opts = GLOB_NOCHECK | (_CRT_glob & (GLOB_CASEMATCH | GLOB_BRACE));
 
   /* We explicitly DO NOT use the GLOB_DOOFFS capability; ensure that
    * the associated field, in the glob_t structure, is initialized to
@@ -121,12 +121,18 @@ void __mingw32_setargv( const char *cmdline )
        * need special handling.
        */
       case '\\':
-       /* We don't (yet) know if this is a literal backslash,
-        * (directory separator), or an escape for a following
-        * quote character; just note its presence, until we
-        * have looked far enough ahead to decide.
-        */
-       ++bslash;
+       if( quoted == '\'' )
+         /* Backslashes within single quotes are always literal.
+          */
+         *argptr++ = '\\';
+
+       else
+         /* We don't (yet) know if this is a literal backslash,
+          * (directory separator), or an escape for a following
+          * quote character; just note its presence, until we
+          * have looked far enough ahead to decide.
+          */
+         ++bslash;
        break;
 
       case '[':
@@ -181,9 +187,9 @@ void __mingw32_setargv( const char *cmdline )
         * literally, after flushing out any pending backslashes.
         */
        argptr = backslash( bslash, argptr );
-       if( (quoted == 0) && isspace( c ) )
+       if( (quoted == 0) && isblank( c ) )
        {
-         /* The one exception is any white space character,
+         /* The one exception is any blank or tab character,
           * when it is not contained within quotes; this acts
           * as an argument separator, (or is simply discarded
           * if there is no argument already collected)...