initialize.c: Do not expand quoted arguments.
authorPascal Obry <obry@adacore.com>
Wed, 29 Apr 2009 09:55:37 +0000 (09:55 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 29 Apr 2009 09:55:37 +0000 (11:55 +0200)
2009-04-29  Pascal Obry  <obry@adacore.com>

* initialize.c: Do not expand quoted arguments.

From-SVN: r146941

gcc/ada/ChangeLog
gcc/ada/initialize.c

index 968ec55..fd56ece 100644 (file)
@@ -1,3 +1,7 @@
+2009-04-29  Pascal Obry  <obry@adacore.com>
+
+       * initialize.c: Do not expand quoted arguments.
+
 2009-04-29  Emmanuel Briot  <briot@adacore.com>
 
        * prj-ext.adb, prj.adb, prj.ads: Fix memory leaks.
index 8ad15bd..705cbf2 100644 (file)
@@ -130,6 +130,7 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
      int last;
      int argc_expanded = 0;
      TCHAR result [MAX_PATH];
+     int quoted;
 
      wargv = CommandLineToArgvW (GetCommandLineW(), &wargc);
 
@@ -146,9 +147,12 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
 
         for (k=1; k<wargc; k++)
           {
-            /* Check for wildcard expansion. */
-            if (_tcsstr (wargv[k], _T("?")) != 0 ||
-                _tcsstr (wargv[k], _T("*")) != 0)
+            quoted = (wargv[k][0] == _T('\''));
+
+            /* Check for wildcard expansion if the argument is not quoted. */
+            if (!quoted
+                && (_tcsstr (wargv[k], _T("?")) != 0 ||
+                    _tcsstr (wargv[k], _T("*")) != 0))
               {
                 /* Wilcards are present, append all corresponding matches. */
                 WIN32_FIND_DATA FileData;
@@ -173,8 +177,19 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
               }
             else
               {
-                /*  No wildcard. Store parameter as-is. */
-                append_arg (&argc_expanded, wargv[k], &gnat_argv, &last);
+                /*  No wildcard. Store parameter as-is. Remove quote if
+                    needed. */
+                if (quoted)
+                  {
+                    int len = _tcslen (wargv[k]);
+
+                    /* Remove ending quote */
+                    wargv[k][len-1] = _T('\0');
+                    append_arg
+                      (&argc_expanded, &wargv[k][1], &gnat_argv, &last);
+                  }
+                else
+                  append_arg (&argc_expanded, wargv[k], &gnat_argv, &last);
               }
           }