Overview
Comment: | Use trunc() instead of floor() in several places
floor() does not have the desired effect here when the number is |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3c20dd5f95671ab27fe23569f1fb96dd |
User & Date: | js on 2018-05-26 14:46:35 |
Other Links: | manifest | tags |
Context
2018-05-26
| ||
14:49 | Remove #define INTUITION_CLASSES_H hack check-in: b31bd48f90 user: js tags: trunk | |
14:46 | Use trunc() instead of floor() in several places check-in: 3c20dd5f95 user: js tags: trunk | |
14:43 | MessagePack: Add support for the date extension check-in: 3395923962 user: js tags: trunk | |
Changes
Modified src/OFDate.m from [8b281f77b2] to [a3e5369167].
︙ | ︙ | |||
47 48 49 50 51 52 53 | #endif #ifdef HAVE_GMTIME_R # define GMTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm tm; \ \ | | | | | | | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | #endif #ifdef HAVE_GMTIME_R # define GMTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm tm; \ \ if (seconds != trunc(_seconds)) \ @throw [OFOutOfRangeException exception]; \ \ if (gmtime_r(&seconds, &tm) == NULL) \ @throw [OFOutOfRangeException exception]; \ \ return tm.field; # define LOCALTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm tm; \ \ if (seconds != trunc(_seconds)) \ @throw [OFOutOfRangeException exception]; \ \ if (localtime_r(&seconds, &tm) == NULL) \ @throw [OFOutOfRangeException exception]; \ \ return tm.field; #else # ifdef OF_HAVE_THREADS # define GMTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ if (seconds != trunc(_seconds)) \ @throw [OFOutOfRangeException exception]; \ \ [mutex lock]; \ \ @try { \ if ((tm = gmtime(&seconds)) == NULL) \ @throw [OFOutOfRangeException exception]; \ \ return tm->field; \ } @finally { \ [mutex unlock]; \ } # define LOCALTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ if (seconds != trunc(_seconds)) \ @throw [OFOutOfRangeException exception]; \ \ [mutex lock]; \ \ @try { \ if ((tm = localtime(&seconds)) == NULL) \ @throw [OFOutOfRangeException exception]; \ \ return tm->field; \ } @finally { \ [mutex unlock]; \ } # else # define GMTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ if (seconds != trunc(_seconds)) \ @throw [OFOutOfRangeException exception]; \ \ if ((tm = gmtime(&seconds)) == NULL) \ @throw [OFOutOfRangeException exception]; \ \ return tm->field; # define LOCALTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ if (seconds != trunc(_seconds)) \ @throw [OFOutOfRangeException exception]; \ \ if ((tm = localtime(&seconds)) == NULL) \ @throw [OFOutOfRangeException exception]; \ \ return tm->field; # endif |
︙ | ︙ | |||
497 498 499 500 501 502 503 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (uint32_t)microsecond { | | | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (uint32_t)microsecond { return (uint32_t)((_seconds - trunc(_seconds)) * 1000000); } - (uint8_t)second { GMTIME_RET(tm_sec) } |
︙ | ︙ | |||
587 588 589 590 591 592 593 | size_t pageSize; #ifndef OF_WINDOWS char *buffer; #else wchar_t *buffer; #endif | | | 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | size_t pageSize; #ifndef OF_WINDOWS char *buffer; #else wchar_t *buffer; #endif if (seconds != trunc(_seconds)) @throw [OFOutOfRangeException exception]; #ifdef HAVE_GMTIME_R if (gmtime_r(&seconds, &tm) == NULL) @throw [OFOutOfRangeException exception]; #else # ifdef OF_HAVE_THREADS |
︙ | ︙ | |||
647 648 649 650 651 652 653 | size_t pageSize; #ifndef OF_WINDOWS char *buffer; #else wchar_t *buffer; #endif | | | 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | size_t pageSize; #ifndef OF_WINDOWS char *buffer; #else wchar_t *buffer; #endif if (seconds != trunc(_seconds)) @throw [OFOutOfRangeException exception]; #ifdef HAVE_LOCALTIME_R if (localtime_r(&seconds, &tm) == NULL) @throw [OFOutOfRangeException exception]; #else # ifdef OF_HAVE_THREADS |
︙ | ︙ |
Modified src/OFThread.m from [9adc83c2c8] to [a7a9564a2b].
︙ | ︙ | |||
200 201 202 203 204 205 206 | Sleep((unsigned int)(timeInterval * 1000)); #elif defined(HAVE_NANOSLEEP) struct timespec rqtp; rqtp.tv_sec = (time_t)timeInterval; rqtp.tv_nsec = lrint((timeInterval - rqtp.tv_sec) * 1000000000); | | | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | Sleep((unsigned int)(timeInterval * 1000)); #elif defined(HAVE_NANOSLEEP) struct timespec rqtp; rqtp.tv_sec = (time_t)timeInterval; rqtp.tv_nsec = lrint((timeInterval - rqtp.tv_sec) * 1000000000); if (rqtp.tv_sec != trunc(timeInterval)) @throw [OFOutOfRangeException exception]; nanosleep(&rqtp, NULL); #elif defined(OF_AMIGAOS) if (timeInterval * 50 > ULONG_MAX) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
229 230 231 232 233 234 235 | svcSleepThread((int64_t)(timeInterval * 1000000000)); #else if (timeInterval > UINT_MAX) @throw [OFOutOfRangeException exception]; sleep((unsigned int)timeInterval); usleep((unsigned int)lrint( | | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | svcSleepThread((int64_t)(timeInterval * 1000000000)); #else if (timeInterval > UINT_MAX) @throw [OFOutOfRangeException exception]; sleep((unsigned int)timeInterval); usleep((unsigned int)lrint( (timeInterval - trunc(timeInterval)) * 1000000)); #endif } + (void)sleepUntilDate: (OFDate *)date { [self sleepForTimeInterval: [date timeIntervalSinceNow]]; } |
︙ | ︙ |
Modified utils/ofhttp/ProgressBar.m from [23f24c88de] to [87361df1da].
︙ | ︙ | |||
102 103 104 105 106 107 108 | (float)(_resumedFrom + _length) * 100; [of_stdout writeString: @"\r ▕"]; for (size_t i = 0; i < (size_t)bars; i++) [of_stdout writeString: @"█"]; if (bars < barWidth) { | | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | (float)(_resumedFrom + _length) * 100; [of_stdout writeString: @"\r ▕"]; for (size_t i = 0; i < (size_t)bars; i++) [of_stdout writeString: @"█"]; if (bars < barWidth) { float rem = bars - truncf(bars); if (rem >= 0.875) [of_stdout writeString: @"▉"]; else if (rem >= 0.75) [of_stdout writeString: @"▊"]; else if (rem >= 0.625) [of_stdout writeString: @"▋"]; |
︙ | ︙ |