]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ada: Fix argument expansion with unbalanced quote on Windows
authorMivirl <octoberstargazer7405@mivirl.dev>
Fri, 24 Oct 2025 15:43:02 +0000 (17:43 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Fri, 24 Oct 2025 16:52:46 +0000 (18:52 +0200)
The last character of the argument is chopped as if it was a quote.

gcc/ada/
PR ada/122367
* rtinit.c (__gnat_runtime_initialize) [__MINGW32__]: Fix detection
of quoted arguments.

gcc/ada/rtinit.c

index 6a135529870b2deaadb3cef461666b50f439a667..598550c4051ca386566db8175cc5c9ed52ee0435 100644 (file)
@@ -419,6 +419,7 @@ __gnat_runtime_initialize (int install_handler)
      int last;
      int argc_expanded = 0;
      TCHAR result [MAX_PATH];
+     int arglen;
      int quoted;
 
      __gnat_get_argw (GetCommandLineW (), &wargv, &wargc);
@@ -436,7 +437,10 @@ __gnat_runtime_initialize (int install_handler)
 
         for (k=1; k<wargc; k++)
           {
-            quoted = (wargv[k][0] == _T('\''));
+            arglen = _tcslen (wargv[k]);
+            quoted = wargv[k][0] == _T('\'')
+                     && arglen > 1
+                     && wargv[k][arglen - 1] == _T('\'');
 
             /* Check for wildcard expansion if the argument is not quoted. */
             if (!quoted && __gnat_do_argv_expansion