chiark / gitweb /
klibc: version 1.0.14
[elogind.git] / klibc / klibc / strntoumax.c
index 4e30637d2c3bd5ebf8a219693693852da3ba9d3b..4c47fe8662f9524d8e782b326da315550be77073 100644 (file)
@@ -33,12 +33,13 @@ uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n)
   }
 
   /* Single optional + or - */
-  if ( n && *nptr == '-' ) {
-    minus = 1;
-    nptr++;
-    n--;
-  } else if ( n && *nptr == '+' ) {
-    nptr++;
+  if ( n ) {
+    char c = *nptr;
+    if ( c == '-' || c == '+' ) {
+      minus = (c == '-');
+      nptr++;
+      n--;
+    }
   }
 
   if ( base == 0 ) {