This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Remove a trailing space resulting from file name completion


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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]