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]

[PATCH] PR-10034 Bad space handling in set remote exec-file command


Hi,

In the set remote exec-file command if we provide space at the end of
the file-name the space is not being cleared. This behaviour is
inconsistent across similar set commands like set logging file etc. My
patch will fix that behaviour. Please review this patch.

Further, I have found that there is a function in cli/cli-utils.c
called remove_trailing_whitespace that never used. In many times we
have removed trailing spaces and for that inline code is written. In
my next patch I am planning to modify the remove_trailing_whitespace
function and use it whenever possible in that. Since that patch will
be relevant to current fix I am proposing, I have mentioned here that
point.

Thanks,
Abhijit Halder

Attachment: ChangeLog.txt
Description: Text document

Index: gdb/cli/cli-setshow.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-setshow.c,v
retrieving revision 1.46
diff -a -p -u -r1.46 cli-setshow.c
--- gdb/cli/cli-setshow.c	4 Aug 2011 19:10:13 -0000	1.46
+++ gdb/cli/cli-setshow.c	25 Sep 2011 08:28:52 -0000
@@ -181,6 +181,14 @@ do_setshow_command (char *arg, int from_
 	    arg = "";
 	  if (*(char **) c->var != NULL)
 	    xfree (*(char **) c->var);
+	  {
+	    /* Clear trailing whitespace of string.  */
+	    char *ptr = arg + strlen (arg) - 1;
+
+	    while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
+	      ptr--;
+	    *(ptr + 1) = '\0';
+	  }
 	  *(char **) c->var = xstrdup (arg);
 	  break;
 	case var_optional_filename:
@@ -188,6 +196,14 @@ do_setshow_command (char *arg, int from_
 	    arg = "";
 	  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 = xstrdup (arg);
 	  break;
 	case var_filename:

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