Differences From Artifact [51b9feaad9]:
- File
src/OFString.m
— part of check-in
[c9621825fc]
at
2017-06-04 18:48:03
on branch trunk
— Treat MorphOS + ixemul as a separate platform
This reduces the ifdef hell and makes much more sense, as with ixemul,
no native calls are allowed. (user: js, size: 65474) [annotate] [blame] [check-ins using]
To Artifact [b7816611b8]:
- File src/OFString.m — part of check-in [dbdc125802] at 2017-06-10 11:46:08 on branch trunk — macros.h: Add of_ascii_isspace() (user: js, size: 64232) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
2348 2349 2350 2351 2352 2353 2354 | { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t i = 0, length = [self length]; intmax_t value = 0; bool expectWhitespace = false; | | < < < | > | | < < < | | 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 | { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t i = 0, length = [self length]; intmax_t value = 0; bool expectWhitespace = false; while (length > 0 && of_ascii_isspace(*characters)) { characters++; length--; } if (length == 0) { objc_autoreleasePoolPop(pool); return 0; } if (characters[0] == '-' || characters[0] == '+') i++; for (; i < length; i++) { if (expectWhitespace) { 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 (of_ascii_isspace(characters[i])) expectWhitespace = true; else @throw [OFInvalidFormatException exception]; } if (characters[0] == '-') value *= -1; |
︙ | ︙ | |||
2402 2403 2404 2405 2406 2407 2408 | { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t i = 0, length = [self length]; uintmax_t value = 0; bool expectWhitespace = false, foundValue = false; | | < < < | > | | < | | < | 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 | { void *pool = objc_autoreleasePoolPush(); 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 && of_ascii_isspace(*characters)) { characters++; length--; } if (length == 0) { objc_autoreleasePoolPop(pool); return 0; } if (length >= 2 && characters[0] == '0' && characters[1] == 'x') i = 2; else if (length >= 1 && (characters[0] == 'x' || characters[0] == '$')) i = 1; for (; i < length; i++) { uintmax_t newValue; if (expectWhitespace) { 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; } else if (characters[i] >= 'A' && characters[i] <= 'F') { 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' || of_ascii_isspace(characters[i])) { expectWhitespace = true; continue; } else @throw [OFInvalidFormatException exception]; if (newValue < value) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
2469 2470 2471 2472 2473 2474 2475 | { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t i = 0, length = [self length]; uintmax_t value = 0; bool expectWhitespace = false; | | < < < | > | | < < < | | 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 | { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t i = 0, length = [self length]; uintmax_t value = 0; bool expectWhitespace = false; while (length > 0 && of_ascii_isspace(*characters)) { characters++; length--; } if (length == 0) { objc_autoreleasePoolPop(pool); return 0; } for (; i < length; i++) { uintmax_t newValue; if (expectWhitespace) { 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 (of_ascii_isspace(characters[i])) { expectWhitespace = true; continue; } else @throw [OFInvalidFormatException exception]; if (newValue < value) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
2543 2544 2545 2546 2547 2548 2549 | const char *UTF8String = [[self stringByReplacingOccurrencesOfString: @"." withString: decimalPoint] UTF8String]; #endif char *endPointer = NULL; float value; | | < < < | | 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 | const char *UTF8String = [[self stringByReplacingOccurrencesOfString: @"." withString: decimalPoint] UTF8String]; #endif char *endPointer = NULL; float value; while (of_ascii_isspace(*UTF8String)) UTF8String++; #ifdef HAVE_STRTOF_L value = strtof_l(UTF8String, &endPointer, cLocale); #else value = strtof(UTF8String, &endPointer); #endif /* Check if there are any invalid chars left */ if (endPointer != NULL) for (; *endPointer != '\0'; endPointer++) if (!of_ascii_isspace(*endPointer)) @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return value; } |
︙ | ︙ | |||
2596 2597 2598 2599 2600 2601 2602 | const char *UTF8String = [[self stringByReplacingOccurrencesOfString: @"." withString: decimalPoint] UTF8String]; #endif char *endPointer = NULL; double value; | | < < < | | 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 | const char *UTF8String = [[self stringByReplacingOccurrencesOfString: @"." withString: decimalPoint] UTF8String]; #endif char *endPointer = NULL; double value; while (of_ascii_isspace(*UTF8String)) UTF8String++; #ifdef HAVE_STRTOD_L value = strtod_l(UTF8String, &endPointer, cLocale); #else value = strtod(UTF8String, &endPointer); #endif /* Check if there are any invalid chars left */ if (endPointer != NULL) for (; *endPointer != '\0'; endPointer++) if (!of_ascii_isspace(*endPointer)) @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return value; } |
︙ | ︙ |