Overview
Comment: | macros.h: Add of_ascii_isspace() |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
dbdc12580248264734bf72fad6140f1e |
User & Date: | js on 2017-06-10 11:46:08 |
Other Links: | manifest | tags |
Context
2017-06-10
| ||
21:08 | OFFileManager: More use of native APIs on MorphOS check-in: f119b9dc07 user: js tags: trunk | |
11:46 | macros.h: Add of_ascii_isspace() check-in: dbdc125802 user: js tags: trunk | |
10:00 | Rename OFDeflateStream back to OFInflateStream check-in: f56a50ee50 user: js tags: trunk | |
Changes
Modified src/OFINIFile.m from [6eaed9a153] to [5212c0b9d0].
︙ | ︙ | |||
35 36 37 38 39 40 41 | static bool isWhitespaceLine(OFString *line) { const char *cString = [line UTF8String]; size_t length = [line UTF8StringLength]; | | | < < < < < < < < | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | static bool isWhitespaceLine(OFString *line) { const char *cString = [line UTF8String]; size_t length = [line UTF8StringLength]; for (size_t i = 0; i < length; i++) if (!of_ascii_isspace(cString[i])) return false; return true; } @implementation OFINIFile + (instancetype)fileWithPath: (OFString *)path { |
︙ | ︙ |
Modified src/OFMutableString.m from [b2395b2e90] to [7b8005c3d9].
︙ | ︙ | |||
261 262 263 264 265 266 267 | tableSize = middleTableSize; } if (c >> 8 < tableSize && table[c >> 8][c & 0xFF]) [self setCharacter: table[c >> 8][c & 0xFF] atIndex: i]; | < < < < < | < < < < < | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | tableSize = middleTableSize; } if (c >> 8 < tableSize && table[c >> 8][c & 0xFF]) [self setCharacter: table[c >> 8][c & 0xFF] atIndex: i]; isStart = of_ascii_isspace(c); } objc_autoreleasePoolPop(pool); } #else - (void)of_convertWithWordStartFunction: (char (*)(char))startFunction wordMiddleFunction: (char (*)(char))middleFunction |
︙ | ︙ | |||
294 295 296 297 298 299 300 | (isStart ? startFunction : middleFunction);; of_unichar_t c = characters[i]; if (c <= 0x7F) [self setCharacter: (int)function(c) atIndex: i]; | < < < < < | < < < < < | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | (isStart ? startFunction : middleFunction);; of_unichar_t c = characters[i]; if (c <= 0x7F) [self setCharacter: (int)function(c) atIndex: i]; isStart = of_ascii_isspace(c); } objc_autoreleasePoolPop(pool); } #endif - (void)setCharacter: (of_unichar_t)character |
︙ | ︙ | |||
566 567 568 569 570 571 572 | void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t i, length = [self length]; for (i = 0; i < length; i++) { of_unichar_t c = characters[i]; | | < | 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t i, length = [self length]; for (i = 0; i < length; i++) { of_unichar_t c = characters[i]; if (!of_ascii_isspace(c)) break; } objc_autoreleasePoolPop(pool); [self deleteCharactersInRange: of_range(0, i)]; } |
︙ | ︙ | |||
592 593 594 595 596 597 598 | return; pool = objc_autoreleasePoolPush(); characters = [self characters]; d = 0; for (p = characters + length - 1; p >= characters; p--) { | < | | 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | return; pool = objc_autoreleasePoolPush(); characters = [self characters]; d = 0; for (p = characters + length - 1; p >= characters; p--) { if (!of_ascii_isspace(*p)) break; d++; } objc_autoreleasePoolPop(pool); |
︙ | ︙ |
Modified src/OFMutableString_UTF8.m from [247368600b] to [4a3385c744].
︙ | ︙ | |||
75 76 77 78 79 80 81 | for (i = 0; i < _s->cStringLength; i++) { if (isStart) table = startTable; else table = middleTable; | < < < < < | < < < < < | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | for (i = 0; i < _s->cStringLength; i++) { if (isStart) table = startTable; else table = middleTable; isStart = of_ascii_isspace(_s->cString[i]); if ((t = table[0][(uint8_t)_s->cString[i]]) != 0) _s->cString[i] = t; } return; } |
︙ | ︙ | |||
123 124 125 126 127 128 129 | _s->cStringLength - i, &c); if (cLen <= 0 || c > 0x10FFFF) { [self freeMemory: unicodeString]; @throw [OFInvalidEncodingException exception]; } | < < < < < | < < < < < | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | _s->cStringLength - i, &c); if (cLen <= 0 || c > 0x10FFFF) { [self freeMemory: unicodeString]; @throw [OFInvalidEncodingException exception]; } isStart = of_ascii_isspace(c); if (c >> 8 < tableSize) { of_unichar_t tc = table[c >> 8][c & 0xFF]; if (tc) c = tc; } |
︙ | ︙ | |||
744 745 746 747 748 749 750 | } - (void)deleteLeadingWhitespaces { size_t i; for (i = 0; i < _s->cStringLength; i++) | < < | | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | } - (void)deleteLeadingWhitespaces { size_t i; for (i = 0; i < _s->cStringLength; i++) if (!of_ascii_isspace(_s->cString[i])) break; _s->hashed = false; _s->cStringLength -= i; _s->length -= i; memmove(_s->cString, _s->cString + i, _s->cStringLength); |
︙ | ︙ | |||
773 774 775 776 777 778 779 | size_t d; char *p; _s->hashed = false; d = 0; for (p = _s->cString + _s->cStringLength - 1; p >= _s->cString; p--) { | < | | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | size_t d; char *p; _s->hashed = false; d = 0; for (p = _s->cString + _s->cStringLength - 1; p >= _s->cString; p--) { if (!of_ascii_isspace(*p)) break; *p = '\0'; d++; } _s->cStringLength -= d; |
︙ | ︙ | |||
801 802 803 804 805 806 807 | size_t d, i; char *p; _s->hashed = false; d = 0; for (p = _s->cString + _s->cStringLength - 1; p >= _s->cString; p--) { | < | < < | | 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | size_t d, i; char *p; _s->hashed = false; d = 0; for (p = _s->cString + _s->cStringLength - 1; p >= _s->cString; p--) { if (!of_ascii_isspace(*p)) break; *p = '\0'; d++; } _s->cStringLength -= d; _s->length -= d; for (i = 0; i < _s->cStringLength; i++) if (!of_ascii_isspace(_s->cString[i])) break; _s->cStringLength -= i; _s->length -= i; memmove(_s->cString, _s->cString + i, _s->cStringLength); _s->cString[_s->cStringLength] = '\0'; |
︙ | ︙ |
Modified src/OFString.m from [51b9feaad9] to [b7816611b8].
︙ | ︙ | |||
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; } |
︙ | ︙ |
Modified src/macros.h from [1a378051a0] to [4e6153e065].
︙ | ︙ | |||
647 648 649 650 651 652 653 654 655 656 657 658 659 660 | } static OF_INLINE bool of_ascii_isalnum(char c) { return (of_ascii_isalpha(c) || (c >= '0' && c <= '9')); } static OF_INLINE char of_ascii_toupper(char c) { return (c >= 'a' && c <= 'z' ? 'A' + (c - 'a') : c); } | > > > > > > > | 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | } static OF_INLINE bool of_ascii_isalnum(char c) { return (of_ascii_isalpha(c) || (c >= '0' && c <= '9')); } static OF_INLINE bool of_ascii_isspace(char c) { return (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v'); } static OF_INLINE char of_ascii_toupper(char c) { return (c >= 'a' && c <= 'z' ? 'A' + (c - 'a') : c); } |
︙ | ︙ |
Modified src/of_strptime.m from [0c80605e9d] to [5a1ba51c70].
︙ | ︙ | |||
209 210 211 212 213 214 215 216 | break; case '%': if (buffer[j++] != '%') return NULL; break; case 'n': case 't': | > > > < < | < < | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | break; case '%': if (buffer[j++] != '%') return NULL; break; case 'n': if (buffer[j++] != '\n') return NULL; break; case 't': if (buffer[j++] != '\t') return NULL; break; } state = SEARCH_CONVERSION_SPECIFIER; break; } |
︙ | ︙ |