* Re: Quotes after --args
[not found] ` <833965voww.fsf@gnu.org>
@ 2012-06-09 14:34 ` Eli Zaretskii
2012-06-09 14:58 ` Eli Zaretskii
2012-06-12 15:23 ` Tom Tromey
0 siblings, 2 replies; 6+ messages in thread
From: Eli Zaretskii @ 2012-06-09 14:34 UTC (permalink / raw)
To: gdb-patches; +Cc: bhr2
[Redirecting to gdb-patches@ from gdb@.]
> Date: Fri, 08 Jun 2012 17:50:07 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: gdb@sourceware.org
>
> > Date: Fri, 08 Jun 2012 16:21:02 +0200
> > From: "Markus Bühren" <bhr2@gmx.de>
> >
> > gdb --eval-command=run --batch --args test.exe -f "my testfile.txt"
> >
> > My program should get two arguments, '-f' and 'my testfile.txt'. However, replacing my actual program test.exe by a program that just prints the input arguments, I get the following result:
> >
> > C:\>gdb --eval-command=run --batch --args test.exe -f "my testfile.txt"
> > [New thread 6180.0xad0]
> > argv[0] = >>C:/test.exe<<
> > argv[1] = >>-f<<
> > argv[2] = >>my\<<
> > argv[3] = >>testfile.txt<<
> >
> > Program exited normally.
> >
> > Can you help me to avoid that the file name is splitted into two arguments, with replacing the blank ' ' after 'my' by a backslash '\'? I have tried a lot of combinations of double double quotes '""', escaped double quotes '\"' and so on but I did not manage to get the file name passed as a single argument into my program.
>
> It's a bug. GDB handles the whitespace in a way that works on Posix
> platforms, but not on Windows.
Any objections to the patch below, which fixes this problem? (I tried
to minimize uglifying the original sources; if someone sees a better
way, please tell.)
2012-06-09 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.
--- infcmd.c~0 2012-02-23 10:18:38.000000000 +0200
+++ infcmd.c 2012-06-09 17:20:57.750500000 +0300
@@ -275,10 +275,18 @@ construct_inferior_arguments (int argc,
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";
+ const char quote = '\'';
+#endif
int i;
int length = 0;
char *out, *cp;
@@ -298,11 +306,20 @@ construct_inferior_arguments (int argc,
/* 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,
/* 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';
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Quotes after --args
2012-06-09 14:34 ` Quotes after --args Eli Zaretskii
@ 2012-06-09 14:58 ` Eli Zaretskii
2012-06-12 15:23 ` Tom Tromey
2012-06-12 15:23 ` Tom Tromey
1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2012-06-09 14:58 UTC (permalink / raw)
To: gdb-patches
> Date: Sat, 09 Jun 2012 17:33:47 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: bhr2@gmx.de
>
> Any objections to the patch below, which fixes this problem? (I tried
> to minimize uglifying the original sources; if someone sees a better
> way, please tell.)
>
>
> 2012-06-09 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.
>
> --- infcmd.c~0 2012-02-23 10:18:38.000000000 +0200
> +++ infcmd.c 2012-06-09 17:20:57.750500000 +0300
> @@ -275,10 +275,18 @@ construct_inferior_arguments (int argc,
>
> 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";
> + const char quote = '\'';
> +#endif
Btw, any idea why the Unix special characters mention the quote "
twice (see above)?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Quotes after --args
2012-06-09 14:58 ` Eli Zaretskii
@ 2012-06-12 15:23 ` Tom Tromey
2012-06-12 16:37 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2012-06-12 15:23 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
Eli> Btw, any idea why the Unix special characters mention the quote "
Eli> twice (see above)?
It's just a bug.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Quotes after --args
2012-06-09 14:34 ` Quotes after --args Eli Zaretskii
2012-06-09 14:58 ` Eli Zaretskii
@ 2012-06-12 15:23 ` Tom Tromey
2012-06-12 16:37 ` Eli Zaretskii
1 sibling, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2012-06-12 15:23 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, bhr2
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
Eli> 2012-06-09 Eli Zaretskii <eliz@gnu.org>
Eli> * infcmd.c (construct_inferior_arguments) [__MINGW32__]: Quote
Eli> special characters correctly for the Windows shells. See
Eli> http://sourceware.org/ml/gdb/2012-06/msg00047.html for the bug
Eli> report.
Looks good to me.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Quotes after --args
2012-06-12 15:23 ` Tom Tromey
@ 2012-06-12 16:37 ` Eli Zaretskii
0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2012-06-12 16:37 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
> From: Tom Tromey <tromey@redhat.com>
> Cc: gdb-patches@sourceware.org
> Date: Tue, 12 Jun 2012 09:23:00 -0600
>
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>
> Eli> Btw, any idea why the Unix special characters mention the quote "
> Eli> twice (see above)?
>
> It's just a bug.
I fixed it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Quotes after --args
2012-06-12 15:23 ` Tom Tromey
@ 2012-06-12 16:37 ` Eli Zaretskii
0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2012-06-12 16:37 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, bhr2
> From: Tom Tromey <tromey@redhat.com>
> Cc: gdb-patches@sourceware.org, bhr2@gmx.de
> Date: Tue, 12 Jun 2012 09:22:46 -0600
>
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>
> Eli> 2012-06-09 Eli Zaretskii <eliz@gnu.org>
> Eli> * infcmd.c (construct_inferior_arguments) [__MINGW32__]: Quote
> Eli> special characters correctly for the Windows shells. See
> Eli> http://sourceware.org/ml/gdb/2012-06/msg00047.html for the bug
> Eli> report.
>
> Looks good to me.
Thanks, committed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-06-12 16:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1339164112.4081.ezmlm@sourceware.org>
[not found] ` <20120608142102.302310@gmx.net>
[not found] ` <833965voww.fsf@gnu.org>
2012-06-09 14:34 ` Quotes after --args Eli Zaretskii
2012-06-09 14:58 ` Eli Zaretskii
2012-06-12 15:23 ` Tom Tromey
2012-06-12 16:37 ` Eli Zaretskii
2012-06-12 15:23 ` Tom Tromey
2012-06-12 16:37 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox