]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix quoting of special characters for the MinGW build.
authorEli Zaretskii <eliz@gnu.org>
Tue, 12 Jun 2012 16:36:42 +0000 (16:36 +0000)
committerEli Zaretskii <eliz@gnu.org>
Tue, 12 Jun 2012 16:36:42 +0000 (16:36 +0000)
 infcmd.c (construct_inferior_arguments) [__MINGW32__]: Quote
 special characters correctly for the Windows shells.  See
 http://sourceware.org/ml/gdb/2012-06/msg00047.html for the bug
 report.
 [!__MINGW32__]: Remove extra double quote character from special
 characters.

gdb/ChangeLog
gdb/infcmd.c

index 1cbe08685f5980696e461e9e1066768f9bf0120b..8228aba8624347b0eddaa19c85c6a0e7ec3d8ce8 100644 (file)
@@ -1,3 +1,12 @@
+2012-06-12  Eli Zaretskii  <eliz@gnu.org>
+
+       * infcmd.c (construct_inferior_arguments) [__MINGW32__]: Quote
+       special characters correctly for the Windows shells.  See
+       http://sourceware.org/ml/gdb/2012-06/msg00047.html for the bug
+       report.
+       [!__MINGW32__]: Remove extra double quote character from special
+       characters.
+
 2012-06-11  Stan Shebs  <stan@codesourcery.com>
 
        * ui-out.h: Remove #if 0 declarations.
index 5accd28552430f85c8aa5bb7fd51e947183cf126..b7770ccfb90d4e278653b20b27ca7d017e067696 100644 (file)
@@ -275,10 +275,18 @@ construct_inferior_arguments (int argc, char **argv)
 
   if (STARTUP_WITH_SHELL)
     {
+#ifdef __MINGW32__
+      /* This holds all the characters considered special to the
+        Windows shells.  */
+      char *special = "\"!&*|[]{}<>?`~^=;, \t\n";
+      const char quote = '"';
+#else
       /* This holds all the characters considered special to the
         typical Unix shells.  We include `^' because the SunOS
         /bin/sh treats it as a synonym for `|'.  */
-      char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
+      char *special = "\"!#$&*()\\|[]{}<>?'`~^; \t\n";
+      const char quote = '\'';
+#endif
       int i;
       int length = 0;
       char *out, *cp;
@@ -298,11 +306,20 @@ construct_inferior_arguments (int argc, char **argv)
          /* Need to handle empty arguments specially.  */
          if (argv[i][0] == '\0')
            {
-             *out++ = '\'';
-             *out++ = '\'';
+             *out++ = quote;
+             *out++ = quote;
            }
          else
            {
+#ifdef __MINGW32__
+             int quoted = 0;
+
+             if (strpbrk (argv[i], special))
+               {
+                 quoted = 1;
+                 *out++ = quote;
+               }
+#endif
              for (cp = argv[i]; *cp; ++cp)
                {
                  if (*cp == '\n')
@@ -310,17 +327,25 @@ construct_inferior_arguments (int argc, char **argv)
                      /* A newline cannot be quoted with a backslash (it
                         just disappears), only by putting it inside
                         quotes.  */
-                     *out++ = '\'';
+                     *out++ = quote;
                      *out++ = '\n';
-                     *out++ = '\'';
+                     *out++ = quote;
                    }
                  else
                    {
+#ifdef __MINGW32__
+                     if (*cp == quote)
+#else
                      if (strchr (special, *cp) != NULL)
+#endif
                        *out++ = '\\';
                      *out++ = *cp;
                    }
                }
+#ifdef __MINGW32__
+             if (quoted)
+               *out++ = quote;
+#endif
            }
        }
       *out = '\0';