@@ -2350,13 +2350,11 @@ const of_unichar_t *characters = [self characters]; size_t i = 0, length = [self length]; intmax_t value = 0; bool expectWhitespace = false; - while (length > 0 && (*characters == ' ' || *characters == '\t' || - *characters == '\n' || *characters == '\r' || - *characters == '\f')) { + while (length > 0 && of_ascii_isspace(*characters)) { characters++; length--; } if (length == 0) { @@ -2367,26 +2365,23 @@ if (characters[0] == '-' || characters[0] == '+') i++; for (; i < length; i++) { if (expectWhitespace) { - if (characters[i] != ' ' && characters[i] != '\t' && - characters[i] != '\n' && characters[i] != '\r' && - characters[i] != '\f') - @throw [OFInvalidFormatException exception]; - continue; + if (of_ascii_isspace(characters[i])) + continue; + + @throw [OFInvalidFormatException exception]; } if (characters[i] >= '0' && characters[i] <= '9') { if (INTMAX_MAX / 10 < value || INTMAX_MAX - value * 10 < characters[i] - '0') @throw [OFOutOfRangeException exception]; value = (value * 10) + (characters[i] - '0'); - } else if (characters[i] == ' ' || characters[i] == '\t' || - characters[i] == '\n' || characters[i] == '\r' || - characters[i] == '\f') + } else if (of_ascii_isspace(characters[i])) expectWhitespace = true; else @throw [OFInvalidFormatException exception]; } @@ -2404,13 +2399,11 @@ const of_unichar_t *characters = [self characters]; size_t i = 0, length = [self length]; uintmax_t value = 0; bool expectWhitespace = false, foundValue = false; - while (length > 0 && (*characters == ' ' || *characters == '\t' || - *characters == '\n' || *characters == '\r' || - *characters == '\f')) { + while (length > 0 && of_ascii_isspace(*characters)) { characters++; length--; } if (length == 0) { @@ -2425,15 +2418,14 @@ for (; i < length; i++) { uintmax_t newValue; if (expectWhitespace) { - if (characters[i] != ' ' && characters[i] != '\t' && - characters[i] != '\n' && characters[i] != '\r' && - characters[i] != '\f') - @throw [OFInvalidFormatException exception]; - continue; + if (of_ascii_isspace(characters[i])) + continue; + + @throw [OFInvalidFormatException exception]; } if (characters[i] >= '0' && characters[i] <= '9') { newValue = (value << 4) | (characters[i] - '0'); foundValue = true; @@ -2441,13 +2433,12 @@ newValue = (value << 4) | (characters[i] - 'A' + 10); foundValue = true; } else if (characters[i] >= 'a' && characters[i] <= 'f') { newValue = (value << 4) | (characters[i] - 'a' + 10); foundValue = true; - } else if (characters[i] == 'h' || characters[i] == ' ' || - characters[i] == '\t' || characters[i] == '\n' || - characters[i] == '\r' || characters[i] == '\f') { + } else if (characters[i] == 'h' || + of_ascii_isspace(characters[i])) { expectWhitespace = true; continue; } else @throw [OFInvalidFormatException exception]; @@ -2471,13 +2462,11 @@ const of_unichar_t *characters = [self characters]; size_t i = 0, length = [self length]; uintmax_t value = 0; bool expectWhitespace = false; - while (length > 0 && (*characters == ' ' || *characters == '\t' || - *characters == '\n' || *characters == '\r' || - *characters == '\f')) { + while (length > 0 && of_ascii_isspace(*characters)) { characters++; length--; } if (length == 0) { @@ -2487,22 +2476,19 @@ for (; i < length; i++) { uintmax_t newValue; if (expectWhitespace) { - if (characters[i] != ' ' && characters[i] != '\t' && - characters[i] != '\n' && characters[i] != '\r' && - characters[i] != '\f') - @throw [OFInvalidFormatException exception]; - continue; + if (of_ascii_isspace(characters[i])) + continue; + + @throw [OFInvalidFormatException exception]; } if (characters[i] >= '0' && characters[i] <= '7') newValue = (value << 3) | (characters[i] - '0'); - else if (characters[i] == ' ' || characters[i] == '\t' || - characters[i] == '\n' || characters[i] == '\r' || - characters[i] == '\f') { + else if (of_ascii_isspace(characters[i])) { expectWhitespace = true; continue; } else @throw [OFInvalidFormatException exception]; @@ -2545,12 +2531,11 @@ withString: decimalPoint] UTF8String]; #endif char *endPointer = NULL; float value; - while (*UTF8String == ' ' || *UTF8String == '\t' || - *UTF8String == '\n' || *UTF8String == '\r' || *UTF8String == '\f') + while (of_ascii_isspace(*UTF8String)) UTF8String++; #ifdef HAVE_STRTOF_L value = strtof_l(UTF8String, &endPointer, cLocale); #else @@ -2558,13 +2543,11 @@ #endif /* Check if there are any invalid chars left */ if (endPointer != NULL) for (; *endPointer != '\0'; endPointer++) - if (*endPointer != ' ' && *endPointer != '\t' && - *endPointer != '\n' && *endPointer != '\r' && - *endPointer != '\f') + if (!of_ascii_isspace(*endPointer)) @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return value; @@ -2598,12 +2581,11 @@ withString: decimalPoint] UTF8String]; #endif char *endPointer = NULL; double value; - while (*UTF8String == ' ' || *UTF8String == '\t' || - *UTF8String == '\n' || *UTF8String == '\r' || *UTF8String == '\f') + while (of_ascii_isspace(*UTF8String)) UTF8String++; #ifdef HAVE_STRTOD_L value = strtod_l(UTF8String, &endPointer, cLocale); #else @@ -2611,13 +2593,11 @@ #endif /* Check if there are any invalid chars left */ if (endPointer != NULL) for (; *endPointer != '\0'; endPointer++) - if (*endPointer != ' ' && *endPointer != '\t' && - *endPointer != '\n' && *endPointer != '\r' && - *endPointer != '\f') + if (!of_ascii_isspace(*endPointer)) @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return value;