From 63bee803533d6c0b890174637a751c958e25a08a Mon Sep 17 00:00:00 2001 From: Joern Rennecke Date: Tue, 2 Aug 2005 16:17:59 +0000 Subject: [PATCH] * interp.c (strswaplen): Add one for '\0' delimiter. --- sim/sh/ChangeLog | 4 ++++ sim/sh/interp.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog index 5d6a1461bca..4f2aea38100 100644 --- a/sim/sh/ChangeLog +++ b/sim/sh/ChangeLog @@ -1,3 +1,7 @@ +2005-08-02 J"orn Rennecke + + * interp.c (strswaplen): Add one for '\0' delimiter. + 2005-06-16 Daniel Jacobowitz * gencode.c (tab): Avoid lvalue casts. Suggested by diff --git a/sim/sh/interp.c b/sim/sh/interp.c index 5d4a4f558ae..107842b8753 100644 --- a/sim/sh/interp.c +++ b/sim/sh/interp.c @@ -959,6 +959,10 @@ ptr (x) return (char *) (x + saved_state.asregs.memory); } +/* STR points to a zero-terminated string in target byte order. Return + the number of bytes that need to be converted to host byte order in order + to use this string as a zero-terminated string on the host. + (Not counting the rounding up needed to operate on entire words.) */ static int strswaplen (str) int str; @@ -971,7 +975,7 @@ strswaplen (str) return 0; end = str; for (end = str; memory[end ^ endian]; end++) ; - return end - str; + return end - str + 1; } static void -- 2.30.2