From d551c0972c261cc3a69b07263ae3c8072d929a50 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 10 Jan 2017 22:55:00 +0000 Subject: [unix] build for *nix fixed, code clean-ups; missing declarations; unused vars, functions etc; types normalization; --- generic/tclClock.c | 6 +--- generic/tclClockFmt.c | 31 ++++++++++--------- generic/tclDate.c | 8 ++--- generic/tclDate.h | 80 +++++++++++++++++++++++++------------------------ generic/tclGetDate.y | 8 ++--- generic/tclStrIdxTree.c | 8 ++--- generic/tclStrIdxTree.h | 8 ++--- unix/Makefile.in | 4 +-- 8 files changed, 77 insertions(+), 76 deletions(-) diff --git a/generic/tclClock.c b/generic/tclClock.c index 7d4263c..1b1faae 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -137,10 +137,6 @@ static unsigned long TzsetGetEpoch(void); static void TzsetIfNecessary(void); static void ClockDeleteCmdProc(ClientData); -static int ClockTestObjCmd( - ClientData clientData, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); - /* * Structure containing description of "native" clock commands to create. */ @@ -3365,7 +3361,7 @@ repeat_rel: /* relative time (seconds), if exceeds current date, do the day conversion and * leave rest of the increment in yyRelSeconds to add it hereafter in UTC seconds */ if (yyRelSeconds) { - time_t newSecs = yySeconds + yyRelSeconds; + int newSecs = yySeconds + yyRelSeconds; /* if seconds increment outside of current date, increment day */ if (newSecs / SECONDS_PER_DAY != yySeconds / SECONDS_PER_DAY) { diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c index 680e33d..a5ddd18 100644 --- a/generic/tclClockFmt.c +++ b/generic/tclClockFmt.c @@ -43,13 +43,13 @@ CLOCK_LOCALE_LITERAL_ARRAY(MsgCtLitIdxs, "_IDX_"); inline int _str2int( - time_t *out, + int *out, register const char *p, const char *e, int sign) { - register time_t val = 0, prev = 0; + register int val = 0, prev = 0; if (sign >= 0) { while (p < e) { val = val * 10 + (*p++ - '0'); @@ -880,6 +880,7 @@ ObjListSearch(ClockFmtScnCmdArgs *opts, } return TCL_RETURN; } +#if 0 static int LocaleListSearch(ClockFmtScnCmdArgs *opts, @@ -905,6 +906,7 @@ LocaleListSearch(ClockFmtScnCmdArgs *opts, return ObjListSearch(opts, info, val, lstv, lstc, minLen, maxLen); } +#endif static TclStrIdxTree * ClockMCGetListIdxTree( @@ -1039,6 +1041,7 @@ ClockStrIdxTreeSearch(ClockFmtScnCmdArgs *opts, return TCL_OK; } +#if 0 static int StaticListSearch(ClockFmtScnCmdArgs *opts, @@ -1062,6 +1065,7 @@ StaticListSearch(ClockFmtScnCmdArgs *opts, } return TCL_RETURN; } +#endif inline const char * FindWordEnd( @@ -1069,7 +1073,7 @@ FindWordEnd( register const char * p, const char * end) { register const char *x = tok->tokWord.start; - const char *pfnd; + const char *pfnd = p; if (x == tok->tokWord.end - 1) { /* fast phase-out for single char word */ if (*p == *x) { return ++p; @@ -1088,14 +1092,14 @@ static int ClockScnToken_Month_Proc(ClockFmtScnCmdArgs *opts, DateInfo *info, ClockScanToken *tok) { - /* +#if 0 static const char * months[] = { - /* full * / + /* full */ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", - /* abbr * / + /* abbr */ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL @@ -1106,7 +1110,7 @@ ClockScnToken_Month_Proc(ClockFmtScnCmdArgs *opts, } yyMonth = (val % 12) + 1; return TCL_OK; - */ +#endif static int monthsKeys[] = {MCLIT_MONTHS_FULL, MCLIT_MONTHS_ABBREV, 0}; @@ -1300,7 +1304,7 @@ ClockScnToken_LocaleListMatcher_Proc(ClockFmtScnCmdArgs *opts, } if (tok->map->offs > 0) { - *(time_t *)(((char *)info) + tok->map->offs) = val; + *(int *)(((char *)info) + tok->map->offs) = val; } return TCL_OK; @@ -1334,7 +1338,7 @@ ClockScnToken_TimeZone_Proc(ClockFmtScnCmdArgs *opts, *bp++ = *p++; len++; if (len + 2 < maxLen) { if (*p == ':') { - *p++; len++; + p++; len++; } } } @@ -1392,7 +1396,7 @@ ClockScnToken_StarDate_Proc(ClockFmtScnCmdArgs *opts, { int minLen, maxLen; register const char *p = yyInput, *end; const char *s; - time_t year, fractYear, fractDayDiv, fractDay; + int year, fractYear, fractDayDiv, fractDay; static const char *stardatePref = "stardate "; DetermineGreedySearchLen(opts, info, tok, &minLen, &maxLen); @@ -1626,7 +1630,7 @@ EstimateTokenCount( #define AllocTokenInChain(tok, chain, tokCnt) \ if (++(tok) >= (chain) + (tokCnt)) { \ - (char *)(chain) = ckrealloc((char *)(chain), \ + *((char **)&chain) = ckrealloc((char *)(chain), \ (tokCnt + CLOCK_MIN_TOK_CHAIN_BLOCK_SIZE) * sizeof(*(tok))); \ if ((chain) == NULL) { goto done; }; \ (tok) = (chain) + (tokCnt); \ @@ -1929,7 +1933,7 @@ ClockScan( if (map->offs) { p = yyInput; x = p + size; if (!(map->flags & (CLF_LOCALSEC|CLF_POSIXSEC))) { - if (_str2int((time_t *)(((char *)info) + map->offs), + if (_str2int((int *)(((char *)info) + map->offs), p, x, sign) != TCL_OK) { goto overflow; } @@ -2678,7 +2682,6 @@ ClockFormat( register DateFormat *dateFmt, /* Date fields used for parsing & converting */ ClockFmtScnCmdArgs *opts) /* Command options */ { - ClockClientData *dataPtr = opts->clientData; ClockFmtScnStorage *fss; ClockFormatToken *tok; ClockFormatTokenMap *map; @@ -2716,7 +2719,7 @@ ClockFormat( { case CFMTT_INT: if (1) { - int val = (int)*(time_t *)(((char *)dateFmt) + map->offs); + int val = (int)*(int *)(((char *)dateFmt) + map->offs); if (map->fmtproc == NULL) { if (map->flags & CLFMT_DECR) { val--; diff --git a/generic/tclDate.c b/generic/tclDate.c index 5bd96d0..64cb804 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -2448,11 +2448,11 @@ TclDateerror( infoPtr->separatrix = "\n"; } -time_t +MODULE_SCOPE int ToSeconds( - time_t Hours, - time_t Minutes, - time_t Seconds, + int Hours, + int Minutes, + int Seconds, MERIDIAN Meridian) { if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) { diff --git a/generic/tclDate.h b/generic/tclDate.h index c50753d..c9c6726 100644 --- a/generic/tclDate.h +++ b/generic/tclDate.h @@ -142,21 +142,21 @@ typedef struct TclDateFields { * epoch */ Tcl_WideInt localSeconds; /* Local time expressed in nominal seconds * from the Posix epoch */ - time_t tzOffset; /* Time zone offset in seconds east of + int tzOffset; /* Time zone offset in seconds east of * Greenwich */ - time_t julianDay; /* Julian Day Number in local time zone */ + int julianDay; /* Julian Day Number in local time zone */ enum {BCE=1, CE=0} era; /* Era */ - time_t gregorian; /* Flag == 1 if the date is Gregorian */ - time_t year; /* Year of the era */ - time_t dayOfYear; /* Day of the year (1 January == 1) */ - time_t month; /* Month number */ - time_t dayOfMonth; /* Day of the month */ - time_t iso8601Year; /* ISO8601 week-based year */ - time_t iso8601Week; /* ISO8601 week number */ - time_t dayOfWeek; /* Day of the week */ - time_t hour; /* Hours of day (in-between time only calculation) */ - time_t minutes; /* Minutes of day (in-between time only calculation) */ - time_t secondOfDay; /* Seconds of day (in-between time only calculation) */ + int gregorian; /* Flag == 1 if the date is Gregorian */ + int year; /* Year of the era */ + int dayOfYear; /* Day of the year (1 January == 1) */ + int month; /* Month number */ + int dayOfMonth; /* Day of the month */ + int iso8601Year; /* ISO8601 week-based year */ + int iso8601Week; /* ISO8601 week number */ + int dayOfWeek; /* Day of the week */ + int hour; /* Hours of day (in-between time only calculation) */ + int minutes; /* Minutes of day (in-between time only calculation) */ + int secondOfDay; /* Seconds of day (in-between time only calculation) */ /* Non cacheable fields: */ @@ -180,34 +180,34 @@ typedef struct DateInfo { int flags; - time_t dateHaveDate; + int dateHaveDate; - time_t dateMeridian; - time_t dateHaveTime; + int dateMeridian; + int dateHaveTime; - time_t dateTimezone; - time_t dateDSTmode; - time_t dateHaveZone; + int dateTimezone; + int dateDSTmode; + int dateHaveZone; - time_t dateRelMonth; - time_t dateRelDay; - time_t dateRelSeconds; - time_t dateHaveRel; + int dateRelMonth; + int dateRelDay; + int dateRelSeconds; + int dateHaveRel; - time_t dateMonthOrdinalIncr; - time_t dateMonthOrdinal; - time_t dateHaveOrdinalMonth; + int dateMonthOrdinalIncr; + int dateMonthOrdinal; + int dateHaveOrdinalMonth; - time_t dateDayOrdinal; - time_t dateDayNumber; - time_t dateHaveDay; + int dateDayOrdinal; + int dateDayNumber; + int dateHaveDay; - time_t *dateRelPointer; + int *dateRelPointer; - time_t dateSpaceCount; - time_t dateDigitCount; + int dateSpaceCount; + int dateDigitCount; - time_t dateCentury; + int dateCentury; Tcl_Obj* messages; /* Error messages */ const char* separatrix; /* String separating messages */ @@ -244,7 +244,7 @@ typedef struct DateInfo { #define yyDigitCount (info->dateDigitCount) #define yySpaceCount (info->dateSpaceCount) -inline void +static inline void ClockInitDateInfo(DateInfo *info) { memset(info, 0, sizeof(DateInfo)); } @@ -314,7 +314,7 @@ typedef struct ClockClientData { Tcl_WideInt seconds; Tcl_WideInt rangesVal[2]; /* Bounds for cached time zone offset */ /* values */ - time_t tzOffset; + int tzOffset; Tcl_Obj *tzName; } UTC2Local; /* Las-period cache for fast Local2UTC conversion */ @@ -325,7 +325,7 @@ typedef struct ClockClientData { Tcl_WideInt localSeconds; Tcl_WideInt rangesVal[2]; /* Bounds for cached time zone offset */ /* values */ - time_t tzOffset; + int tzOffset; } Local2UTC; } ClockClientData; @@ -444,16 +444,18 @@ typedef struct ClockFmtScnStorage { ClockFmtScnStorage *nextPtr; ClockFmtScnStorage *prevPtr; #endif -/* +Tcl_HashEntry hashEntry /* ClockFmtScnStorage is a derivate of Tcl_HashEntry, +#if 0 + +Tcl_HashEntry hashEntry /* ClockFmtScnStorage is a derivate of Tcl_HashEntry, * stored by offset +sizeof(self) */ +#endif } ClockFmtScnStorage; /* * Prototypes of module functions. */ -MODULE_SCOPE time_t ToSeconds(time_t Hours, time_t Minutes, - time_t Seconds, MERIDIAN Meridian); +MODULE_SCOPE int ToSeconds(int Hours, int Minutes, + int Seconds, MERIDIAN Meridian); MODULE_SCOPE int IsGregorianLeapYear(TclDateFields *); MODULE_SCOPE void GetJulianDayFromEraYearWeekDay( diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index 9e3623f..6d6a0d0 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -659,11 +659,11 @@ TclDateerror( infoPtr->separatrix = "\n"; } -time_t +MODULE_SCOPE int ToSeconds( - time_t Hours, - time_t Minutes, - time_t Seconds, + int Hours, + int Minutes, + int Seconds, MERIDIAN Meridian) { if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) { diff --git a/generic/tclStrIdxTree.c b/generic/tclStrIdxTree.c index afb53e5..b47b4b7 100644 --- a/generic/tclStrIdxTree.c +++ b/generic/tclStrIdxTree.c @@ -171,11 +171,11 @@ TclStrIdxTreeInsertBranch( parent->firstPtr = item; if (parent->lastPtr == child) parent->lastPtr = item; - if (item->nextPtr = child->nextPtr) { + if ( (item->nextPtr = child->nextPtr) ) { item->nextPtr->prevPtr = item; child->nextPtr = NULL; } - if (item->prevPtr = child->prevPtr) { + if ( (item->prevPtr = child->prevPtr) ) { item->prevPtr->nextPtr = item; child->prevPtr = NULL; } @@ -365,7 +365,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 *)copyPtr->internalRep.twoPtrValue.ptr1), + Tcl_InitObjRef(*((Tcl_Obj **)©Ptr->internalRep.twoPtrValue.ptr1), srcPtr); copyPtr->internalRep.twoPtrValue.ptr2 = NULL; copyPtr->typePtr = &StrIdxTreeObjType; @@ -379,7 +379,7 @@ StrIdxTreeObj_FreeIntRepProc(Tcl_Obj *objPtr) && objPtr->internalRep.twoPtrValue.ptr2 == NULL ) { /* is a link */ - Tcl_UnsetObjRef(((Tcl_Obj *)objPtr->internalRep.twoPtrValue.ptr1)); + Tcl_UnsetObjRef(*((Tcl_Obj **)&objPtr->internalRep.twoPtrValue.ptr1)); } else { /* is a tree */ TclStrIdxTree *tree = (TclStrIdxTree*)&objPtr->internalRep.twoPtrValue.ptr1; diff --git a/generic/tclStrIdxTree.h b/generic/tclStrIdxTree.h index 934e28f..305053c 100644 --- a/generic/tclStrIdxTree.h +++ b/generic/tclStrIdxTree.h @@ -49,7 +49,7 @@ typedef struct TclStrIdx { *---------------------------------------------------------------------- */ -inline const char * +static inline const char * TclUtfFindEqual( register const char *cs, /* UTF string to find in cin. */ register const char *cse, /* End of cs */ @@ -66,7 +66,7 @@ TclUtfFindEqual( return ret; } -inline const char * +static inline const char * TclUtfFindEqualNC( register const char *cs, /* UTF string to find in cin. */ register const char *cse, /* End of cs */ @@ -89,7 +89,7 @@ TclUtfFindEqualNC( return ret; } -inline const char * +static inline const char * TclUtfFindEqualNCInLwr( register const char *cs, /* UTF string (in anycase) to find in cin. */ register const char *cse, /* End of cs */ @@ -111,7 +111,7 @@ TclUtfFindEqualNCInLwr( return ret; } -inline const char * +static inline const char * TclUtfNext( register const char *src) /* The current location in the string. */ { diff --git a/unix/Makefile.in b/unix/Makefile.in index 19ab6ec..9bdcacd 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -292,7 +292,7 @@ XTTEST_OBJS = xtTestInit.o tclTest.o tclTestObj.o tclTestProcBodyObj.o \ GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \ tclAssembly.o tclAsync.o tclBasic.o tclBinary.o tclCkalloc.o \ - tclClock.o tclCmdAH.o tclCmdIL.o tclCmdMZ.o \ + tclClock.o tclClockFmt.o tclCmdAH.o tclCmdIL.o tclCmdMZ.o \ tclCompCmds.o tclCompCmdsGR.o tclCompCmdsSZ.o tclCompExpr.o \ tclCompile.o tclConfig.o tclDate.o tclDictObj.o tclDisassemble.o \ tclEncoding.o tclEnsemble.o \ @@ -304,7 +304,7 @@ GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \ tclObj.o tclOptimize.o tclPanic.o tclParse.o tclPathObj.o tclPipe.o \ tclPkg.o tclPkgConfig.o tclPosixStr.o \ tclPreserve.o tclProc.o tclRegexp.o \ - tclResolve.o tclResult.o tclScan.o tclStringObj.o \ + tclResolve.o tclResult.o tclScan.o tclStringObj.o tclStrIdxTree.o \ tclStrToD.o tclThread.o \ tclThreadAlloc.o tclThreadJoin.o tclThreadStorage.o tclStubInit.o \ tclTimer.o tclTrace.o tclUtf.o tclUtil.o tclVar.o tclZlib.o \ -- cgit v0.12