FreeBSD 10 clang port
This commit is contained in:
committed by
Jon Trulson
parent
8d0551bfda
commit
c3f74eec17
@@ -81,6 +81,7 @@
|
||||
|
||||
#include "ifparser.h"
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
/****************************************************************************
|
||||
Internal Macros and Utilities for Parser
|
||||
@@ -116,19 +117,48 @@ parse_number (g, cp, valp)
|
||||
const char *cp;
|
||||
long *valp;
|
||||
{
|
||||
long base = 10;
|
||||
SKIPSPACE (cp);
|
||||
|
||||
if (!isdigit(*cp))
|
||||
return CALLFUNC(g, handle_error) (g, cp, "number");
|
||||
|
||||
*valp = strtol(cp, &cp, 0);
|
||||
/* skip trailing qualifiers */
|
||||
*valp = 0;
|
||||
|
||||
if (*cp == '0') {
|
||||
cp++;
|
||||
if ((*cp == 'x') || (*cp == 'X')) {
|
||||
base = 16;
|
||||
cp++;
|
||||
} else {
|
||||
base = 8;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ignore overflows and assume ASCII, what source is usually written in */
|
||||
while (1) {
|
||||
int increment = -1;
|
||||
if (base == 8) {
|
||||
if ((*cp >= '0') && (*cp <= '7'))
|
||||
increment = *cp++ - '0';
|
||||
} else if (base == 16) {
|
||||
if ((*cp >= '0') && (*cp <= '9'))
|
||||
increment = *cp++ - '0';
|
||||
else if ((*cp >= 'A') && (*cp <= 'F'))
|
||||
increment = *cp++ - ('A' - 10);
|
||||
else if ((*cp >= 'a') && (*cp <= 'f'))
|
||||
increment = *cp++ - ('a' - 10);
|
||||
} else { /* Decimal */
|
||||
if ((*cp >= '0') && (*cp <= '9'))
|
||||
increment = *cp++ - '0';
|
||||
}
|
||||
if (increment < 0)
|
||||
break;
|
||||
*valp = (*valp * base) + increment;
|
||||
}
|
||||
|
||||
/* Skip trailing qualifiers */
|
||||
while (*cp == 'U' || *cp == 'u' || *cp == 'L' || *cp == 'l') cp++;
|
||||
#if 0
|
||||
*valp = atoi (cp);
|
||||
/* EMPTY */
|
||||
for (cp++; isdigit(*cp); cp++) ;
|
||||
#endif
|
||||
return cp;
|
||||
}
|
||||
|
||||
@@ -272,7 +302,10 @@ parse_product (g, cp, valp)
|
||||
|
||||
case '/':
|
||||
DO (cp = parse_product (g, cp + 1, &rightval));
|
||||
*valp = (*valp / rightval);
|
||||
if (rightval)
|
||||
*valp = (*valp / rightval);
|
||||
else
|
||||
*valp = LONG_MAX;
|
||||
break;
|
||||
|
||||
case '%':
|
||||
|
||||
Reference in New Issue
Block a user