Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] PR-10034 Bad space handling in set remote exec-file command
@ 2011-09-25 10:18 Abhijit Halder
  2011-09-26  5:41 ` Abhijit Halder
  0 siblings, 1 reply; 10+ messages in thread
From: Abhijit Halder @ 2011-09-25 10:18 UTC (permalink / raw)
  To: gdb-patches@sourceware.org ml

[-- Attachment #1: Type: text/plain, Size: 710 bytes --]

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 #2: ChangeLog.txt --]
[-- Type: text/plain, Size: 181 bytes --]

2011-09-13  Abhijit Halder  <abhijit.k.halder@gmail.com>

	Fix PR remote/10034:
	* cli/cli-setshow.c (do_setshow_command): Clear trailing whitespace
	from command argument strings.

[-- Attachment #3: gdb-space-issue.patch --]
[-- Type: text/x-patch, Size: 1167 bytes --]

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:

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH] PR-10034 Bad space handling in `set remote exec-file' command.
@ 2011-10-02  8:14 Abhijit Halder
  2011-10-04 15:51 ` Tom Tromey
  0 siblings, 1 reply; 10+ messages in thread
From: Abhijit Halder @ 2011-10-02  8:14 UTC (permalink / raw)
  To: gdb-patches@sourceware.org ml

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

Hi,

In the `set remote exec-file' command if we provide space at the end
of the file-name, the space is not being chopped off and being
considered as part of file-name. This behavior is inconsistent across
similar set commands like `set logging file' etc. My patch will fix
that problem. Please review this patch and put your comments.

Thanks,
Abhijit Halder

[-- Attachment #2: ChangeLog.txt --]
[-- Type: text/plain, Size: 181 bytes --]

2011-09-13  Abhijit Halder  <abhijit.k.halder@gmail.com>

	Fix PR remote/10034:
	* cli/cli-setshow.c (do_setshow_command): Clear trailing whitespace
	from command argument strings.

[-- Attachment #3: gdb-space-issue.patch --]
[-- Type: application/octet-stream, Size: 2034 bytes --]

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	29 Sep 2011 07:39:45 -0000
@@ -177,15 +177,18 @@ do_setshow_command (char *arg, int from_
 	  }
 	  break;
 	case var_string_noescape:
-	  if (arg == NULL)
-	    arg = "";
-	  if (*(char **) c->var != NULL)
-	    xfree (*(char **) c->var);
-	  *(char **) c->var = xstrdup (arg);
-	  break;
 	case var_optional_filename:
 	  if (arg == NULL)
 	    arg = "";
+	  else
+	    {
+	      /* Clear trailing whitespace.  */
+	      char *ptr = arg + strlen (arg) - 1;
+
+	      while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
+		ptr--;
+	      *(ptr + 1) = '\0';
+	    }
 	  if (*(char **) c->var != NULL)
 	    xfree (*(char **) c->var);
 	  *(char **) c->var = xstrdup (arg);
@@ -193,16 +196,17 @@ do_setshow_command (char *arg, int from_
 	case var_filename:
 	  if (arg == NULL)
 	    error_no_arg (_("filename to set it to."));
+	  else
+	    {
+	      /* Clear trailing whitespace.  */
+	      char *ptr = arg + strlen (arg) - 1;
+
+	      while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
+		ptr--;
+	      *(ptr + 1) = '\0';
+	    }
 	  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:
@@ -419,7 +423,7 @@ cmd_show_list (struct cmd_list_element *
   for (; list != NULL; list = list->next)
     {
       /* If we find a prefix, run its list, prefixing our output by its
-         prefix (with "show " skipped).  */
+	 prefix (with "show " skipped).  */
       if (list->prefixlist && !list->abbrev_flag)
 	{
 	  struct cleanup *optionlist_chain

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-10-14 11:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-25 10:18 [PATCH] PR-10034 Bad space handling in set remote exec-file command Abhijit Halder
2011-09-26  5:41 ` Abhijit Halder
2011-09-26 16:01   ` Abhijit Halder
2011-09-29  8:27     ` Abhijit Halder
2011-10-02  8:14 [PATCH] PR-10034 Bad space handling in `set remote exec-file' command Abhijit Halder
2011-10-04 15:51 ` Tom Tromey
2011-10-05  4:19   ` Abhijit Halder
2011-10-05 14:01     ` Tom Tromey
2011-10-14  9:53     ` Abhijit Halder
2011-10-14 11:47       ` Abhijit Halder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox