diff mbox

[v5,2/8] Merge multiple hex conversions

Message ID 20140319223044.14668.13369.stgit@host1.jankratochvil.net
State Committed
Headers show

Commit Message

Jan Kratochvil March 19, 2014, 10:30 p.m. UTC
Hi,

here most of the patch has been reimplemented in the meantime and this is only
a small remaint.


Jan


gdb/
2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com

	Merge multiple hex conversions.
	* monitor.c: Include rsp-low.h.
	(fromhex): Remove definition.

gdb/gdbserver/
2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com

	Merge multiple hex conversions.
	* gdbreplay.c (tohex): Rename to 'fromhex'.
	(logchar): Use fromhex.
---
 gdb/gdbserver/gdbreplay.c |    6 +++---
 gdb/monitor.c             |   16 +---------------
 2 files changed, 4 insertions(+), 18 deletions(-)

Comments

Tom Tromey May 19, 2014, 6:24 p.m. UTC | #1
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> here most of the patch has been reimplemented in the meantime and
Jan> this is only a small remaint.

Jan> gdb/
Jan> 2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com

Jan> 	Merge multiple hex conversions.
Jan> 	* monitor.c: Include rsp-low.h.
Jan> 	(fromhex): Remove definition.

Jan> gdb/gdbserver/
Jan> 2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com

Jan> 	Merge multiple hex conversions.
Jan> 	* gdbreplay.c (tohex): Rename to 'fromhex'.
Jan> 	(logchar): Use fromhex.

This is ok.
Please put it in.

Tom
diff mbox

Patch

diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c
index 706fda6..3fa8e3d 100644
--- a/gdb/gdbserver/gdbreplay.c
+++ b/gdb/gdbserver/gdbreplay.c
@@ -264,7 +264,7 @@  remote_open (char *name)
 }
 
 static int
-tohex (int ch)
+fromhex (int ch)
 {
   if (ch >= '0' && ch <= '9')
     {
@@ -327,11 +327,11 @@  logchar (FILE *fp)
 	  ch2 = fgetc (fp);
 	  fputc (ch2, stdout);
 	  fflush (stdout);
-	  ch = tohex (ch2) << 4;
+	  ch = fromhex (ch2) << 4;
 	  ch2 = fgetc (fp);
 	  fputc (ch2, stdout);
 	  fflush (stdout);
-	  ch |= tohex (ch2);
+	  ch |= fromhex (ch2);
 	  break;
 	default:
 	  /* Treat any other char as just itself */
diff --git a/gdb/monitor.c b/gdb/monitor.c
index c46e2df..e675772 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -55,6 +55,7 @@ 
 #include "regcache.h"
 #include "gdbthread.h"
 #include "readline/readline.h"
+#include "rsp-low.h"
 
 static char *dev_name;
 static struct target_ops *targ_ops;
@@ -226,21 +227,6 @@  monitor_error (char *function, char *message,
 	   message, safe_string);
 }
 
-/* Convert hex digit A to a number.  */
-
-static int
-fromhex (int a)
-{
-  if (a >= '0' && a <= '9')
-    return a - '0';
-  else if (a >= 'a' && a <= 'f')
-    return a - 'a' + 10;
-  else if (a >= 'A' && a <= 'F')
-    return a - 'A' + 10;
-  else
-    error (_("Invalid hex digit %d"), a);
-}
-
 /* monitor_vsprintf - similar to vsprintf but handles 64-bit addresses
 
    This function exists to get around the problem that many host platforms