Subversion Repositories Tewi

Rev

Rev 182 | Rev 215 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 182 Rev 212
Line 33... Line 33...
33
 */
33
 */
34
 
34
 
35
//#include <sys/cdefs.h>
35
//#include <sys/cdefs.h>
36
//__RCSID("$NetBSD: strptime.c,v 1.62 2017/08/24 01:01:09 ginsbach Exp $");
36
//__RCSID("$NetBSD: strptime.c,v 1.62 2017/08/24 01:01:09 ginsbach Exp $");
37
 
37
 
38
#if defined(__MINGW32__)
38
#if defined(__MINGW32__) || defined(_MSC_VER)
39
 
39
 
40
#include <ctype.h>
40
#include <ctype.h>
41
#include <string.h>
41
#include <string.h>
42
#include <time.h>
42
#include <time.h>
43
#include <stdint.h>
43
#include <stdint.h>
Line 289... Line 289...
289
        case 'x':	/* The date, using the locale's format. */
289
        case 'x':	/* The date, using the locale's format. */
290
            /* fall throug */
290
            /* fall throug */
291
 
291
 
292
        case 'D':	/* The date as "%y/%m/%d". */
292
        case 'D':	/* The date as "%y/%m/%d". */
293
        {
293
        {
-
 
294
	    int year;
294
            new_fmt = HERE_D_FMT;
295
            new_fmt = HERE_D_FMT;
295
            LEGAL_ALT(0);
296
            LEGAL_ALT(0);
296
            state |= S_MON | S_MDAY | S_YEAR;
297
            state |= S_MON | S_MDAY | S_YEAR;
297
            const int year = split_year ? tm->tm_year : 0;
298
            year = split_year ? tm->tm_year : 0;
298
 
299
 
299
            bp = (const unsigned char *)strptime((const char *)bp,
300
            bp = (const unsigned char *)strptime((const char *)bp,
300
                                new_fmt, tm);
301
                                new_fmt, tm);
301
            LEGAL_ALT(ALT_E);
302
            LEGAL_ALT(ALT_E);
302
            tm->tm_year += year;
303
            tm->tm_year += year;
Line 396... Line 397...
396
            bp = conv_num(bp, &tm->tm_sec, 0, 61);
397
            bp = conv_num(bp, &tm->tm_sec, 0, 61);
397
            LEGAL_ALT(ALT_O);
398
            LEGAL_ALT(ALT_O);
398
            continue;
399
            continue;
399
 
400
 
400
#ifndef TIME_MAX
401
#ifndef TIME_MAX
-
 
402
#ifdef _MSC_VER
-
 
403
#define TIME_MAX	INT32_MAX
-
 
404
#else
401
#define TIME_MAX	INT64_MAX
405
#define TIME_MAX	INT64_MAX
402
#endif
406
#endif
-
 
407
#endif
403
        case 's':	/* seconds since the epoch */
408
        case 's':	/* seconds since the epoch */
404
            {
409
            {
405
                time_t sse = 0;
410
                time_t sse = 0;
-
 
411
#ifdef _MSC_VER
-
 
412
                uint32_t rulim = TIME_MAX;
-
 
413
#else
406
                uint64_t rulim = TIME_MAX;
414
                uint64_t rulim = TIME_MAX;
-
 
415
#endif
407
 
416
 
408
                if (*bp < '0' || *bp > '9') {
417
                if (*bp < '0' || *bp > '9') {
409
                    bp = NULL;
418
                    bp = NULL;
410
                    continue;
419
                    continue;
411
                }
420
                }
Line 414... Line 423...
414
                    sse *= 10;
423
                    sse *= 10;
415
                    sse += *bp++ - '0';
424
                    sse += *bp++ - '0';
416
                    rulim /= 10;
425
                    rulim /= 10;
417
                } while ((sse * 10 <= TIME_MAX) &&
426
                } while ((sse * 10 <= TIME_MAX) &&
418
                     rulim && *bp >= '0' && *bp <= '9');
427
                     rulim && *bp >= '0' && *bp <= '9');
-
 
428
#ifdef _MSC_VER
-
 
429
                if (sse < 0 || (uint32_t)sse > TIME_MAX) {
419
 
430
#else
420
                if (sse < 0 || (uint64_t)sse > TIME_MAX) {
431
                if (sse < 0 || (uint64_t)sse > TIME_MAX) {
-
 
432
#endif
421
                    bp = NULL;
433
                    bp = NULL;
422
                    continue;
434
                    continue;
423
                }
435
                }
424
#ifdef _WIN32
436
#ifdef _WIN32
-
 
437
#ifdef _MSC_VER
-
 
438
		if (1)
-
 
439
#else
425
                if (localtime_s(tm, &sse) == 0)
440
                if (localtime_s(tm, &sse) == 0)
-
 
441
#endif
426
#else
442
#else
427
                if (localtime_r(&sse, tm))
443
                if (localtime_r(&sse, tm))
428
#endif
444
#endif
429
                    state |= S_YDAY | S_WDAY | S_MON | S_MDAY | S_YEAR;
445
                    state |= S_YDAY | S_WDAY | S_MON | S_MDAY | S_YEAR;
430
                else
446
                else