diff options
-rw-r--r-- | doc/clock.n | 6 | ||||
-rw-r--r-- | generic/tclClock.c | 176 | ||||
-rw-r--r-- | generic/tclClockFmt.c | 239 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 22 | ||||
-rw-r--r-- | generic/tclDate.c | 12 | ||||
-rw-r--r-- | generic/tclDate.h | 10 | ||||
-rw-r--r-- | generic/tclEnsemble.c | 4 | ||||
-rw-r--r-- | generic/tclEnv.c | 2 | ||||
-rw-r--r-- | generic/tclExecute.c | 2 | ||||
-rw-r--r-- | generic/tclGetDate.y | 2 | ||||
-rw-r--r-- | generic/tclInt.h | 2 | ||||
-rw-r--r-- | generic/tclStrIdxTree.c | 36 | ||||
-rw-r--r-- | generic/tclStrIdxTree.h | 8 | ||||
-rw-r--r-- | library/clock.tcl | 112 | ||||
-rw-r--r-- | library/init.tcl | 6 | ||||
-rw-r--r-- | library/msgcat/msgcat.tcl | 125 | ||||
-rwxr-xr-x | library/reg/pkgIndex.tcl | 12 | ||||
-rw-r--r-- | tests/msgcat.test | 2 | ||||
-rw-r--r-- | unix/tclUnixTime.c | 2 | ||||
-rw-r--r-- | win/tclWinTime.c | 8 |
20 files changed, 374 insertions, 414 deletions
diff --git a/doc/clock.n b/doc/clock.n index 5d00aeb..dbe00ba 100644 --- a/doc/clock.n +++ b/doc/clock.n @@ -539,7 +539,7 @@ Common Era. \fB%Es\fR This affects similar to \fB%s\fR, but in opposition to \fB%s\fR it parses or formats local seconds (not the posix seconds). -Because \fB%s\fR has the same precedence as \fB%s\fR (uniquely determines +Because \fB%s\fR has the same precedence as \fB%s\fR (uniquely determines a point in time), it overrides all other input formats. .TP \fB%Ex\fR @@ -736,7 +736,7 @@ week number \fB%V\fR; programs should use \fB%G\fR for that purpose. On output, produces the current time zone, expressed in hours and minutes east (+hhmm) or west (\-hhmm) of Greenwich. On input, accepts a time zone specifier (see \fBTIME ZONES\fR below) that will be used to -determine the time zone (this token is optionally applicable on input, +determine the time zone (this token is optionally applicable on input, so the value is not mandatory and can be missing in input). .TP \fB%Z\fR @@ -951,7 +951,7 @@ precision of type of the token. In example below the second date-string contains "next January", therefore it results in next year but in January. And third date-string besides "January" contains also additionally "Fri", so it results in the nearest Friday. -Thus both win before "385 days" resp. make it more precise, because of higher +Thus both win before "385 days" resp. make it more precise, because of higher precision of this token types. .CS % clock format [clock scan "5 years 18 months 385 days" -base 0 -gmt 1] -gmt 1 diff --git a/generic/tclClock.c b/generic/tclClock.c index aeb4654..c38af6b 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -96,8 +96,8 @@ static int ClockConvertlocaltoutcObjCmd( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int ClockGetDateFields(ClientData clientData, - Tcl_Interp *interp, TclDateFields *fields, +static int ClockGetDateFields(ClientData clientData, + Tcl_Interp *interp, TclDateFields *fields, Tcl_Obj *timezoneObj, int changeover); static int ClockGetdatefieldsObjCmd( ClientData clientData, Tcl_Interp *interp, @@ -130,7 +130,7 @@ static int ClockScanCommit( ClientData clientData, register DateInfo *info, register ClockFmtScnCmdArgs *opts); static int ClockFreeScan( - register DateInfo *info, + register DateInfo *info, Tcl_Obj *strObj, ClockFmtScnCmdArgs *opts); static int ClockCalcRelTime( register DateInfo *info, ClockFmtScnCmdArgs *opts); @@ -267,10 +267,10 @@ TclClockInit( clientData = data; data->refCount++; } - cmdPtr = (Command *)Tcl_CreateObjCommand(interp, cmdName, + cmdPtr = (Command *)Tcl_CreateObjCommand(interp, cmdName, clockCmdPtr->objCmdProc, clientData, clockCmdPtr->clientData ? NULL : ClockDeleteCmdProc); - cmdPtr->compileProc = clockCmdPtr->compileProc ? + cmdPtr->compileProc = clockCmdPtr->compileProc ? clockCmdPtr->compileProc : TclCompileBasicMin0ArgCmd; } } @@ -386,7 +386,7 @@ NormTimezoneObj( { const char *tz; if ( timezoneObj == dataPtr->LastUnnormSetupTimeZone - && dataPtr->LastSetupTimeZone != NULL + && dataPtr->LastSetupTimeZone != NULL ) { return dataPtr->LastSetupTimeZone; } @@ -468,7 +468,7 @@ static inline Tcl_Obj * ClockGetCurrentLocale( ClockClientData *dataPtr, /* Client data containing literal pool */ Tcl_Interp *interp) /* Tcl interpreter */ -{ +{ if (Tcl_EvalObjv(interp, 1, &dataPtr->literals[LIT_GETCURRENTLOCALE], 0) != TCL_OK) { return NULL; } @@ -504,7 +504,7 @@ NormLocaleObj( { const char *loc; if ( localeObj == NULL || localeObj == dataPtr->CurrentLocale - || localeObj == dataPtr->literals[LIT_C] + || localeObj == dataPtr->literals[LIT_C] || localeObj == dataPtr->literals[LIT_CURRENT] ) { if (dataPtr->CurrentLocale == NULL) { @@ -555,8 +555,8 @@ NormLocaleObj( } *mcDictObj = dataPtr->CurrentLocaleDict; localeObj = dataPtr->CurrentLocale; - } - else + } + else if ( (localeObj->length == 6 /* system */ && strncasecmp(loc, Literals[LIT_SYSTEM], localeObj->length) == 0) @@ -565,8 +565,8 @@ NormLocaleObj( localeObj = ClockGetSystemLocale(dataPtr, interp); Tcl_SetObjRef(dataPtr->LastUsedLocale, localeObj); *mcDictObj = NULL; - } - else + } + else { *mcDictObj = NULL; } @@ -578,7 +578,7 @@ NormLocaleObj( * * ClockMCDict -- * - * Retrieves a localized storage dictionary object for the given + * Retrieves a localized storage dictionary object for the given * locale object. * * This corresponds with call `::tcl::clock::mcget locale`. @@ -600,13 +600,13 @@ ClockMCDict(ClockFmtScnCmdArgs *opts) /* if locale was not yet used */ if ( !(opts->flags & CLF_LOCALE_USED) ) { - + opts->localeObj = NormLocaleObj(opts->clientData, opts->interp, opts->localeObj, &opts->mcDictObj); - + if (opts->localeObj == NULL) { - Tcl_SetResult(opts->interp, - (char*)"locale not specified and no default locale set", TCL_STATIC); + Tcl_SetObjResult(opts->interp, + Tcl_NewStringObj("locale not specified and no default locale set", -1)); Tcl_SetErrorCode(opts->interp, "CLOCK", "badOption", NULL); return NULL; } @@ -617,7 +617,7 @@ ClockMCDict(ClockFmtScnCmdArgs *opts) int i; dataPtr->mcLiterals = ckalloc(MCLIT__END * sizeof(Tcl_Obj*)); for (i = 0; i < MCLIT__END; ++i) { - Tcl_InitObjRef(dataPtr->mcLiterals[i], + Tcl_InitObjRef(dataPtr->mcLiterals[i], Tcl_NewStringObj(MsgCtLiterals[i], -1)); } } @@ -672,7 +672,7 @@ ClockMCDict(ClockFmtScnCmdArgs *opts) MODULE_SCOPE Tcl_Obj * ClockMCGet( - ClockFmtScnCmdArgs *opts, + ClockFmtScnCmdArgs *opts, int mcKey) { ClockClientData *dataPtr = opts->clientData; @@ -685,7 +685,7 @@ ClockMCGet( return NULL; } - Tcl_DictObjGet(opts->interp, opts->mcDictObj, + Tcl_DictObjGet(opts->interp, opts->mcDictObj, dataPtr->mcLiterals[mcKey], &valObj); return valObj; /* or NULL in obscure case if Tcl_DictObjGet failed */ @@ -708,7 +708,7 @@ ClockMCGet( MODULE_SCOPE Tcl_Obj * ClockMCGetIdx( - ClockFmtScnCmdArgs *opts, + ClockFmtScnCmdArgs *opts, int mcKey) { ClockClientData *dataPtr = opts->clientData; @@ -725,8 +725,8 @@ ClockMCGetIdx( if (dataPtr->mcLitIdxs == NULL) { return NULL; } - - if (Tcl_DictObjGet(NULL, opts->mcDictObj, + + if (Tcl_DictObjGet(NULL, opts->mcDictObj, dataPtr->mcLitIdxs[mcKey], &valObj) != TCL_OK ) { return NULL; @@ -752,7 +752,7 @@ ClockMCGetIdx( MODULE_SCOPE int ClockMCSetIdx( - ClockFmtScnCmdArgs *opts, + ClockFmtScnCmdArgs *opts, int mcKey, Tcl_Obj *valObj) { ClockClientData *dataPtr = opts->clientData; @@ -768,12 +768,12 @@ ClockMCSetIdx( int i; dataPtr->mcLitIdxs = ckalloc(MCLIT__END * sizeof(Tcl_Obj*)); for (i = 0; i < MCLIT__END; ++i) { - Tcl_InitObjRef(dataPtr->mcLitIdxs[i], + Tcl_InitObjRef(dataPtr->mcLitIdxs[i], Tcl_NewStringObj(MsgCtLitIdxs[i], -1)); } } - return Tcl_DictObjPut(opts->interp, opts->mcDictObj, + return Tcl_DictObjPut(opts->interp, opts->mcDictObj, dataPtr->mcLitIdxs[mcKey], valObj); } @@ -804,7 +804,7 @@ ClockConfigureObjCmd( Tcl_Obj *const objv[]) /* Parameter vector */ { ClockClientData *dataPtr = clientData; - + static const char *const options[] = { "-system-tz", "-setup-tz", "-default-locale", "-clear", @@ -821,7 +821,7 @@ ClockConfigureObjCmd( int i; for (i = 1; i < objc; i++) { - if (Tcl_GetIndexFromObj(interp, objv[i++], options, + if (Tcl_GetIndexFromObj(interp, objv[i++], options, "option", 0, &optionIndex) != TCL_OK) { Tcl_SetErrorCode(interp, "CLOCK", "badOption", Tcl_GetString(objv[i-1]), NULL); @@ -838,8 +838,8 @@ ClockConfigureObjCmd( Tcl_UnsetObjRef(dataPtr->SystemSetupTZData); } dataPtr->LastTZEpoch = lastTZEpoch; - } - if (i+1 >= objc && dataPtr->SystemTimeZone != NULL + } + if (i+1 >= objc && dataPtr->SystemTimeZone != NULL && dataPtr->LastTZEpoch == lastTZEpoch) { Tcl_SetObjResult(interp, dataPtr->SystemTimeZone); } @@ -874,7 +874,7 @@ ClockConfigureObjCmd( Tcl_SetObjRef(dataPtr->AnySetupTimeZone, timezoneObj); Tcl_UnsetObjRef(dataPtr->AnySetupTZData); } - } + } break; } } @@ -906,7 +906,7 @@ ClockConfigureObjCmd( continue; } if (i+1 >= objc) { - Tcl_SetObjResult(interp, + Tcl_SetObjResult(interp, Tcl_NewIntObj(dataPtr->currentYearCentury)); } break; @@ -921,7 +921,7 @@ ClockConfigureObjCmd( continue; } if (i+1 >= objc) { - Tcl_SetObjResult(interp, + Tcl_SetObjResult(interp, Tcl_NewIntObj(dataPtr->yearOfCenturySwitch)); } break; @@ -978,7 +978,7 @@ ClockGetTZData( } out = &dataPtr->SystemSetupTZData; } - else + else if (timezoneObj == dataPtr->GMTSetupTimeZone) { if (dataPtr->GMTSetupTZData != NULL) { return dataPtr->GMTSetupTZData; @@ -1033,7 +1033,7 @@ ClockGetSystemTimeZone( Tcl_Obj **literals; /* if known (cached and same epoch) - return now */ - if (dataPtr->SystemTimeZone != NULL + if (dataPtr->SystemTimeZone != NULL && dataPtr->LastTZEpoch == TzsetGetEpoch()) { return dataPtr->SystemTimeZone; } @@ -1121,7 +1121,7 @@ ClockSetupTimeZone( *---------------------------------------------------------------------- */ -Tcl_Obj * +Tcl_Obj * ClockFormatNumericTimeZone(int z) { char sign = '+'; int h, m; @@ -1298,7 +1298,7 @@ ClockGetdatefieldsObjCmd( /* Extract fields */ - if (ClockGetDateFields(clientData, interp, &fields, objv[2], + if (ClockGetDateFields(clientData, interp, &fields, objv[2], changeover) != TCL_OK) { return TCL_ERROR; } @@ -1344,8 +1344,8 @@ ClockGetdatefieldsObjCmd( * * ClockGetDateFields -- * - * Converts given UTC time (seconds in a TclDateFields structure) - * to local time and determines the values that clock routines will + * Converts given UTC time (seconds in a TclDateFields structure) + * to local time and determines the values that clock routines will * use in scanning or formatting a date. * * Results: @@ -1704,7 +1704,7 @@ ConvertLocalToUTC( return TCL_ERROR; }; } else { - if (ConvertLocalToUTCUsingTable(interp, fields, rowc, rowv, + if (ConvertLocalToUTCUsingTable(interp, fields, rowc, rowv, dataPtr->Local2UTC.rangesVal) != TCL_OK) { return TCL_ERROR; }; @@ -1806,7 +1806,7 @@ ConvertLocalToUTCUsingTable( Tcl_WideInt backCompVal; /* check DST-hole interval contains UTC time */ TclGetWideIntFromObj(NULL, cellv[0], &backCompVal); - if ( fields->seconds >= backCompVal - fields->tzOffset + if ( fields->seconds >= backCompVal - fields->tzOffset && fields->seconds <= backCompVal + fields->tzOffset ) { row = LookupLastTransition(interp, fields->seconds, rowc, rowv); @@ -1817,7 +1817,7 @@ ConvertLocalToUTCUsingTable( } if (fields->localSeconds != fields->seconds + corrOffset) { Tcl_Panic("wrong local time %ld by LocalToUTC conversion," - " local time seems to be in between DST-hole", + " local time seems to be in between DST-hole", fields->localSeconds); /* correcting offset * / fields->tzOffset -= corrOffset; @@ -1943,8 +1943,8 @@ ConvertUTCToLocal( Tcl_Obj **rowv; /* Pointers to the rows */ /* fast phase-out for shared GMT-object (don't need to convert UTC 2 UTC) */ - if (timezoneObj == dataPtr->GMTSetupTimeZone - && dataPtr->GMTSetupTimeZone != NULL + if (timezoneObj == dataPtr->GMTSetupTimeZone + && dataPtr->GMTSetupTimeZone != NULL && dataPtr->GMTSetupTZData != NULL ) { fields->localSeconds = fields->seconds; @@ -2001,7 +2001,7 @@ ConvertUTCToLocal( return TCL_ERROR; } } else { - if (ConvertUTCToLocalUsingTable(interp, fields, rowc, rowv, + if (ConvertUTCToLocalUsingTable(interp, fields, rowc, rowv, dataPtr->UTC2Local.rangesVal) != TCL_OK) { return TCL_ERROR; } @@ -2993,7 +2993,7 @@ static int ClockParseFmtScnArgs( register ClockFmtScnCmdArgs *opts, /* Result vector: format, locale, timezone... */ - TclDateFields *date, /* Extracted date-time corresponding base + TclDateFields *date, /* Extracted date-time corresponding base * (by scan or add) resp. clockval (by format) */ int objc, /* Parameter count */ Tcl_Obj *const objv[], /* Parameter vector */ @@ -3034,14 +3034,14 @@ ClockParseFmtScnArgs( } } /* get option */ - if (Tcl_GetIndexFromObj(interp, objv[i], options, + if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0, &optionIndex) != TCL_OK) { goto badOption; } /* if already specified */ if (saw & (1 << optionIndex)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad option \"%s\": doubly present", + "bad option \"%s\": doubly present", TclGetString(objv[i])) ); goto badOption; @@ -3080,7 +3080,7 @@ ClockParseFmtScnArgs( if ((saw & (1 << CLC_ARGS_GMT)) && (saw & (1 << CLC_ARGS_TIMEZONE))) { - Tcl_SetResult(interp, (char*)"cannot use -gmt and -timezone in same call", TCL_STATIC); + Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot use -gmt and -timezone in same call", -1)); Tcl_SetErrorCode(interp, "CLOCK", "gmtWithTimezone", NULL); return TCL_ERROR; } @@ -3091,7 +3091,7 @@ ClockParseFmtScnArgs( /* If time zone not specified use system time zone */ if ( opts->timezoneObj == NULL - || TclGetString(opts->timezoneObj) == NULL + || TclGetString(opts->timezoneObj) == NULL || opts->timezoneObj->length == 0 ) { opts->timezoneObj = ClockGetSystemTimeZone(opts->clientData, interp); @@ -3178,7 +3178,7 @@ baseNow: return TCL_OK; -badOptionMsg: +badOptionMsg: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad option \"%s\": unexpected for command \"%s\"", @@ -3189,7 +3189,7 @@ badOption: Tcl_SetErrorCode(interp, "CLOCK", "badOption", i < objc ? Tcl_GetString(objv[i]) : NULL, NULL); - + return TCL_ERROR; } @@ -3201,7 +3201,7 @@ badOption: * * Formats a count of seconds since the Posix Epoch as a time of day. * - * The 'clock format' command formats times of day for output. Refer + * The 'clock format' command formats times of day for output. Refer * to the user documentation to see what it does. * * Results: @@ -3313,7 +3313,7 @@ ClockScanObjCmd( } ClockInitDateInfo(&yy); - + /* * Extract values for the keywords. */ @@ -3334,13 +3334,13 @@ ClockScanObjCmd( /* [SB] TODO: Perhaps someday we'll localize the legacy code. Right now, it's not localized. */ if (opts.localeObj != NULL) { - Tcl_SetResult(interp, - (char*)"legacy [clock scan] does not support -locale", TCL_STATIC); + Tcl_SetObjResult(interp, + Tcl_NewStringObj("legacy [clock scan] does not support -locale", -1)); Tcl_SetErrorCode(interp, "CLOCK", "flagWithLegacyFormat", NULL); return TCL_ERROR; } ret = ClockFreeScan(&yy, objv[1], &opts); - } + } else { /* Use compiled version of Scan - */ @@ -3420,14 +3420,14 @@ ClockScanCommit( } if (info->flags & (CLF_ASSEMBLE_SECONDS|CLF_ASSEMBLE_JULIANDAY|CLF_LOCALSEC)) { - if (ConvertLocalToUTC(clientData, opts->interp, &yydate, opts->timezoneObj, + if (ConvertLocalToUTC(clientData, opts->interp, &yydate, opts->timezoneObj, GREGORIAN_CHANGE_DATE) != TCL_OK) { return TCL_ERROR; } } /* Increment UTC seconds with relative time */ - + yydate.seconds += yyRelSeconds; return TCL_OK; @@ -3452,8 +3452,8 @@ int ClockFreeScan( register DateInfo *info, /* Date fields used for parsing & converting - * simultaneously a yy-parse structure of the - * TclClockFreeScan */ + * simultaneously a yy-parse structure of the + * TclClockFreeScan */ Tcl_Obj *strObj, /* String containing the time to scan */ ClockFmtScnCmdArgs *opts) /* Command options */ { @@ -3466,15 +3466,15 @@ ClockFreeScan( * Parse the date. The parser will fill a structure "info" with date, * time, time zone, relative month/day/seconds, relative weekday, ordinal * month. - * Notice that many yy-defines point to values in the "info" or "date" - * structure, e. g. yySeconds -> info->date.secondOfDay or + * Notice that many yy-defines point to values in the "info" or "date" + * structure, e. g. yySeconds -> info->date.secondOfDay or * yySeconds -> info->date.month (same as yydate.month) */ yyInput = Tcl_GetString(strObj); if (TclClockFreeScan(interp, info) != TCL_OK) { Tcl_Obj *msg = Tcl_NewObj(); - Tcl_AppendPrintfToObj(msg, "unable to convert date-time string \"%s\": %s", + Tcl_AppendPrintfToObj(msg, "unable to convert date-time string \"%s\": %s", Tcl_GetString(strObj), TclGetString(Tcl_GetObjResult(interp))); Tcl_SetObjResult(interp, msg); goto done; @@ -3501,7 +3501,7 @@ ClockFreeScan( } /* - * If the caller supplied a time zone in the string, make it into a time + * If the caller supplied a time zone in the string, make it into a time * zone indicator of +-hhmm and setup this time zone. */ @@ -3524,8 +3524,8 @@ ClockFreeScan( info->flags |= CLF_ASSEMBLE_SECONDS; } - - /* + + /* * Assemble date, time, zone into seconds-from-epoch */ @@ -3538,8 +3538,8 @@ ClockFreeScan( yySeconds = ToSeconds(yyHour, yyMinutes, yySeconds, yyMeridian); info->flags |= CLF_ASSEMBLE_SECONDS; - } - else + } + else if ( (yyHaveDay && !yyHaveDate) || yyHaveOrdinalMonth || ( yyHaveRel @@ -3548,7 +3548,7 @@ ClockFreeScan( ) { yySeconds = 0; info->flags |= CLF_ASSEMBLE_SECONDS; - } + } else { yySeconds = yydate.localSeconds % SECONDS_PER_DAY; } @@ -3588,13 +3588,13 @@ ClockCalcRelTime( { /* * Because some calculations require in-between conversion of the - * julian day, we can repeat this processing multiple times + * julian day, we can repeat this processing multiple times */ repeat_rel: if (yyHaveRel) { - /* + /* * Relative conversion normally possible in UTC time only, because * of possible wrong local time increment if ignores in-between DST-hole. * (see test-cases clock-34.53, clock-34.54). @@ -3641,7 +3641,7 @@ repeat_rel: info->flags &= ~CLF_ASSEMBLE_JULIANDAY; } yydate.julianDay += yyRelDay; - + /* julianDay was changed, on demand (lazy) extract year, month, etc. again */ info->flags |= CLF_ASSEMBLE_DATE|CLF_ASSEMBLE_SECONDS; @@ -3652,12 +3652,12 @@ repeat_rel: * leave rest of the increment in yyRelSeconds to add it hereafter in UTC seconds */ if (yyRelSeconds) { int newSecs = yySeconds + yyRelSeconds; - + /* if seconds increment outside of current date, increment day */ if (newSecs / SECONDS_PER_DAY != yySeconds / SECONDS_PER_DAY) { - + yyRelDay += newSecs / SECONDS_PER_DAY; - yySeconds = 0; + yySeconds = 0; yyRelSeconds = newSecs % SECONDS_PER_DAY; goto repeat_rel; @@ -3738,7 +3738,7 @@ repeat_rel: * * Get offset in days for the number of week days corresponding the * given day of week (skipping Saturdays and Sundays). - * + * * * Results: * Returns a day increment adjusted the given weekdays @@ -3819,7 +3819,7 @@ ClockWeekdaysOffs( * Used to determine the Gregorian change date. * * Results: - * Returns a standard Tcl result with the given time adjusted + * Returns a standard Tcl result with the given time adjusted * by the given offset(s) in order. * * Notes: @@ -3870,7 +3870,7 @@ ClockAddObjCmd( } ClockInitDateInfo(&yy); - + /* * Extract values for the keywords. */ @@ -3883,7 +3883,7 @@ ClockAddObjCmd( } /* time together as seconds of the day */ - yySeconds = yydate.localSeconds % SECONDS_PER_DAY; + yySeconds = yydate.localSeconds % SECONDS_PER_DAY; /* seconds are in localSeconds (relative base date), so reset time here */ yyHour = 0; yyMinutes = 0; yyMeridian = MER24; @@ -3913,12 +3913,12 @@ ClockAddObjCmd( continue; } - /* if in-between conversion needed (already have relative date/time), - * correct date info, because the date may be changed, + /* if in-between conversion needed (already have relative date/time), + * correct date info, because the date may be changed, * so refresh it now */ if ( yyHaveRel - && ( unitIndex == CLC_ADD_WEEKDAYS + && ( unitIndex == CLC_ADD_WEEKDAYS /* some months can be shorter as another */ || yyRelMonth || yyRelDay /* day changed */ @@ -4050,13 +4050,13 @@ TzsetGetEpoch(void) static char* tzWas = INT2PTR(-1); /* Previous value of TZ, protected by * clockMutex. */ static long tzLastRefresh = 0; /* Used for latency before next refresh */ - static unsigned long tzWasEpoch = 0; /* Epoch, signals that TZ changed */ - static unsigned long tzEnvEpoch = 0; /* Last env epoch, for faster signaling, + static size_t tzWasEpoch = 0; /* Epoch, signals that TZ changed */ + static size_t tzEnvEpoch = 0; /* Last env epoch, for faster signaling, that TZ changed via TCL */ - + const char *tzIsNow; /* Current value of TZ */ - - /* + + /* * Prevent performance regression on some platforms by resolving of system time zone: * small latency for check whether environment was changed (once per second) * no latency if environment was chaned with tcl-env (compare both epoch values) diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c index 0ec8817..5de05d0 100644 --- a/generic/tclClockFmt.c +++ b/generic/tclClockFmt.c @@ -50,7 +50,7 @@ static void ClockFrmScnFinalize(ClientData clientData); * pre-validated within parsing routines) * * Results: - * Returns a standard Tcl result. + * Returns a standard Tcl result. * TCL_OK - by successful conversion, TCL_ERROR by (wide) int overflow * *---------------------------------------------------------------------- @@ -59,7 +59,7 @@ static void ClockFrmScnFinalize(ClientData clientData); static inline int _str2int( int *out, - register + register const char *p, const char *e, int sign) @@ -84,12 +84,12 @@ _str2int( } *out = val; return TCL_OK; -} +} static inline int _str2wideInt( Tcl_WideInt *out, - register + register const char *p, const char *e, int sign) @@ -289,13 +289,13 @@ _witoaw( /* * Global GC as LIFO for released scan/format object storages. - * + * * Used to holds last released CLOCK_FMT_SCN_STORAGE_GC_SIZE formats * (after last reference from Tcl-object will be removed). This is helpful * to avoid continuous (re)creation and compiling by some dynamically resp. * variable format objects, that could be often reused. - * - * As long as format storage is used resp. belongs to GC, it takes place in + * + * As long as format storage is used resp. belongs to GC, it takes place in * FmtScnHashTable also. */ @@ -326,7 +326,7 @@ static struct { */ static inline void -ClockFmtScnStorageGC_In(ClockFmtScnStorage *entry) +ClockFmtScnStorageGC_In(ClockFmtScnStorage *entry) { /* add new entry */ TclSpliceIn(entry, ClockFmtScnStorage_GC.stackPtr); @@ -382,7 +382,7 @@ ClockFmtScnStorage_GC_Out(ClockFmtScnStorage *entry) * Global format storage hash table of type ClockFmtScnStorageHashKeyType * (contains list of scan/format object storages, shared across all threads). * - * Used for fast searching by format string. + * Used for fast searching by format string. */ static Tcl_HashTable FmtScnHashTable; static int initialized = 0; @@ -422,7 +422,7 @@ ClockFmtScnStorageAllocProc( const char *string = (const char *) keyPtr; Tcl_HashEntry *hPtr; - unsigned int size, + unsigned int size, allocsize = sizeof(ClockFmtScnStorage) + sizeof(Tcl_HashEntry); allocsize += (size = strlen(string) + 1); @@ -455,7 +455,7 @@ ClockFmtScnStorageAllocProc( *---------------------------------------------------------------------- */ -static void +static void ClockFmtScnStorageFreeProc( Tcl_HashEntry *hPtr) { @@ -488,10 +488,10 @@ ClockFmtScnStorageFreeProc( *---------------------------------------------------------------------- */ -static void +static void ClockFmtScnStorageDelete(ClockFmtScnStorage *fss) { Tcl_HashEntry *hPtr = HashEntry4FmtScn(fss); - /* + /* * This will delete a hash entry and call "ckfree" for storage self, if * some additionally handling required, freeEntryProc can be used instead */ @@ -499,7 +499,7 @@ ClockFmtScnStorageDelete(ClockFmtScnStorage *fss) { } -/* +/* * Derivation of tclStringHashKeyType with another allocEntryProc */ @@ -567,10 +567,10 @@ ClockFmtObj_FreeInternalRep(objPtr) #if CLOCK_FMT_SCN_STORAGE_GC_SIZE > 0 /* don't remove it right now (may be reusable), just add to GC */ ClockFmtScnStorageGC_In(fss); - #else + #else /* remove storage (format representation) */ ClockFmtScnStorageDelete(fss); - #endif + #endif } Tcl_MutexUnlock(&ClockFmtMutex); } @@ -630,7 +630,7 @@ ClockFmtObj_UpdateString(objPtr) * Retrieves format key object used to search localized format. * * This is normally stored in second pointer of internal representation. - * If format object is not localizable, it is equal the given format + * If format object is not localizable, it is equal the given format * pointer (special case to fast fallback by not-localizable formats). * * Results: @@ -655,7 +655,7 @@ ClockFrmObjGetLocFmtKey( return NULL; } } - + keyObj = ObjLocFmtKey(objPtr); if (keyObj) { return keyObj; @@ -692,7 +692,7 @@ ClockFrmObjGetLocFmtKey( static ClockFmtScnStorage * FindOrCreateFmtScnStorage( - Tcl_Interp *interp, + Tcl_Interp *interp, Tcl_Obj *objPtr) { const char *strFmt = TclGetString(objPtr); @@ -720,7 +720,7 @@ FindOrCreateFmtScnStorage( /* get or create entry (and alocate storage) */ hPtr = Tcl_CreateHashEntry(&FmtScnHashTable, strFmt, &new); if (hPtr != NULL) { - + fss = FmtScn4HashEntry(hPtr); #if CLOCK_FMT_SCN_STORAGE_GC_SIZE > 0 @@ -772,7 +772,7 @@ Tcl_GetClockFrmScnFromObj( Tcl_Obj *objPtr) { ClockFmtScnStorage *fss; - + if (objPtr->typePtr != &ClockFmtObjType) { if (ClockFmtObj_SetFromAny(interp, objPtr) != TCL_OK) { return NULL; @@ -822,7 +822,7 @@ ClockLocalizeFormat( return opts->formatObj; } - /* prevents loss of key object if the format object (where key stored) + /* prevents loss of key object if the format object (where key stored) * becomes changed (loses its internal representation during evals) */ Tcl_IncrRefCount(keyObj); @@ -833,7 +833,7 @@ ClockLocalizeFormat( } /* try to find in cache within locale mc-catalog */ - if (Tcl_DictObjGet(NULL, opts->mcDictObj, + if (Tcl_DictObjGet(NULL, opts->mcDictObj, keyObj, &valObj) != TCL_OK) { goto done; } @@ -947,7 +947,7 @@ FindTokenBegin( static void DetermineGreedySearchLen(ClockFmtScnCmdArgs *opts, - DateInfo *info, ClockScanToken *tok, + DateInfo *info, ClockScanToken *tok, int *minLenPtr, int *maxLenPtr) { register int minLen = tok->map->minSize; @@ -973,7 +973,7 @@ DetermineGreedySearchLen(ClockFmtScnCmdArgs *opts, }; if (minLen < tok->map->minSize) { minLen = tok->map->minSize; - } + } if (minLen > maxLen) { maxLen = minLen; } @@ -1032,7 +1032,7 @@ DetermineGreedySearchLen(ClockFmtScnCmdArgs *opts, * * ObjListSearch -- * - * Find largest part of the input string from start regarding min and + * Find largest part of the input string from start regarding min and * max lengths in the given list (utf-8, case sensitive). * * Results: @@ -1044,9 +1044,9 @@ DetermineGreedySearchLen(ClockFmtScnCmdArgs *opts, *---------------------------------------------------------------------- */ -static inline int -ObjListSearch(ClockFmtScnCmdArgs *opts, - DateInfo *info, int *val, +static inline int +ObjListSearch(ClockFmtScnCmdArgs *opts, + DateInfo *info, int *val, Tcl_Obj **lstv, int lstc, int minLen, int maxLen) { @@ -1091,9 +1091,9 @@ ObjListSearch(ClockFmtScnCmdArgs *opts, #if 0 /* currently unused */ -static int -LocaleListSearch(ClockFmtScnCmdArgs *opts, - DateInfo *info, int mcKey, int *val, +static int +LocaleListSearch(ClockFmtScnCmdArgs *opts, + DateInfo *info, int mcKey, int *val, int minLen, int maxLen) { Tcl_Obj **lstv; @@ -1139,7 +1139,7 @@ LocaleListSearch(ClockFmtScnCmdArgs *opts, static TclStrIdxTree * ClockMCGetListIdxTree( - ClockFmtScnCmdArgs *opts, + ClockFmtScnCmdArgs *opts, int mcKey) { TclStrIdxTree * idxTree; @@ -1166,7 +1166,7 @@ ClockMCGetListIdxTree( goto done; } - if (TclListObjGetElements(opts->interp, valObj, + if (TclListObjGetElements(opts->interp, valObj, &lstc, &lstv) != TCL_OK) { goto done; }; @@ -1196,8 +1196,8 @@ done: * Retrieves localized string indexed tree in the locale catalog for * multiple lists by literal indices mcKeys (and builds it on demand). * - * Searches localized index in locale catalog for mcKey, and if not - * yet exists, creates string indexed tree and stores it in the + * Searches localized index in locale catalog for mcKey, and if not + * yet exists, creates string indexed tree and stores it in the * locale catalog. * * Results: @@ -1211,8 +1211,8 @@ done: static TclStrIdxTree * ClockMCGetMultiListIdxTree( - ClockFmtScnCmdArgs *opts, - int mcKey, + ClockFmtScnCmdArgs *opts, + int mcKey, int *mcKeys) { TclStrIdxTree * idxTree; @@ -1241,7 +1241,7 @@ ClockMCGetMultiListIdxTree( goto done; } - if (TclListObjGetElements(opts->interp, valObj, + if (TclListObjGetElements(opts->interp, valObj, &lstc, &lstv) != TCL_OK) { goto done; }; @@ -1275,7 +1275,7 @@ done: * * Results: * TCL_OK - match found and the index stored in *val, - * TCL_RETURN - not matched or ambigous, + * TCL_RETURN - not matched or ambigous, * TCL_ERROR - in error case. * * Side effects: @@ -1285,15 +1285,15 @@ done: */ static inline int -ClockStrIdxTreeSearch(ClockFmtScnCmdArgs *opts, - DateInfo *info, TclStrIdxTree *idxTree, int *val, +ClockStrIdxTreeSearch(ClockFmtScnCmdArgs *opts, + DateInfo *info, TclStrIdxTree *idxTree, int *val, int minLen, int maxLen) { const char *f; TclStrIdx *foundItem; - f = TclStrIdxTreeSearch(NULL, &foundItem, idxTree, + f = TclStrIdxTreeSearch(NULL, &foundItem, idxTree, yyInput, yyInput + maxLen); - + if (f <= yyInput || (f - yyInput) < minLen) { /* not found */ return TCL_RETURN; @@ -1313,15 +1313,15 @@ ClockStrIdxTreeSearch(ClockFmtScnCmdArgs *opts, #if 0 /* currently unused */ -static int -StaticListSearch(ClockFmtScnCmdArgs *opts, +static int +StaticListSearch(ClockFmtScnCmdArgs *opts, DateInfo *info, const char **lst, int *val) { int len; const char **s = lst; while (*s != NULL) { len = strlen(*s); - if ( len <= info->dateEnd - yyInput + if ( len <= info->dateEnd - yyInput && strncasecmp(yyInput, *s, len) == 0 ) { *val = (s - lst); @@ -1339,7 +1339,7 @@ StaticListSearch(ClockFmtScnCmdArgs *opts, static inline const char * FindWordEnd( - ClockScanToken *tok, + ClockScanToken *tok, register const char * p, const char * end) { register const char *x = tok->tokWord.start; @@ -1358,7 +1358,7 @@ FindWordEnd( return pfnd; } -static int +static int ClockScnToken_Month_Proc(ClockFmtScnCmdArgs *opts, DateInfo *info, ClockScanToken *tok) { @@ -1371,7 +1371,7 @@ ClockScnToken_Month_Proc(ClockFmtScnCmdArgs *opts, "July", "August", "September", "October", "November", "December", /* abbr */ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL }; @@ -1408,7 +1408,7 @@ ClockScnToken_Month_Proc(ClockFmtScnCmdArgs *opts, } -static int +static int ClockScnToken_DayOfWeek_Proc(ClockFmtScnCmdArgs *opts, DateInfo *info, ClockScanToken *tok) { @@ -1425,7 +1425,7 @@ ClockScnToken_DayOfWeek_Proc(ClockFmtScnCmdArgs *opts, if ( curTok != 'a' && curTok != 'A' && ((minLen <= 1 && maxLen >= 1) || PTR2INT(tok->map->data)) ) { - + val = -1; if (PTR2INT(tok->map->data) == 0) { @@ -1450,8 +1450,7 @@ ClockScnToken_DayOfWeek_Proc(ClockFmtScnCmdArgs *opts, val = 7; } if (val > 7) { - Tcl_SetResult(opts->interp, (char*)"day of week is greater than 7", - TCL_STATIC); + Tcl_SetObjResult(opts->interp, Tcl_NewStringObj("day of week is greater than 7", -1)); Tcl_SetErrorCode(opts->interp, "CLOCK", "badDayOfWeek", NULL); return TCL_ERROR; } @@ -1484,8 +1483,8 @@ ClockScnToken_DayOfWeek_Proc(ClockFmtScnCmdArgs *opts, } -static int -ClockScnToken_amPmInd_Proc(ClockFmtScnCmdArgs *opts, +static int +ClockScnToken_amPmInd_Proc(ClockFmtScnCmdArgs *opts, DateInfo *info, ClockScanToken *tok) { int ret, val; @@ -1504,7 +1503,7 @@ ClockScnToken_amPmInd_Proc(ClockFmtScnCmdArgs *opts, ret = ObjListSearch(opts, info, &val, amPmObj, 2, minLen, maxLen); if (ret != TCL_OK) { - return ret; + return ret; } if (val == 0) { @@ -1516,8 +1515,8 @@ ClockScnToken_amPmInd_Proc(ClockFmtScnCmdArgs *opts, return TCL_OK; } -static int -ClockScnToken_LocaleERA_Proc(ClockFmtScnCmdArgs *opts, +static int +ClockScnToken_LocaleERA_Proc(ClockFmtScnCmdArgs *opts, DateInfo *info, ClockScanToken *tok) { ClockClientData *dataPtr = opts->clientData; @@ -1542,7 +1541,7 @@ ClockScnToken_LocaleERA_Proc(ClockFmtScnCmdArgs *opts, ret = ObjListSearch(opts, info, &val, eraObj, 6, minLen, maxLen); if (ret != TCL_OK) { - return ret; + return ret; } if (val & 1) { @@ -1554,8 +1553,8 @@ ClockScnToken_LocaleERA_Proc(ClockFmtScnCmdArgs *opts, return TCL_OK; } -static int -ClockScnToken_LocaleListMatcher_Proc(ClockFmtScnCmdArgs *opts, +static int +ClockScnToken_LocaleListMatcher_Proc(ClockFmtScnCmdArgs *opts, DateInfo *info, ClockScanToken *tok) { int ret, val; @@ -1583,8 +1582,8 @@ ClockScnToken_LocaleListMatcher_Proc(ClockFmtScnCmdArgs *opts, return TCL_OK; } -static int -ClockScnToken_TimeZone_Proc(ClockFmtScnCmdArgs *opts, +static int +ClockScnToken_TimeZone_Proc(ClockFmtScnCmdArgs *opts, DateInfo *info, ClockScanToken *tok) { int minLen, maxLen; @@ -1598,7 +1597,7 @@ ClockScnToken_TimeZone_Proc(ClockFmtScnCmdArgs *opts, if (*p == '+' || *p == '-') { /* max chars in numeric zone = "+00:00:00" */ #define MAX_ZONE_LEN 9 - char buf[MAX_ZONE_LEN + 1]; + char buf[MAX_ZONE_LEN + 1]; char *bp = buf; *bp++ = *p++; len++; if (maxLen > MAX_ZONE_LEN) @@ -1621,7 +1620,7 @@ ClockScnToken_TimeZone_Proc(ClockFmtScnCmdArgs *opts, return TCL_RETURN; } #undef MAX_ZONE_LEN - + /* timezone */ tzObjStor = Tcl_NewStringObj(buf, bp-buf); } else { @@ -1629,7 +1628,7 @@ ClockScnToken_TimeZone_Proc(ClockFmtScnCmdArgs *opts, if (maxLen > 4) maxLen = 4; while (len < maxLen) { - if ( (*p & 0x80) + if ( (*p & 0x80) || (!isalpha(UCHAR(*p)) && !isdigit(UCHAR(*p))) ) { /* INTL: ISO only. */ break; @@ -1650,7 +1649,7 @@ ClockScnToken_TimeZone_Proc(ClockFmtScnCmdArgs *opts, /* try to apply new time zone */ Tcl_IncrRefCount(tzObjStor); - opts->timezoneObj = ClockSetupTimeZone(opts->clientData, opts->interp, + opts->timezoneObj = ClockSetupTimeZone(opts->clientData, opts->interp, tzObjStor); Tcl_DecrRefCount(tzObjStor); @@ -1663,8 +1662,8 @@ ClockScnToken_TimeZone_Proc(ClockFmtScnCmdArgs *opts, return TCL_OK; } -static int -ClockScnToken_StarDate_Proc(ClockFmtScnCmdArgs *opts, +static int +ClockScnToken_StarDate_Proc(ClockFmtScnCmdArgs *opts, DateInfo *info, ClockScanToken *tok) { int minLen, maxLen; @@ -1741,7 +1740,7 @@ ClockScnToken_StarDate_Proc(ClockFmtScnCmdArgs *opts, return TCL_OK; } -static const char *ScnSTokenMapIndex = +static const char *ScnSTokenMapIndex = "dmbyYHMSpJjCgGVazUsntQ"; static ClockScanTokenMap ScnSTokenMap[] = { /* %d %e */ @@ -1814,7 +1813,7 @@ static const char *ScnSTokenMapAliasIndex[2] = { "dmbbHHHpaaazU" }; -static const char *ScnETokenMapIndex = +static const char *ScnETokenMapIndex = "Eys"; static ClockScanTokenMap ScnETokenMap[] = { /* %EE */ @@ -1832,7 +1831,7 @@ static const char *ScnETokenMapAliasIndex[2] = { "" }; -static const char *ScnOTokenMapIndex = +static const char *ScnOTokenMapIndex = "dmyHMSu"; static ClockScanTokenMap ScnOTokenMap[] = { /* %Od %Oe */ @@ -1862,7 +1861,7 @@ static const char *ScnOTokenMapAliasIndex[2] = { "dHHHu" }; -static const char *ScnSpecTokenMapIndex = +static const char *ScnSpecTokenMapIndex = " "; static ClockScanTokenMap ScnSpecTokenMap[] = { {CTOKT_SPACE, 0, 0, 1, 1, 0, @@ -1870,7 +1869,7 @@ static ClockScanTokenMap ScnSpecTokenMap[] = { }; static ClockScanTokenMap ScnWordTokenMap = { - CTOKT_WORD, 0, 0, 1, 1, 0, + CTOKT_WORD, 0, 0, 1, 1, 0, NULL }; @@ -1937,7 +1936,7 @@ ClockGetOrParseScanFormat( /* estimate token count by % char and format length */ fss->scnTokC = EstimateTokenCount(p, e); - + fss->scnSpaceCount = 0; Tcl_MutexLock(&ClockFmtMutex); @@ -1959,7 +1958,7 @@ ClockGetOrParseScanFormat( /* try to find modifier: */ switch (*p) { case '%': - /* begin new word token - don't join with previous word token, + /* begin new word token - don't join with previous word token, * because current mapping should be "...%%..." -> "...%..." */ tok->map = &ScnWordTokenMap; tok->tokWord.start = p; @@ -1969,7 +1968,7 @@ ClockGetOrParseScanFormat( continue; break; case 'E': - scnMap = ScnETokenMap, + scnMap = ScnETokenMap, mapIndex = ScnETokenMapIndex, aliasIndex = ScnETokenMapAliasIndex; p++; @@ -2018,7 +2017,7 @@ ClockGetOrParseScanFormat( } /* increase space count used in format */ - if ( tok->map->type == CTOKT_CHAR + if ( tok->map->type == CTOKT_CHAR && isspace(UCHAR(*((char *)tok->map->data))) ) { fss->scnSpaceCount++; @@ -2161,13 +2160,13 @@ ClockScan( } info->dateStart = p = yyInput; info->dateEnd = end; - + /* parse string */ for (; tok->map != NULL; tok++) { map = tok->map; /* bypass spaces at begin of input before parsing each token */ - if ( !(opts->flags & CLF_STRICT) - && ( map->type != CTOKT_SPACE + if ( !(opts->flags & CLF_STRICT) + && ( map->type != CTOKT_SPACE && map->type != CTOKT_WORD && map->type != CTOKT_CHAR ) ) { @@ -2206,13 +2205,13 @@ ClockScan( if (map->offs) { p = yyInput; x = p + size; if (!(map->flags & (CLF_LOCALSEC|CLF_POSIXSEC))) { - if (_str2int((int *)(((char *)info) + map->offs), + if (_str2int((int *)(((char *)info) + map->offs), p, x, sign) != TCL_OK) { goto overflow; } p = x; } else { - if (_str2wideInt((Tcl_WideInt *)(((char *)info) + map->offs), + if (_str2wideInt((Tcl_WideInt *)(((char *)info) + map->offs), p, x, sign) != TCL_OK) { goto overflow; } @@ -2297,8 +2296,8 @@ ClockScan( tok++; } - /* - * Invalidate result + /* + * Invalidate result */ /* seconds token (%s) take precedence over all other tokens */ @@ -2332,17 +2331,17 @@ ClockScan( } /* YearWeekDay below YearMonthDay */ - if ( (flags & CLF_ISO8601) + if ( (flags & CLF_ISO8601) && ( (flags & (CLF_YEAR|CLF_DAYOFYEAR)) == (CLF_YEAR|CLF_DAYOFYEAR) || (flags & (CLF_YEAR|CLF_DAYOFMONTH|CLF_MONTH)) == (CLF_YEAR|CLF_DAYOFMONTH|CLF_MONTH) - ) + ) ) { /* yy precedence below yyyy */ if (!(flags & CLF_ISO8601CENTURY) && (flags & CLF_CENTURY)) { /* normally precedence of ISO is higher, but no century - so put it down */ flags &= ~CLF_ISO8601; - } - else + } + else /* yymmdd or yyddd over naked weekday */ if (!(flags & CLF_ISO8601YEAR)) { flags &= ~CLF_ISO8601; @@ -2400,15 +2399,15 @@ ClockScan( overflow: - Tcl_SetResult(opts->interp, (char*)"requested date too large to represent", - TCL_STATIC); + Tcl_SetObjResult(opts->interp, Tcl_NewStringObj("requested date too large to represent", + -1)); Tcl_SetErrorCode(opts->interp, "CLOCK", "dateTooLarge", NULL); goto done; not_match: - Tcl_SetResult(opts->interp, (char*)"input string does not match supplied format", - TCL_STATIC); + Tcl_SetObjResult(opts->interp, Tcl_NewStringObj("input string does not match supplied format", + -1)); Tcl_SetErrorCode(opts->interp, "CLOCK", "badInputString", NULL); done: @@ -2423,7 +2422,7 @@ FrmResultAllocate( { int needed = dateFmt->output + len - dateFmt->resEnd; if (needed >= 0) { /* >= 0 - regards NTS zero */ - int newsize = dateFmt->resEnd - dateFmt->resMem + int newsize = dateFmt->resEnd - dateFmt->resMem + needed + MIN_FMT_RESULT_BLOCK_ALLOC; char *newRes = ckrealloc(dateFmt->resMem, newsize); if (newRes == NULL) { @@ -2499,9 +2498,9 @@ ClockFmtToken_StarDate_Proc( if (FrmResultAllocate(dateFmt, 30) != TCL_OK) { return TCL_ERROR; }; memcpy(dateFmt->output, "Stardate ", 9); dateFmt->output += 9; - dateFmt->output = _itoaw(dateFmt->output, + dateFmt->output = _itoaw(dateFmt->output, dateFmt->date.year - RODDENBERRY, '0', 2); - dateFmt->output = _itoaw(dateFmt->output, + dateFmt->output = _itoaw(dateFmt->output, fractYear, '0', 3); *dateFmt->output++ = '.'; /* be sure positive after decimal point (note: clock-value can be negative) */ @@ -2556,7 +2555,7 @@ ClockFmtToken_TimeZone_Proc( const char *s; int len; /* convert seconds to local seconds to obtain tzName object */ if (ConvertUTCToLocal(opts->clientData, opts->interp, - &dateFmt->date, opts->timezoneObj, + &dateFmt->date, opts->timezoneObj, GREGORIAN_CHANGE_DATE) != TCL_OK) { return TCL_ERROR; }; @@ -2616,7 +2615,7 @@ ClockFmtToken_LocaleERAYear_Proc( return TCL_ERROR; } if (rowc != 0) { - dateFmt->localeEra = LookupLastTransition(opts->interp, + dateFmt->localeEra = LookupLastTransition(opts->interp, dateFmt->date.localSeconds, rowc, rowv, NULL); } if (dateFmt->localeEra == NULL) { @@ -2629,11 +2628,11 @@ ClockFmtToken_LocaleERAYear_Proc( if (FrmResultAllocate(dateFmt, 11) != TCL_OK) { return TCL_ERROR; }; if (*tok->tokWord.start == 'C') { /* %EC */ *val = dateFmt->date.year / 100; - dateFmt->output = _itoaw(dateFmt->output, + dateFmt->output = _itoaw(dateFmt->output, *val, '0', 2); } else { /* %Ey */ *val = dateFmt->date.year % 100; - dateFmt->output = _itoaw(dateFmt->output, + dateFmt->output = _itoaw(dateFmt->output, *val, '0', 2); } } else { @@ -2667,7 +2666,7 @@ ClockFmtToken_LocaleERAYear_Proc( } else { /* year as integer */ if (FrmResultAllocate(dateFmt, 11) != TCL_OK) { return TCL_ERROR; }; - dateFmt->output = _itoaw(dateFmt->output, + dateFmt->output = _itoaw(dateFmt->output, *val, '0', 2); return TCL_OK; } @@ -2682,7 +2681,7 @@ ClockFmtToken_LocaleERAYear_Proc( } -static const char *FmtSTokenMapIndex = +static const char *FmtSTokenMapIndex = "demNbByYCHMSIklpaAuwUVzgGjJsntQ"; static ClockFormatTokenMap FmtSTokenMap[] = { /* %d */ @@ -2712,15 +2711,15 @@ static ClockFormatTokenMap FmtSTokenMap[] = { /* %S */ {CFMTT_INT, "0", 2, 0, 0, 60, TclOffset(DateFormat, date.secondOfDay), NULL}, /* %I */ - {CFMTT_INT, "0", 2, CLFMT_CALC, 0, 0, TclOffset(DateFormat, date.secondOfDay), + {CFMTT_INT, "0", 2, CLFMT_CALC, 0, 0, TclOffset(DateFormat, date.secondOfDay), ClockFmtToken_HourAMPM_Proc, NULL}, /* %k */ {CFMTT_INT, " ", 2, 0, 3600, 24, TclOffset(DateFormat, date.secondOfDay), NULL}, /* %l */ - {CFMTT_INT, " ", 2, CLFMT_CALC, 0, 0, TclOffset(DateFormat, date.secondOfDay), + {CFMTT_INT, " ", 2, CLFMT_CALC, 0, 0, TclOffset(DateFormat, date.secondOfDay), ClockFmtToken_HourAMPM_Proc, NULL}, /* %p %P */ - {CFMTT_INT, NULL, 0, 0, 0, 0, TclOffset(DateFormat, date.secondOfDay), + {CFMTT_INT, NULL, 0, 0, 0, 0, TclOffset(DateFormat, date.secondOfDay), ClockFmtToken_AMPM_Proc, NULL}, /* %a */ {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 0, 7, TclOffset(DateFormat, date.dayOfWeek), @@ -2733,12 +2732,12 @@ static ClockFormatTokenMap FmtSTokenMap[] = { /* %w */ {CFMTT_INT, " ", 1, 0, 0, 7, TclOffset(DateFormat, date.dayOfWeek), NULL}, /* %U %W */ - {CFMTT_INT, "0", 2, CLFMT_CALC, 0, 0, TclOffset(DateFormat, date.dayOfYear), + {CFMTT_INT, "0", 2, CLFMT_CALC, 0, 0, TclOffset(DateFormat, date.dayOfYear), ClockFmtToken_WeekOfYear_Proc, NULL}, /* %V */ {CFMTT_INT, "0", 2, 0, 0, 0, TclOffset(DateFormat, date.iso8601Week), NULL}, /* %z %Z */ - {CFMTT_INT, NULL, 0, 0, 0, 0, 0, + {CFMTT_INT, NULL, 0, 0, 0, 0, 0, ClockFmtToken_TimeZone_Proc, NULL}, /* %g */ {CFMTT_INT, "0", 2, 0, 0, 100, TclOffset(DateFormat, date.iso8601Year), NULL}, @@ -2755,7 +2754,7 @@ static ClockFormatTokenMap FmtSTokenMap[] = { /* %t */ {CTOKT_CHAR, "\t", 0, 0, 0, 0, 0, NULL}, /* %Q */ - {CFMTT_INT, NULL, 0, 0, 0, 0, 0, + {CFMTT_INT, NULL, 0, 0, 0, 0, 0, ClockFmtToken_StarDate_Proc, NULL}, }; static const char *FmtSTokenMapAliasIndex[2] = { @@ -2763,11 +2762,11 @@ static const char *FmtSTokenMapAliasIndex[2] = { "bpUz" }; -static const char *FmtETokenMapIndex = +static const char *FmtETokenMapIndex = "Eys"; static ClockFormatTokenMap FmtETokenMap[] = { /* %EE */ - {CFMTT_INT, NULL, 0, 0, 0, 0, TclOffset(DateFormat, date.era), + {CFMTT_INT, NULL, 0, 0, 0, 0, TclOffset(DateFormat, date.era), ClockFmtToken_LocaleERA_Proc, NULL}, /* %Ey %EC */ {CFMTT_INT, NULL, 0, 0, 0, 0, TclOffset(DateFormat, date.year), @@ -2780,7 +2779,7 @@ static const char *FmtETokenMapAliasIndex[2] = { "y" }; -static const char *FmtOTokenMapIndex = +static const char *FmtOTokenMapIndex = "dmyHIMSuw"; static ClockFormatTokenMap FmtOTokenMap[] = { /* %Od %Oe */ @@ -2793,22 +2792,22 @@ static ClockFormatTokenMap FmtOTokenMap[] = { {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 0, 100, TclOffset(DateFormat, date.year), NULL, (void *)MCLIT_LOCALE_NUMERALS}, /* %OH %Ok */ - {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 3600, 24, TclOffset(DateFormat, date.secondOfDay), + {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 3600, 24, TclOffset(DateFormat, date.secondOfDay), NULL, (void *)MCLIT_LOCALE_NUMERALS}, /* %OI %Ol */ - {CFMTT_INT, NULL, 0, CLFMT_CALC | CLFMT_LOCALE_INDX, 0, 0, TclOffset(DateFormat, date.secondOfDay), + {CFMTT_INT, NULL, 0, CLFMT_CALC | CLFMT_LOCALE_INDX, 0, 0, TclOffset(DateFormat, date.secondOfDay), ClockFmtToken_HourAMPM_Proc, (void *)MCLIT_LOCALE_NUMERALS}, /* %OM */ - {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 60, 60, TclOffset(DateFormat, date.secondOfDay), + {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 60, 60, TclOffset(DateFormat, date.secondOfDay), NULL, (void *)MCLIT_LOCALE_NUMERALS}, /* %OS */ - {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 0, 60, TclOffset(DateFormat, date.secondOfDay), + {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 0, 60, TclOffset(DateFormat, date.secondOfDay), NULL, (void *)MCLIT_LOCALE_NUMERALS}, /* %Ou */ {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 0, 100, TclOffset(DateFormat, date.dayOfWeek), NULL, (void *)MCLIT_LOCALE_NUMERALS}, /* %Ow */ - {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 0, 7, TclOffset(DateFormat, date.dayOfWeek), + {CFMTT_INT, NULL, 0, CLFMT_LOCALE_INDX, 0, 7, TclOffset(DateFormat, date.dayOfWeek), NULL, (void *)MCLIT_LOCALE_NUMERALS}, }; static const char *FmtOTokenMapAliasIndex[2] = { @@ -2866,7 +2865,7 @@ ClockGetOrParseFmtFormat( /* try to find modifier: */ switch (*p) { case '%': - /* begin new word token - don't join with previous word token, + /* begin new word token - don't join with previous word token, * because current mapping should be "...%%..." -> "...%..." */ tok->map = &FmtWordTokenMap; tok->tokWord.start = p; @@ -2876,7 +2875,7 @@ ClockGetOrParseFmtFormat( continue; break; case 'E': - fmtMap = FmtETokenMap, + fmtMap = FmtETokenMap, mapIndex = FmtETokenMapIndex, aliasIndex = FmtETokenMapAliasIndex; p++; @@ -2977,7 +2976,7 @@ ClockFormat( if (dateFmt->date.secondOfDay < 0) { dateFmt->date.secondOfDay += SECONDS_PER_DAY; } - + /* result container object */ dateFmt->resMem = ckalloc(MIN_FMT_RESULT_BLOCK_ALLOC); if (dateFmt->resMem == NULL) { diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index b62ccf8..e0929f0 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -4009,7 +4009,7 @@ Tcl_TimeObjCmd( start = TclpGetWideClicks(); #endif while (i-- > 0) { - result = TclEvalObjEx(interp, objPtr, 0, NULL, 0); + result = Tcl_EvalObjEx(interp, objPtr, 0); if (result != TCL_OK) { return result; } @@ -4052,8 +4052,8 @@ Tcl_TimeObjCmd( * Tcl_TimeRateObjCmd -- * * This object-based procedure is invoked to process the "timerate" Tcl - * command. - * This is similar to command "time", except the execution limited by + * command. + * This is similar to command "time", except the execution limited by * given time (in milliseconds) instead of repetition count. * * Example: @@ -4075,14 +4075,14 @@ Tcl_TimeRateObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - static + static double measureOverhead = 0; /* global measure-overhead */ double overhead = -1; /* given measure-overhead */ register Tcl_Obj *objPtr; register int result, i; Tcl_Obj *calibrate = NULL, *direct = NULL; Tcl_WideInt count = 0; /* Holds repetition count */ - Tcl_WideInt maxms = -0x7FFFFFFFFFFFFFFFL; + Tcl_WideInt maxms = -0x7FFFFFFFFFFFFFFFL; /* Maximal running time (in milliseconds) */ Tcl_WideInt threshold = 1; /* Current threshold for check time (faster * repeat count without time check) */ @@ -4152,13 +4152,13 @@ usage: Tcl_Obj *clobjv[6]; Tcl_WideInt maxCalTime = 5000; double lastMeasureOverhead = measureOverhead; - - clobjv[0] = objv[0]; + + clobjv[0] = objv[0]; i = 1; if (direct) { clobjv[i++] = direct; } - clobjv[i++] = objPtr; + clobjv[i++] = objPtr; /* reset last measurement overhead */ measureOverhead = (double)0; @@ -4175,7 +4175,7 @@ usage: i--; clobjv[i++] = calibrate; - clobjv[i++] = objPtr; + clobjv[i++] = objPtr; /* set last measurement overhead to max */ measureOverhead = (double)0x7FFFFFFFFFFFFFFFL; @@ -4268,7 +4268,7 @@ usage: if (result != TCL_OK) { goto done; } - + /* don't check time up to threshold */ if (--threshold > 0) continue; @@ -4348,7 +4348,7 @@ usage: } objs[2] = Tcl_NewWideIntObj(count); /* iterations */ - + /* calculate speed as rate (count) per sec */ if (!middle) middle++; /* +1 ms, just to avoid divide by zero */ if (count < (0x7FFFFFFFFFFFFFFFL / 1000000)) { diff --git a/generic/tclDate.c b/generic/tclDate.c index 64cb804..934fe5f 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -1,20 +1,20 @@ /* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - + Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software Foundation, Inc. - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -27,7 +27,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -2685,7 +2685,7 @@ TclClockFreeScan( /* * yyInput = stringToParse; - * + * * ClockInitDateInfo(info) should be executed to pre-init info; */ diff --git a/generic/tclDate.h b/generic/tclDate.h index abc231b..570a8e4 100644 --- a/generic/tclDate.h +++ b/generic/tclDate.h @@ -109,7 +109,7 @@ typedef enum ClockMsgCtLiteral { MCLIT__NIL, /* placeholder */ MCLIT_MONTHS_FULL, MCLIT_MONTHS_ABBREV, MCLIT_MONTHS_COMB, MCLIT_DAYS_OF_WEEK_FULL, MCLIT_DAYS_OF_WEEK_ABBREV, MCLIT_DAYS_OF_WEEK_COMB, - MCLIT_AM, MCLIT_PM, + MCLIT_AM, MCLIT_PM, MCLIT_LOCALE_ERAS, MCLIT_BCE, MCLIT_CE, MCLIT_BCE2, MCLIT_CE2, @@ -486,16 +486,16 @@ MODULE_SCOPE Tcl_Obj * ClockMCGet(ClockFmtScnCmdArgs *opts, int mcKey); MODULE_SCOPE Tcl_Obj * ClockMCGetIdx(ClockFmtScnCmdArgs *opts, int mcKey); -MODULE_SCOPE int ClockMCSetIdx(ClockFmtScnCmdArgs *opts, int mcKey, +MODULE_SCOPE int ClockMCSetIdx(ClockFmtScnCmdArgs *opts, int mcKey, Tcl_Obj *valObj); /* tclClockFmt.c module declarations */ -MODULE_SCOPE Tcl_Obj* +MODULE_SCOPE Tcl_Obj* ClockFrmObjGetLocFmtKey(Tcl_Interp *interp, Tcl_Obj *objPtr); -MODULE_SCOPE ClockFmtScnStorage * +MODULE_SCOPE ClockFmtScnStorage * Tcl_GetClockFrmScnFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr); MODULE_SCOPE Tcl_Obj * @@ -504,7 +504,7 @@ MODULE_SCOPE Tcl_Obj * MODULE_SCOPE int ClockScan(register DateInfo *info, Tcl_Obj *strObj, ClockFmtScnCmdArgs *opts); -MODULE_SCOPE int ClockFormat(register DateFormat *dateFmt, +MODULE_SCOPE int ClockFormat(register DateFormat *dateFmt, ClockFmtScnCmdArgs *opts); MODULE_SCOPE void ClockFrmScnClearCaches(void); diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index c4cf7f1..477aeee 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -328,7 +328,7 @@ TclNamespaceEnsembleCmd( } continue; case CRT_COMPILE: - if (Tcl_GetBooleanFromObj(interp, objv[1], + if (Tcl_GetBooleanFromObj(interp, objv[1], &ensCompFlag) != TCL_OK) { return TCL_ERROR; }; @@ -358,7 +358,7 @@ TclNamespaceEnsembleCmd( Tcl_SetEnsembleMappingDict(interp, token, mapObj); Tcl_SetEnsembleUnknownHandler(interp, token, unknownObj); Tcl_SetEnsembleParameterList(interp, token, paramObj); - /* + /* * Ensemble should be compiled if it has map (performance purposes) */ if (ensCompFlag > 0 && mapObj != NULL) { diff --git a/generic/tclEnv.c b/generic/tclEnv.c index 0041a40..d05cc61 100644 --- a/generic/tclEnv.c +++ b/generic/tclEnv.c @@ -19,7 +19,7 @@ TCL_DECLARE_MUTEX(envMutex) /* To serialize access to environ. */ /* MODULE_SCOPE */ -unsigned long TclEnvEpoch = 0; /* Epoch of the tcl environment +size_t TclEnvEpoch = 0; /* Epoch of the tcl environment * (if changed with tcl-env). */ static struct { diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 2d1c07f..30ef536 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -2695,7 +2695,7 @@ TEBCresume( if (objv[0]->bytes == &tclEmptyString) { objResultPtr = objv[1]; goto endINST_STR_CONCAT1; - } + } else if (objv[1]->bytes == &tclEmptyString) { objResultPtr = objv[0]; diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index 6d6a0d0..b83644b 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -896,7 +896,7 @@ TclClockFreeScan( /* * yyInput = stringToParse; - * + * * ClockInitDateInfo(info) should be executed to pre-init info; */ diff --git a/generic/tclInt.h b/generic/tclInt.h index 9e73743..e1ddb36 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4893,7 +4893,7 @@ typedef struct NRE_callback { * Other externals. */ -MODULE_SCOPE unsigned long TclEnvEpoch; /* Epoch of the tcl environment +MODULE_SCOPE size_t TclEnvEpoch; /* Epoch of the tcl environment * (if changed with tcl-env). */ #endif /* _TCLINT */ diff --git a/generic/tclStrIdxTree.c b/generic/tclStrIdxTree.c index 0045ea5..557d575 100644 --- a/generic/tclStrIdxTree.c +++ b/generic/tclStrIdxTree.c @@ -1,7 +1,7 @@ /* * tclStrIdxTree.c -- * - * Contains the routines for managing string index tries in Tcl. + * Contains the routines for managing string index tries in Tcl. * * This code is back-ported from the tclSE engine, by Serg G. Brester. * @@ -12,11 +12,11 @@ * * ----------------------------------------------------------------------- * - * String index tries are prepaired structures used for fast greedy search of the string + * String index tries are prepaired structures used for fast greedy search of the string * (index) by unique string prefix as key. * * Index tree build for two lists together can be explained in the following datagram - * + * * Lists: * * {Januar Februar Maerz April Mai Juni Juli August September Oktober November Dezember} @@ -42,9 +42,9 @@ * i 5 * zb 12 * rz 3 * * ... - * + * * Thereby value 0 shows pure group items (corresponding ambigous matches). - * But the group may have a value if it contains only same values + * But the group may have a value if it contains only same values * (see for example group "f" above). * * StrIdxTree's are very fast, so: @@ -109,7 +109,7 @@ TclStrIdxTreeSearch( s = f; /* if match item, go deeper as long as possible */ if (offs >= item->length && item->childTree.firstPtr) { - /* save previuosly found item (if not ambigous) for + /* save previuosly found item (if not ambigous) for * possible fallback (few greedy match) */ if (item->value != NULL) { prevf = f; @@ -145,7 +145,7 @@ done: return start; } -MODULE_SCOPE void +MODULE_SCOPE void TclStrIdxTreeFree( TclStrIdx *tree) { @@ -157,13 +157,13 @@ TclStrIdxTreeFree( } t = tree, tree = tree->nextPtr; ckfree(t); - } + } } /* * Several bidirectional list primitives */ -inline void +inline void TclStrIdxTreeInsertBranch( TclStrIdxTree *parent, register TclStrIdx *item, @@ -282,7 +282,7 @@ TclStrIdxTreeBuildFromList( foundItem->length = lwrv[i]->length; continue; } - /* split tree (e. g. j->(jan,jun) + jul == j->(jan,ju->(jun,jul)) ) + /* split tree (e. g. j->(jan,jun) + jul == j->(jan,ju->(jun,jul)) ) * but don't split by fulfilled child of found item ( ii->iii->iiii ) */ if (foundItem->length != (f - s)) { /* first split found item (insert one between parent and found + new one) */ @@ -351,7 +351,7 @@ Tcl_ObjType StrIdxTreeObjType = { NULL /* setFromAnyProc */ }; -MODULE_SCOPE Tcl_Obj* +MODULE_SCOPE Tcl_Obj* TclStrIdxTreeNewObj() { Tcl_Obj *objPtr = Tcl_NewObj(); @@ -372,7 +372,7 @@ StrIdxTreeObj_DupIntRepProc(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr) srcPtr = (Tcl_Obj*)srcPtr->internalRep.twoPtrValue.ptr1; } /* create smart pointer to it (ptr1 != NULL, ptr2 = NULL) */ - Tcl_InitObjRef(*((Tcl_Obj **)©Ptr->internalRep.twoPtrValue.ptr1), + Tcl_InitObjRef(*((Tcl_Obj **)©Ptr->internalRep.twoPtrValue.ptr1), srcPtr); copyPtr->internalRep.twoPtrValue.ptr2 = NULL; copyPtr->typePtr = &StrIdxTreeObjType; @@ -428,7 +428,7 @@ TclStrIdxTreeGetFromObj(Tcl_Obj *objPtr) { #if 0 /* currently unused, debug resp. test purposes only */ -void +void TclStrIdxTreePrint( Tcl_Interp *interp, TclStrIdx *tree, @@ -439,7 +439,7 @@ TclStrIdxTreePrint( Tcl_InitObjRef(obj[0], Tcl_NewStringObj("::puts", -1)); while (tree != NULL) { s = TclGetString(tree->key) + offs; - Tcl_InitObjRef(obj[1], Tcl_ObjPrintf("%*s%.*s\t:%d", + Tcl_InitObjRef(obj[1], Tcl_ObjPrintf("%*s%.*s\t:%d", offs, "", tree->length - offs, s, tree->value)); Tcl_PutsObjCmd(NULL, interp, 2, obj); Tcl_UnsetObjRef(obj[1]); @@ -469,10 +469,10 @@ TclStrIdxTreeTestObjCmd( int optionIndex; if (objc < 2) { - Tcl_SetResult(interp, (char*)"wrong # args", TCL_STATIC); + Tcl_WrongNumArgs(interp, 1, objv, ""); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], options, + if (Tcl_GetIndexFromObj(interp, objv[1], options, "option", 0, &optionIndex) != TCL_OK) { Tcl_SetErrorCode(interp, "CLOCK", "badOption", Tcl_GetString(objv[1]), NULL); @@ -481,7 +481,7 @@ TclStrIdxTreeTestObjCmd( switch (optionIndex) { case O_FINDEQUAL: if (objc < 4) { - Tcl_SetResult(interp, (char*)"wrong # args", TCL_STATIC); + Tcl_WrongNumArgs(interp, 1, objv, ""); return TCL_ERROR; } cs = TclGetString(objv[2]); @@ -499,7 +499,7 @@ TclStrIdxTreeTestObjCmd( TclStrIdxTree idxTree = {NULL, NULL}; i = 1; while (++i < objc) { - if (TclListObjGetElements(interp, objv[i], + if (TclListObjGetElements(interp, objv[i], &lstc, &lstv) != TCL_OK) { return TCL_ERROR; }; diff --git a/generic/tclStrIdxTree.h b/generic/tclStrIdxTree.h index 9f26907..6ed5170 100644 --- a/generic/tclStrIdxTree.h +++ b/generic/tclStrIdxTree.h @@ -1,7 +1,7 @@ /* * tclStrIdxTree.h -- * - * Declarations of string index tries and other primitives currently + * Declarations of string index tries and other primitives currently * back-ported from tclSE. * * Copyright (c) 2016 Serg G. Brester (aka sebres) @@ -38,7 +38,7 @@ typedef struct TclStrIdx { * * TclUtfFindEqual, TclUtfFindEqualNC -- * - * Find largest part of string cs in string cin (case sensitive and not). + * Find largest part of string cs in string cin (case sensitive and not). * * Results: * Return position of UTF character in cs after last equal character. @@ -148,13 +148,13 @@ if (1) { \ MODULE_SCOPE const char* TclStrIdxTreeSearch(TclStrIdxTree **foundParent, - TclStrIdx **foundItem, TclStrIdxTree *tree, + TclStrIdx **foundItem, TclStrIdxTree *tree, const char *start, const char *end); MODULE_SCOPE int TclStrIdxTreeBuildFromList(TclStrIdxTree *idxTree, int lstc, Tcl_Obj **lstv, ClientData *values); -MODULE_SCOPE Tcl_Obj* +MODULE_SCOPE Tcl_Obj* TclStrIdxTreeNewObj(); MODULE_SCOPE TclStrIdxTree* diff --git a/library/clock.tcl b/library/clock.tcl index 94d2341..471deff 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -506,18 +506,103 @@ proc ::tcl::clock::Initialize {} { variable FormatProc; # Array mapping format group # and locale to the name of a procedure # that renders the given format + + variable mcLocales [dict create]; # Dictionary with loaded locales + variable mcMergedCat [dict create]; # Dictionary with merged locale catalogs } ::tcl::clock::Initialize #---------------------------------------------------------------------- -proc mcget {locale args} { - switch -- $locale system { - set locale [GetSystemLocale] +# mcget -- +# +# Return the merged translation catalog for the ::tcl::clock namespace +# Searching of catalog is similar to "msgcat::mc". +# +# Contrary to "msgcat::mc" may additionally load a package catalog +# on demand. +# +# Arguments: +# loc The locale used for translation. +# +# Results: +# Returns the dictionary object as whole catalog of the package/locale. +# +proc mcget {loc} { + variable mcMergedCat + switch -- $loc system { + set loc [GetSystemLocale] } current { - set locale [mclocale] + set loc [mclocale] + } + if {$loc eq {C}} { + set loclist [msgcat::PackagePreferences ::tcl::clock] + set loc [lindex $loclist 0] + } else { + set loc [string tolower $loc] + } + + # try to retrieve now if already available: + if {[dict exists $mcMergedCat $loc]} { + set mrgcat [dict get $mcMergedCat $loc] + return [dict smartref $mrgcat] } - msgcat::mcget ::tcl::clock $locale {*}$args + + # get locales list for given locale (de_de -> {de_de de {}}) + variable mcLocales + if {[dict exists $mcLocales $loc]} { + set loclist [dict get $mcLocales $loc] + } else { + # save current locale: + set prevloc [mclocale] + # lazy load catalog on demand (set it will load the catalog) + mcpackagelocale set $loc + set loclist [msgcat::GetPreferences $loc] + dict set $mcLocales $loc $loclist + # restore: + if {$prevloc ne $loc} { + mcpackagelocale set $prevloc + } + } + # get whole catalog: + mcMerge $loclist +} + +# mcMerge -- +# +# Merge message catalog dictionaries to one dictionary. +# +# Arguments: +# locales List of locales to merge. +# +# Results: +# Returns the (weak pointer) to merged dictionary of message catalog. +# +proc mcMerge {locales} { + variable mcMergedCat + if {[dict exists $mcMergedCat [set loc [lindex $locales 0]]]} { + set mrgcat [dict get $mcMergedCat $loc] + return [dict smartref $mrgcat] + } + # package msgcat currently does not provide possibility to get whole catalog: + upvar ::msgcat::Msgs Msgs + set ns ::tcl::clock + # Merge sequential locales (in reverse order, e. g. {} -> en -> en_en): + if {[llength $locales] > 1} { + set mrgcat [mcMerge [lrange $locales 1 end]] + if {[dict exists $Msgs $ns $loc]} { + set mrgcat [dict merge $mrgcat [dict get $Msgs $ns $loc]] + } + } else { + if {[dict exists $Msgs $ns $loc]} { + set mrgcat [dict get $Msgs $ns $loc] + } else { + set mrgcat [dict create] + } + } + dict set mcMergedCat $loc $mrgcat + # return smart reference (shared dict as object with exact one ref-counter) + return [dict smartref $mrgcat] } #---------------------------------------------------------------------- @@ -741,7 +826,7 @@ proc ::tcl::clock::LoadWindowsDateTimeFormats { locale } { proc ::tcl::clock::LocalizeFormat { locale format {fmtkey {}} } { variable LocaleFormats - + if { $fmtkey eq {} } { set fmtkey FMT_$format } if { [catch { set locfmt [dict get $LocaleFormats $locale $fmtkey] @@ -751,10 +836,10 @@ proc ::tcl::clock::LocalizeFormat { locale format {fmtkey {}} } { if { [catch { set mlst [dict get $LocaleFormats $locale MLST] }] } { - + # message catalog dictionary: set mcd [mcget $locale] - + # Handle locale-dependent format groups by mapping them out of the format # string. Note that the order of the [string map] operations is # significant because later formats can refer to later ones; for example @@ -779,7 +864,7 @@ proc ::tcl::clock::LocalizeFormat { locale format {fmtkey {}} } { dict set LocaleFormats $locale MLST $mlst } - # translate copy of format (don't use format object here, because otherwise + # translate copy of format (don't use format object here, because otherwise # it can lose its internal representation (string map - convert to unicode) set locfmt [string map $mlst [string range " $format" 1 end]] @@ -787,10 +872,10 @@ proc ::tcl::clock::LocalizeFormat { locale format {fmtkey {}} } { dict set LocaleFormats $locale $fmtkey $locfmt } - # Save original format as long as possible, because of internal + # Save original format as long as possible, because of internal # representation (performance). # Note that in this case such format will be never localized (also - # using another locales). To prevent this return a duplicate (but + # using another locales). To prevent this return a duplicate (but # it may be slower). if {$locfmt eq $format} { set locfmt $format @@ -849,7 +934,7 @@ proc ::tcl::clock::GetSystemTimeZone {} { if { [dict exists $TimeZoneBad $timezone] } { set timezone :localtime } - + # tell backend - current system timezone: configure -system-tz $timezone @@ -2004,13 +2089,14 @@ proc ::tcl::clock::ClearCaches {} { variable FormatProc variable LocaleFormats variable LocaleNumeralCache + variable mcMergedCat variable TimeZoneBad # tell backend - should invalidate: configure -clear # clear msgcat cache: - msgcat::ClearCaches ::tcl::clock + set mcMergedCat [dict create] foreach p [info procs [namespace current]::scanproc'*] { rename $p {} diff --git a/library/init.tcl b/library/init.tcl index fc88a72..dba73b0 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -159,7 +159,7 @@ if {[interp issafe]} { package unknown {::tcl::tm::UnknownHandler ::tclPkgUnknown} } else { # Default known auto_index (avoid loading auto index implicit after interp create): - + array set ::auto_index { ::tcl::tm::UnknownHandler {source [info library]/tm.tcl} ::tclPkgUnknown {source [info library]/package.tcl} @@ -433,7 +433,7 @@ proc auto_load {cmd {namespace {}}} { # workaround non canonical auto_index entries that might be around # from older auto_mkindex versions if {$cmd ni $nameList} {lappend nameList $cmd} - + # try to load (and create sub-cmd handler "_sub_load_cmd" for further usage): foreach name $nameList [set _sub_load_cmd { # via auto_index: @@ -463,7 +463,7 @@ proc auto_load {cmd {namespace {}}} { } } }] - + # load auto_index if possible: if {![info exists auto_path]} { return 0 diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index f9f57db..928474d 100644 --- a/library/msgcat/msgcat.tcl +++ b/library/msgcat/msgcat.tcl @@ -225,65 +225,6 @@ proc msgcat::mc {src args} { } } -# msgcat::mcget -- -# -# Return the translation for the given string based on the given -# locale setting or the whole dictionary object of the package/locale. -# Searching of catalog is similar to "msgcat::mc". -# -# Contrary to "msgcat::mc" may additionally load a package catalog -# on demand. -# -# Arguments: -# ns The package namespace (as catalog selector). -# loc The locale used for translation. -# {src} The string to translate. -# {args} Args to pass to the format command -# -# Results: -# Returns the translated string. Propagates errors thrown by the -# format command. - -proc msgcat::mcget {ns loc args} { - if {$loc eq {C}} { - set loclist [PackagePreferences $ns] - set loc [lindex $loclist 0] - } else { - set loc [string tolower $loc] - variable PackageConfig - # get locales list for given locale (de_de -> {de_de de {}}) - if {[catch { - set loclist [dict get $PackageConfig locales $ns $loc] - }]} { - # lazy load catalog on demand - mcpackagelocale load $loc $ns - set loclist [dict get $PackageConfig locales $ns $loc] - } - } - if {![llength $args]} { - # get whole catalog: - return [msgcat::Merge $ns $loclist] - } - set src [lindex $args 0] - # search translation for each locale (regarding parent namespaces) - for {set nscur $ns} {$nscur != ""} {set nscur [namespace parent $nscur]} { - foreach loc $loclist { - set msgs [mcget $nscur $loc] - if {![catch { set val [dict get $msgs $src] }]} { - if {[llength $args] == 1} { - return $val - } - return [format $val {*}[lrange $args 1 end]] - } - } - } - # no translation : - if {[llength $args] == 1} { - return $src - } - return [format $src {*}[lrange $args 1 end]] -} - # msgcat::mcexists -- # # Check if a catalog item is set or if mc would invoke mcunknown. @@ -474,10 +415,6 @@ proc msgcat::mcloadedlocales {subcommand} { # items, if the former locale was the default locale. # Returns the normalized set locale. # The default locale is taken, if locale is not given. -# load -# Load a package locale without set it (lazy loading from mcget). -# Returns the normalized set locale. -# The default locale is taken, if locale is not given. # get # Get the locale valid for this package. # isset @@ -505,7 +442,7 @@ proc msgcat::mcloadedlocales {subcommand} { # Results: # Empty string, if not stated differently for the subcommand -proc msgcat::mcpackagelocale {subcommand {locale ""} {ns ""}} { +proc msgcat::mcpackagelocale {subcommand {locale ""}} { # todo: implement using an ensemble variable Loclist variable LoadedLocales @@ -525,9 +462,7 @@ proc msgcat::mcpackagelocale {subcommand {locale ""} {ns ""}} { } set locale [string tolower $locale] } - if {$ns eq ""} { - set ns [uplevel 1 {::namespace current}] - } + set ns [uplevel 1 {::namespace current}] switch -exact -- $subcommand { get { return [lindex [PackagePreferences $ns] 0] } @@ -535,7 +470,7 @@ proc msgcat::mcpackagelocale {subcommand {locale ""} {ns ""}} { loaded { return [PackageLocales $ns] } present { return [expr {$locale in [PackageLocales $ns]} ]} isset { return [dict exists $PackageConfig loclist $ns] } - set - load { # set a package locale or add a package locale + set { # set a package locale or add a package locale # Copy the default locale if no package locale set so far if {![dict exists $PackageConfig loclist $ns]} { @@ -545,21 +480,17 @@ proc msgcat::mcpackagelocale {subcommand {locale ""} {ns ""}} { # Check if changed set loclist [dict get $PackageConfig loclist $ns] - if {[llength [info level 0]] == 2 || $locale eq [lindex $loclist 0] } { + if {! [info exists locale] || $locale eq [lindex $loclist 0] } { return [lindex $loclist 0] } # Change loclist set loclist [GetPreferences $locale] set locale [lindex $loclist 0] - if {$subcommand eq {set}} { - # set loclist - dict set PackageConfig loclist $ns $loclist - } + dict set PackageConfig loclist $ns $loclist # load eventual missing locales set loadedLocales [dict get $PackageConfig loadedlocales $ns] - dict set PackageConfig locales $ns $locale $loclist if {$locale in $loadedLocales} { return $locale } set loadLocales [ListComplement $loadedLocales $loclist] dict set PackageConfig loadedlocales $ns\ @@ -590,7 +521,6 @@ proc msgcat::mcpackagelocale {subcommand {locale ""} {ns ""}} { [dict get $PackageConfig loadedlocales $ns] $LoadedLocales] dict unset PackageConfig loadedlocales $ns dict unset PackageConfig loclist $ns - dict unset PackageConfig locales $ns # unset keys not in global loaded locales if {[dict exists $Msgs $ns]} { @@ -917,47 +847,6 @@ proc msgcat::Load {ns locales {callbackonly 0}} { return $x } -# msgcat::Merge -- -# -# Merge message catalog dictionaries to one dictionary. -# -# Arguments: -# ns Namespace (equal package) to load the message catalog. -# locales List of locales to merge. -# -# Results: -# Returns the merged dictionary of message catalogs. -proc msgcat::Merge {ns locales} { - variable Merged - if {![catch { - set mrgcat [dict get $Merged $ns [set loc [lindex $locales 0]]] - }]} { - return $mrgcat - } - variable Msgs - # Merge sequential locales (in reverse order, e. g. {} -> en -> en_en): - if {[llength $locales] > 1} { - set mrgcat [msgcat::Merge $ns [lrange $locales 1 end]] - catch { - set mrgcat [dict merge $mrgcat [dict get $Msgs $ns $loc]] - } - } else { - if {[catch { - set mrgcat [dict get $Msgs $ns $loc] - }]} { - set mrgcat [dict create] - } - } - dict set Merged $ns $loc $mrgcat - # return smart reference (shared dict as object with exact one ref-counter) - return [dict smartref $mrgcat] -} - -proc msgcat::ClearCaches {ns} { - variable Merged - dict unset Merged $ns -} - # msgcat::Invoke -- # # Invoke a set of registered callbacks. @@ -1030,7 +919,6 @@ proc msgcat::Invoke {index arglist {ns ""} {resultname ""} {failerror 0}} { proc msgcat::mcset {locale src {dest ""}} { variable Msgs - variable Merged if {[llength [info level 0]] == 3} { ;# dest not specified set dest $src } @@ -1040,7 +928,6 @@ proc msgcat::mcset {locale src {dest ""}} { set locale [string tolower $locale] dict set Msgs $ns $locale $src $dest - dict unset Merged $ns return $dest } @@ -1080,7 +967,6 @@ proc msgcat::mcflset {src {dest ""}} { proc msgcat::mcmset {locale pairs} { variable Msgs - variable Merged set length [llength $pairs] if {$length % 2} { @@ -1094,7 +980,6 @@ proc msgcat::mcmset {locale pairs} { foreach {src dest} $pairs { dict set Msgs $ns $locale $src $dest } - dict unset Merged $ns return [expr {$length / 2}] } diff --git a/library/reg/pkgIndex.tcl b/library/reg/pkgIndex.tcl index ab022ab..b1fe234 100755 --- a/library/reg/pkgIndex.tcl +++ b/library/reg/pkgIndex.tcl @@ -1,19 +1,9 @@ if {([info commands ::tcl::pkgconfig] eq "") - || ([info sharedlibextension] ne ".dll")} return + || ([info sharedlibextension] ne ".dll")} return if {[::tcl::pkgconfig get debug]} { - if {[info exists [file join $dir tclreg13g.dll]]} { package ifneeded registry 1.3.2 \ [list load [file join $dir tclreg13g.dll] registry] - } else { - package ifneeded registry 1.3.2 \ - [list load tclreg13g registry] - } } else { - if {[info exists [file join $dir tclreg13.dll]]} { package ifneeded registry 1.3.2 \ [list load [file join $dir tclreg13.dll] registry] - } else { - package ifneeded registry 1.3.2 \ - [list load tclreg13 registry] - } } diff --git a/tests/msgcat.test b/tests/msgcat.test index 584e420..1c3ce58 100644 --- a/tests/msgcat.test +++ b/tests/msgcat.test @@ -811,7 +811,7 @@ namespace eval ::msgcat::test { test msgcat-12.1 {mcpackagelocale no subcommand} -body { mcpackagelocale } -returnCodes 1\ - -result {wrong # args: should be "mcpackagelocale subcommand ?locale? ?ns?"} + -result {wrong # args: should be "mcpackagelocale subcommand ?locale?"} test msgcat-12.2 {mclpackagelocale wrong subcommand} -body { mcpackagelocale junk diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c index d95d39b..1d8b351 100644 --- a/unix/tclUnixTime.c +++ b/unix/tclUnixTime.c @@ -251,7 +251,7 @@ TclpWideClicksToNanoseconds( * * TclpWideClickInMicrosec -- * - * This procedure return scale to convert click values from the + * This procedure return scale to convert click values from the * TclpGetWideClicks native resolution to microsecond resolution * and back. * diff --git a/win/tclWinTime.c b/win/tclWinTime.c index d123985..bbcfe96 100644 --- a/win/tclWinTime.c +++ b/win/tclWinTime.c @@ -256,7 +256,7 @@ TclpGetWideClicks(void) /* * The frequency of the performance counter is fixed at system boot and - * is consistent across all processors. Therefore, the frequency need + * is consistent across all processors. Therefore, the frequency need * only be queried upon application initialization. */ if (QueryPerformanceFrequency(&perfCounterFreq)) { @@ -267,7 +267,7 @@ TclpGetWideClicks(void) wideClick.perfCounter = 0; wideClick.microsecsScale = 1; } - + wideClick.initialized = 1; } if (wideClick.perfCounter) { @@ -288,7 +288,7 @@ TclpGetWideClicks(void) * * TclpWideClickInMicrosec -- * - * This procedure return scale to convert wide click values from the + * This procedure return scale to convert wide click values from the * TclpGetWideClicks native resolution to microsecond resolution * and back. * @@ -327,7 +327,7 @@ TclpWideClickInMicrosec(void) *---------------------------------------------------------------------- */ -Tcl_WideInt +Tcl_WideInt TclpGetMicroseconds(void) { Tcl_WideInt usecSincePosixEpoch; |