OLD | NEW |
1 #include "time_impl.h" | 1 #include "time_impl.h" |
2 #include <errno.h> | 2 #include <errno.h> |
3 | 3 |
4 time_t mktime(struct tm *tm) | 4 time_t mktime(struct tm* tm) { |
5 { | 5 struct tm new; |
6 » struct tm new; | 6 long opp; |
7 » long opp; | 7 long long t = __tm_to_secs(tm); |
8 » long long t = __tm_to_secs(tm); | |
9 | 8 |
10 » __secs_to_zone(t, 1, &new.tm_isdst, &new.__tm_gmtoff, &opp, &new.__tm_zo
ne); | 9 __secs_to_zone(t, 1, &new.tm_isdst, &new.__tm_gmtoff, &opp, &new.__tm_zone); |
11 | 10 |
12 » if (tm->tm_isdst>=0 && new.tm_isdst!=tm->tm_isdst) | 11 if (tm->tm_isdst >= 0 && new.tm_isdst != tm->tm_isdst) |
13 » » t -= opp - new.__tm_gmtoff; | 12 t -= opp - new.__tm_gmtoff; |
14 | 13 |
15 » t -= new.__tm_gmtoff; | 14 t -= new.__tm_gmtoff; |
16 » if ((time_t)t != t) goto error; | 15 if ((time_t)t != t) |
| 16 goto error; |
17 | 17 |
18 » __secs_to_zone(t, 0, &new.tm_isdst, &new.__tm_gmtoff, &opp, &new.__tm_zo
ne); | 18 __secs_to_zone(t, 0, &new.tm_isdst, &new.__tm_gmtoff, &opp, &new.__tm_zone); |
19 | 19 |
20 » if (__secs_to_tm(t + new.__tm_gmtoff, &new) < 0) goto error; | 20 if (__secs_to_tm(t + new.__tm_gmtoff, &new) < 0) |
| 21 goto error; |
21 | 22 |
22 » *tm = new; | 23 *tm = new; |
23 » return t; | 24 return t; |
24 | 25 |
25 error: | 26 error: |
26 » errno = EOVERFLOW; | 27 errno = EOVERFLOW; |
27 » return -1; | 28 return -1; |
28 } | 29 } |
OLD | NEW |