From 3f4d5bf376d90f975767a31721faf3110206e456 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 15 Feb 1999 05:52:08 +0000 Subject: [PATCH] Fix off-by-one placement of hex bytes in a number. --- lexor.lex | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lexor.lex b/lexor.lex index 6291d78ae..8a684261b 100644 --- a/lexor.lex +++ b/lexor.lex @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: lexor.lex,v 1.7 1998/12/18 05:16:25 steve Exp $" +#ident "$Id: lexor.lex,v 1.8 1999/02/15 05:52:08 steve Exp $" #endif //# define YYSTYPE lexval @@ -417,7 +417,7 @@ static verinum*make_sized_hex(const char*txt) verinum::V*bits = new verinum::V[size]; unsigned idx = 0; - char*eptr = ptr + strlen(ptr); + char*eptr = ptr + strlen(ptr) - 1; while ((eptr > ptr) && (idx < (size-4))) { switch (*eptr) { @@ -443,14 +443,18 @@ static verinum*make_sized_hex(const char*txt) bits[idx++] = (val&8)? verinum::V1 : verinum::V0; break; } - default: + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': { unsigned val = *eptr - '0'; bits[idx++] = (val&1)? verinum::V1 : verinum::V0; bits[idx++] = (val&2)? verinum::V1 : verinum::V0; bits[idx++] = (val&4)? verinum::V1 : verinum::V0; bits[idx++] = (val&8)? verinum::V1 : verinum::V0; + break; } + default: + assert(0); } eptr -= 1;