Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Handle \r\n in gdbreplay
Date: Thu, 21 Feb 2019 14:05:00 -0000	[thread overview]
Message-ID: <20190221140513.29508-1-tromey@adacore.com> (raw)

I tried gdbreplay yesterday, but the remotelogfile I received was made
on Windows, so the lines were terminated with \r\n rather than plain
\n.

This patch changes gdbreplay to allow \r or \r\n line termination when
reading the log file.

gdb/gdbserver/ChangeLog
2019-02-21  Tom Tromey  <tromey@adacore.com>

	* gdbreplay.c (logchar): Handle \r and \r\n.
---
 gdb/gdbserver/ChangeLog   |  4 ++++
 gdb/gdbserver/gdbreplay.c | 15 +++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c
index 26a55533ff6..b1a9401909c 100644
--- a/gdb/gdbserver/gdbreplay.c
+++ b/gdb/gdbserver/gdbreplay.c
@@ -316,10 +316,21 @@ logchar (FILE *fp)
   int ch2;
 
   ch = fgetc (fp);
-  fputc (ch, stdout);
-  fflush (stdout);
+  if (ch != '\r')
+    {
+      fputc (ch, stdout);
+      fflush (stdout);
+    }
   switch (ch)
     {
+      /* Treat all of \r, \n, and \r\n as a newline.  */
+    case '\r':
+      ch = fgetc (fp);
+      if (ch != '\n')
+	ungetc (ch, fp);
+      fputc ('\n', stdout);
+      fflush (stdout);
+      /* Fall through.  */
     case '\n':
       ch = EOL;
       break;
-- 
2.20.1


             reply	other threads:[~2019-02-21 14:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 14:05 Tom Tromey [this message]
2019-02-21 15:14 ` Eli Zaretskii
2019-02-21 16:07   ` Tom Tromey
2019-02-21 16:12     ` Paul Koning
2019-02-27 18:49     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190221140513.29508-1-tromey@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox