Differences From Artifact [fbf885bed7]:
- File
src/OFString.m
— part of check-in
[ce5dfd4a83]
at
2020-08-13 19:27:37
on branch trunk
— Always cast argument to isspace() to unsigned char
Some implementations define this as a macro that indexes into a table,
where this would result in a negative index if char is signed. (user: js, size: 65427) [annotate] [blame] [check-ins using]
To Artifact [3a36a1ae89]:
- File
src/OFString.m
— part of check-in
[04bb18457a]
at
2020-08-13 19:43:33
on branch trunk
— Set errno to 0 before calling strto*
It is not guaranteed that errno is set to 0 when there is no
overflow/underflow, so it needs to be set to 0 before, in case it
already is ERANGE from a previous call. (user: js, size: 65475) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 | - (long long)longLongValueWithBase: (int)base { void *pool = objc_autoreleasePoolPush(); const char *UTF8String = self.UTF8String; char *endPointer = NULL; long long value; value = strtoll(UTF8String, &endPointer, base); if ((value == LLONG_MIN || value == LLONG_MAX) && errno == ERANGE) @throw [OFOutOfRangeException exception]; /* Check if there are any invalid chars left */ if (endPointer != NULL) | > | 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 | - (long long)longLongValueWithBase: (int)base { void *pool = objc_autoreleasePoolPush(); const char *UTF8String = self.UTF8String; char *endPointer = NULL; long long value; errno = 0; value = strtoll(UTF8String, &endPointer, base); if ((value == LLONG_MIN || value == LLONG_MAX) && errno == ERANGE) @throw [OFOutOfRangeException exception]; /* Check if there are any invalid chars left */ if (endPointer != NULL) |
︙ | ︙ | |||
2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 | /* Use isspace since strtoull uses the same. */ while (isspace((unsigned char)*UTF8String)) UTF8String++; if (*UTF8String == '-') @throw [OFInvalidFormatException exception]; value = strtoull(UTF8String, &endPointer, base); if (value == ULLONG_MAX && errno == ERANGE) @throw [OFOutOfRangeException exception]; /* Check if there are any invalid chars left */ if (endPointer != NULL) | > | 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 | /* Use isspace since strtoull uses the same. */ while (isspace((unsigned char)*UTF8String)) UTF8String++; if (*UTF8String == '-') @throw [OFInvalidFormatException exception]; errno = 0; value = strtoull(UTF8String, &endPointer, base); if (value == ULLONG_MAX && errno == ERANGE) @throw [OFOutOfRangeException exception]; /* Check if there are any invalid chars left */ if (endPointer != NULL) |
︙ | ︙ | |||
2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 | const char *UTF8String = [self stringByReplacingOccurrencesOfString: @"." withString: decimalPoint].UTF8String; #endif char *endPointer = NULL; float value; #ifdef HAVE_STRTOF_L value = strtof_l(UTF8String, &endPointer, cLocale); #else value = strtof(UTF8String, &endPointer); #endif if (value == HUGE_VALF) | > | 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 | const char *UTF8String = [self stringByReplacingOccurrencesOfString: @"." withString: decimalPoint].UTF8String; #endif char *endPointer = NULL; float value; errno = 0; #ifdef HAVE_STRTOF_L value = strtof_l(UTF8String, &endPointer, cLocale); #else value = strtof(UTF8String, &endPointer); #endif if (value == HUGE_VALF) |
︙ | ︙ | |||
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 | const char *UTF8String = [self stringByReplacingOccurrencesOfString: @"." withString: decimalPoint].UTF8String; #endif char *endPointer = NULL; double value; #ifdef HAVE_STRTOD_L value = strtod_l(UTF8String, &endPointer, cLocale); #else value = strtod(UTF8String, &endPointer); #endif if (value == HUGE_VAL) | > | 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 | const char *UTF8String = [self stringByReplacingOccurrencesOfString: @"." withString: decimalPoint].UTF8String; #endif char *endPointer = NULL; double value; errno = 0; #ifdef HAVE_STRTOD_L value = strtod_l(UTF8String, &endPointer, cLocale); #else value = strtod(UTF8String, &endPointer); #endif if (value == HUGE_VAL) |
︙ | ︙ |