diff options
author | hobbs <hobbs> | 1999-09-21 04:20:28 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 1999-09-21 04:20:28 (GMT) |
commit | a583a768fbe40ec2b7d661fe32d8347a34632fcf (patch) | |
tree | 8063ba8ff9da4fa71559d95b2c2389d1a8b516c0 /generic/tclDate.c | |
parent | 1f66507f55794f140cf5952e6d45da60c066c014 (diff) | |
download | tcl-a583a768fbe40ec2b7d661fe32d8347a34632fcf.zip tcl-a583a768fbe40ec2b7d661fe32d8347a34632fcf.tar.gz tcl-a583a768fbe40ec2b7d661fe32d8347a34632fcf.tar.bz2 |
1999-09-16 Jeff Hobbs <hobbs@scriptics.com>
* tests/timer.test: changed after delay in timer test 6.29 from
1 to 10. [Bug: 2796]
* tests/pkg.test:
* generic/tclPkg.c: fixed package version check to disallow 1.2..3
[Bug: 2539]
* unix/Makefile.in: fixed gendate target - this never worked
since RCS was intro'd.
* generic/tclGetDate.y: updated to reflect previous changes
to tclDate.c (leap year calc) and added CEST and UCT time zone
recognition. Fixed 4 missing UCHAR() casts. [Bug: 2717, 954,
1245, 1249]
* generic/tclCkalloc.c: changed Tcl_DumpActiveMemory to really
dump to stderr and close it [Bug: 725] and changed Tcl_Ckrealloc
and Tcl_Ckfree to not bomb when NULL was passed in [Bug: 1719]
and changed Tcl_Alloc, et al to not panic when a alloc request
for zero came through and NULL was returned (valid on AIX, Tru64)
[Bug: 2795, etc]
* tests/clock.test:
* doc/clock.n:
* generic/tclClock.c: added -milliseconds switch to clock clicks
to guarantee that the return value of clicks is in the millisecs
granularity [Bug: 2682, 1332]
1999-09-15 Jeff Hobbs <hobbs@scriptics.com>
* generic/tclIOCmd.c: fixed potential core dump in conjunction
with stacked channels with result obj manipulation in
Tcl_ReadChars [Bug: 2623]
* tests/format.test:
* generic/tclCmdAH.c: fixed translation of %0#s in format [Bug: 2605]
* doc/msgcat.n: fixed \\ bug in example [Bug: 2548]
* unix/tcl.m4:
* unix/aclocal.m4: added fix for FreeBSD-[1-2] recognition
[Bug: 2070] and fix for IRIX SHLIB_LB_LIBS. [Bug: 2610]
* doc/array.n:
* tests/var.test:
* tests/set.test:
* generic/tclVar.c: added an array unset operation, with docs
and tests. Variation of [Bug: 1775]. Added fix in TclArraySet
to check when trying to set in a non-existent namespace. [Bug: 2613]
1999-09-14 Jeff Hobbs <hobbs@scriptics.com>
* tests/linsert.test:
* doc/linsert.n:
* generic/tclCmdIL.c: fixed end-int interpretation of linsert
to correctly calculate value for end, added test and docs [Bug: 2693]
* doc/regexp.n:
* doc/regsub.n:
* tests/regexp.test:
* generic/tclCmdMZ.c: add -start switch to regexp and regsub
with docs and tests
* doc/switch.n: added proper use of comments to example.
* generic/tclCmdMZ.c: changed switch to complain when an error
occurs that seems to be due to a misplaced comment.
* generic/tclCmdMZ.c: fixed illegal ref for \[0-9] substitutions
in regsub [Bug: 2723]
* generic/tclCmdMZ.c: changed [string equal] to return an Int
type object (was a Boolean)
Diffstat (limited to 'generic/tclDate.c')
-rw-r--r-- | generic/tclDate.c | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/generic/tclDate.c b/generic/tclDate.c index 3544737..3f8336a 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclDate.c,v 1.5 1999/05/14 18:29:50 stanton Exp $ + * RCS: @(#) $Id: tclDate.c,v 1.6 1999/09/21 04:20:40 hobbs Exp $ */ #include "tclInt.h" @@ -135,22 +135,27 @@ typedef union -#ifdef __cplusplus +#if defined(__cplusplus) || defined(__STDC__) + +#if defined(__cplusplus) && defined(__EXTERN_C__) +extern "C" { +#endif #ifndef TclDateerror +#if defined(__cplusplus) void TclDateerror(const char *); #endif - +#endif #ifndef TclDatelex -#ifdef __EXTERN_C__ - extern "C" { int TclDatelex(void); } -#else int TclDatelex(void); #endif -#endif int TclDateparse(void); +#if defined(__cplusplus) && defined(__EXTERN_C__) +} +#endif #endif + #define TclDateclearin TclDatechar = -1 #define TclDateerrok TclDateerrflag = 0 extern int TclDatechar; @@ -258,7 +263,8 @@ static TABLE TimezoneTable[] = { { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ { "utc", tZONE, HOUR( 0) }, - { "wet", tZONE, HOUR( 0) } , /* Western European */ + { "uct", tZONE, HOUR( 0) }, /* Universal Coordinated Time */ + { "wet", tZONE, HOUR( 0) }, /* Western European */ { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ { "wat", tZONE, HOUR( 1) }, /* West Africa */ { "at", tZONE, HOUR( 2) }, /* Azores */ @@ -290,6 +296,7 @@ static TABLE TimezoneTable[] = { { "nt", tZONE, HOUR(11) }, /* Nome */ { "idlw", tZONE, HOUR(12) }, /* International Date Line West */ { "cet", tZONE, -HOUR( 1) }, /* Central European */ + { "cest", tDAYZONE, -HOUR( 1) }, /* Central European Summer */ { "met", tZONE, -HOUR( 1) }, /* Middle European */ { "mewt", tZONE, -HOUR( 1) }, /* Middle European Winter */ { "mest", tDAYZONE, -HOUR( 1) }, /* Middle European Summer */ @@ -419,11 +426,11 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode, TimePtr) time_t Julian; int i; - DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) + DaysInMonth[1] = (Year % 4 == 0) && (Year % 100 != 0 || Year % 400 == 0) ? 29 : 28; if (Month < 1 || Month > 12 - || Year < START_OF_TIME || Year > END_OF_TIME - || Day < 1 || Day > DaysInMonth[(int)--Month]) + || Year < START_OF_TIME || Year > END_OF_TIME + || Day < 1 || Day > DaysInMonth[(int)--Month]) return -1; for (Julian = Day - 1, i = 0; i < Month; i++) @@ -656,14 +663,14 @@ TclDatelex() int sign; for ( ; ; ) { - while (isspace((unsigned char) (*TclDateInput))) { + while (isspace(UCHAR(*TclDateInput))) { TclDateInput++; } - if (isdigit(c = *TclDateInput) || c == '-' || c == '+') { /* INTL: digit */ + if (isdigit(UCHAR(c = *TclDateInput)) || c == '-' || c == '+') { /* INTL: digit */ if (c == '-' || c == '+') { sign = c == '-' ? -1 : 1; - if (!isdigit(*++TclDateInput)) { /* INTL: digit */ + if (!isdigit(UCHAR(*++TclDateInput))) { /* INTL: digit */ /* * skip the '-' sign */ @@ -673,7 +680,7 @@ TclDatelex() sign = 0; } for (TclDatelval.Number = 0; - isdigit(c = *TclDateInput++); ) { /* INTL: digit */ + isdigit(UCHAR(c = *TclDateInput++)); ) { /* INTL: digit */ TclDatelval.Number = 10 * TclDatelval.Number + c - '0'; } TclDateInput--; @@ -683,7 +690,7 @@ TclDatelex() return sign ? tSNUMBER : tUNUMBER; } if (!(c & 0x80) && isalpha(UCHAR(c))) { /* INTL: ISO only. */ - for (p = buff; isalpha(c = *TclDateInput++) /* INTL: ISO only. */ + for (p = buff; isalpha(UCHAR(c = *TclDateInput++)) /* INTL: ISO only. */ || c == '.'; ) { if (p < &buff[sizeof buff - 1]) { *p++ = c; @@ -803,14 +810,14 @@ TclGetDate(p, now, zone, timePtr) *timePtr = Start; return 0; } -TclDatetabelem TclDateexca[] ={ +static const TclDatetabelem TclDateexca[] ={ -1, 1, 0, -1, -2, 0, }; # define YYNPROD 41 # define YYLAST 227 -TclDatetabelem TclDateact[]={ +static const TclDatetabelem TclDateact[]={ 14, 11, 23, 28, 17, 12, 19, 18, 16, 9, 10, 13, 42, 21, 46, 45, 44, 48, 41, 37, @@ -835,39 +842,39 @@ TclDatetabelem TclDateact[]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 20, 25, 24, 27, 26, 42, 0, 0, 0, 0, 40 }; -TclDatetabelem TclDatepact[]={ +static const TclDatetabelem TclDatepact[]={ -10000000, -258,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000, -45, -267,-10000000, -244,-10000000, -14, -231, -240,-10000000,-10000000,-10000000, -10000000, -246,-10000000, -247, -248,-10000000,-10000000,-10000000,-10000000, -15, -10000000,-10000000,-10000000,-10000000,-10000000, -40, -20,-10000000, -251,-10000000, -10000000, -252,-10000000, -253,-10000000, -249,-10000000,-10000000,-10000000 }; -TclDatetabelem TclDatepgo[]={ +static const TclDatetabelem TclDatepgo[]={ 0, 28, 39, 38, 37, 36, 35, 34, 33, 32, 31 }; -TclDatetabelem TclDater1[]={ +static const TclDatetabelem TclDater1[]={ 0, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 1, 1 }; -TclDatetabelem TclDater2[]={ +static const TclDatetabelem TclDater2[]={ 0, 0, 4, 3, 3, 3, 3, 3, 2, 5, 9, 9, 13, 13, 5, 3, 3, 3, 5, 5, 7, 11, 5, 9, 5, 3, 7, 5, 2, 5, 5, 3, 5, 5, 3, 5, 5, 3, 3, 1, 3 }; -TclDatetabelem TclDatechk[]={ +static const TclDatetabelem TclDatechk[]={ -10000000, -2, -3, -4, -5, -6, -7, -8, -9, 267, 268, 259, 263, 269, 258, -10, 266, 262, 265, 264, 261, 58, 258, 47, 263, 262, 265, 264, 270, 267, 44, 257, 262, 265, 264, 267, 267, 267, 44, -1, 266, 58, 261, 47, 267, 267, 267, -1, 266 }; -TclDatetabelem TclDatedef[]={ +static const TclDatetabelem TclDatedef[]={ 1, -2, 2, 3, 4, 5, 6, 7, 8, 38, 15, 16, 0, 25, 17, 28, 0, 31, 34, 37, @@ -979,7 +986,7 @@ char * TclDatereds[] = #define YYRECOVERING() (!!TclDateerrflag) #define YYNEW(type) malloc(sizeof(type) * TclDatenewmax) #define YYCOPY(to, from, type) \ - (type *) memcpy(to, (char *) from, TclDatenewmax * sizeof(type)) + (type *) memcpy(to, (char *) from, TclDatemaxdepth * sizeof (type)) #define YYENLARGE( from, type) \ (type *) realloc((char *) from, TclDatenewmax * sizeof(type)) #ifndef YYDEBUG @@ -1063,12 +1070,12 @@ int TclDateparse(void) int TclDateparse() #endif { - register YYSTYPE *TclDatepvt; /* top of value stack for $vars */ + register YYSTYPE *TclDatepvt = 0; /* top of value stack for $vars */ #if defined(__cplusplus) || defined(lint) /* - hacks to please C++ and lint - goto's inside switch should never be - executed; TclDatepvt is set to 0 to avoid "used before set" warning. + hacks to please C++ and lint - goto's inside + switch should never be executed */ static int __yaccpar_lint_hack__ = 0; switch (__yaccpar_lint_hack__) @@ -1076,7 +1083,6 @@ int TclDateparse() case 1: goto TclDateerrlab; case 2: goto TclDatenewstate; } - TclDatepvt = 0; #endif /* @@ -1167,9 +1173,9 @@ int TclDateparse() ** reallocate and recover. Note that pointers ** have to be reset, or bad things will happen */ - int TclDateps_index = (TclDate_ps - TclDates); - int TclDatepv_index = (TclDate_pv - TclDatev); - int TclDatepvt_index = (TclDatepvt - TclDatev); + long TclDateps_index = (TclDate_ps - TclDates); + long TclDatepv_index = (TclDate_pv - TclDatev); + long TclDatepvt_index = (TclDatepvt - TclDatev); int TclDatenewmax; #ifdef YYEXPAND TclDatenewmax = YYEXPAND(TclDatemaxdepth); @@ -1295,7 +1301,7 @@ int TclDateparse() ** look through exception table */ { - register int *TclDatexi = TclDateexca; + register const int *TclDatexi = TclDateexca; while ( ( *TclDatexi != -1 ) || ( TclDatexi[1] != TclDate_state ) ) @@ -1572,10 +1578,10 @@ case 24:{ TclDateDay = TclDatepvt[-1].Number; } break; case 25:{ - TclDateMonth = 1; - TclDateDay = 1; - TclDateYear = EPOCH; - } break; + TclDateMonth = 1; + TclDateDay = 1; + TclDateYear = EPOCH; + } break; case 26:{ TclDateMonth = TclDatepvt[-1].Number; TclDateDay = TclDatepvt[-2].Number; |