Commit 6d47b1e3 by Pascal Obry Committed by Arnaud Charlet

initialize.c: Do not expand quoted arguments.

2009-04-29  Pascal Obry  <obry@adacore.com>

	* initialize.c: Do not expand quoted arguments.

From-SVN: r146941
parent d45871da
2009-04-29 Pascal Obry <obry@adacore.com>
* initialize.c: Do not expand quoted arguments.
2009-04-29 Emmanuel Briot <briot@adacore.com> 2009-04-29 Emmanuel Briot <briot@adacore.com>
* prj-ext.adb, prj.adb, prj.ads: Fix memory leaks. * prj-ext.adb, prj.adb, prj.ads: Fix memory leaks.
......
...@@ -130,6 +130,7 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED) ...@@ -130,6 +130,7 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
int last; int last;
int argc_expanded = 0; int argc_expanded = 0;
TCHAR result [MAX_PATH]; TCHAR result [MAX_PATH];
int quoted;
wargv = CommandLineToArgvW (GetCommandLineW(), &wargc); wargv = CommandLineToArgvW (GetCommandLineW(), &wargc);
...@@ -146,9 +147,12 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED) ...@@ -146,9 +147,12 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
for (k=1; k<wargc; k++) for (k=1; k<wargc; k++)
{ {
/* Check for wildcard expansion. */ quoted = (wargv[k][0] == _T('\''));
if (_tcsstr (wargv[k], _T("?")) != 0 ||
_tcsstr (wargv[k], _T("*")) != 0) /* 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. */ /* Wilcards are present, append all corresponding matches. */
WIN32_FIND_DATA FileData; WIN32_FIND_DATA FileData;
...@@ -173,8 +177,19 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED) ...@@ -173,8 +177,19 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
} }
else else
{ {
/* No wildcard. Store parameter as-is. */ /* No wildcard. Store parameter as-is. Remove quote if
append_arg (&argc_expanded, wargv[k], &gnat_argv, &last); 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);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment