diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclClock.c | 176 | ||||
-rw-r--r-- | generic/tclClockFmt.c | 239 | ||||
-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/tclGetDate.y | 2 | ||||
-rw-r--r-- | generic/tclInt.h | 2 | ||||
-rw-r--r-- | generic/tclStrIdxTree.c | 36 | ||||
-rw-r--r-- | generic/tclStrIdxTree.h | 8 |
10 files changed, 245 insertions, 246 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c index 0895bbb..95b3e36 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/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 2480685..5b8deb6 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/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 5bd4324..8edc518 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4875,7 +4875,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* |