| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: strptime.c,v 1.33 2009/05/24 02:25:43 ginsbach Exp $ */ | | 1 | /* $NetBSD: strptime.c,v 1.34 2009/12/14 05:51:56 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code was contributed to The NetBSD Foundation by Klaus Klein. | | 7 | * This code was contributed to The NetBSD Foundation by Klaus Klein. |
8 | * Heavily optimised by David Laight | | 8 | * Heavily optimised by David Laight |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -21,27 +21,27 @@ | | | @@ -21,27 +21,27 @@ |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | #if defined(LIBC_SCCS) && !defined(lint) | | 33 | #if defined(LIBC_SCCS) && !defined(lint) |
34 | __RCSID("$NetBSD: strptime.c,v 1.33 2009/05/24 02:25:43 ginsbach Exp $"); | | 34 | __RCSID("$NetBSD: strptime.c,v 1.34 2009/12/14 05:51:56 matt Exp $"); |
35 | #endif | | 35 | #endif |
36 | | | 36 | |
37 | #include "namespace.h" | | 37 | #include "namespace.h" |
38 | #include <sys/localedef.h> | | 38 | #include <sys/localedef.h> |
39 | #include <ctype.h> | | 39 | #include <ctype.h> |
40 | #include <locale.h> | | 40 | #include <locale.h> |
41 | #include <string.h> | | 41 | #include <string.h> |
42 | #include <time.h> | | 42 | #include <time.h> |
43 | #include <tzfile.h> | | 43 | #include <tzfile.h> |
44 | #include "private.h" | | 44 | #include "private.h" |
45 | | | 45 | |
46 | #ifdef __weak_alias | | 46 | #ifdef __weak_alias |
47 | __weak_alias(strptime,_strptime) | | 47 | __weak_alias(strptime,_strptime) |
| @@ -257,27 +257,27 @@ literal: | | | @@ -257,27 +257,27 @@ literal: |
257 | { | | 257 | { |
258 | time_t sse = 0; | | 258 | time_t sse = 0; |
259 | uint64_t rulim = TIME_MAX; | | 259 | uint64_t rulim = TIME_MAX; |
260 | | | 260 | |
261 | if (*bp < '0' || *bp > '9') { | | 261 | if (*bp < '0' || *bp > '9') { |
262 | bp = NULL; | | 262 | bp = NULL; |
263 | continue; | | 263 | continue; |
264 | } | | 264 | } |
265 | | | 265 | |
266 | do { | | 266 | do { |
267 | sse *= 10; | | 267 | sse *= 10; |
268 | sse += *bp++ - '0'; | | 268 | sse += *bp++ - '0'; |
269 | rulim /= 10; | | 269 | rulim /= 10; |
270 | } while ((sse * 10 <= TIME_MAX) && | | 270 | } while (((uint64_t)(sse * 10) <= TIME_MAX) && |
271 | rulim && *bp >= '0' && *bp <= '9'); | | 271 | rulim && *bp >= '0' && *bp <= '9'); |
272 | | | 272 | |
273 | if (sse < 0 || (uint64_t)sse > TIME_MAX) { | | 273 | if (sse < 0 || (uint64_t)sse > TIME_MAX) { |
274 | bp = NULL; | | 274 | bp = NULL; |
275 | continue; | | 275 | continue; |
276 | } | | 276 | } |
277 | | | 277 | |
278 | if (localtime_r(&sse, tm) == NULL) | | 278 | if (localtime_r(&sse, tm) == NULL) |
279 | bp = NULL; | | 279 | bp = NULL; |
280 | } | | 280 | } |
281 | continue; | | 281 | continue; |
282 | | | 282 | |
283 | case 'U': /* The week of year, beginning on sunday. */ | | 283 | case 'U': /* The week of year, beginning on sunday. */ |