Module Name:    src
Committed By:   joerg
Date:           Tue Apr 16 19:34:58 UTC 2013

Modified Files:
        src/common/lib/libc/stdlib: _strtol.h _strtoul.h

Log Message:
Do not use isalpha here, since we explicitly only support the Portable
Character Set as base and in theory a locale could define a ASCII
control character as letter, resulting in negations. Also avoid isdigit
here to give the compiler a better chance of deciding whether an
unsigned compare or a jump table is a better option, both are very
likely better choices than the memory indirection.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/stdlib/_strtol.h \
    src/common/lib/libc/stdlib/_strtoul.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/stdlib/_strtol.h
diff -u src/common/lib/libc/stdlib/_strtol.h:1.3 src/common/lib/libc/stdlib/_strtol.h:1.4
--- src/common/lib/libc/stdlib/_strtol.h:1.3	Fri Mar  9 15:41:16 2012
+++ src/common/lib/libc/stdlib/_strtol.h	Tue Apr 16 19:34:57 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtol.h,v 1.3 2012/03/09 15:41:16 christos Exp $ */
+/* $NetBSD: _strtol.h,v 1.4 2013/04/16 19:34:57 joerg Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -120,10 +120,12 @@ _FUNCNAME(const char *nptr, char **endpt
 		cutlim = -cutlim;
 	}
 	for (acc = 0, any = 0;; c = *s++) {
-		if (isdigit(c))
+		if (c >= '0' && c <= '9')
 			i = c - '0';
-		else if (isalpha(c))
-			i = c - (isupper(c) ? 'A' - 10 : 'a' - 10);
+		else if (c >= 'a' && c <= 'z')
+			i = (c - 'a') + 10;
+		else if (c >= 'A' && c <= 'Z')
+			i = (c - 'A') + 10;
 		else
 			break;
 		if (i >= base)
Index: src/common/lib/libc/stdlib/_strtoul.h
diff -u src/common/lib/libc/stdlib/_strtoul.h:1.3 src/common/lib/libc/stdlib/_strtoul.h:1.4
--- src/common/lib/libc/stdlib/_strtoul.h:1.3	Thu Mar 22 15:57:29 2012
+++ src/common/lib/libc/stdlib/_strtoul.h	Tue Apr 16 19:34:58 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoul.h,v 1.3 2012/03/22 15:57:29 christos Exp $ */
+/* $NetBSD: _strtoul.h,v 1.4 2013/04/16 19:34:58 joerg Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -94,10 +94,12 @@ _FUNCNAME(const char *nptr, char **endpt
 	cutoff = ((__UINT)__UINT_MAX / (__UINT)base);
 	cutlim = (int)((__UINT)__UINT_MAX % (__UINT)base);
 	for (acc = 0, any = 0;; c = *s++) {
-		if (isdigit(c))
+		if (c >= '0' && c <= '9')
 			i = c - '0';
-		else if (isalpha(c))
-			i = c - (isupper(c) ? 'A' - 10 : 'a' - 10);
+		else if (c >= 'a' && c <= 'z')
+			i = (c - 'a') + 10;
+		else if (c >= 'A' && c <= 'Z')
+			i = (c - 'A') + 10;
 		else
 			break;
 		if (i >= base)

Reply via email to