* Remove a trailing space resulting from file name completion
@ 2007-05-10 13:07 Maciej W. Rozycki
2007-05-10 13:17 ` Daniel Jacobowitz
2007-05-11 8:12 ` Eli Zaretskii
0 siblings, 2 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2007-05-10 13:07 UTC (permalink / raw)
To: gdb-patches; +Cc: Chris Dearman, Maciej W. Rozycki
Hi,
There is an annoying problem with file name completion when it comes to
internal variables. When a command like:
(gdb) set logging file log.txt<Tab>
is issued (<Tab> here denoting a stroke of the named key) and "log.txt"
already exists, then a space is appended (of course it may not make too
much sense to use completion at the very end of the "log.txt" string, but
it may earlier). After issuing the command as is, this space is included
in the variable holding the log file name and consequently, if the log
file is subsequently written, it is created with the trailing space, i.e.
as "log.txt ". The space has to be explicitly deleted if this is not
desired.
As a file with a trailing space is indeed not desired in about any case,
I propose the following change to be included.
2007-05-10 Chris Dearman <chris@mips.com>
Maciej W. Rozycki <macro@mips.com>
* cli/cli-setshow.c (do_setshow_command): Remove trailing
whitespace when setting a var_filename.
This change was tested natively for mips-unknown-linux-gnu and
remotely for mipsisa32-sde-elf, using mips-sim-sde32/-EB and
mips-sim-sde32/-EL as the targets, with no regressions.
OK to apply?
Maciej
12227.diff
Index: gdb/src/gdb/cli/cli-setshow.c
===================================================================
--- gdb.orig/src/gdb/cli/cli-setshow.c 2007-02-13 13:51:14.000000000 +0000
+++ gdb/src/gdb/cli/cli-setshow.c 2007-02-13 13:51:29.000000000 +0000
@@ -192,6 +192,13 @@
error_no_arg (_("filename to set it to."));
if (*(char **) c->var != NULL)
xfree (*(char **) c->var);
+ {
+ /* Clear trailing whitespace of filename. */
+ char *ptr = arg + strlen (arg) - 1;
+ while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
+ ptr--;
+ *(ptr + 1) = '\0';
+ }
*(char **) c->var = tilde_expand (arg);
break;
case var_boolean:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove a trailing space resulting from file name completion
2007-05-10 13:07 Remove a trailing space resulting from file name completion Maciej W. Rozycki
@ 2007-05-10 13:17 ` Daniel Jacobowitz
2007-05-11 8:12 ` Eli Zaretskii
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-05-10 13:17 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: gdb-patches, Chris Dearman, Maciej W. Rozycki
On Thu, May 10, 2007 at 02:06:32PM +0100, Maciej W. Rozycki wrote:
> Hi,
>
> There is an annoying problem with file name completion when it comes to
> internal variables. When a command like:
>
> (gdb) set logging file log.txt<Tab>
>
> is issued (<Tab> here denoting a stroke of the named key) and "log.txt"
> already exists, then a space is appended (of course it may not make too
> much sense to use completion at the very end of the "log.txt" string, but
> it may earlier). After issuing the command as is, this space is included
> in the variable holding the log file name and consequently, if the log
> file is subsequently written, it is created with the trailing space, i.e.
> as "log.txt ". The space has to be explicitly deleted if this is not
> desired.
>
> As a file with a trailing space is indeed not desired in about any case,
> I propose the following change to be included.
OK. I have an Evil Plan for fixing this more thoroughly, which will
change the quoting of most "set" commands to be more consistent and
friendlier to paths containing spaces and backslashes. But since I
still have not gotten to it, I think this is a step in the right direction.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove a trailing space resulting from file name completion
2007-05-10 13:07 Remove a trailing space resulting from file name completion Maciej W. Rozycki
2007-05-10 13:17 ` Daniel Jacobowitz
@ 2007-05-11 8:12 ` Eli Zaretskii
2007-05-14 12:40 ` Maciej W. Rozycki
1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2007-05-11 8:12 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: gdb-patches, chris, macro
> Date: Thu, 10 May 2007 14:06:32 +0100 (BST)
> From: "Maciej W. Rozycki" <macro@mips.com>
> cc: Chris Dearman <chris@mips.com>, "Maciej W. Rozycki" <macro@linux-mips.org>
>
> As a file with a trailing space is indeed not desired in about any case,
> I propose the following change to be included.
>
> 2007-05-10 Chris Dearman <chris@mips.com>
> Maciej W. Rozycki <macro@mips.com>
>
> * cli/cli-setshow.c (do_setshow_command): Remove trailing
> whitespace when setting a var_filename.
This is okay, but suppose I _did_ want a file name with trailing
space: how would I go about that in this situation? Is there a way?
If there isn't, either we should introduce one, or else we should tell
in the command's doc string and in the manual that this is a
restriction.
> +++ gdb/src/gdb/cli/cli-setshow.c 2007-02-13 13:51:29.000000000 +0000
> @@ -192,6 +192,13 @@
> error_no_arg (_("filename to set it to."));
> if (*(char **) c->var != NULL)
> xfree (*(char **) c->var);
> + {
> + /* Clear trailing whitespace of filename. */
> + char *ptr = arg + strlen (arg) - 1;
> + while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
> + ptr--;
> + *(ptr + 1) = '\0';
> + }
Shouldn't you again check whether anything was left after stripping
whitespace, and if not, output the same ``no filename to set it to"
error message?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove a trailing space resulting from file name completion
2007-05-11 8:12 ` Eli Zaretskii
@ 2007-05-14 12:40 ` Maciej W. Rozycki
0 siblings, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2007-05-14 12:40 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, chris, macro
On Fri, 11 May 2007, Eli Zaretskii wrote:
> This is okay, but suppose I _did_ want a file name with trailing
> space: how would I go about that in this situation? Is there a way?
> If there isn't, either we should introduce one, or else we should tell
> in the command's doc string and in the manual that this is a
> restriction.
Well, my feeling is some form of escaping would be reasonable, e.g. using
a backslash. Daniel says he has some Evil Plan in this area, which I look
forward. ;-)
> Shouldn't you again check whether anything was left after stripping
> whitespace, and if not, output the same ``no filename to set it to"
> error message?
I am unable to trigger a case where the file name would be set to an
empty string -- I get: "Argument required (filename to set it to.)."
Maciej
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-05-14 12:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-10 13:07 Remove a trailing space resulting from file name completion Maciej W. Rozycki
2007-05-10 13:17 ` Daniel Jacobowitz
2007-05-11 8:12 ` Eli Zaretskii
2007-05-14 12:40 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox