diff mbox

[1/4] windows-nat: Trim a trailing '\n' from OutputDebugString before echoing it

Message ID 1433352592-9728-2-git-send-email-jon.turney@dronecode.org.uk
State New
Headers show

Commit Message

Jon TURNEY June 3, 2015, 5:29 p.m. UTC
For cosmetic purposes, trim a trailing '\n' from OutputDebugString before
echoing it, as warning() will add a '\n', anyhow.

gdb/ChangeLog:

2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>

	* windows-nat.c (handle_output_debug_string): Trim trailing '\n'
	from OutputDebugString.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
 gdb/ChangeLog     | 5 +++++
 gdb/windows-nat.c | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

Comments

Joel Brobecker June 9, 2015, 6:49 p.m. UTC | #1
> 2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>
> 
> 	* windows-nat.c (handle_output_debug_string): Trim trailing '\n'
> 	from OutputDebugString.

Pre-approved with one formatting nit.

> -	warning (("%s"), s);
> +	{
> +	  char *p = strchr (s, '\0');
> +	  if (p > s && *--p == '\n')
> +	    *p = '\0';
> +	  warning (("%s"), s);
> +	}

Empty line between local variable declarations and the first statement
after that. So empty line after "char *p = [...]".

Thanks,
diff mbox

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 37d619b..ee9f1df 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>
+
+	* windows-nat.c (handle_output_debug_string): Trim trailing '\n'
+	from OutputDebugString.
+
 2015-06-02  Simon Marchi  <simon.marchi@ericsson.com>
 
 	PR gdb/15564
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 701d2c5..b56b916 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -818,7 +818,12 @@  handle_output_debug_string (struct target_waitstatus *ourstatus)
 #ifdef __CYGWIN__
       if (!startswith (s, "cYg"))
 #endif
-	warning (("%s"), s);
+	{
+	  char *p = strchr (s, '\0');
+	  if (p > s && *--p == '\n')
+	    *p = '\0';
+	  warning (("%s"), s);
+	}
     }
 #ifdef __COPY_CONTEXT_SIZE
   else