* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ctime.c 5.23 (Berkeley) 6/22/90";
-#endif /* LIBC_SCCS and not lint */
-
/*
** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
** POSIX-style TZ environment variable handling from Guy Harris
** (guy@auspex.com).
*/
-
-
-
-#include <crtdll/fcntl.h>
-#include <crtdll/time.h>
-#include <crtdll/string.h>
-#include <crtdll/ctype.h>
-#include <crtdll/stdio.h>
-#include <crtdll/stdlib.h>
+#include <msvcrt/fcntl.h>
+#include <msvcrt/time.h>
+#include <msvcrt/string.h>
+#include <msvcrt/ctype.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/stdlib.h>
#include <windows.h>
#include "tzfile.h"
-#include <crtdll/io.h>
+#include <msvcrt/io.h>
#include "posixrul.h"
+
+#ifdef __cplusplus
+#define CPP_CONST const
+#else
+#define CPP_CONST
+#endif
+
#define P(s) s
#define alloc_size_t size_t
#define qsort_size_t size_t
** manual page of what this "time zone abbreviation" means (doing this so
** that tzname[0] has the "normal" length of three characters).
*/
-int _daylight_dll;
-int _timezone_dll;
+
+void _set_daylight_export(int);
+void _set_timezone_export(int);
+
static char WILDABBR[] = " ";
/*
** Prototypes for static functions.
*/
-
+#if 0
static long detzcode P((const char * codep));
static const char * getzname P((const char * strp));
-static const char * getnum P((const char * strp, int * nump, int min,
- int max));
+static const char * getnum P((const char * strp, int * nump, int min, int max));
static const char * getsecs P((const char * strp, long * secsp));
static const char * getoffset P((const char * strp, long * offsetp));
static const char * getrule P((const char * strp, struct rule * rulep));
static void gmtload P((struct state * sp));
-static void gmtsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static void localsub P((const time_t * timep, long offset,
- struct tm * tmp));
+static void gmtsub P((const time_t * timep, long offset, struct tm * tmp));
+static void localsub P((const time_t * timep, long offset, struct tm * tmp));
static void normalize P((int * tensptr, int * unitsptr, int base));
static void settzname P((void));
-static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * const, const long, struct tm * const),
- long offset));
-static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * const, const long, struct tm * const),
- long offset, int * okayp));
-static void timesub P((const time_t * timep, long offset,
- const struct state * sp, struct tm * tmp));
-static int tmcomp P((const struct tm * atmp,
- const struct tm * btmp));
-static time_t transtime P((time_t janfirst, int year,
- const struct rule * rulep, long offset));
+static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset));
+static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset, int * okayp));
+static void timesub P((const time_t * timep, long offset, const struct state * sp, struct tm * tmp));
+static int tmcomp P((const struct tm * atmp, const struct tm * btmp));
+static time_t transtime P((time_t janfirst, int year, const struct rule * rulep, long offset));
static int tzload P((const char * name, struct state * sp));
-static int tzparse P((const char * name, struct state * sp,
- int lastditch));
+static int tzparse P((const char * name, struct state * sp, int lastditch));
static void tzsetwall(void);
+#else
+
+static const char * getnum(const char * strp, int * CPP_CONST nump, const int min, const int max);
+static void timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp);
+static time_t transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset);
+static void tzsetwall(void);
+
+#endif
+
#ifdef ALL_STATE
static struct state *lclptr;
static struct state *gmtptr;
};
static long
-detzcode(const char * const codep)
+detzcode(const char * CPP_CONST codep)
{
long result;
int i;
static void
settzname(void)
{
- const struct state * const sp = lclptr;
+ const struct state * CPP_CONST sp = lclptr;
int i;
_tzname[0] = WILDABBR;
#endif /* defined ALL_STATE */
for (i = 0; i < sp->typecnt; ++i)
{
- register const struct ttinfo * const ttisp = &sp->ttis[i];
+ register const struct ttinfo * CPP_CONST ttisp = &sp->ttis[i];
_tzname[ttisp->tt_isdst] =
(char *)&sp->chars[ttisp->tt_abbrind];
#if 0
- if (ttisp->tt_isdst)
- _daylight = 1;
- if (i == 0 || !ttisp->tt_isdst)
- _timezone_dll = -(ttisp->tt_gmtoff);
- if (i == 0 || ttisp->tt_isdst)
+ if (ttisp->tt_isdst) {
+ //_daylight = 1;
+ _set_daylight_export(1);
+ }
+ if (i == 0 || !ttisp->tt_isdst) {
+ //_timezone_dll = -(ttisp->tt_gmtoff);
+ _set_timezone_export(-(ttisp->tt_gmtoff));
+ }
+ if (i == 0 || ttisp->tt_isdst) {
_altzone = -(ttisp->tt_gmtoff);
+ }
#endif
}
/*
*/
for (i = 0; i < sp->timecnt; ++i)
{
- const struct ttinfo * const ttisp = &sp->ttis[sp->types[i]];
+ const struct ttinfo * CPP_CONST ttisp = &sp->ttis[sp->types[i]];
_tzname[ttisp->tt_isdst] = (char *)&sp->chars[ttisp->tt_abbrind];
}
}
static int
-tzload(const char *name, struct state * const sp)
+tzload(const char *name, struct state * CPP_CONST sp)
{
const char * p;
int i;
*/
static const char *
-getnum(const char *strp, int * const nump, const int min, const int max)
+getnum(const char *strp, int * CPP_CONST nump, const int min, const int max)
{
char c;
int num;
*/
static const char *
-getsecs(const char *strp, long * const secsp)
+getsecs(const char *strp, long * CPP_CONST secsp)
{
int num;
*/
static const char *
-getoffset(const char *strp, long * const offsetp)
+getoffset(const char *strp, long * CPP_CONST offsetp)
{
int neg;
*/
static const char *
-getrule(const char *strp, struct rule * const rulep)
+getrule(const char *strp, struct rule * CPP_CONST rulep)
{
if (*strp == 'J')
{
*/
static time_t
-transtime(const time_t janfirst, const int year, const struct rule * const rulep, const long offset)
+transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset)
{
int leapyear;
time_t value=0;
*/
static int
-tzparse(const char *name, struct state * const sp, const int lastditch)
+tzparse(const char *name, struct state * CPP_CONST sp, const int lastditch)
{
const char * stdname;
const char * dstname=0;
}
static void
-gmtload(struct state * const sp)
+gmtload(struct state * CPP_CONST sp)
{
if (tzload(GMT, sp) != 0)
(void) tzparse(GMT, sp, TRUE);
/*ARGSUSED*/
static void
-localsub(const time_t * const timep, const long offset, struct tm * const tmp)
+localsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp)
{
const struct state * sp;
const struct ttinfo * ttisp;
}
struct tm *
-localtime(const time_t * const timep)
+localtime(const time_t * CPP_CONST timep)
{
static struct tm tm;
*/
static void
-gmtsub(const time_t * const timep, const long offset, struct tm * const tmp)
+gmtsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp)
{
if (!gmt_is_set)
{
}
struct tm *
-gmtime(const time_t * const timep)
+gmtime(const time_t * CPP_CONST timep)
{
static struct tm tm;
}
static void
-timesub(const time_t * const timep, const long offset, const struct state * const sp, struct tm * const tmp)
+timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp)
{
const struct lsinfo * lp;
long days;
}
char *
-ctime(const time_t * const timep)
+ctime(const time_t * CPP_CONST timep)
{
return asctime(localtime(timep));
}
#endif /* !defined WRONG */
static void
-normalize(int * const tensptr, int * const unitsptr, const int base)
+normalize(int * CPP_CONST tensptr, int * CPP_CONST unitsptr, const int base)
{
if (*unitsptr >= base)
{
}
static int
-tmcomp(const struct tm * const atmp, const struct tm * const btmp)
+tmcomp(const struct tm * CPP_CONST atmp, const struct tm * CPP_CONST btmp)
{
int result;
}
static time_t
-time2(struct tm *tmp, void (*const funcp)(const time_t *const,const long,struct tm *), const long offset, int * const okayp)
+time2(struct tm *tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset, int * CPP_CONST okayp)
{
const struct state * sp;
int dir;
** If time_t is signed, then 0 is the median value,
** if time_t is unsigned, then 1 << bits is median.
*/
+#ifdef _MSVCRT_LIB_
+ t = (time_t) ((1 << bits) - 1);
+#else // TODO: FIXME: review which is correct
t = (time_t) 1 << bits;
+#endif /*_MSVCRT_LIB_*/
+
for ( ; ; )
{
(*funcp)(&t, offset, &mytm);
}
static time_t
-time1(struct tm * const tmp, void (*const funcp)(const time_t * const, const long, struct tm *), const long offset)
+time1(struct tm * CPP_CONST tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset)
{
time_t t;
const struct state * sp;
{
return time1(tmp, localsub, 0L);
}
-
-
-
-