r8405: update var.c from upstream
authorAndrew Tridgell <tridge@samba.org>
Wed, 13 Jul 2005 00:47:54 +0000 (00:47 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:22:58 +0000 (13:22 -0500)
(This used to be commit 288c178d5fef80947590fd58e3c9b1fbcdddcdf6)

source4/lib/appweb/mpr/var.c

index 9d2afe5306f5e9175b60b18c768081b4e903a996..533248dd067424a77d1e93fdbad2bb607738f694 100644 (file)
@@ -1711,11 +1711,13 @@ void mprVarToString(char** out, int size, char *fmt, MprVar *obj)
 
 MprVar mprParseVar(char *buf, MprType preferredType)
 {
-       MprType         type = MPR_TYPE_UNDEFINED;
+       MprType         type;
        char            *cp;
 
        mprAssert(buf);
 
+       type = preferredType;
+
        if (preferredType == MPR_TYPE_UNDEFINED) {
                if (*buf == '-') {
                        type = MPR_NUM_VAR;
@@ -1730,18 +1732,18 @@ MprVar mprParseVar(char *buf, MprType preferredType)
                } else if (isdigit((int) *buf)) {
                        type = MPR_NUM_VAR;
                        cp = buf;
-                       if (*cp && tolower((unsigned char)cp[1]) == 'x') {
+                       if (*cp && tolower(cp[1]) == 'x') {
                                cp = &cp[2];
                        }
                        for (cp = buf; *cp; cp++) {
-                               if (! isdigit((unsigned char) *cp)) {
+                               if (! isdigit((int) *cp)) {
                                        break;
                                }
                        }
 
                        if (*cp != '\0') {
 #if BLD_FEATURE_FLOATING_POINT
-                               if (*cp == '.' || tolower((unsigned char)*cp) == 'e') {
+                               if (*cp == '.' || tolower(*cp) == 'e') {
                                        type = MPR_TYPE_FLOAT;
                                } else
 #endif
@@ -1750,8 +1752,6 @@ MprVar mprParseVar(char *buf, MprType preferredType)
                                }
                        }
                }
-       } else {
-               type = preferredType;
        }
 
        switch (type) {
@@ -1993,11 +1993,11 @@ int64 mprParseInteger64(char *str)
                }
        } else {
                cp++;
-               if (tolower((unsigned char)*cp) == 'x') {
+               if (tolower(*cp) == 'x') {
                        cp++;
                        radix = 16;
                        while (*cp) {
-                               c = tolower((unsigned char)*cp);
+                               c = tolower(*cp);
                                if (isdigit(c)) {
                                        num64 = (c - '0') + (num64 * radix);
                                } else if (c >= 'a' && c <= 'f') {
@@ -2011,7 +2011,7 @@ int64 mprParseInteger64(char *str)
                } else{
                        radix = 8;
                        while (*cp) {
-                               c = tolower((unsigned char)*cp);
+                               c = tolower(*cp);
                                if (isdigit(c) && c < '8') {
                                        num64 = (c - '0') + (num64 * radix);
                                } else {
@@ -2110,11 +2110,11 @@ int mprParseInteger(char *str)
                }
        } else {
                cp++;
-               if (tolower((unsigned char)*cp) == 'x') {
+               if (tolower(*cp) == 'x') {
                        cp++;
                        radix = 16;
                        while (*cp) {
-                               c = tolower((unsigned char)*cp);
+                               c = tolower(*cp);
                                if (isdigit(c)) {
                                        num = (c - '0') + (num * radix);
                                } else if (c >= 'a' && c <= 'f') {
@@ -2128,7 +2128,7 @@ int mprParseInteger(char *str)
                } else{
                        radix = 8;
                        while (*cp) {
-                               c = tolower((unsigned char)*cp);
+                               c = tolower(*cp);
                                if (isdigit(c) && c < '8') {
                                        num = (c - '0') + (num * radix);
                                } else {