This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Remove a trailing space resulting from file name completion
- From: Eli Zaretskii <eliz at gnu dot org>
- To: "Maciej W. Rozycki" <macro at mips dot com>
- Cc: gdb-patches at sourceware dot org, chris at mips dot com, macro at linux-mips dot org
- Date: Fri, 11 May 2007 11:11:11 +0300
- Subject: Re: Remove a trailing space resulting from file name completion
- References: <Pine.LNX.4.61.0705101326150.29962@perivale.mips.com>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> 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?