From 8a5f7d09c9ed3c394b1a199b112ae546b54ea21f Mon Sep 17 00:00:00 2001 From: ceriel Date: Wed, 25 Mar 1987 17:54:24 +0000 Subject: [PATCH] minor mods --- modules/src/string/str2bts.c | 3 +-- modules/src/string/str2long.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/src/string/str2bts.c b/modules/src/string/str2bts.c index 566183118..4b9abd0b7 100644 --- a/modules/src/string/str2bts.c +++ b/modules/src/string/str2bts.c @@ -9,8 +9,7 @@ static is_oct(c) char c; { - return (c == '0' || c == '1' || c == '2' || c == '3' || - c == '4' || c == '5' || c == '6' || c == '7'); + return ((unsigned int)(c-'0') <= ('7'-'0')); } /* str2bts() strips the escaped characters of a diff --git a/modules/src/string/str2long.c b/modules/src/string/str2long.c index 208d52c07..294042496 100644 --- a/modules/src/string/str2long.c +++ b/modules/src/string/str2long.c @@ -10,12 +10,14 @@ value(c, b) char c; int b; { - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; + register int ch; + + ch = c - '0'; + if ((unsigned) ch <= 9) return ch; + ch = c - 'A'; + if ((unsigned) ch <= 5) return ch + 10; + ch = c - 'a'; + if ((unsigned) ch <= 5) return ch + 10; return b; } -- 2.34.1