Subversion Repositories Tewi

Rev

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

Rev 212 Rev 215
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__) || defined(_MSC_VER)
38
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
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 101... Line 101...
101
** We use this to avoid addition overflow problems.
101
** We use this to avoid addition overflow problems.
102
*/
102
*/
103
 
103
 
104
#define isleap_sum(a, b)	isleap((a) % 400 + (b) % 400)
104
#define isleap_sum(a, b)	isleap((a) % 400 + (b) % 400)
105
 
105
 
106
#ifdef _MSC_VER
106
#if defined(_MSC_VER) || defined(__BORLANDC__)
107
#define tzname              _tzname
107
#define tzname              _tzname
108
#define strncasecmp         _strnicmp
108
#define strncasecmp         _strnicmp
109
#endif
109
#endif
110
 
110
 
-
 
111
#ifdef __BORLANDC__
-
 
112
char* cm_strdup(const char* str);
-
 
113
 
-
 
114
int _strnicmp(const char* _a, const char* _b, int len){
-
 
115
	char* a = cm_strdup(_a);
-
 
116
	char* b = cm_strdup(_b);
-
 
117
	int i;
-
 
118
	char* r;
-
 
119
	for(i = 0; a[i] != 0; i++){
-
 
120
		a[i] = tolower(a[i]);
-
 
121
	}
-
 
122
	for(i = 0; b[i] != 0; i++){
-
 
123
		b[i] = tolower(b[i]);
-
 
124
	}
-
 
125
	r = strncmp(a, b, len);
-
 
126
	free(a);
-
 
127
	free(b);
-
 
128
	return r;
-
 
129
}
-
 
130
#endif
-
 
131
 
111
#ifdef TM_ZONE
132
#ifdef TM_ZONE
112
static char* utc = "UTC";
133
static char* utc = "UTC";
113
#endif
134
#endif
114
/* RFC-822/RFC-2822 */
135
/* RFC-822/RFC-2822 */
115
static const char* const nast[] = {
136
static const char* const nast[] = {
Line 397... Line 418...
397
            bp = conv_num(bp, &tm->tm_sec, 0, 61);
418
            bp = conv_num(bp, &tm->tm_sec, 0, 61);
398
            LEGAL_ALT(ALT_O);
419
            LEGAL_ALT(ALT_O);
399
            continue;
420
            continue;
400
 
421
 
401
#ifndef TIME_MAX
422
#ifndef TIME_MAX
402
#ifdef _MSC_VER
423
#if defined(_MSC_VER) || defined(__BORLANDC__)
403
#define TIME_MAX	INT32_MAX
424
#define TIME_MAX	INT32_MAX
404
#else
425
#else
405
#define TIME_MAX	INT64_MAX
426
#define TIME_MAX	INT64_MAX
406
#endif
427
#endif
407
#endif
428
#endif
408
        case 's':	/* seconds since the epoch */
429
        case 's':	/* seconds since the epoch */
409
            {
430
            {
410
                time_t sse = 0;
431
                time_t sse = 0;
411
#ifdef _MSC_VER
432
#if defined(_MSC_VER) || defined(__BORLANDC__)
412
                uint32_t rulim = TIME_MAX;
433
                uint32_t rulim = TIME_MAX;
413
#else
434
#else
414
                uint64_t rulim = TIME_MAX;
435
                uint64_t rulim = TIME_MAX;
415
#endif
436
#endif
416
 
437
 
Line 423... Line 444...
423
                    sse *= 10;
444
                    sse *= 10;
424
                    sse += *bp++ - '0';
445
                    sse += *bp++ - '0';
425
                    rulim /= 10;
446
                    rulim /= 10;
426
                } while ((sse * 10 <= TIME_MAX) &&
447
                } while ((sse * 10 <= TIME_MAX) &&
427
                     rulim && *bp >= '0' && *bp <= '9');
448
                     rulim && *bp >= '0' && *bp <= '9');
428
#ifdef _MSC_VER
449
#if defined(_MSC_VER) || defined(__BORLANDC__)
429
                if (sse < 0 || (uint32_t)sse > TIME_MAX) {
450
                if (sse < 0 || (uint32_t)sse > TIME_MAX) {
430
#else
451
#else
431
                if (sse < 0 || (uint64_t)sse > TIME_MAX) {
452
                if (sse < 0 || (uint64_t)sse > TIME_MAX) {
432
#endif
453
#endif
433
                    bp = NULL;
454
                    bp = NULL;
434
                    continue;
455
                    continue;
435
                }
456
                }
436
#ifdef _WIN32
457
#ifdef _WIN32
437
#ifdef _MSC_VER
458
#if defined(_MSC_VER) || defined(__BORLANDC__)
438
		if (1)
459
		if (1)
439
#else
460
#else
440
                if (localtime_s(tm, &sse) == 0)
461
                if (localtime_s(tm, &sse) == 0)
441
#endif
462
#endif
442
#else
463
#else