summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2008-10-26 18:34:03 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2008-10-26 18:34:03 (GMT)
commitd84707cdee0b26bca07af2756cb4e234e11a6195 (patch)
treeb47f8826ac440515804f80e59f434ef1dff42fd1 /generic
parentc2a4f7e6129491089c0fa4d0202ed91617d29591 (diff)
downloadtcl-d84707cdee0b26bca07af2756cb4e234e11a6195.zip
tcl-d84707cdee0b26bca07af2756cb4e234e11a6195.tar.gz
tcl-d84707cdee0b26bca07af2756cb4e234e11a6195.tar.bz2
Style improvements - invoking callbacks without visual junk.
Diffstat (limited to 'generic')
-rw-r--r--generic/regexec.c2
-rw-r--r--generic/tclAsync.c4
-rw-r--r--generic/tclBinary.c98
-rw-r--r--generic/tclClock.c409
-rw-r--r--generic/tclCmdAH.c4
-rw-r--r--generic/tclCompExpr.c4
-rw-r--r--generic/tclCompile.c18
-rw-r--r--generic/tclEncoding.c84
-rw-r--r--generic/tclEvent.c11
-rw-r--r--generic/tclExecute.c15
-rw-r--r--generic/tclHistory.c4
-rw-r--r--generic/tclIO.c98
-rw-r--r--generic/tclIORTrans.c994
-rw-r--r--generic/tclNamesp.c8
-rw-r--r--generic/tclNotify.c14
-rw-r--r--generic/tclObj.c22
-rw-r--r--generic/tclPanic.c6
-rw-r--r--generic/tclParse.c8
-rw-r--r--generic/tclPathObj.c14
-rw-r--r--generic/tclPreserve.c6
-rw-r--r--generic/tclResult.c14
-rw-r--r--generic/tclStringObj.c9
-rw-r--r--generic/tclTimer.c8
-rw-r--r--generic/tclTrace.c18
-rw-r--r--generic/tclUtil.c19
-rw-r--r--generic/tclVar.c10
26 files changed, 948 insertions, 953 deletions
diff --git a/generic/regexec.c b/generic/regexec.c
index 24edb41..ed6ceec 100644
--- a/generic/regexec.c
+++ b/generic/regexec.c
@@ -1132,7 +1132,7 @@ cbrdissect(
i = 0;
for (p = begin; p <= stop && (i < max || max == INFINITY); p += len) {
- if ((*v->g->compare)(paren, p, len) != 0) {
+ if (v->g->compare(paren, p, len) != 0) {
break;
}
i++;
diff --git a/generic/tclAsync.c b/generic/tclAsync.c
index 1e5733e..175eaad 100644
--- a/generic/tclAsync.c
+++ b/generic/tclAsync.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclAsync.c,v 1.16 2008/05/03 19:31:07 das Exp $
+ * RCS: @(#) $Id: tclAsync.c,v 1.17 2008/10/26 18:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -237,7 +237,7 @@ Tcl_AsyncInvoke(
}
asyncPtr->ready = 0;
Tcl_MutexUnlock(&tsdPtr->asyncMutex);
- code = (*asyncPtr->proc)(asyncPtr->clientData, interp, code);
+ code = asyncPtr->proc(asyncPtr->clientData, interp, code);
Tcl_MutexLock(&tsdPtr->asyncMutex);
}
tsdPtr->asyncActive = 0;
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 4073a61..680ef41 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBinary.c,v 1.48 2008/10/15 06:17:04 nijtmans Exp $
+ * RCS: @(#) $Id: tclBinary.c,v 1.49 2008/10/26 18:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -71,7 +71,7 @@ static void UpdateStringOfByteArray(Tcl_Obj *listPtr);
static void DeleteScanNumberCache(Tcl_HashTable *numberCachePtr);
static int NeedReversing(int format);
static void CopyNumber(const void *from, void *to,
- unsigned int length, int type);
+ unsigned length, int type);
/* Binary ensemble commands */
static int BinaryFormatCmd(ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[]);
@@ -452,7 +452,7 @@ SetByteArrayFromAny(
byteArrayPtr = (ByteArray *) ckalloc(BYTEARRAY_SIZE(length));
for (dst = byteArrayPtr->bytes; src < srcEnd; ) {
src += Tcl_UtfToUniChar(src, &ch);
- *dst++ = (unsigned char) ch;
+ *dst++ = UCHAR(ch);
}
byteArrayPtr->used = dst - byteArrayPtr->bytes;
@@ -977,7 +977,7 @@ BinaryFormatCmd(
goto badValue;
}
if (((offset + 1) % 8) == 0) {
- *cursor++ = (unsigned char) value;
+ *cursor++ = UCHAR(value);
value = 0;
}
}
@@ -992,7 +992,7 @@ BinaryFormatCmd(
goto badValue;
}
if (!((offset + 1) % 8)) {
- *cursor++ = (unsigned char) value;
+ *cursor++ = UCHAR(value);
value = 0;
}
}
@@ -1003,7 +1003,7 @@ BinaryFormatCmd(
} else {
value >>= 8 - (offset % 8);
}
- *cursor++ = (unsigned char) value;
+ *cursor++ = UCHAR(value);
}
while (cursor < last) {
*cursor++ = '\0';
@@ -1067,7 +1067,7 @@ BinaryFormatCmd(
}
value |= ((c << 4) & 0xf0);
if (offset % 2) {
- *cursor++ = (unsigned char)(value & 0xff);
+ *cursor++ = UCHAR(value & 0xff);
value = 0;
}
}
@@ -1078,7 +1078,7 @@ BinaryFormatCmd(
} else {
value >>= 4;
}
- *cursor++ = (unsigned char) value;
+ *cursor++ = UCHAR(value);
}
while (cursor < last) {
@@ -1751,7 +1751,7 @@ static void
CopyNumber(
const void *from, /* source */
void *to, /* destination */
- unsigned int length, /* Number of bytes to copy */
+ unsigned length, /* Number of bytes to copy */
int type) /* What type of thing are we copying? */
{
switch (NeedReversing(type)) {
@@ -1904,23 +1904,23 @@ FormatNumber(
return TCL_ERROR;
}
if (NeedReversing(type)) {
- *(*cursorPtr)++ = (unsigned char) wvalue;
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 8);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 16);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 24);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 32);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 40);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 48);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 56);
+ *(*cursorPtr)++ = UCHAR(wvalue);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 8);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 16);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 24);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 32);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 40);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 48);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 56);
} else {
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 56);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 48);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 40);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 32);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 24);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 16);
- *(*cursorPtr)++ = (unsigned char) (wvalue >> 8);
- *(*cursorPtr)++ = (unsigned char) wvalue;
+ *(*cursorPtr)++ = UCHAR(wvalue >> 56);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 48);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 40);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 32);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 24);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 16);
+ *(*cursorPtr)++ = UCHAR(wvalue >> 8);
+ *(*cursorPtr)++ = UCHAR(wvalue);
}
return TCL_OK;
@@ -1934,15 +1934,15 @@ FormatNumber(
return TCL_ERROR;
}
if (NeedReversing(type)) {
- *(*cursorPtr)++ = (unsigned char) value;
- *(*cursorPtr)++ = (unsigned char) (value >> 8);
- *(*cursorPtr)++ = (unsigned char) (value >> 16);
- *(*cursorPtr)++ = (unsigned char) (value >> 24);
+ *(*cursorPtr)++ = UCHAR(value);
+ *(*cursorPtr)++ = UCHAR(value >> 8);
+ *(*cursorPtr)++ = UCHAR(value >> 16);
+ *(*cursorPtr)++ = UCHAR(value >> 24);
} else {
- *(*cursorPtr)++ = (unsigned char) (value >> 24);
- *(*cursorPtr)++ = (unsigned char) (value >> 16);
- *(*cursorPtr)++ = (unsigned char) (value >> 8);
- *(*cursorPtr)++ = (unsigned char) value;
+ *(*cursorPtr)++ = UCHAR(value >> 24);
+ *(*cursorPtr)++ = UCHAR(value >> 16);
+ *(*cursorPtr)++ = UCHAR(value >> 8);
+ *(*cursorPtr)++ = UCHAR(value);
}
return TCL_OK;
@@ -1956,11 +1956,11 @@ FormatNumber(
return TCL_ERROR;
}
if (NeedReversing(type)) {
- *(*cursorPtr)++ = (unsigned char) value;
- *(*cursorPtr)++ = (unsigned char) (value >> 8);
+ *(*cursorPtr)++ = UCHAR(value);
+ *(*cursorPtr)++ = UCHAR(value >> 8);
} else {
- *(*cursorPtr)++ = (unsigned char) (value >> 8);
- *(*cursorPtr)++ = (unsigned char) value;
+ *(*cursorPtr)++ = UCHAR(value >> 8);
+ *(*cursorPtr)++ = UCHAR(value);
}
return TCL_OK;
@@ -1971,7 +1971,7 @@ FormatNumber(
if (TclGetLongFromObj(interp, src, &value) != TCL_OK) {
return TCL_ERROR;
}
- *(*cursorPtr)++ = (unsigned char) value;
+ *(*cursorPtr)++ = UCHAR(value);
return TCL_OK;
default:
@@ -2076,7 +2076,7 @@ ScanNumber(
value = (long) (buffer[3]
+ (buffer[2] << 8)
+ (buffer[1] << 16)
- + (((long)buffer[0]) << 24));
+ + (((long) buffer[0]) << 24));
}
/*
@@ -2089,9 +2089,9 @@ ScanNumber(
if (flags & BINARY_UNSIGNED) {
return Tcl_NewWideIntObj((Tcl_WideInt)(unsigned long)value);
}
- if ((value & (((unsigned int)1)<<31)) && (value > 0)) {
- value -= (((unsigned int)1)<<31);
- value -= (((unsigned int)1)<<31);
+ if ((value & (((unsigned) 1)<<31)) && (value > 0)) {
+ value -= (((unsigned) 1)<<31);
+ value -= (((unsigned) 1)<<31);
}
returnNumericObject:
@@ -2104,13 +2104,13 @@ ScanNumber(
hPtr = Tcl_CreateHashEntry(tablePtr, (char *)value, &isNew);
if (!isNew) {
- return (Tcl_Obj *) Tcl_GetHashValue(hPtr);
+ return Tcl_GetHashValue(hPtr);
}
if (tablePtr->numEntries <= BINARY_SCAN_MAX_CACHE) {
register Tcl_Obj *objPtr = Tcl_NewLongObj(value);
Tcl_IncrRefCount(objPtr);
- Tcl_SetHashValue(hPtr, (ClientData) objPtr);
+ Tcl_SetHashValue(hPtr, objPtr);
return objPtr;
}
@@ -2360,10 +2360,9 @@ BinaryDecodeHex(
if (!isxdigit((int) c)) {
if (strict) {
goto badChar;
- } else {
- i--;
- continue;
}
+ i--;
+ continue;
}
value <<= 4;
c -= '0';
@@ -2572,10 +2571,9 @@ BinaryDecodeUu(
if (c < 33 || c > 96) {
if (strict) {
goto badUu;
- } else {
- i--;
- continue;
}
+ i--;
+ continue;
}
} else {
++cut;
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 8b2e259..7b445ca 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -7,12 +7,12 @@
*
* Copyright 1991-1995 Karl Lehenbauer and Mark Diekhans.
* Copyright (c) 1995 Sun Microsystems, Inc.
- * Copyright (c) 2004 by Kevin B. Kenny. All rights reserved.
+ * Copyright (c) 2004 by Kevin B. Kenny. All rights reserved.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclClock.c,v 1.71 2008/10/16 22:34:19 nijtmans Exp $
+ * RCS: @(#) $Id: tclClock.c,v 1.72 2008/10/26 18:34:03 dkf Exp $
*/
#include "tclInt.h"
@@ -33,12 +33,12 @@
#define SECONDS_PER_DAY 86400
#define JULIAN_SEC_POSIX_EPOCH (((Tcl_WideInt) JULIAN_DAY_POSIX_EPOCH) \
* SECONDS_PER_DAY)
-#define FOUR_CENTURIES 146097 /* days */
+#define FOUR_CENTURIES 146097 /* days */
#define JDAY_1_JAN_1_CE_JULIAN 1721424
#define JDAY_1_JAN_1_CE_GREGORIAN 1721426
-#define ONE_CENTURY_GREGORIAN 36524 /* days */
-#define FOUR_YEARS 1461 /* days */
-#define ONE_YEAR 365 /* days */
+#define ONE_CENTURY_GREGORIAN 36524 /* days */
+#define FOUR_YEARS 1461 /* days */
+#define ONE_YEAR 365 /* days */
/*
* Table of the days in each month, leap and common years
@@ -94,8 +94,8 @@ static const char *const literals[] = {
*/
typedef struct ClockClientData {
- int refCount; /* Number of live references */
- Tcl_Obj** literals; /* Pool of object literals */
+ int refCount; /* Number of live references. */
+ Tcl_Obj **literals; /* Pool of object literals. */
} ClockClientData;
/*
@@ -109,7 +109,7 @@ typedef struct TclDateFields {
* from the Posix epoch */
int tzOffset; /* Time zone offset in seconds east of
* Greenwich */
- Tcl_Obj* tzName; /* Time zone name */
+ Tcl_Obj *tzName; /* Time zone name */
int julianDay; /* Julian Day Number in local time zone */
enum {BCE=1, CE=0} era; /* Era */
int gregorian; /* Flag == 1 if the date is Gregorian */
@@ -141,26 +141,26 @@ TCL_DECLARE_MUTEX(clockMutex)
* Function prototypes for local procedures in this file:
*/
-static int ConvertUTCToLocal(Tcl_Interp*,
- TclDateFields*, Tcl_Obj*, int);
-static int ConvertUTCToLocalUsingTable(Tcl_Interp*,
- TclDateFields*, int, Tcl_Obj *const[]);
-static int ConvertUTCToLocalUsingC(Tcl_Interp*,
- TclDateFields*, int);
-static int ConvertLocalToUTC(Tcl_Interp*,
- TclDateFields*, Tcl_Obj*, int);
-static int ConvertLocalToUTCUsingTable(Tcl_Interp*,
- TclDateFields*, int, Tcl_Obj *const[]);
-static int ConvertLocalToUTCUsingC(Tcl_Interp*,
- TclDateFields*, int);
-static Tcl_Obj* LookupLastTransition(Tcl_Interp*, Tcl_WideInt,
+static int ConvertUTCToLocal(Tcl_Interp *,
+ TclDateFields *, Tcl_Obj *, int);
+static int ConvertUTCToLocalUsingTable(Tcl_Interp *,
+ TclDateFields *, int, Tcl_Obj *const[]);
+static int ConvertUTCToLocalUsingC(Tcl_Interp *,
+ TclDateFields *, int);
+static int ConvertLocalToUTC(Tcl_Interp *,
+ TclDateFields *, Tcl_Obj *, int);
+static int ConvertLocalToUTCUsingTable(Tcl_Interp *,
+ TclDateFields *, int, Tcl_Obj *const[]);
+static int ConvertLocalToUTCUsingC(Tcl_Interp *,
+ TclDateFields *, int);
+static Tcl_Obj * LookupLastTransition(Tcl_Interp *, Tcl_WideInt,
int, Tcl_Obj *const *);
-static void GetYearWeekDay(TclDateFields*, int);
-static void GetGregorianEraYearDay(TclDateFields*, int);
-static void GetMonthDay(TclDateFields*);
-static void GetJulianDayFromEraYearWeekDay(TclDateFields*, int);
-static void GetJulianDayFromEraYearMonthDay(TclDateFields*, int);
-static int IsGregorianLeapYear(TclDateFields*);
+static void GetYearWeekDay(TclDateFields *, int);
+static void GetGregorianEraYearDay(TclDateFields *, int);
+static void GetMonthDay(TclDateFields *);
+static void GetJulianDayFromEraYearWeekDay(TclDateFields *, int);
+static void GetJulianDayFromEraYearMonthDay(TclDateFields *, int);
+static int IsGregorianLeapYear(TclDateFields *);
static int WeekdayOnOrBefore(int, int);
static int ClockClicksObjCmd(
ClientData clientData, Tcl_Interp *interp,
@@ -187,7 +187,7 @@ static int ClockMillisecondsObjCmd(
ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[]);
static int ClockParseformatargsObjCmd(
- ClientData clientData, Tcl_Interp* interp,
+ ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[]);
static int ClockSecondsObjCmd(
ClientData clientData, Tcl_Interp *interp,
@@ -225,7 +225,7 @@ static const struct ClockCommand clockCommands[] = {
{ "ParseFormatArgs", ClockParseformatargsObjCmd },
{ NULL, NULL }
};
-
+
/*
*----------------------------------------------------------------------
*
@@ -261,7 +261,7 @@ TclClockInit(
data = (ClockClientData *) ckalloc(sizeof(ClockClientData));
data->refCount = 0;
- data->literals = (Tcl_Obj**) ckalloc(LIT__END * sizeof(Tcl_Obj*));
+ data->literals = (Tcl_Obj **) ckalloc(LIT__END * sizeof(Tcl_Obj*));
for (i = 0; i < LIT__END; ++i) {
data->literals[i] = Tcl_NewStringObj(literals[i], -1);
Tcl_IncrRefCount(data->literals[i]);
@@ -280,7 +280,7 @@ TclClockInit(
ClockDeleteCmdProc);
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -310,15 +310,15 @@ TclClockInit(
static int
ClockConvertlocaltoutcObjCmd(
- ClientData clientData, /* Client data */
- Tcl_Interp* interp, /* Tcl interpreter */
+ ClientData clientData, /* Client data */
+ Tcl_Interp *interp, /* Tcl interpreter */
int objc, /* Parameter count */
Tcl_Obj *const *objv) /* Parameter vector */
{
- ClockClientData* data = (ClockClientData*) clientData;
- Tcl_Obj* const * literals = data->literals;
- Tcl_Obj* secondsObj;
- Tcl_Obj* dict;
+ ClockClientData *data = clientData;
+ Tcl_Obj *const *literals = data->literals;
+ Tcl_Obj *secondsObj;
+ Tcl_Obj *dict;
int changeover;
TclDateFields fields;
int created = 0;
@@ -334,16 +334,16 @@ ClockConvertlocaltoutcObjCmd(
}
dict = objv[1];
if (Tcl_DictObjGet(interp, dict, literals[LIT_LOCALSECONDS],
- &secondsObj)!= TCL_OK) {
+ &secondsObj)!= TCL_OK) {
return TCL_ERROR;
}
if (secondsObj == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("key \"localseconds\" not "
- "found in dictionary", -1));
+ "found in dictionary", -1));
return TCL_ERROR;
}
if ((Tcl_GetWideIntFromObj(interp, secondsObj,
- &(fields.localSeconds)) != TCL_OK)
+ &fields.localSeconds) != TCL_OK)
|| (TclGetIntFromObj(interp, objv[3], &changeover) != TCL_OK)
|| ConvertLocalToUTC(interp, &fields, objv[2], changeover)) {
return TCL_ERROR;
@@ -369,7 +369,7 @@ ClockConvertlocaltoutcObjCmd(
}
return status;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -383,16 +383,16 @@ ClockConvertlocaltoutcObjCmd(
*
* Parameters:
* seconds - Time expressed in seconds from the Posix epoch.
- * tzdata - Time zone data of the time zone in which time is to
- * be expressed.
+ * tzdata - Time zone data of the time zone in which time is to be
+ * expressed.
* changeover - Julian Day Number at which the current locale adopted
* the Gregorian calendar
*
* Results:
* Returns a dictonary populated with the fields:
* seconds - Seconds from the Posix epoch
- * localSeconds - Nominal seconds from the Posix epoch in
- * the local time zone.
+ * localSeconds - Nominal seconds from the Posix epoch in the
+ * local time zone.
* tzOffset - Time zone offset in seconds east of Greenwich
* tzName - Time zone name
* julianDay - Julian Day Number in the local time zone
@@ -403,14 +403,14 @@ ClockConvertlocaltoutcObjCmd(
int
ClockGetdatefieldsObjCmd(
ClientData clientData, /* Opaque pointer to literal pool, etc. */
- Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Interp *interp, /* Tcl interpreter */
int objc, /* Parameter count */
Tcl_Obj *const *objv) /* Parameter vector */
{
TclDateFields fields;
- Tcl_Obj* dict;
- ClockClientData* data = (ClockClientData*) clientData;
- Tcl_Obj* const * literals = data->literals;
+ Tcl_Obj *dict;
+ ClockClientData *data = clientData;
+ Tcl_Obj *const *literals = data->literals;
int changeover;
/*
@@ -421,14 +421,14 @@ ClockGetdatefieldsObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "seconds tzdata changeover");
return TCL_ERROR;
}
- if (Tcl_GetWideIntFromObj(interp, objv[1], &(fields.seconds)) != TCL_OK
+ if (Tcl_GetWideIntFromObj(interp, objv[1], &fields.seconds) != TCL_OK
|| TclGetIntFromObj(interp, objv[3], &changeover) != TCL_OK) {
return TCL_ERROR;
}
/*
- * fields.seconds could be an unsigned number that overflowed. Make
- * sure that it isn't.
+ * fields.seconds could be an unsigned number that overflowed. Make sure
+ * that it isn't.
*/
if (objv[1]->typePtr == &tclBignumType) {
@@ -492,7 +492,7 @@ ClockGetdatefieldsObjCmd(
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -515,17 +515,17 @@ ClockGetdatefieldsObjCmd(
*/
static int
-ClockGetjuliandayfromerayearmonthdayObjCmd (
+ClockGetjuliandayfromerayearmonthdayObjCmd(
ClientData clientData, /* Opaque pointer to literal pool, etc. */
- Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Interp *interp, /* Tcl interpreter */
int objc, /* Parameter count */
Tcl_Obj *const *objv) /* Parameter vector */
{
TclDateFields fields;
- Tcl_Obj* dict;
- ClockClientData* data = (ClockClientData*) clientData;
- Tcl_Obj* const * literals = data->literals;
- Tcl_Obj* fieldPtr;
+ Tcl_Obj *dict;
+ ClockClientData *data = clientData;
+ Tcl_Obj *const *literals = data->literals;
+ Tcl_Obj *fieldPtr;
int changeover;
int copied = 0;
int status;
@@ -545,14 +545,13 @@ ClockGetjuliandayfromerayearmonthdayObjCmd (
&era) != TCL_OK
|| Tcl_DictObjGet(interp, dict, literals[LIT_YEAR],
&fieldPtr) != TCL_OK
- || TclGetIntFromObj(interp, fieldPtr, &(fields.year)) != TCL_OK
+ || TclGetIntFromObj(interp, fieldPtr, &fields.year) != TCL_OK
|| Tcl_DictObjGet(interp, dict, literals[LIT_MONTH],
&fieldPtr) != TCL_OK
- || TclGetIntFromObj(interp, fieldPtr, &(fields.month)) != TCL_OK
+ || TclGetIntFromObj(interp, fieldPtr, &fields.month) != TCL_OK
|| Tcl_DictObjGet(interp, dict, literals[LIT_DAYOFMONTH],
&fieldPtr) != TCL_OK
- || TclGetIntFromObj(interp, fieldPtr,
- &(fields.dayOfMonth)) != TCL_OK
+ || TclGetIntFromObj(interp, fieldPtr, &fields.dayOfMonth)!=TCL_OK
|| TclGetIntFromObj(interp, objv[2], &changeover) != TCL_OK) {
return TCL_ERROR;
}
@@ -583,7 +582,7 @@ ClockGetjuliandayfromerayearmonthdayObjCmd (
}
return status;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -606,17 +605,17 @@ ClockGetjuliandayfromerayearmonthdayObjCmd (
*/
static int
-ClockGetjuliandayfromerayearweekdayObjCmd (
+ClockGetjuliandayfromerayearweekdayObjCmd(
ClientData clientData, /* Opaque pointer to literal pool, etc. */
- Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Interp *interp, /* Tcl interpreter */
int objc, /* Parameter count */
Tcl_Obj *const *objv) /* Parameter vector */
{
TclDateFields fields;
- Tcl_Obj* dict;
- ClockClientData* data = (ClockClientData*) clientData;
- Tcl_Obj* const * literals = data->literals;
- Tcl_Obj* fieldPtr;
+ Tcl_Obj *dict;
+ ClockClientData *data = clientData;
+ Tcl_Obj *const *literals = data->literals;
+ Tcl_Obj *fieldPtr;
int changeover;
int copied = 0;
int status;
@@ -636,16 +635,13 @@ ClockGetjuliandayfromerayearweekdayObjCmd (
&era) != TCL_OK
|| Tcl_DictObjGet(interp, dict, literals[LIT_ISO8601YEAR],
&fieldPtr) != TCL_OK
- || TclGetIntFromObj(interp, fieldPtr,
- &(fields.iso8601Year)) != TCL_OK
+ || TclGetIntFromObj(interp, fieldPtr, &fields.iso8601Year)!=TCL_OK
|| Tcl_DictObjGet(interp, dict, literals[LIT_ISO8601WEEK],
&fieldPtr) != TCL_OK
- || TclGetIntFromObj(interp, fieldPtr,
- &(fields.iso8601Week)) != TCL_OK
+ || TclGetIntFromObj(interp, fieldPtr, &fields.iso8601Week)!=TCL_OK
|| Tcl_DictObjGet(interp, dict, literals[LIT_DAYOFWEEK],
&fieldPtr) != TCL_OK
- || TclGetIntFromObj(interp, fieldPtr,
- &(fields.dayOfWeek)) != TCL_OK
+ || TclGetIntFromObj(interp, fieldPtr, &fields.dayOfWeek) != TCL_OK
|| TclGetIntFromObj(interp, objv[2], &changeover) != TCL_OK) {
return TCL_ERROR;
}
@@ -676,7 +672,7 @@ ClockGetjuliandayfromerayearweekdayObjCmd (
}
return status;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -697,13 +693,13 @@ ClockGetjuliandayfromerayearweekdayObjCmd (
static int
ConvertLocalToUTC(
- Tcl_Interp* interp, /* Tcl interpreter */
- TclDateFields* fields, /* Fields of the time */
- Tcl_Obj* tzdata, /* Time zone data */
+ Tcl_Interp *interp, /* Tcl interpreter */
+ TclDateFields *fields, /* Fields of the time */
+ Tcl_Obj *tzdata, /* Time zone data */
int changeover) /* Julian Day of the Gregorian transition */
{
int rowc; /* Number of rows in tzdata */
- Tcl_Obj** rowv; /* Pointers to the rows */
+ Tcl_Obj **rowv; /* Pointers to the rows */
/*
* Unpack the tz data.
@@ -724,7 +720,7 @@ ConvertLocalToUTC(
return ConvertLocalToUTCUsingTable(interp, fields, rowc, rowv);
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -745,14 +741,14 @@ ConvertLocalToUTC(
static int
ConvertLocalToUTCUsingTable(
- Tcl_Interp* interp, /* Tcl interpreter */
- TclDateFields* fields, /* Time to convert, with 'seconds' filled in */
+ Tcl_Interp *interp, /* Tcl interpreter */
+ TclDateFields *fields, /* Time to convert, with 'seconds' filled in */
int rowc, /* Number of points at which time changes */
Tcl_Obj *const rowv[]) /* Points at which time changes */
{
- Tcl_Obj* row;
+ Tcl_Obj *row;
int cellc;
- Tcl_Obj** cellv;
+ Tcl_Obj **cellv;
int have[8];
int nHave = 0;
int i;
@@ -777,7 +773,7 @@ ConvertLocalToUTCUsingTable(
|| TclListObjGetElements(interp, row, &cellc,
&cellv) != TCL_OK
|| TclGetIntFromObj(interp, cellv[1],
- &(fields->tzOffset)) != TCL_OK) {
+ &fields->tzOffset) != TCL_OK) {
return TCL_ERROR;
}
found = 0;
@@ -800,7 +796,7 @@ ConvertLocalToUTCUsingTable(
fields->seconds = fields->localSeconds - fields->tzOffset;
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -821,8 +817,8 @@ ConvertLocalToUTCUsingTable(
static int
ConvertLocalToUTCUsingC(
- Tcl_Interp* interp, /* Tcl interpreter */
- TclDateFields* fields, /* Time to convert, with 'seconds' filled in */
+ Tcl_Interp *interp, /* Tcl interpreter */
+ TclDateFields *fields, /* Time to convert, with 'seconds' filled in */
int changeover) /* Julian Day of the Gregorian transition */
{
struct tm timeVal;
@@ -882,7 +878,7 @@ ConvertLocalToUTCUsingC(
}
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -901,13 +897,13 @@ ConvertLocalToUTCUsingC(
static int
ConvertUTCToLocal(
- Tcl_Interp* interp, /* Tcl interpreter */
- TclDateFields* fields, /* Fields of the time */
- Tcl_Obj* tzdata, /* Time zone data */
+ Tcl_Interp *interp, /* Tcl interpreter */
+ TclDateFields *fields, /* Fields of the time */
+ Tcl_Obj *tzdata, /* Time zone data */
int changeover) /* Julian Day of the Gregorian transition */
{
int rowc; /* Number of rows in tzdata */
- Tcl_Obj** rowv; /* Pointers to the rows */
+ Tcl_Obj **rowv; /* Pointers to the rows */
/*
* Unpack the tz data.
@@ -928,7 +924,7 @@ ConvertUTCToLocal(
return ConvertUTCToLocalUsingTable(interp, fields, rowc, rowv);
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -949,15 +945,15 @@ ConvertUTCToLocal(
static int
ConvertUTCToLocalUsingTable(
- Tcl_Interp* interp, /* Tcl interpreter */
- TclDateFields* fields, /* Fields of the date */
+ Tcl_Interp *interp, /* Tcl interpreter */
+ TclDateFields *fields, /* Fields of the date */
int rowc, /* Number of rows in the conversion table
* (>= 1) */
Tcl_Obj *const rowv[]) /* Rows of the conversion table */
{
- Tcl_Obj* row; /* Row containing the current information */
+ Tcl_Obj *row; /* Row containing the current information */
int cellc; /* Count of cells in the row (must be 4) */
- Tcl_Obj** cellv; /* Pointers to the cells */
+ Tcl_Obj **cellv; /* Pointers to the cells */
/*
* Look up the nearest transition time.
@@ -966,7 +962,7 @@ ConvertUTCToLocalUsingTable(
row = LookupLastTransition(interp, fields->seconds, rowc, rowv);
if (row == NULL ||
TclListObjGetElements(interp, row, &cellc, &cellv) != TCL_OK ||
- TclGetIntFromObj(interp,cellv[1],&(fields->tzOffset)) != TCL_OK) {
+ TclGetIntFromObj(interp, cellv[1], &fields->tzOffset) != TCL_OK) {
return TCL_ERROR;
}
@@ -979,7 +975,7 @@ ConvertUTCToLocalUsingTable(
fields->localSeconds = fields->seconds + fields->tzOffset;
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1001,12 +997,12 @@ ConvertUTCToLocalUsingTable(
static int
ConvertUTCToLocalUsingC(
- Tcl_Interp* interp, /* Tcl interpreter */
- TclDateFields* fields, /* Time to convert, with 'seconds' filled in */
+ Tcl_Interp *interp, /* Tcl interpreter */
+ TclDateFields *fields, /* Time to convert, with 'seconds' filled in */
int changeover) /* Julian Day of the Gregorian transition */
{
time_t tock;
- struct tm* timeVal; /* Time after conversion */
+ struct tm *timeVal; /* Time after conversion */
int diff; /* Time zone diff local-Greenwich */
char buffer[8]; /* Buffer for time zone name */
@@ -1072,7 +1068,7 @@ ConvertUTCToLocalUsingC(
Tcl_IncrRefCount(fields->tzName);
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1087,16 +1083,16 @@ ConvertUTCToLocalUsingC(
*----------------------------------------------------------------------
*/
-static Tcl_Obj*
+static Tcl_Obj *
LookupLastTransition(
- Tcl_Interp* interp, /* Interpreter for error messages */
+ Tcl_Interp *interp, /* Interpreter for error messages */
Tcl_WideInt tick, /* Time from the epoch */
int rowc, /* Number of rows of tzdata */
Tcl_Obj *const *rowv) /* Rows in tzdata */
{
int l;
int u;
- Tcl_Obj* compObj;
+ Tcl_Obj *compObj;
Tcl_WideInt compVal;
/*
@@ -1138,7 +1134,7 @@ LookupLastTransition(
}
return rowv[l];
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1159,7 +1155,7 @@ LookupLastTransition(
static void
GetYearWeekDay(
- TclDateFields* fields, /* Date to convert, must have 'julianDay' */
+ TclDateFields *fields, /* Date to convert, must have 'julianDay' */
int changeover) /* Julian Day Number of the Gregorian
* transition */
{
@@ -1205,7 +1201,7 @@ GetYearWeekDay(
fields->dayOfWeek += 7;
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1226,7 +1222,7 @@ GetYearWeekDay(
static void
GetGregorianEraYearDay(
- TclDateFields* fields, /* Date fields containing 'julianDay' */
+ TclDateFields *fields, /* Date fields containing 'julianDay' */
int changeover) /* Gregorian transition date */
{
int jday = fields->julianDay;
@@ -1272,7 +1268,6 @@ GetGregorianEraYearDay(
day += ONE_CENTURY_GREGORIAN;
}
year += 100 * n;
-
} else {
/*
* Julian calendar.
@@ -1281,7 +1276,6 @@ GetGregorianEraYearDay(
fields->gregorian = 0;
year = 1;
day = jday - JDAY_1_JAN_1_CE_JULIAN;
-
}
/*
@@ -1325,7 +1319,7 @@ GetGregorianEraYearDay(
}
fields->dayOfYear = day + 1;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1344,11 +1338,11 @@ GetGregorianEraYearDay(
static void
GetMonthDay(
- TclDateFields* fields) /* Date to convert */
+ TclDateFields *fields) /* Date to convert */
{
int day = fields->dayOfYear;
int month;
- const int* h = hath[IsGregorianLeapYear(fields)];
+ const int *h = hath[IsGregorianLeapYear(fields)];
for (month = 0; month < 12 && day > h[month]; ++month) {
day -= h[month];
@@ -1356,7 +1350,7 @@ GetMonthDay(
fields->month = month+1;
fields->dayOfMonth = day;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1376,18 +1370,18 @@ GetMonthDay(
static void
GetJulianDayFromEraYearWeekDay(
- TclDateFields* fields, /* Date to convert */
+ TclDateFields *fields, /* Date to convert */
int changeover) /* Julian Day Number of the Gregorian
* transition */
{
int firstMonday; /* Julian day number of week 1, day 1 in the
* given year */
+ TclDateFields firstWeek;
/*
* Find January 4 in the ISO8601 year, which will always be in week 1.
*/
- TclDateFields firstWeek;
firstWeek.era = fields->era;
firstWeek.year = fields->iso8601Year;
firstWeek.month = 1;
@@ -1407,7 +1401,7 @@ GetJulianDayFromEraYearWeekDay(
fields->julianDay = firstMonday + 7 * (fields->iso8601Week - 1)
+ fields->dayOfWeek - 1;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1427,13 +1421,10 @@ GetJulianDayFromEraYearWeekDay(
static void
GetJulianDayFromEraYearMonthDay(
- TclDateFields* fields, /* Date to convert */
+ TclDateFields *fields, /* Date to convert */
int changeover) /* Gregorian transition date as a Julian Day */
{
- int year; int ym1;
- int month; int mm1;
- int q; int r;
- int ym1o4; int ym1o100; int ym1o400;
+ int year, ym1, month, mm1, q, r, ym1o4, ym1o100, ym1o400;
if (fields->era == BCE) {
year = 1 - fields->year;
@@ -1505,10 +1496,10 @@ GetJulianDayFromEraYearMonthDay(
+ fields->dayOfMonth
+ daysInPriorMonths[year%4 == 0][month - 1]
+ (365 * ym1)
- + ym1o4;
+ + ym1o4;
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1525,7 +1516,7 @@ GetJulianDayFromEraYearMonthDay(
static int
IsGregorianLeapYear(
- TclDateFields* fields) /* Date to test */
+ TclDateFields *fields) /* Date to test */
{
int year;
@@ -1546,7 +1537,7 @@ IsGregorianLeapYear(
return 1;
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1572,7 +1563,7 @@ WeekdayOnOrBefore(
}
return julianDay - ((julianDay - k) % 7);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1597,12 +1588,12 @@ WeekdayOnOrBefore(
int
ClockGetenvObjCmd(
ClientData clientData,
- Tcl_Interp* interp,
+ Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
- const char* varName;
- const char* varValue;
+ const char *varName;
+ const char *varValue;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "name");
@@ -1616,7 +1607,7 @@ ClockGetenvObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(varValue, -1));
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1643,8 +1634,7 @@ ThreadSafeLocalTime(
* Get a thread-local buffer to hold the returned time.
*/
- struct tm *tmPtr = (struct tm *)
- Tcl_GetThreadData(&tmKey, (int) sizeof(struct tm));
+ struct tm *tmPtr = Tcl_GetThreadData(&tmKey, (int) sizeof(struct tm));
#ifdef HAVE_LOCALTIME_R
localtime_r(timePtr, tmPtr);
#else
@@ -1655,14 +1645,13 @@ ThreadSafeLocalTime(
if (sysTmPtr == NULL) {
Tcl_MutexUnlock(&clockMutex);
return NULL;
- } else {
- memcpy((void *) tmPtr, (void *) localtime(timePtr), sizeof(struct tm));
- Tcl_MutexUnlock(&clockMutex);
}
+ memcpy(tmPtr, localtime(timePtr), sizeof(struct tm));
+ Tcl_MutexUnlock(&clockMutex);
#endif
return tmPtr;
}
-
+
/*----------------------------------------------------------------------
*
* ClockClicksObjCmd --
@@ -1684,18 +1673,19 @@ ThreadSafeLocalTime(
int
ClockClicksObjCmd(
ClientData clientData, /* Client data is unused */
- Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Interp *interp, /* Tcl interpreter */
int objc, /* Parameter count */
- Tcl_Obj* const* objv) /* Parameter values */
+ Tcl_Obj *const *objv) /* Parameter values */
{
static const char *const clicksSwitches[] = {
"-milliseconds", "-microseconds", NULL
};
enum ClicksSwitch {
- CLICKS_MILLIS, CLICKS_MICROS, CLICKS_NATIVE
+ CLICKS_MILLIS, CLICKS_MICROS, CLICKS_NATIVE
};
int index = CLICKS_NATIVE;
Tcl_Time now;
+ Tcl_WideInt clicks = 0;
switch (objc) {
case 1:
@@ -1714,28 +1704,25 @@ ClockClicksObjCmd(
switch (index) {
case CLICKS_MILLIS:
Tcl_GetTime(&now);
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt)
- now.sec * 1000 + now.usec / 1000));
+ clicks = (Tcl_WideInt) now.sec * 1000 + now.usec / 1000;
break;
- case CLICKS_NATIVE: {
-#ifndef TCL_WIDE_CLICKS
- unsigned long clicks = TclpGetClicks();
+ case CLICKS_NATIVE:
+#ifdef TCL_WIDE_CLICKS
+ clicks = TclpGetWideClicks();
#else
- Tcl_WideInt clicks = TclpGetWideClicks();
+ clicks = (Tcl_WideInt) TclpGetClicks();
#endif
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt) clicks));
break;
- }
case CLICKS_MICROS:
Tcl_GetTime(&now);
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
- ((Tcl_WideInt) now.sec * 1000000) + now.usec));
+ clicks = ((Tcl_WideInt) now.sec * 1000000) + now.usec;
break;
}
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(clicks));
return TCL_OK;
}
-
+
/*----------------------------------------------------------------------
*
* ClockMillisecondsObjCmd -
@@ -1757,9 +1744,9 @@ ClockClicksObjCmd(
int
ClockMillisecondsObjCmd(
ClientData clientData, /* Client data is unused */
- Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Interp *interp, /* Tcl interpreter */
int objc, /* Parameter count */
- Tcl_Obj* const* objv) /* Parameter values */
+ Tcl_Obj *const *objv) /* Parameter values */
{
Tcl_Time now;
@@ -1768,11 +1755,11 @@ ClockMillisecondsObjCmd(
return TCL_ERROR;
}
Tcl_GetTime(&now);
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj( (Tcl_WideInt)
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt)
now.sec * 1000 + now.usec / 1000));
return TCL_OK;
}
-
+
/*----------------------------------------------------------------------
*
* ClockMicrosecondsObjCmd -
@@ -1794,9 +1781,9 @@ ClockMillisecondsObjCmd(
int
ClockMicrosecondsObjCmd(
ClientData clientData, /* Client data is unused */
- Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Interp *interp, /* Tcl interpreter */
int objc, /* Parameter count */
- Tcl_Obj* const* objv) /* Parameter values */
+ Tcl_Obj *const *objv) /* Parameter values */
{
Tcl_Time now;
@@ -1809,7 +1796,7 @@ ClockMicrosecondsObjCmd(
((Tcl_WideInt) now.sec * 1000000) + now.usec));
return TCL_OK;
}
-
+
/*
*-----------------------------------------------------------------------------
*
@@ -1818,12 +1805,12 @@ ClockMicrosecondsObjCmd(
* Parses the arguments for [clock format].
*
* Results:
- * Returns a standard Tcl result, whose value is a four-element
- * list comprising the time format, the locale, and the timezone.
+ * Returns a standard Tcl result, whose value is a four-element list
+ * comprising the time format, the locale, and the timezone.
*
* This function exists because the loop that parses the [clock format]
- * options is a known performance "hot spot", and is implemented in an
- * effort to speed that particular code up.
+ * options is a known performance "hot spot", and is implemented in an effort
+ * to speed that particular code up.
*
*-----------------------------------------------------------------------------
*/
@@ -1831,56 +1818,53 @@ ClockMicrosecondsObjCmd(
static int
ClockParseformatargsObjCmd(
ClientData clientData, /* Client data containing literal pool */
- Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Interp *interp, /* Tcl interpreter */
int objc, /* Parameter count */
- Tcl_Obj *const objv[] /* Parameter vector */
-) {
-
- ClockClientData* dataPtr = (ClockClientData*) clientData;
- Tcl_Obj** litPtr = dataPtr->literals;
-
- /* Format, locale and timezone */
-
- Tcl_Obj* results[3];
+ Tcl_Obj *const objv[]) /* Parameter vector */
+{
+ ClockClientData *dataPtr = clientData;
+ Tcl_Obj **litPtr = dataPtr->literals;
+ Tcl_Obj *results[3]; /* Format, locale and timezone */
#define formatObj results[0]
#define localeObj results[1]
#define timezoneObj results[2]
int gmtFlag = 0;
-
- /* Command line options expected */
-
- static const char *const options[] = {
- "-format", "-gmt", "-locale",
- "-timezone", NULL };
+ static const char *const options[] = { /* Command line options expected */
+ "-format", "-gmt", "-locale",
+ "-timezone", NULL };
enum optionInd {
CLOCK_FORMAT_FORMAT, CLOCK_FORMAT_GMT, CLOCK_FORMAT_LOCALE,
CLOCK_FORMAT_TIMEZONE
};
- int optionIndex; /* Index of an option */
- int saw = 0; /* Flag == 1 if option was seen already */
- Tcl_WideInt clockVal; /* Clock value - just used to parse */
+ int optionIndex; /* Index of an option. */
+ int saw = 0; /* Flag == 1 if option was seen already. */
+ Tcl_WideInt clockVal; /* Clock value - just used to parse. */
int i;
- /* Args consist of a time followed by keyword-value pairs */
+ /*
+ * Args consist of a time followed by keyword-value pairs.
+ */
if (objc < 2 || (objc % 2) != 0) {
Tcl_WrongNumArgs(interp, 0, objv,
- "clock format clockval ?-format string? "
- "?-gmt boolean? ?-locale LOCALE? ?-timezone ZONE?");
+ "clock format clockval ?-format string? "
+ "?-gmt boolean? ?-locale LOCALE? ?-timezone ZONE?");
Tcl_SetErrorCode(interp, "CLOCK", "wrongNumArgs", NULL);
return TCL_ERROR;
}
- /* Extract values for the keywords */
+ /*
+ * Extract values for the keywords.
+ */
formatObj = litPtr[LIT__DEFAULT_FORMAT];
localeObj = litPtr[LIT_C];
timezoneObj = litPtr[LIT__NIL];
for (i = 2; i < objc; i+=2) {
if (Tcl_GetIndexFromObj(interp, objv[i], options, "switch", 0,
- &optionIndex) != TCL_OK) {
+ &optionIndex) != TCL_OK) {
Tcl_SetErrorCode(interp, "CLOCK", "badSwitch",
- Tcl_GetString(objv[i]), NULL);
+ Tcl_GetString(objv[i]), NULL);
return TCL_ERROR;
}
switch (optionIndex) {
@@ -1888,7 +1872,7 @@ ClockParseformatargsObjCmd(
formatObj = objv[i+1];
break;
case CLOCK_FORMAT_GMT:
- if (Tcl_GetBooleanFromObj(interp, objv[i+1], &gmtFlag) != TCL_OK) {
+ if (Tcl_GetBooleanFromObj(interp, objv[i+1], &gmtFlag) != TCL_OK){
return TCL_ERROR;
}
break;
@@ -1899,16 +1883,18 @@ ClockParseformatargsObjCmd(
timezoneObj = objv[i+1];
break;
}
- saw |= (1 << optionIndex);
+ saw |= 1 << optionIndex;
}
- /* Check options */
+ /*
+ * Check options.
+ */
if (Tcl_GetWideIntFromObj(interp, objv[1], &clockVal) != TCL_OK) {
return TCL_ERROR;
}
if ((saw & (1 << CLOCK_FORMAT_GMT))
- && (saw & (1 << CLOCK_FORMAT_TIMEZONE))) {
+ && (saw & (1 << CLOCK_FORMAT_TIMEZONE))) {
Tcl_SetObjResult(interp, litPtr[LIT_CANNOT_USE_GMT_AND_TIMEZONE]);
Tcl_SetErrorCode(interp, "CLOCK", "gmtWithTimezone", NULL);
return TCL_ERROR;
@@ -1917,7 +1903,9 @@ ClockParseformatargsObjCmd(
timezoneObj = litPtr[LIT_GMT];
}
- /* Return options as a list */
+ /*
+ * Return options as a list.
+ */
Tcl_SetObjResult(interp, Tcl_NewListObj(3, results));
return TCL_OK;
@@ -1925,9 +1913,8 @@ ClockParseformatargsObjCmd(
#undef timezoneObj
#undef localeObj
#undef formatObj
-
}
-
+
/*----------------------------------------------------------------------
*
* ClockSecondsObjCmd -
@@ -1949,9 +1936,9 @@ ClockParseformatargsObjCmd(
int
ClockSecondsObjCmd(
ClientData clientData, /* Client data is unused */
- Tcl_Interp* interp, /* Tcl interpreter */
+ Tcl_Interp *interp, /* Tcl interpreter */
int objc, /* Parameter count */
- Tcl_Obj* const* objv) /* Parameter values */
+ Tcl_Obj *const *objv) /* Parameter values */
{
Tcl_Time now;
@@ -1963,7 +1950,7 @@ ClockSecondsObjCmd(
Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt) now.sec));
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1984,9 +1971,9 @@ ClockSecondsObjCmd(
static void
TzsetIfNecessary(void)
{
- static char* tzWas = NULL; /* Previous value of TZ, protected by
+ static char *tzWas = NULL; /* Previous value of TZ, protected by
* clockMutex. */
- const char* tzIsNow; /* Current value of TZ */
+ const char *tzIsNow; /* Current value of TZ */
Tcl_MutexLock(&clockMutex);
tzIsNow = getenv("TZ");
@@ -2004,7 +1991,7 @@ TzsetIfNecessary(void)
}
Tcl_MutexUnlock(&clockMutex);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2023,19 +2010,19 @@ static void
ClockDeleteCmdProc(
ClientData clientData) /* Opaque pointer to the client data */
{
- ClockClientData *data = (ClockClientData*) clientData;
+ ClockClientData *data = clientData;
int i;
- --(data->refCount);
+ --data->refCount;
if (data->refCount == 0) {
for (i = 0; i < LIT__END; ++i) {
Tcl_DecrRefCount(data->literals[i]);
}
- ckfree((char*) (data->literals));
- ckfree((char*) data);
+ ckfree((char *) data->literals);
+ ckfree((char *) data);
}
}
-
+
/*
* Local Variables:
* mode: c
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 724e80b..df24e16 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdAH.c,v 1.108 2008/10/23 03:28:09 msofer Exp $
+ * RCS: @(#) $Id: tclCmdAH.c,v 1.109 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1506,7 +1506,7 @@ GetStatBuf(
return TCL_ERROR;
}
- status = (*statProc)(pathPtr, statPtr);
+ status = statProc(pathPtr, statPtr);
if (status < 0) {
if (interp != NULL) {
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index f6ef042..9c1ee74 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompExpr.c,v 1.97 2008/02/28 20:40:24 dgp Exp $
+ * RCS: @(#) $Id: tclCompExpr.c,v 1.98 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1823,7 +1823,7 @@ ParseLexeme(
*lexemePtr = END;
return 0;
}
- byte = (unsigned char)(*start);
+ byte = UCHAR(*start);
if (byte < sizeof(Lexeme) && Lexeme[byte] != 0) {
*lexemePtr = Lexeme[byte];
return 1;
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index ddf3818..adaa38b 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompile.c,v 1.159 2008/10/15 06:17:04 nijtmans Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.160 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1396,8 +1396,8 @@ TclCompileScript(
update = 1;
}
- code = (cmdPtr->compileProc)(interp, parsePtr,
- cmdPtr, envPtr);
+ code = cmdPtr->compileProc(interp, parsePtr, cmdPtr,
+ envPtr);
if (code == TCL_OK) {
if (update) {
@@ -1457,7 +1457,7 @@ TclCompileScript(
/*
* Single word script: unshare the command name to
* avoid shimmering between bytecode and cmdName
- * representations [Bug 458361]
+ * representations. [Bug 458361]
*/
TclHideLiteral(interp, envPtr, objIndex);
@@ -2452,7 +2452,7 @@ EnterCmdWordData(
size_t newElems = (currElems ? 2*currElems : 1);
size_t newBytes = newElems * sizeof(ECL);
- eclPtr->loc = (ECL *) ckrealloc((char *)(eclPtr->loc), newBytes);
+ eclPtr->loc = (ECL *) ckrealloc((char *) eclPtr->loc, newBytes);
eclPtr->nloc = newElems;
}
@@ -2553,7 +2553,7 @@ TclCreateExceptRange(
if (envPtr->mallocedExceptArray) {
envPtr->exceptArrayPtr = (ExceptionRange *)
- ckrealloc((char *)(envPtr->exceptArrayPtr), newBytes);
+ ckrealloc((char *) envPtr->exceptArrayPtr, newBytes);
} else {
/*
* envPtr->exceptArrayPtr isn't a ckalloc'd pointer, so we must
@@ -2630,7 +2630,7 @@ TclCreateAuxData(
if (envPtr->mallocedAuxDataArray) {
envPtr->auxDataArrayPtr = (AuxData *)
- ckrealloc((char *)(envPtr->auxDataArrayPtr), newBytes);
+ ckrealloc((char *) envPtr->auxDataArrayPtr, newBytes);
} else {
/*
* envPtr->auxDataArrayPtr isn't a ckalloc'd pointer, so we must
@@ -2718,7 +2718,7 @@ TclExpandJumpFixupArray(
if (fixupArrayPtr->mallocedArray) {
fixupArrayPtr->fixup = (JumpFixup *)
- ckrealloc((char *)(fixupArrayPtr->fixup), newBytes);
+ ckrealloc((char *) fixupArrayPtr->fixup, newBytes);
} else {
/*
* fixupArrayPtr->fixup isn't a ckalloc'd pointer, so we must
@@ -3952,7 +3952,7 @@ RecordByteCodeStats(
statsPtr->currentByteCodeBytes += (double) codePtr->structureSize;
statsPtr->srcCount[TclLog2(codePtr->numSrcBytes)]++;
- statsPtr->byteCodeCount[TclLog2((int)(codePtr->structureSize))]++;
+ statsPtr->byteCodeCount[TclLog2((int) codePtr->structureSize)]++;
statsPtr->currentInstBytes += (double) codePtr->numCodeBytes;
statsPtr->currentLitBytes += (double)
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 7378e49..9ef937f 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEncoding.c,v 1.63 2008/10/22 20:23:59 nijtmans Exp $
+ * RCS: @(#) $Id: tclEncoding.c,v 1.64 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -94,7 +94,7 @@ typedef struct TableEncodingData {
*/
typedef struct EscapeSubTable {
- unsigned int sequenceLen; /* Length of following string. */
+ unsigned sequenceLen; /* Length of following string. */
char sequence[16]; /* Escape code that marks this encoding. */
char name[32]; /* Name for encoding. */
Encoding *encodingPtr; /* Encoding loaded using above name, or NULL
@@ -106,10 +106,10 @@ typedef struct EscapeEncodingData {
int fallback; /* Character (in this encoding) to substitute
* when this encoding cannot represent a UTF-8
* character. */
- unsigned int initLen; /* Length of following string. */
+ unsigned initLen; /* Length of following string. */
char init[16]; /* String to emit or expect before first char
* in conversion. */
- unsigned int finalLen; /* Length of following string. */
+ unsigned finalLen; /* Length of following string. */
char final[16]; /* String to emit or expect after last char in
* conversion. */
char prefixBytes[256]; /* If a byte in the input stream is the first
@@ -848,7 +848,7 @@ FreeEncoding(
encodingPtr->refCount--;
if (encodingPtr->refCount == 0) {
if (encodingPtr->freeProc != NULL) {
- (*encodingPtr->freeProc)(encodingPtr->clientData);
+ encodingPtr->freeProc(encodingPtr->clientData);
}
if (encodingPtr->hPtr != NULL) {
Tcl_DeleteHashEntry(encodingPtr->hPtr);
@@ -1128,15 +1128,14 @@ Tcl_ExternalToUtfDString(
if (src == NULL) {
srcLen = 0;
} else if (srcLen < 0) {
- srcLen = (*encodingPtr->lengthProc)(src);
+ srcLen = encodingPtr->lengthProc(src);
}
flags = TCL_ENCODING_START | TCL_ENCODING_END;
while (1) {
- result = (*encodingPtr->toUtfProc)(encodingPtr->clientData, src,
- srcLen, flags, &state, dst, dstLen, &srcRead, &dstWrote,
- &dstChars);
+ result = encodingPtr->toUtfProc(encodingPtr->clientData, src, srcLen,
+ flags, &state, dst, dstLen, &srcRead, &dstWrote, &dstChars);
soFar = dst + dstWrote - Tcl_DStringValue(dstPtr);
if (result != TCL_CONVERT_NOSPACE) {
@@ -1216,7 +1215,7 @@ Tcl_ExternalToUtf(
if (src == NULL) {
srcLen = 0;
} else if (srcLen < 0) {
- srcLen = (*encodingPtr->lengthProc)(src);
+ srcLen = encodingPtr->lengthProc(src);
}
if (statePtr == NULL) {
flags |= TCL_ENCODING_START | TCL_ENCODING_END;
@@ -1239,7 +1238,7 @@ Tcl_ExternalToUtf(
*/
dstLen--;
- result = (*encodingPtr->toUtfProc)(encodingPtr->clientData, src, srcLen,
+ result = encodingPtr->toUtfProc(encodingPtr->clientData, src, srcLen,
flags, statePtr, dst, dstLen, srcReadPtr, dstWrotePtr,
dstCharsPtr);
dst[*dstWrotePtr] = '\0';
@@ -1299,7 +1298,7 @@ Tcl_UtfToExternalDString(
}
flags = TCL_ENCODING_START | TCL_ENCODING_END;
while (1) {
- result = (*encodingPtr->fromUtfProc)(encodingPtr->clientData, src,
+ result = encodingPtr->fromUtfProc(encodingPtr->clientData, src,
srcLen, flags, &state, dst, dstLen, &srcRead, &dstWrote,
&dstChars);
soFar = dst + dstWrote - Tcl_DStringValue(dstPtr);
@@ -1401,7 +1400,7 @@ Tcl_UtfToExternal(
}
dstLen -= encodingPtr->nullSize;
- result = (*encodingPtr->fromUtfProc)(encodingPtr->clientData, src, srcLen,
+ result = encodingPtr->fromUtfProc(encodingPtr->clientData, src, srcLen,
flags, statePtr, dst, dstLen, srcReadPtr, dstWrotePtr,
dstCharsPtr);
if (encodingPtr->nullSize == 2) {
@@ -1660,7 +1659,7 @@ LoadTableEncoding(
char *line;
int i, hi, lo, numPages, symbol, fallback;
unsigned char used[256];
- unsigned int size;
+ unsigned size;
TableEncodingData *dataPtr;
unsigned short *pageMemPtr;
Tcl_EncodingType encType;
@@ -1937,7 +1936,7 @@ LoadEscapeEncoding(
Tcl_Channel chan) /* File containing new encoding. */
{
int i;
- unsigned int size;
+ unsigned size;
Tcl_DString escapeData;
char init[16], final[16];
EscapeEncodingData *dataPtr;
@@ -2981,7 +2980,7 @@ EscapeToUtfProc(
* correspond to the bytes stored in the
* output buffer. */
{
- EscapeEncodingData *dataPtr;
+ EscapeEncodingData *dataPtr = clientData;
char *prefixBytes, *tablePrefixBytes;
unsigned short **tableToUnicode;
Encoding *encodingPtr;
@@ -2990,11 +2989,8 @@ EscapeToUtfProc(
char *dstStart, *dstEnd;
result = TCL_OK;
-
tablePrefixBytes = NULL; /* lint. */
tableToUnicode = NULL; /* lint. */
-
- dataPtr = (EscapeEncodingData *) clientData;
prefixBytes = dataPtr->prefixBytes;
encodingPtr = NULL;
@@ -3018,7 +3014,7 @@ EscapeToUtfProc(
}
byte = *((unsigned char *) src);
if (prefixBytes[byte]) {
- unsigned int left, len, longest;
+ unsigned left, len, longest;
int checked, i;
EscapeSubTable *subTablePtr;
@@ -3118,7 +3114,7 @@ EscapeToUtfProc(
TableEncodingData *tableDataPtr;
encodingPtr = GetTableEncoding(dataPtr, state);
- tableDataPtr = (TableEncodingData *) encodingPtr->clientData;
+ tableDataPtr = encodingPtr->clientData;
tablePrefixBytes = tableDataPtr->prefixBytes;
tableToUnicode = tableDataPtr->toUnicode;
}
@@ -3195,7 +3191,7 @@ EscapeFromUtfProc(
* correspond to the bytes stored in the
* output buffer. */
{
- EscapeEncodingData *dataPtr;
+ EscapeEncodingData *dataPtr = clientData;
Encoding *encodingPtr;
const char *srcStart, *srcEnd, *srcClose;
char *dstStart, *dstEnd;
@@ -3206,8 +3202,6 @@ EscapeFromUtfProc(
result = TCL_OK;
- dataPtr = (EscapeEncodingData *) clientData;
-
srcStart = src;
srcEnd = src + srcLen;
srcClose = srcEnd;
@@ -3219,7 +3213,7 @@ EscapeFromUtfProc(
dstEnd = dst + dstLen - 1;
/*
- * RFC1468 states that the text starts in ASCII, and switches to Japanese
+ * RFC 1468 states that the text starts in ASCII, and switches to Japanese
* characters, and that the text must end in ASCII. [Patch 474358]
*/
@@ -3237,12 +3231,12 @@ EscapeFromUtfProc(
}
encodingPtr = GetTableEncoding(dataPtr, state);
- tableDataPtr = (TableEncodingData *) encodingPtr->clientData;
+ tableDataPtr = encodingPtr->clientData;
tablePrefixBytes = tableDataPtr->prefixBytes;
tableFromUnicode = tableDataPtr->fromUnicode;
for (numChars = 0; src < srcEnd; numChars++) {
- unsigned int len;
+ unsigned len;
int word;
Tcl_UniChar ch;
@@ -3265,7 +3259,7 @@ EscapeFromUtfProc(
oldState = state;
for (state = 0; state < dataPtr->numSubTables; state++) {
encodingPtr = GetTableEncoding(dataPtr, state);
- tableDataPtr = (TableEncodingData *) encodingPtr->clientData;
+ tableDataPtr = encodingPtr->clientData;
word = tableDataPtr->fromUnicode[(ch >> 8)][ch & 0xff];
if (word != 0) {
break;
@@ -3279,7 +3273,7 @@ EscapeFromUtfProc(
break;
}
encodingPtr = GetTableEncoding(dataPtr, state);
- tableDataPtr = (TableEncodingData *) encodingPtr->clientData;
+ tableDataPtr = encodingPtr->clientData;
word = tableDataPtr->fallback;
}
@@ -3332,22 +3326,22 @@ EscapeFromUtfProc(
}
if ((result == TCL_OK) && (flags & TCL_ENCODING_END)) {
- unsigned int len = dataPtr->subTables[0].sequenceLen;
+ unsigned len = dataPtr->subTables[0].sequenceLen;
+
/*
- * Certain encodings like iso2022-jp need to write
- * an escape sequence after all characters have
- * been converted. This logic checks that enough
- * room is available in the buffer for the escape bytes.
- * The TCL_ENCODING_END flag is cleared after a final
- * escape sequence has been added to the buffer so
- * that another call to this method does not attempt
- * to append escape bytes a second time.
+ * Certain encodings like iso2022-jp need to write an escape sequence
+ * after all characters have been converted. This logic checks that
+ * enough room is available in the buffer for the escape bytes. The
+ * TCL_ENCODING_END flag is cleared after a final escape sequence has
+ * been added to the buffer so that another call to this method does
+ * not attempt to append escape bytes a second time.
*/
+
if ((dst + dataPtr->finalLen + (state?len:0)) > dstEnd) {
result = TCL_CONVERT_NOSPACE;
} else {
if (state) {
- memcpy(dst, dataPtr->subTables[0].sequence, (size_t) len);
+ memcpy(dst, dataPtr->subTables[0].sequence, len);
dst += len;
}
memcpy(dst, dataPtr->final, (size_t) dataPtr->finalLen);
@@ -3385,11 +3379,10 @@ EscapeFreeProc(
ClientData clientData) /* EscapeEncodingData that specifies
* encoding. */
{
- EscapeEncodingData *dataPtr;
+ EscapeEncodingData *dataPtr = clientData;
EscapeSubTable *subTablePtr;
int i;
- dataPtr = (EscapeEncodingData *) clientData;
if (dataPtr == NULL) {
return;
}
@@ -3426,11 +3419,8 @@ GetTableEncoding(
EscapeEncodingData *dataPtr,/* Contains names of encodings. */
int state) /* Index in dataPtr of desired Encoding. */
{
- EscapeSubTable *subTablePtr;
- Encoding *encodingPtr;
-
- subTablePtr = &dataPtr->subTables[state];
- encodingPtr = subTablePtr->encodingPtr;
+ EscapeSubTable *subTablePtr = &dataPtr->subTables[state];
+ Encoding *encodingPtr = subTablePtr->encodingPtr;
if (encodingPtr == NULL) {
encodingPtr = (Encoding *) Tcl_GetEncoding(NULL, subTablePtr->name);
@@ -3539,7 +3529,7 @@ InitializeEncodingSearchPath(
bytes = Tcl_GetStringFromObj(searchPath, &numBytes);
*lengthPtr = numBytes;
- *valuePtr = ckalloc((unsigned int) numBytes + 1);
+ *valuePtr = ckalloc((unsigned) numBytes + 1);
memcpy(*valuePtr, bytes, (size_t) numBytes + 1);
Tcl_DecrRefCount(searchPath);
}
diff --git a/generic/tclEvent.c b/generic/tclEvent.c
index 3d29cb5..203dc5a 100644
--- a/generic/tclEvent.c
+++ b/generic/tclEvent.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEvent.c,v 1.84 2008/10/16 22:34:19 nijtmans Exp $
+ * RCS: @(#) $Id: tclEvent.c,v 1.85 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -947,7 +947,7 @@ Tcl_Finalize(void)
firstExitPtr = exitPtr->nextPtr;
Tcl_MutexUnlock(&exitMutex);
- (*exitPtr->proc)(exitPtr->clientData);
+ exitPtr->proc(exitPtr->clientData);
ckfree((char *) exitPtr);
Tcl_MutexLock(&exitMutex);
}
@@ -1135,7 +1135,7 @@ Tcl_FinalizeThread(void)
*/
tsdPtr->firstExitPtr = exitPtr->nextPtr;
- (*exitPtr->proc)(exitPtr->clientData);
+ exitPtr->proc(exitPtr->clientData);
ckfree((char *) exitPtr);
}
TclFinalizeIOSubsystem();
@@ -1388,16 +1388,15 @@ static Tcl_ThreadCreateType
NewThreadProc(
ClientData clientData)
{
- ThreadClientData *cdPtr;
+ ThreadClientData *cdPtr = clientData;
ClientData threadClientData;
Tcl_ThreadCreateProc *threadProc;
- cdPtr = (ThreadClientData *) clientData;
threadProc = cdPtr->proc;
threadClientData = cdPtr->clientData;
ckfree((char *) clientData); /* Allocated in Tcl_CreateThread() */
- (*threadProc)(threadClientData);
+ threadProc(threadClientData);
TCL_THREAD_CREATE_RETURN;
}
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 99f16db..d1ff368 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.418 2008/10/17 16:32:58 dgp Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.419 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -6208,6 +6208,7 @@ TclExecuteByteCode(
/ sizeof(unsigned short)) - 1)) {
unsigned short base = Exp32Index[l1-3]
+ (unsigned short) l2 - 9;
+
if (base < Exp32Index[l1-2]) {
/*
* 32-bit number raised to intermediate power, done by
@@ -6225,14 +6226,14 @@ TclExecuteByteCode(
NEXT_INST_F(1, 1, 0);
}
}
- if (-l1 >= 3
- && (unsigned long)(-l1) < (sizeof(Exp32Index)
- / sizeof(unsigned short)) - 1) {
- unsigned short base
- = Exp32Index[-l1-3] + (unsigned short) l2 - 9;
+ if (-l1 >= 3 && (unsigned long)(-l1) <
+ (sizeof(Exp32Index) / sizeof(unsigned short)) - 1) {
+ unsigned short base =
+ Exp32Index[-l1-3] + (unsigned short) l2 - 9;
+
if (base < Exp32Index[-l1-2]) {
long lResult = (oddExponent) ?
- -Exp32Value[base] : Exp32Value[base];
+ -Exp32Value[base] : Exp32Value[base];
/*
* 32-bit number raised to intermediate power, done by
diff --git a/generic/tclHistory.c b/generic/tclHistory.c
index ea1a8ff..48739ad 100644
--- a/generic/tclHistory.c
+++ b/generic/tclHistory.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclHistory.c,v 1.12 2008/07/13 09:03:33 msofer Exp $
+ * RCS: @(#) $Id: tclHistory.c,v 1.13 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -124,7 +124,7 @@ Tcl_RecordAndEvalObj(
result = Tcl_GetCommandInfo(interp, "history", &info);
if (result && (info.deleteProc == TclProcDeleteProc)) {
- Proc *procPtr = (Proc *)(info.objClientData);
+ Proc *procPtr = (Proc *) info.objClientData;
call = (procPtr->cmdPtr->compileProc != TclCompileNoOp);
}
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 7ec28c8..d7524fe 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.145 2008/10/16 22:34:19 nijtmans Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.146 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -350,10 +350,10 @@ TclFinalizeIOSubsystem(void)
*/
if (chanPtr->typePtr->closeProc != TCL_CLOSE2PROC) {
- (chanPtr->typePtr->closeProc)(chanPtr->instanceData, NULL);
+ chanPtr->typePtr->closeProc(chanPtr->instanceData, NULL);
} else {
- (chanPtr->typePtr->close2Proc)(chanPtr->instanceData,
- NULL, 0);
+ chanPtr->typePtr->close2Proc(chanPtr->instanceData, NULL,
+ 0);
}
/*
@@ -932,7 +932,7 @@ Tcl_UnregisterChannel(
IsBufferReady(statePtr->curOutPtr)) {
SetFlag(statePtr, BUFFER_READY);
}
- Tcl_Preserve((ClientData)statePtr);
+ Tcl_Preserve(statePtr);
if (!(statePtr->flags & BG_FLUSH_SCHEDULED)) {
/*
* We don't want to re-enter Tcl_Close().
@@ -941,13 +941,13 @@ Tcl_UnregisterChannel(
if (!(statePtr->flags & CHANNEL_CLOSED)) {
if (Tcl_Close(interp, chan) != TCL_OK) {
SetFlag(statePtr, CHANNEL_CLOSED);
- Tcl_Release((ClientData)statePtr);
+ Tcl_Release(statePtr);
return TCL_ERROR;
}
}
}
SetFlag(statePtr, CHANNEL_CLOSED);
- Tcl_Release((ClientData)statePtr);
+ Tcl_Release(statePtr);
}
return TCL_OK;
}
@@ -1573,7 +1573,7 @@ Tcl_StackChannel(
threadActionProc = Tcl_ChannelThreadActionProc(chanPtr->typePtr);
if (threadActionProc != NULL) {
- (*threadActionProc)(chanPtr->instanceData, TCL_CHANNEL_THREAD_INSERT);
+ threadActionProc(chanPtr->instanceData, TCL_CHANNEL_THREAD_INSERT);
}
return (Tcl_Channel) chanPtr;
@@ -1710,8 +1710,7 @@ Tcl_UnstackChannel(
threadActionProc = Tcl_ChannelThreadActionProc(chanPtr->typePtr);
if (threadActionProc != NULL) {
- (*threadActionProc)(chanPtr->instanceData,
- TCL_CHANNEL_THREAD_REMOVE);
+ threadActionProc(chanPtr->instanceData,TCL_CHANNEL_THREAD_REMOVE);
}
statePtr->topChanPtr = downChanPtr;
@@ -1727,10 +1726,10 @@ Tcl_UnstackChannel(
*/
if (chanPtr->typePtr->closeProc != TCL_CLOSE2PROC) {
- result = (chanPtr->typePtr->closeProc)(chanPtr->instanceData,
+ result = chanPtr->typePtr->closeProc(chanPtr->instanceData,
interp);
} else {
- result = (chanPtr->typePtr->close2Proc)(chanPtr->instanceData,
+ result = chanPtr->typePtr->close2Proc(chanPtr->instanceData,
interp, 0);
}
@@ -2002,8 +2001,8 @@ Tcl_GetChannelHandle(
int result;
chanPtr = ((Channel *) chan)->state->bottomChanPtr;
- result = (chanPtr->typePtr->getHandleProc)(chanPtr->instanceData,
- direction, &handle);
+ result = chanPtr->typePtr->getHandleProc(chanPtr->instanceData, direction,
+ &handle);
if (handlePtr) {
*handlePtr = handle;
}
@@ -2302,7 +2301,7 @@ FlushChannel(
*/
toWrite = BytesLeft(bufPtr);
- written = (chanPtr->typePtr->outputProc)(chanPtr->instanceData,
+ written = chanPtr->typePtr->outputProc(chanPtr->instanceData,
RemovePoint(bufPtr), toWrite, &errorCode);
/*
@@ -2438,7 +2437,7 @@ FlushChannel(
return errorCode;
} else if (statePtr->outQueueHead == NULL) {
ResetFlag(statePtr, BG_FLUSH_SCHEDULED);
- (chanPtr->typePtr->watchProc)(chanPtr->instanceData,
+ chanPtr->typePtr->watchProc(chanPtr->instanceData,
statePtr->interestMask);
}
}
@@ -2529,7 +2528,7 @@ CloseChannel(
int dummy;
char c = (char) statePtr->outEofChar;
- (chanPtr->typePtr->outputProc)(chanPtr->instanceData, &c, 1, &dummy);
+ chanPtr->typePtr->outputProc(chanPtr->instanceData, &c, 1, &dummy);
}
/*
@@ -2558,10 +2557,10 @@ CloseChannel(
*/
if (chanPtr->typePtr->closeProc != TCL_CLOSE2PROC) {
- result = (chanPtr->typePtr->closeProc)(chanPtr->instanceData, interp);
+ result = chanPtr->typePtr->closeProc(chanPtr->instanceData, interp);
} else {
- result = (chanPtr->typePtr->close2Proc)(chanPtr->instanceData,
- interp, 0);
+ result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp,
+ 0);
}
/*
@@ -2715,7 +2714,7 @@ CutChannel(
threadActionProc = Tcl_ChannelThreadActionProc(Tcl_GetChannelType(chan));
if (threadActionProc != NULL) {
- (*threadActionProc)(Tcl_GetChannelInstanceData(chan),
+ threadActionProc(Tcl_GetChannelInstanceData(chan),
TCL_CHANNEL_THREAD_REMOVE);
}
}
@@ -2763,8 +2762,7 @@ Tcl_CutChannel(
while (chanPtr) {
threadActionProc = Tcl_ChannelThreadActionProc(chanPtr->typePtr);
if (threadActionProc != NULL) {
- (*threadActionProc)(chanPtr->instanceData,
- TCL_CHANNEL_THREAD_REMOVE);
+ threadActionProc(chanPtr->instanceData,TCL_CHANNEL_THREAD_REMOVE);
}
chanPtr= chanPtr->upChanPtr;
}
@@ -2826,7 +2824,7 @@ SpliceChannel(
threadActionProc = Tcl_ChannelThreadActionProc(Tcl_GetChannelType(chan));
if (threadActionProc != NULL) {
- (*threadActionProc) (Tcl_GetChannelInstanceData(chan),
+ threadActionProc(Tcl_GetChannelInstanceData(chan),
TCL_CHANNEL_THREAD_INSERT);
}
}
@@ -2864,8 +2862,7 @@ Tcl_SpliceChannel(
while (chanPtr) {
threadActionProc = Tcl_ChannelThreadActionProc(chanPtr->typePtr);
if (threadActionProc != NULL) {
- (*threadActionProc)(chanPtr->instanceData,
- TCL_CHANNEL_THREAD_INSERT);
+ threadActionProc(chanPtr->instanceData,TCL_CHANNEL_THREAD_INSERT);
}
chanPtr= chanPtr->upChanPtr;
}
@@ -2976,7 +2973,7 @@ Tcl_Close(
while (statePtr->closeCbPtr != NULL) {
cbPtr = statePtr->closeCbPtr;
statePtr->closeCbPtr = cbPtr->nextPtr;
- (cbPtr->proc)(cbPtr->clientData);
+ cbPtr->proc(cbPtr->clientData);
ckfree((char *) cbPtr);
}
@@ -2996,7 +2993,7 @@ Tcl_Close(
*/
if (chanPtr->typePtr->closeProc == TCL_CLOSE2PROC) {
- result = (chanPtr->typePtr->close2Proc)(chanPtr->instanceData, interp,
+ result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp,
TCL_CLOSE_READ);
} else {
result = 0;
@@ -3229,8 +3226,8 @@ Tcl_WriteRaw(
* The code was stolen from 'FlushChannel'.
*/
- written = (chanPtr->typePtr->outputProc) (chanPtr->instanceData,
- src, srcLen, &errorCode);
+ written = chanPtr->typePtr->outputProc(chanPtr->instanceData, src,
+ srcLen, &errorCode);
if (written < 0) {
Tcl_SetErrno(errorCode);
@@ -5036,7 +5033,7 @@ Tcl_ReadRaw(
* The case of 'bytesToRead == 0' at this point cannot happen.
*/
- nread = (chanPtr->typePtr->inputProc)(chanPtr->instanceData,
+ nread = chanPtr->typePtr->inputProc(chanPtr->instanceData,
bufPtr + copied, bytesToRead - copied, &result);
#ifdef TCL_IO_TRACK_OS_FOR_DRIVER_WITH_BAD_BLOCKING
@@ -6196,7 +6193,7 @@ GetInput(
} else {
#endif /* TCL_IO_TRACK_OS_FOR_DRIVER_WITH_BAD_BLOCKING */
- nread = (chanPtr->typePtr->inputProc)(chanPtr->instanceData,
+ nread = chanPtr->typePtr->inputProc(chanPtr->instanceData,
InsertPoint(bufPtr), toRead, &result);
#ifdef TCL_IO_TRACK_OS_FOR_DRIVER_WITH_BAD_BLOCKING
@@ -6394,14 +6391,14 @@ Tcl_Seek(
if (HaveVersion(chanPtr->typePtr, TCL_CHANNEL_VERSION_3) &&
chanPtr->typePtr->wideSeekProc != NULL) {
- curPos = (chanPtr->typePtr->wideSeekProc) (chanPtr->instanceData,
+ curPos = chanPtr->typePtr->wideSeekProc(chanPtr->instanceData,
offset, mode, &result);
} else if (offset < Tcl_LongAsWide(LONG_MIN) ||
offset > Tcl_LongAsWide(LONG_MAX)) {
result = EOVERFLOW;
curPos = Tcl_LongAsWide(-1);
} else {
- curPos = Tcl_LongAsWide((chanPtr->typePtr->seekProc) (
+ curPos = Tcl_LongAsWide(chanPtr->typePtr->seekProc(
chanPtr->instanceData, Tcl_WideAsLong(offset), mode,
&result));
}
@@ -6512,10 +6509,10 @@ Tcl_Tell(
if (HaveVersion(chanPtr->typePtr, TCL_CHANNEL_VERSION_3) &&
chanPtr->typePtr->wideSeekProc != NULL) {
- curPos = (chanPtr->typePtr->wideSeekProc) (chanPtr->instanceData,
+ curPos = chanPtr->typePtr->wideSeekProc(chanPtr->instanceData,
Tcl_LongAsWide(0), SEEK_CUR, &result);
} else {
- curPos = Tcl_LongAsWide((chanPtr->typePtr->seekProc) (
+ curPos = Tcl_LongAsWide(chanPtr->typePtr->seekProc(
chanPtr->instanceData, 0, SEEK_CUR, &result));
}
if (curPos == Tcl_LongAsWide(-1)) {
@@ -7275,8 +7272,8 @@ Tcl_GetChannelOption(
* and message.
*/
- return (chanPtr->typePtr->getOptionProc) (chanPtr->instanceData,
- interp, optionName, dsPtr);
+ return chanPtr->typePtr->getOptionProc(chanPtr->instanceData, interp,
+ optionName, dsPtr);
} else {
/*
* No driver specific options case.
@@ -7577,8 +7574,8 @@ Tcl_SetChannelOption(
ckfree((char *) argv);
return TCL_OK;
} else if (chanPtr->typePtr->setOptionProc != NULL) {
- return (*chanPtr->typePtr->setOptionProc)(chanPtr->instanceData,
- interp, optionName, newValue);
+ return chanPtr->typePtr->setOptionProc(chanPtr->instanceData, interp,
+ optionName, newValue);
} else {
return Tcl_BadChannelOption(interp, optionName, NULL);
}
@@ -7735,7 +7732,7 @@ Tcl_NotifyChannel(
upTypePtr = upChanPtr->typePtr;
upHandlerProc = Tcl_ChannelHandlerProc(upTypePtr);
if (upHandlerProc != NULL) {
- mask = (*upHandlerProc) (upChanPtr->instanceData, mask);
+ mask = upHandlerProc(upChanPtr->instanceData, mask);
}
/*
@@ -7796,7 +7793,7 @@ Tcl_NotifyChannel(
if ((chPtr->mask & mask) != 0) {
nh.nextHandlerPtr = chPtr->nextPtr;
- (*(chPtr->proc))(chPtr->clientData, mask);
+ chPtr->proc(chPtr->clientData, mask);
chPtr = nh.nextHandlerPtr;
} else {
chPtr = chPtr->nextPtr;
@@ -7912,7 +7909,7 @@ UpdateInterest(
}
}
}
- (chanPtr->typePtr->watchProc)(chanPtr->instanceData, mask);
+ chanPtr->typePtr->watchProc(chanPtr->instanceData, mask);
}
/*
@@ -9508,7 +9505,7 @@ StackSetBlockMode(
while (chanPtr != NULL) {
blockModeProc = Tcl_ChannelBlockModeProc(chanPtr->typePtr);
if (blockModeProc != NULL) {
- result = (*blockModeProc) (chanPtr->instanceData, mode);
+ result = blockModeProc(chanPtr->instanceData, mode);
if (result != 0) {
Tcl_SetErrno(result);
return result;
@@ -9935,7 +9932,7 @@ Tcl_ChannelBlockModeProc(
* The v1 structure had the blockModeProc in a different place.
*/
- return (Tcl_DriverBlockModeProc *) (chanTypePtr->version);
+ return (Tcl_DriverBlockModeProc *) chanTypePtr->version;
}
}
@@ -10610,8 +10607,9 @@ DupChannelIntRep(
* currently have an internal rep.*/
{
ChannelState *statePtr = GET_CHANNELSTATE(srcPtr);
+
SET_CHANNELSTATE(copyPtr, statePtr);
- Tcl_Preserve((ClientData) statePtr);
+ Tcl_Preserve(statePtr);
copyPtr->typePtr = &tclChannelType;
}
@@ -10647,7 +10645,7 @@ SetChannelFromAny(
statePtr = GET_CHANNELSTATE(objPtr);
if (statePtr->flags & (CHANNEL_TAINTED|CHANNEL_CLOSED)) {
ResetFlag(statePtr, CHANNEL_TAINTED);
- Tcl_Release((ClientData) statePtr);
+ Tcl_Release(statePtr);
UpdateStringOfChannel(objPtr);
objPtr->typePtr = NULL;
}
@@ -10669,8 +10667,8 @@ SetChannelFromAny(
}
TclFreeIntRep(objPtr);
- statePtr = ((Channel *)chan)->state;
- Tcl_Preserve((ClientData) statePtr);
+ statePtr = ((Channel *) chan)->state;
+ Tcl_Preserve(statePtr);
SET_CHANNELSTATE(objPtr, statePtr);
objPtr->typePtr = &tclChannelType;
}
@@ -10734,7 +10732,7 @@ static void
FreeChannelIntRep(
Tcl_Obj *objPtr) /* Object with internal rep to free. */
{
- Tcl_Release((ClientData) GET_CHANNELSTATE(objPtr));
+ Tcl_Release(GET_CHANNELSTATE(objPtr));
}
#if 0
diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c
index 55d0807..b550675 100644
--- a/generic/tclIORTrans.c
+++ b/generic/tclIORTrans.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIORTrans.c,v 1.5 2008/10/17 18:06:08 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIORTrans.c,v 1.6 2008/10/26 18:34:04 dkf Exp $
*/
#include <tclInt.h>
@@ -56,32 +56,32 @@ static int ReflectSetOption(ClientData clientData,
Tcl_Interp *interp, const char *optionName,
const char *newValue);
static int ReflectHandle(ClientData clientData, int direction,
- ClientData* handle);
+ ClientData *handle);
static int ReflectNotify(ClientData clientData, int mask);
/*
- * The C layer channel type/driver definition used by the reflection. This is
- * a version 3 structure.
+ * The C layer channel type/driver definition used by the reflection.
*/
static Tcl_ChannelType tclRTransformType = {
- "tclrtransform", /* Type name. */
- TCL_CHANNEL_VERSION_5, /* v5 channel */
- ReflectClose, /* Close channel, clean instance data */
- ReflectInput, /* Handle read request */
- ReflectOutput, /* Handle write request */
- ReflectSeek, /* Move location of access point. */
- ReflectSetOption, /* Set options. */
- ReflectGetOption, /* Get options. */
- ReflectWatch, /* Initialize notifier */
- ReflectHandle, /* Get OS handle from the channel. */
- NULL, /* No close2 support. NULL'able */
- ReflectBlock, /* Set blocking/nonblocking. */
- NULL, /* Flush channel. Not used by core. NULL'able */
- ReflectNotify, /* Handle events. */
- ReflectSeekWide, /* Move access point (64 bit). */
- NULL, /* thread action */
- NULL, /* truncate */
+ "tclrtransform", /* Type name. */
+ TCL_CHANNEL_VERSION_5, /* v5 channel. */
+ ReflectClose, /* Close channel, clean instance data. */
+ ReflectInput, /* Handle read request. */
+ ReflectOutput, /* Handle write request. */
+ ReflectSeek, /* Move location of access point. */
+ ReflectSetOption, /* Set options. */
+ ReflectGetOption, /* Get options. */
+ ReflectWatch, /* Initialize notifier. */
+ ReflectHandle, /* Get OS handle from the channel. */
+ NULL, /* No close2 support. NULL'able */
+ ReflectBlock, /* Set blocking/nonblocking. */
+ NULL, /* Flush channel. Not used by core.
+ * NULL'able. */
+ ReflectNotify, /* Handle events. */
+ ReflectSeekWide, /* Move access point (64 bit). */
+ NULL, /* thread action */
+ NULL, /* truncate */
};
/*
@@ -90,18 +90,21 @@ static Tcl_ChannelType tclRTransformType = {
*/
typedef struct _ResultBuffer_ {
- unsigned char* buf; /* Reference to the buffer area */
- int allocated; /* Allocated size of the buffer area */
- int used; /* Number of bytes in the buffer, <= allocated */
+ unsigned char *buf; /* Reference to the buffer area. */
+ int allocated; /* Allocated size of the buffer area. */
+ int used; /* Number of bytes in the buffer,
+ * <= allocated. */
} ResultBuffer;
#define ResultLength(r) ((r)->used)
-/* static int ResultLength (ResultBuffer* r); */
+/* static int ResultLength (ResultBuffer *r); */
-static void ResultClear (ResultBuffer* r);
-static void ResultInit (ResultBuffer* r);
-static void ResultAdd (ResultBuffer* r, unsigned char* buf, int toWrite);
-static int ResultCopy (ResultBuffer* r, unsigned char* buf, int toRead);
+static void ResultClear(ResultBuffer *r);
+static void ResultInit(ResultBuffer *r);
+static void ResultAdd(ResultBuffer *r, unsigned char *buf,
+ int toWrite);
+static int ResultCopy(ResultBuffer *r, unsigned char *buf,
+ int toRead);
#define RB_INCREMENT (512)
@@ -118,15 +121,14 @@ static int ResultCopy (ResultBuffer* r, unsigned char* buf, int toRe
typedef struct {
Tcl_Channel chan; /* Back reference to the channel of the
* transformation itself. */
- Tcl_Channel parent; /* Reference to the channel the transformation
+ Tcl_Channel parent; /* Reference to the channel the transformation
* was pushed on. */
Tcl_Interp *interp; /* Reference to the interpreter containing the
* Tcl level part of the channel. */
- Tcl_Obj *handle; /* Reference to transform handle. Also stored
+ Tcl_Obj *handle; /* Reference to transform handle. Also stored
* in the argv, see below. The separate field
* gives us direct access, needed when working
- * with the reflection maps.
- */
+ * with the reflection maps. */
#ifdef TCL_THREADS
Tcl_ThreadId thread; /* Thread the 'interp' belongs to. */
#endif
@@ -144,14 +146,14 @@ typedef struct {
* CT = Belongs to the 'Command handler Thread'.
*/
- int argc; /* Number of preallocated words - 2 */
+ int argc; /* Number of preallocated words - 2. */
Tcl_Obj **argv; /* Preallocated array for calling the handler.
* args[0] is placeholder for cmd word.
* Followed by the arguments in the prefix,
* plus 4 placeholders for method, channel,
* and at most two varying (method specific)
* words. */
- int methods; /* Bitmask of supported methods */
+ int methods; /* Bitmask of supported methods. */
/*
* NOTE (9): Should we have predefined shared literals for the method
@@ -159,11 +161,9 @@ typedef struct {
*/
int mode; /* Mask of R/W mode */
- int nonblocking; /* Flag: Channel is blocking or not */
- int readIsDrained; /* Flag: Read buffers are flushed*/
-
+ int nonblocking; /* Flag: Channel is blocking or not. */
+ int readIsDrained; /* Flag: Read buffers are flushed. */
ResultBuffer result;
-
} ReflectedTransform;
/*
@@ -243,9 +243,9 @@ typedef enum {
/*
* Event used to forward driver invocations to the thread actually managing
- * the channel. We cannot construct the command to execute and forward
- * that. Because then it will contain a mixture of Tcl_Obj's belonging to both
- * the command handler thread (CT), and the thread managing the channel (MT),
+ * the channel. We cannot construct the command to execute and forward that.
+ * Because then it will contain a mixture of Tcl_Obj's belonging to both the
+ * command handler thread (CT), and the thread managing the channel (MT),
* executed in CT. Tcl_Obj's are not allowed to cross thread boundaries. So we
* forward an operation code, the argument details, and reference to results.
* The command is assembled in the CT and belongs fully to that thread. No
@@ -284,7 +284,7 @@ struct ForwardParamLimit {
typedef union ForwardParam {
ForwardParamBase base;
struct ForwardParamTransform transform;
- struct ForwardParamLimit limit;
+ struct ForwardParamLimit limit;
} ForwardParam;
/*
@@ -333,7 +333,7 @@ typedef struct ThreadSpecificData {
* Table of all reflected transformations owned by this thread.
*/
- ReflectedTransformMap* rtmPtr;
+ ReflectedTransformMap *rtmPtr;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -358,7 +358,7 @@ TCL_DECLARE_MUTEX(rtForwardMutex)
*/
static void ForwardOpToOwnerThread(ReflectedTransform *rtPtr,
- ForwardedOperation op, const VOID *param);
+ ForwardedOperation op, const void *param);
static int ForwardProc(Tcl_Event *evPtr, int mask);
static void SrcExitProc(ClientData clientData);
@@ -424,41 +424,50 @@ static void DeleteReflectedTransformMap(ClientData clientData,
* list-quoting to keep the words of the message together. See also [x].
*/
-static const char *msg_read_badlimit = "{Tcl driver returned bad read limit '0'}";
+static const char *msg_read_badlimit =
+ "{Tcl driver returned bad read limit '0'}";
static const char *msg_read_unsup = "{read not supported by Tcl driver}";
static const char *msg_write_unsup = "{write not supported by Tcl driver}";
#ifdef TCL_THREADS
static const char *msg_send_originlost = "{Channel thread lost}";
static const char *msg_send_dstlost = "{Owner lost}";
#endif /* TCL_THREADS */
-static const char *msg_dstlost = "-code 1 -level 0 -errorcode NONE -errorinfo {} -errorline 1 {Owner lost}";
+static const char *msg_dstlost =
+ "-code 1 -level 0 -errorcode NONE -errorinfo {} -errorline 1 {Owner lost}";
/*
* Timer management (flushing out buffered data via artificial events).
*/
/*
- * Number of milliseconds to wait before firing an event to try to
- * flush out information waiting in buffers (fileevent support).
+ * Number of milliseconds to wait before firing an event to try to flush out
+ * information waiting in buffers (fileevent support).
*/
#define FLUSH_DELAY (5)
-static void TimerKill (ReflectedTransform* rtPtr);
-static void TimerSetup (ReflectedTransform* rtPtr);
-static void TimerRun (ClientData clientData);
+static void TimerKill(ReflectedTransform* rtPtr);
+static void TimerSetup(ReflectedTransform* rtPtr);
+static void TimerRun(ClientData clientData);
/*
* Helper functions encapsulating some of the thread forwarding to make the
* control flow in callers easier.
*/
-static int TransformRead (ReflectedTransform* rtPtr, int* errorCodePtr, unsigned char* buf, int toRead);
-static int TransformWrite (ReflectedTransform* rtPtr, int* errorCodePtr, unsigned char* buf, int toWrite);
-static int TransformDrain (ReflectedTransform* rtPtr, int* errorCodePtr);
-static int TransformFlush (ReflectedTransform* rtPtr, int* errorCodePtr, int op);
-static void TransformClear (ReflectedTransform* rtPtr);
-static int TransformLimit (ReflectedTransform* rtPtr, int* errorCodePtr, int* maxPtr);
+static int TransformRead(ReflectedTransform *rtPtr,
+ int *errorCodePtr, unsigned char *buf,
+ int toRead);
+static int TransformWrite(ReflectedTransform *rtPtr,
+ int *errorCodePtr, unsigned char *buf,
+ int toWrite);
+static int TransformDrain(ReflectedTransform *rtPtr,
+ int *errorCodePtr);
+static int TransformFlush(ReflectedTransform *rtPtr,
+ int *errorCodePtr, int op);
+static void TransformClear(ReflectedTransform *rtPtr);
+static int TransformLimit(ReflectedTransform *rtPtr,
+ int *errorCodePtr, int *maxPtr);
/* op'codes for TransformFlush */
#define FLUSH_WRITE 1
@@ -467,14 +476,14 @@ static int TransformLimit (ReflectedTransform* rtPtr, int* errorCodePtr, int* m
/*
* Main methods to plug into the 'chan' ensemble'. ==================
*/
-
+
/*
*----------------------------------------------------------------------
*
* TclChanPushObjCmd --
*
- * This function is invoked to process the "chan push" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "chan push" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result. The handle of the new channel is placed in the
@@ -493,17 +502,17 @@ TclChanPushObjCmd(
int objc,
Tcl_Obj *const *objv)
{
- ReflectedTransform *rtPtr; /* Instance data of the new (transform) channel */
- Tcl_Obj* chanObj; /* Handle of parent channel */
- Tcl_Channel parentChan; /* Token of parent channel */
- int mode; /* R/W mode of parent, later the new
- * channel. Has to match the abilities of the
- * handler commands */
+ ReflectedTransform *rtPtr; /* Instance data of the new (transform)
+ * channel. */
+ Tcl_Obj *chanObj; /* Handle of parent channel */
+ Tcl_Channel parentChan; /* Token of parent channel */
+ int mode; /* R/W mode of parent, later the new channel.
+ * Has to match the abilities of the handler
+ * commands */
Tcl_Obj *cmdObj; /* Command prefix, list of words */
Tcl_Obj *cmdNameObj; /* Command name */
Tcl_Obj *rtId; /* Handle of the new transform (channel) */
Tcl_Obj *modeObj; /* mode in obj form for method call */
-
int listc; /* Result of 'initialize', and of */
Tcl_Obj **listv; /* its sublist in the 2nd element */
int methIndex; /* Encoded method name */
@@ -512,8 +521,8 @@ TclChanPushObjCmd(
int methods; /* Bitmask for supported methods. */
Tcl_Obj *err; /* Error message */
ReflectedTransformMap *rtmPtr;
- /* Map of reflected transforms with handlers in
- * this interp. */
+ /* Map of reflected transforms with handlers
+ * in this interp. */
Tcl_HashEntry *hPtr; /* Entry in the above map */
int isNew; /* Placeholder. */
@@ -541,16 +550,16 @@ TclChanPushObjCmd(
* First argument is a channel handle.
*/
- chanObj = objv[CHAN];
- parentChan = Tcl_GetChannel (interp, Tcl_GetString (chanObj), &mode);
+ chanObj = objv[CHAN];
+ parentChan = Tcl_GetChannel(interp, Tcl_GetString(chanObj), &mode);
if (parentChan == NULL) {
return TCL_ERROR;
}
- parentChan = Tcl_GetTopChannel (parentChan);
+ parentChan = Tcl_GetTopChannel(parentChan);
/*
* Second argument is command prefix, i.e. list of words, first word is
- * name of handler command, other words are fixed arguments. Run
+ * name of handler command, other words are fixed arguments. Run the
* 'initialize' method to get the list of supported methods. Validate
* this.
*/
@@ -588,9 +597,8 @@ TclChanPushObjCmd(
/*
* Verify the result.
- * - List, of method names. Convert to mask.
- * Check for non-optionals through the mask.
- * Compare open mode against optional r/w.
+ * - List, of method names. Convert to mask. Check for non-optionals
+ * through the mask. Compare open mode against optional r/w.
*/
if (Tcl_ListObjGetElements(NULL, resObj, &listc, &listv) != TCL_OK) {
@@ -637,8 +645,12 @@ TclChanPushObjCmd(
* also be supported by the handler, by design of the check.
*/
- if (!HAS(methods, METH_READ)) { mode &= ~TCL_READABLE; }
- if (!HAS(methods, METH_WRITE)) { mode &= ~TCL_WRITABLE; }
+ if (!HAS(methods, METH_READ)) {
+ mode &= ~TCL_READABLE;
+ }
+ if (!HAS(methods, METH_WRITE)) {
+ mode &= ~TCL_WRITABLE;
+ }
if (!mode) {
TclNewLiteralStringObj(err, "chan handler \"");
@@ -675,27 +687,24 @@ TclChanPushObjCmd(
*/
rtPtr->methods = methods;
- rtPtr->mode = mode;
- rtPtr->chan = Tcl_StackChannel (interp, &tclRTransformType,
- (ClientData) rtPtr, mode,
- rtPtr->parent);
+ rtPtr->mode = mode;
+ rtPtr->chan = Tcl_StackChannel(interp, &tclRTransformType, rtPtr, mode,
+ rtPtr->parent);
/*
* Register the transform in our our map for proper handling of deleted
* interpreters and/or threads.
*/
- rtmPtr = GetReflectedTransformMap (interp);
- hPtr = Tcl_CreateHashEntry(&rtmPtr->map, Tcl_GetString(rtId),
- &isNew);
+ rtmPtr = GetReflectedTransformMap(interp);
+ hPtr = Tcl_CreateHashEntry(&rtmPtr->map, Tcl_GetString(rtId), &isNew);
if (!isNew && rtPtr != Tcl_GetHashValue(hPtr)) {
Tcl_Panic("TclChanPushObjCmd: duplicate transformation handle");
}
Tcl_SetHashValue(hPtr, rtPtr);
#ifdef TCL_THREADS
rtmPtr = GetThreadReflectedTransformMap();
- hPtr = Tcl_CreateHashEntry(&rtmPtr->map, Tcl_GetString(rtId),
- &isNew);
+ hPtr = Tcl_CreateHashEntry(&rtmPtr->map, Tcl_GetString(rtId), &isNew);
Tcl_SetHashValue(hPtr, rtPtr);
#endif
@@ -703,11 +712,10 @@ TclChanPushObjCmd(
* Return the channel as the result of the command.
*/
- Tcl_AppendResult (interp, Tcl_GetChannelName (rtPtr->chan),
- (char*) NULL);
+ Tcl_AppendResult(interp, Tcl_GetChannelName(rtPtr->chan), NULL);
return TCL_OK;
- error:
+ error:
/*
* We are not going through ReflectClose as we never had a channel
* structure.
@@ -725,8 +733,8 @@ TclChanPushObjCmd(
*
* TclChanPopObjCmd --
*
- * This function is invoked to process the "chan pop" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "chan pop" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -757,7 +765,7 @@ TclChanPopObjCmd(
const char *chanId; /* Tcl level channel handle */
Tcl_Channel chan; /* Channel associated to the handle */
- int mode; /* Channel r/w mode */
+ int mode; /* Channel r/w mode */
/*
* Number of arguments...
@@ -774,13 +782,14 @@ TclChanPopObjCmd(
*/
chanId = TclGetString(objv[CHAN]);
- chan = Tcl_GetChannel(interp, chanId, &mode);
+ chan = Tcl_GetChannel(interp, chanId, &mode);
if (chan == NULL) {
return TCL_ERROR;
}
- /* Removing transformations is generic, and not restricted to reflected
+ /*
+ * Removing transformations is generic, and not restricted to reflected
* transformations.
*/
@@ -794,7 +803,7 @@ TclChanPopObjCmd(
* Channel error message marshalling utilities.
*/
-static Tcl_Obj*
+static Tcl_Obj *
MarshallError(
Tcl_Interp *interp)
{
@@ -848,8 +857,8 @@ UnmarshallErrorResult(
Tcl_SetObjResult(interp, lv[lc-1]);
}
- (void) Tcl_SetReturnOptions(interp, Tcl_NewListObj(numOptions, lv));
- ((Interp *)interp)->flags &= ~ERR_ALREADY_LOGGED;
+ Tcl_SetReturnOptions(interp, Tcl_NewListObj(numOptions, lv));
+ ((Interp *) interp)->flags &= ~ERR_ALREADY_LOGGED;
}
/*
@@ -878,11 +887,12 @@ ReflectClose(
ClientData clientData,
Tcl_Interp *interp)
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
+ ReflectedTransform *rtPtr = clientData;
int result; /* Result code for 'close' */
Tcl_Obj *resObj; /* Result data for 'close' */
- ReflectedTransformMap *rtmPtr;/* Map of reflected transforms with handlers in
- * this interp */
+ ReflectedTransformMap *rtmPtr;
+ /* Map of reflected transforms with handlers
+ * in this interp. */
Tcl_HashEntry *hPtr; /* Entry in the above map */
if (interp == NULL) {
@@ -933,16 +943,18 @@ ReflectClose(
* that check is not necessary. We always go through 'finalize'.
*/
- if (HAS(rtPtr->methods, METH_DRAIN) && (!rtPtr->readIsDrained)) {
+ if (HAS(rtPtr->methods, METH_DRAIN) && !rtPtr->readIsDrained) {
int errorCode;
- if (!TransformDrain (rtPtr, &errorCode)) {
+
+ if (!TransformDrain(rtPtr, &errorCode)) {
return errorCode;
}
}
if (HAS(rtPtr->methods, METH_FLUSH)) {
int errorCode;
- if (!TransformFlush (rtPtr, &errorCode, FLUSH_WRITE)) {
+
+ if (!TransformFlush(rtPtr, &errorCode, FLUSH_WRITE)) {
return errorCode;
}
}
@@ -965,52 +977,55 @@ ReflectClose(
if (result != TCL_OK) {
PassReceivedErrorInterp(interp, &p);
+ return EINVAL;
}
- } else {
+ return EOK;
+ }
#endif
- result = InvokeTclMethod(rtPtr, "finalize", NULL, NULL, &resObj);
- if ((result != TCL_OK) && (interp != NULL)) {
- Tcl_SetChannelErrorInterp(interp, resObj);
- }
- Tcl_DecrRefCount(resObj); /* Remove reference we held from the
- * invoke */
+ /*
+ * Do the actual invokation of "finalize" now; we're in the right thread.
+ */
- /*
- * Remove the transform from the map before releasing the memory, to
- * prevent future accesses from finding and dereferencing a dangling
- * pointer.
- *
- * NOTE: The transform may not be in the map. This is ok, that happens
- * when the transform was created in a different interpreter and/or
- * thread and then was moved here.
- */
+ result = InvokeTclMethod(rtPtr, "finalize", NULL, NULL, &resObj);
+ if ((result != TCL_OK) && (interp != NULL)) {
+ Tcl_SetChannelErrorInterp(interp, resObj);
+ }
- rtmPtr = GetReflectedTransformMap(interp);
- hPtr = Tcl_FindHashEntry (&rtmPtr->map,
- Tcl_GetString(rtPtr->handle));
- if (hPtr) {
- Tcl_DeleteHashEntry (hPtr);
- }
-#ifdef TCL_THREADS
- /*
- * In a threaded interpreter we manage a per-thread map as well, to
- * allow us to survive if the script level pulls the rug out under a
- * channel by deleting the owning thread.
- */
+ Tcl_DecrRefCount(resObj); /* Remove reference we held from the
+ * invoke. */
- rtmPtr = GetThreadReflectedTransformMap();
- hPtr = Tcl_FindHashEntry (&rtmPtr->map,
- Tcl_GetString(rtPtr->handle));
- if (hPtr) {
- Tcl_DeleteHashEntry (hPtr);
- }
-#endif
+ /*
+ * Remove the transform from the map before releasing the memory, to
+ * prevent future accesses from finding and dereferencing a dangling
+ * pointer.
+ *
+ * NOTE: The transform may not be in the map. This is ok, that happens
+ * when the transform was created in a different interpreter and/or thread
+ * and then was moved here.
+ */
+
+ rtmPtr = GetReflectedTransformMap(interp);
+ hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
+ if (hPtr) {
+ Tcl_DeleteHashEntry(hPtr);
+ }
+
+ /*
+ * In a threaded interpreter we manage a per-thread map as well, to allow
+ * us to survive if the script level pulls the rug out under a channel by
+ * deleting the owning thread.
+ */
- FreeReflectedTransform(rtPtr);
#ifdef TCL_THREADS
+ rtmPtr = GetThreadReflectedTransformMap();
+ hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
+ if (hPtr) {
+ Tcl_DeleteHashEntry(hPtr);
}
#endif
+
+ FreeReflectedTransform(rtPtr);
return (result == TCL_OK) ? EOK : EINVAL;
}
@@ -1032,12 +1047,12 @@ ReflectClose(
static int
ReflectInput(
- ClientData clientData,
- char *buf,
- int toRead,
- int *errorCodePtr)
+ ClientData clientData,
+ char *buf,
+ int toRead,
+ int *errorCodePtr)
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
+ ReflectedTransform *rtPtr = clientData;
int gotBytes, copied, read;
/*
@@ -1055,13 +1070,14 @@ ReflectInput(
gotBytes = 0;
while (toRead > 0) {
- /* Loop until the request is satisfied (or no data available from
+ /*
+ * Loop until the request is satisfied (or no data available from
* below, possibly EOF).
*/
- copied = ResultCopy (&rtPtr->result, UCHARP(buf), toRead);
- toRead -= copied;
- buf += copied;
+ copied = ResultCopy(&rtPtr->result, UCHARP(buf), toRead);
+ toRead -= copied;
+ buf += copied;
gotBytes += copied;
if (toRead == 0) {
@@ -1073,9 +1089,7 @@ ReflectInput(
* have to go to the underlying channel, get more bytes and then
* transform them for delivery. We may not get what we want (full EOF
* or temporarily out of data).
- */
-
- /*
+ *
* Length (rtPtr->result) == 0, toRead > 0 here. Use 'buf'! as target
* to store the intermediary information read from the parent channel.
*
@@ -1088,7 +1102,8 @@ ReflectInput(
if ((rtPtr->methods & FLAG(METH_LIMIT))) {
int maxRead = -1;
- if (!TransformLimit (rtPtr, errorCodePtr, &maxRead)) {
+
+ if (!TransformLimit(rtPtr, errorCodePtr, &maxRead)) {
return -1;
}
if (maxRead == 0) {
@@ -1105,22 +1120,24 @@ ReflectInput(
return gotBytes;
}
- read = Tcl_ReadRaw (rtPtr->parent, buf, toRead);
+ read = Tcl_ReadRaw(rtPtr->parent, buf, toRead);
if (read < 0) {
- /* Report errors to caller.
- * The state of the seek system is unchanged!
+ /*
+ * Report errors to caller. The state of the seek system is
+ * unchanged!
*/
- if ((Tcl_GetErrno () == EAGAIN) && (gotBytes > 0)) {
- /* EAGAIN is a special situation. If we had some data
- * before we report that instead of the request to re-try.
+ if ((Tcl_GetErrno() == EAGAIN) && (gotBytes > 0)) {
+ /*
+ * EAGAIN is a special situation. If we had some data before
+ * we report that instead of the request to re-try.
*/
return gotBytes;
}
- *errorCodePtr = Tcl_GetErrno ();
- return -1;
+ *errorCodePtr = Tcl_GetErrno();
+ return -1;
}
if (read == 0) {
@@ -1134,17 +1151,21 @@ ReflectInput(
* convert and flush all waiting partial data.
*/
- if (!Tcl_Eof (rtPtr->parent)) {
- /* The state of the seek system is unchanged! */
+ if (!Tcl_Eof(rtPtr->parent)) {
+ /*
+ * The state of the seek system is unchanged!
+ */
if ((gotBytes == 0) && rtPtr->nonblocking) {
*errorCodePtr = EWOULDBLOCK;
return -1;
- } else {
- return gotBytes;
}
+ return gotBytes;
} else {
- /* Eof in parent */
+ /*
+ * Eof in parent.
+ */
+
if (rtPtr->readIsDrained) {
return gotBytes;
}
@@ -1155,18 +1176,24 @@ ReflectInput(
*/
if (HAS(rtPtr->methods, METH_DRAIN)) {
- if(!TransformDrain (rtPtr, errorCodePtr)) {
+ if (!TransformDrain(rtPtr, errorCodePtr)) {
return -1;
}
}
- if (ResultLength (&rtPtr->result) == 0) {
- /* The drain delivered nothing */
+ if (ResultLength(&rtPtr->result) == 0) {
+ /*
+ * The drain delivered nothing.
+ */
+
return gotBytes;
}
- /* Reset eof, force caller to drain result buffer */
- ((Channel*) rtPtr->parent)->state->flags &= ~CHANNEL_EOF;
+ /*
+ * Reset eof, force caller to drain result buffer.
+ */
+
+ ((Channel *) rtPtr->parent)->state->flags &= ~CHANNEL_EOF;
continue; /* at: while (toRead > 0) */
}
} /* read == 0 */
@@ -1177,13 +1204,12 @@ ReflectInput(
* iteration will put it into the result.
*/
- if (!TransformRead (rtPtr, errorCodePtr, UCHARP(buf), read)) {
+ if (!TransformRead(rtPtr, errorCodePtr, UCHARP(buf), read)) {
return -1;
}
} /* while toRead > 0 */
return gotBytes;
-
}
/*
@@ -1209,7 +1235,7 @@ ReflectOutput(
int toWrite,
int *errorCodePtr)
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
+ ReflectedTransform *rtPtr = clientData;
/*
* The following check can be done before thread redirection, because we
@@ -1224,8 +1250,10 @@ ReflectOutput(
}
if (toWrite == 0) {
- /* Nothing came in to write, ignore the call
+ /*
+ * Nothing came in to write, ignore the call
*/
+
return 0;
}
@@ -1235,7 +1263,7 @@ ReflectOutput(
*/
if ((rtPtr->methods & FLAG(METH_CLEAR))) {
- TransformClear (rtPtr);
+ TransformClear(rtPtr);
}
/*
@@ -1244,7 +1272,7 @@ ReflectOutput(
* parent channel for further processing.
*/
- if (!TransformWrite (rtPtr, errorCodePtr, UCHARP(buf), toWrite)) {
+ if (!TransformWrite(rtPtr, errorCodePtr, UCHARP(buf), toWrite)) {
return -1;
}
@@ -1263,7 +1291,8 @@ ReflectOutput(
* The new location of the access point.
*
* Side effects:
- * Allocates memory. Arbitrary, per the parent channel, and the called scripts.
+ * Allocates memory. Arbitrary, per the parent channel, and the called
+ * scripts.
*
*----------------------------------------------------------------------
*/
@@ -1275,12 +1304,12 @@ ReflectSeekWide(
int seekMode,
int *errorCodePtr)
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
- Channel* parent = (Channel*) rtPtr->parent;
+ ReflectedTransform *rtPtr = clientData;
+ Channel *parent = (Channel *) rtPtr->parent;
Tcl_WideInt curPos; /* Position on the device. */
- Tcl_DriverSeekProc *seekProc =
- Tcl_ChannelSeekProc(Tcl_GetChannelType (rtPtr->parent));
+ Tcl_DriverSeekProc *seekProc =
+ Tcl_ChannelSeekProc(Tcl_GetChannelType(rtPtr->parent));
/*
* Fail if the parent channel is not seekable.
@@ -1298,19 +1327,16 @@ ReflectSeekWide(
* request down and the result back up unchanged.
*/
- if (
- ((seekMode != SEEK_CUR) || (offset != 0)) &&
- (HAS(rtPtr->methods, METH_CLEAR) ||
- HAS(rtPtr->methods, METH_FLUSH))
- ) {
+ if (((seekMode != SEEK_CUR) || (offset != 0)) &&
+ (HAS(rtPtr->methods,METH_CLEAR) || HAS(rtPtr->methods,METH_FLUSH))){
/*
- * Neither a tell request, nor clear/flush both not supported. We
- * have to go through the Tcl level to clear and/or flush the
+ * Neither a tell request, nor clear/flush both not supported. We have
+ * to go through the Tcl level to clear and/or flush the
* transformation.
*/
if ((rtPtr->methods & FLAG(METH_CLEAR))) {
- TransformClear (rtPtr);
+ TransformClear(rtPtr);
}
/*
@@ -1321,7 +1347,7 @@ ReflectSeekWide(
*/
if (HAS(rtPtr->methods, METH_FLUSH)) {
- if (!TransformFlush (rtPtr, errorCodePtr, FLUSH_DISCARD)) {
+ if (!TransformFlush(rtPtr, errorCodePtr, FLUSH_DISCARD)) {
return -1;
}
}
@@ -1335,14 +1361,14 @@ ReflectSeekWide(
if (HaveVersion(parent->typePtr, TCL_CHANNEL_VERSION_3) &&
parent->typePtr->wideSeekProc != NULL) {
- curPos = (parent->typePtr->wideSeekProc) (parent->instanceData,
- offset, seekMode, errorCodePtr);
+ curPos = parent->typePtr->wideSeekProc(parent->instanceData, offset,
+ seekMode, errorCodePtr);
} else if (offset < Tcl_LongAsWide(LONG_MIN) ||
offset > Tcl_LongAsWide(LONG_MAX)) {
*errorCodePtr = EOVERFLOW;
curPos = Tcl_LongAsWide(-1);
} else {
- curPos = Tcl_LongAsWide((parent->typePtr->seekProc) (
+ curPos = Tcl_LongAsWide(parent->typePtr->seekProc(
parent->instanceData, Tcl_WideAsLong(offset), seekMode,
errorCodePtr));
}
@@ -1394,12 +1420,11 @@ ReflectWatch(
ClientData clientData,
int mask)
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
- Tcl_DriverWatchProc* watchProc;
+ ReflectedTransform *rtPtr = clientData;
+ Tcl_DriverWatchProc *watchProc;
- watchProc = Tcl_ChannelWatchProc (Tcl_GetChannelType (rtPtr->parent));
- (*watchProc) (Tcl_GetChannelInstanceData(rtPtr->parent),
- mask);
+ watchProc = Tcl_ChannelWatchProc(Tcl_GetChannelType(rtPtr->parent));
+ watchProc(Tcl_GetChannelInstanceData(rtPtr->parent), mask);
/*
* Management of the internal timer.
@@ -1408,11 +1433,11 @@ ReflectWatch(
if (!(mask & TCL_READABLE) || (ResultLength(&rtPtr->result) == 0)) {
/*
* A pending timer may exist, but either is there no (more) interest
- * in the events it generates or nothing is available for
- * reading. Remove it, if existing.
+ * in the events it generates or nothing is available for reading.
+ * Remove it, if existing.
*/
- TimerKill (rtPtr);
+ TimerKill(rtPtr);
} else {
/*
* There might be no pending timer, but there is interest in readable
@@ -1420,7 +1445,7 @@ ReflectWatch(
* flush that if it does not exist.
*/
- TimerSetup (rtPtr);
+ TimerSetup(rtPtr);
}
}
@@ -1446,7 +1471,7 @@ ReflectBlock(
ClientData clientData,
int nonblocking)
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
+ ReflectedTransform *rtPtr = clientData;
/*
* Transformations simply record the blocking mode in their C level
@@ -1481,7 +1506,7 @@ ReflectSetOption(
const char *optionName, /* Name of requested option */
const char *newValue) /* The new value */
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
+ ReflectedTransform *rtPtr = clientData;
/*
* Transformations have no options. Thus the call is passed down unchanged
@@ -1490,15 +1515,14 @@ ReflectSetOption(
* level is not involved there is no need for thread forwarding.
*/
- Tcl_DriverSetOptionProc *setOptionProc =
- Tcl_ChannelSetOptionProc (Tcl_GetChannelType (rtPtr->parent));
+ Tcl_DriverSetOptionProc *setOptionProc =
+ Tcl_ChannelSetOptionProc(Tcl_GetChannelType(rtPtr->parent));
- if (setOptionProc != NULL) {
- return (*setOptionProc) (Tcl_GetChannelInstanceData (rtPtr->parent),
- interp, optionName, newValue);
- } else {
- return TCL_ERROR;
+ if (setOptionProc == NULL) {
+ return TCL_ERROR;
}
+ return setOptionProc(Tcl_GetChannelInstanceData(rtPtr->parent), interp,
+ optionName, newValue);
}
/*
@@ -1524,7 +1548,7 @@ ReflectGetOption(
const char *optionName, /* Name of reuqested option */
Tcl_DString *dsPtr) /* String to place the result into */
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
+ ReflectedTransform *rtPtr = clientData;
/*
* Transformations have no options. Thus the call is passed down unchanged
@@ -1537,16 +1561,16 @@ ReflectGetOption(
* specific option has to fail.
*/
- Tcl_DriverGetOptionProc *getOptionProc =
- Tcl_ChannelGetOptionProc (Tcl_GetChannelType (rtPtr->parent));
+ Tcl_DriverGetOptionProc *getOptionProc =
+ Tcl_ChannelGetOptionProc(Tcl_GetChannelType(rtPtr->parent));
if (getOptionProc != NULL) {
- return (*getOptionProc) (Tcl_GetChannelInstanceData (rtPtr->parent),
- interp, optionName, dsPtr);
- } else if (optionName == (char*) NULL) {
- return TCL_OK;
+ return getOptionProc(Tcl_GetChannelInstanceData(rtPtr->parent),
+ interp, optionName, dsPtr);
+ } else if (optionName == NULL) {
+ return TCL_OK;
} else {
- return TCL_ERROR;
+ return TCL_ERROR;
}
}
@@ -1568,11 +1592,11 @@ ReflectGetOption(
static int
ReflectHandle(
- ClientData clientData,
- int direction,
- ClientData* handlePtr)
+ ClientData clientData,
+ int direction,
+ ClientData *handlePtr)
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
+ ReflectedTransform *rtPtr = clientData;
/*
* Transformations have no handle of their own. As such we simply query
@@ -1584,7 +1608,7 @@ ReflectHandle(
* involved no forwarding is required.
*/
- return Tcl_GetChannelHandle (rtPtr->parent, direction, handlePtr);
+ return Tcl_GetChannelHandle(rtPtr->parent, direction, handlePtr);
}
/*
*----------------------------------------------------------------------
@@ -1604,10 +1628,10 @@ ReflectHandle(
static int
ReflectNotify(
- ClientData clientData,
- int mask)
+ ClientData clientData,
+ int mask)
{
- ReflectedTransform *rtPtr = (ReflectedTransform *) clientData;
+ ReflectedTransform *rtPtr = clientData;
/*
* An event occured in the underlying channel.
@@ -1618,7 +1642,7 @@ ReflectNotify(
* us to recreate the timer (in ReflectWatch).
*/
- TimerKill (rtPtr);
+ TimerKill(rtPtr);
/*
* Pass to higher layers.
@@ -1722,14 +1746,17 @@ NewReflectedTransform(
rtPtr->interp = interp;
rtPtr->handle = handleObj;
Tcl_IncrRefCount(handleObj);
- rtPtr->timer = (Tcl_TimerToken) NULL;
+ rtPtr->timer = NULL;
rtPtr->mode = 0;
rtPtr->readIsDrained = 0;
- rtPtr->nonblocking =
- (((Channel*) parentChan)->state->flags & CHANNEL_NONBLOCKING);
- /* Query parent for current blocking mode. */
+ rtPtr->nonblocking =
+ (((Channel *) parentChan)->state->flags & CHANNEL_NONBLOCKING);
- ResultInit (&rtPtr->result);
+ /*
+ * Query parent for current blocking mode.
+ */
+
+ ResultInit(&rtPtr->result);
/*
* Method placeholder.
@@ -1750,7 +1777,7 @@ NewReflectedTransform(
*/
rtPtr->argc = listc + 2;
- rtPtr->argv = (Tcl_Obj**) ckalloc(sizeof(Tcl_Obj*) * (listc+4));
+ rtPtr->argv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (listc+4));
/*
* Duplicate object references.
@@ -1758,6 +1785,7 @@ NewReflectedTransform(
for (i=0; i<listc ; i++) {
Tcl_Obj *word = rtPtr->argv[i] = listv[i];
+
Tcl_IncrRefCount(word);
}
@@ -1828,8 +1856,8 @@ FreeReflectedTransform(
{
int i, n;
- TimerKill (rtPtr);
- ResultClear (&rtPtr->result);
+ TimerKill(rtPtr);
+ ResultClear(&rtPtr->result);
Tcl_DecrRefCount(rtPtr->handle);
rtPtr->handle = NULL;
@@ -2039,7 +2067,8 @@ GetReflectedTransformMap(
ReflectedTransformMap *rtmPtr = Tcl_GetAssocData(interp, RTMKEY, NULL);
if (rtmPtr == NULL) {
- rtmPtr = (ReflectedTransformMap *) ckalloc(sizeof(ReflectedTransformMap));
+ rtmPtr = (ReflectedTransformMap *)
+ ckalloc(sizeof(ReflectedTransformMap));
Tcl_InitHashTable(&rtmPtr->map, TCL_STRING_KEYS);
Tcl_SetAssocData(interp, RTMKEY,
(Tcl_InterpDeleteProc *) DeleteReflectedTransformMap, rtmPtr);
@@ -2076,7 +2105,6 @@ DeleteReflectedTransformMap(
Tcl_HashSearch hSearch; /* Search variable. */
Tcl_HashEntry *hPtr; /* Search variable. */
ReflectedTransform *rtPtr;
-
#ifdef TCL_THREADS
ForwardingResult *resultPtr;
ForwardingEvent *evPtr;
@@ -2099,7 +2127,7 @@ DeleteReflectedTransformMap(
for (hPtr = Tcl_FirstHashEntry(&rtmPtr->map, &hSearch);
hPtr != NULL;
hPtr = Tcl_FirstHashEntry(&rtmPtr->map, &hSearch)) {
- rtPtr = (ReflectedTransform *) Tcl_GetHashValue (hPtr);
+ rtPtr = Tcl_GetHashValue(hPtr);
rtPtr->interp = NULL;
Tcl_DeleteHashEntry(hPtr);
}
@@ -2119,8 +2147,7 @@ DeleteReflectedTransformMap(
Tcl_MutexLock(&rtForwardMutex);
- for (resultPtr = forwardList;
- resultPtr != NULL;
+ for (resultPtr = forwardList; resultPtr != NULL;
resultPtr = resultPtr->nextPtr) {
if (resultPtr->dsti != interp) {
/*
@@ -2158,7 +2185,7 @@ DeleteReflectedTransformMap(
for (hPtr = Tcl_FirstHashEntry(&rtmPtr->map, &hSearch);
hPtr != NULL;
hPtr = Tcl_NextHashEntry(&hSearch)) {
- rtPtr = (ReflectedTransform *) Tcl_GetHashValue (hPtr);
+ rtPtr = Tcl_GetHashValue(hPtr);
if (rtPtr->interp != interp) {
/*
@@ -2250,8 +2277,7 @@ DeleteThreadReflectedTransformMap(
Tcl_MutexLock(&rtForwardMutex);
- for (resultPtr = forwardList;
- resultPtr != NULL;
+ for (resultPtr = forwardList; resultPtr != NULL;
resultPtr = resultPtr->nextPtr) {
ForwardingEvent *evPtr;
ForwardParam *paramPtr;
@@ -2291,7 +2317,7 @@ DeleteThreadReflectedTransformMap(
for (hPtr = Tcl_FirstHashEntry(&rtmPtr->map, &hSearch);
hPtr != NULL;
hPtr = Tcl_FirstHashEntry(&rtmPtr->map, &hSearch)) {
- ReflectedTransform *rtPtr = (ReflectedTransform *) Tcl_GetHashValue(hPtr);
+ ReflectedTransform *rtPtr = Tcl_GetHashValue(hPtr);
rtPtr->interp = NULL;
Tcl_DeleteHashEntry(hPtr);
@@ -2304,7 +2330,7 @@ static void
ForwardOpToOwnerThread(
ReflectedTransform *rtPtr, /* Channel instance */
ForwardedOperation op, /* Forwarded driver operation */
- const VOID *param) /* Arguments */
+ const void *param) /* Arguments */
{
Tcl_ThreadId dst = rtPtr->thread;
ForwardingEvent *evPtr;
@@ -2363,13 +2389,13 @@ ForwardOpToOwnerThread(
* (see above) for.
*/
- Tcl_CreateThreadExitHandler(SrcExitProc, (ClientData) evPtr);
+ Tcl_CreateThreadExitHandler(SrcExitProc, evPtr);
/*
* Queue the event and poke the other thread's notifier.
*/
- Tcl_ThreadQueueEvent(dst, (Tcl_Event *)evPtr, TCL_QUEUE_TAIL);
+ Tcl_ThreadQueueEvent(dst, (Tcl_Event *) evPtr, TCL_QUEUE_TAIL);
Tcl_ThreadAlert(dst);
/*
@@ -2411,7 +2437,7 @@ ForwardOpToOwnerThread(
* notifier, after it serviced the event.
*/
- Tcl_DeleteThreadExitHandler(SrcExitProc, (ClientData) evPtr);
+ Tcl_DeleteThreadExitHandler(SrcExitProc, evPtr);
result = resultPtr->result;
ckfree((char*) resultPtr);
@@ -2441,8 +2467,10 @@ ForwardProc(
Tcl_Interp *interp = rtPtr->interp;
ForwardParam *paramPtr = evPtr->param;
Tcl_Obj *resObj = NULL; /* Interp result of InvokeTclMethod */
- ReflectedTransformMap* rtmPtr; /* Map of reflected channels with handlers in this interp */
- Tcl_HashEntry* hPtr; /* Entry in the above map */
+ ReflectedTransformMap *rtmPtr;
+ /* Map of reflected channels with handlers in
+ * this interp. */
+ Tcl_HashEntry *hPtr; /* Entry in the above map */
/*
* Ignore the event if no one is waiting for its result anymore.
@@ -2468,7 +2496,8 @@ ForwardProc(
* No parameters/results.
*/
- if (InvokeTclMethod(rtPtr, "finalize", NULL, NULL, &resObj) != TCL_OK) {
+ if (InvokeTclMethod(rtPtr, "finalize", NULL, NULL,
+ &resObj) != TCL_OK) {
ForwardSetObjError(paramPtr, resObj);
}
@@ -2484,10 +2513,9 @@ ForwardProc(
* dereferencing a dangling pointer.
*/
- rtmPtr = GetReflectedTransformMap (interp);
- hPtr = Tcl_FindHashEntry (&rtmPtr->map,
- Tcl_GetString(rtPtr->handle));
- Tcl_DeleteHashEntry (hPtr);
+ rtmPtr = GetReflectedTransformMap(interp);
+ hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
+ Tcl_DeleteHashEntry(hPtr);
/*
* In a threaded interpreter we manage a per-thread map as well, to
@@ -2496,15 +2524,14 @@ ForwardProc(
*/
rtmPtr = GetThreadReflectedTransformMap();
- hPtr = Tcl_FindHashEntry (&rtmPtr->map,
- Tcl_GetString(rtPtr->handle));
- Tcl_DeleteHashEntry (hPtr);
+ hPtr = Tcl_FindHashEntry(&rtmPtr->map, Tcl_GetString(rtPtr->handle));
+ Tcl_DeleteHashEntry(hPtr);
FreeReflectedTransform(rtPtr);
break;
case ForwardedInput: {
- Tcl_Obj *bufObj = Tcl_NewByteArrayObj((unsigned char *) paramPtr->transform.buf,
- paramPtr->transform.size);
+ Tcl_Obj *bufObj = Tcl_NewByteArrayObj((unsigned char *)
+ paramPtr->transform.buf, paramPtr->transform.size);
if (InvokeTclMethod(rtPtr, "read", bufObj, NULL, &resObj) != TCL_OK) {
ForwardSetObjError(paramPtr, resObj);
@@ -2516,14 +2543,15 @@ ForwardProc(
*/
int bytec; /* Number of returned bytes */
- unsigned char *bytev; /* Array of returned bytes */
+ unsigned char *bytev;
+ /* Array of returned bytes */
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
paramPtr->transform.size = bytec;
if (bytec > 0) {
- paramPtr->transform.buf = ckalloc (bytec);
+ paramPtr->transform.buf = ckalloc(bytec);
memcpy(paramPtr->transform.buf, bytev, (size_t)bytec);
} else {
paramPtr->transform.buf = NULL;
@@ -2533,8 +2561,8 @@ ForwardProc(
}
case ForwardedOutput: {
- Tcl_Obj *bufObj = Tcl_NewByteArrayObj((unsigned char *) paramPtr->transform.buf,
- paramPtr->transform.size);
+ Tcl_Obj *bufObj = Tcl_NewByteArrayObj((unsigned char *)
+ paramPtr->transform.buf, paramPtr->transform.size);
if (InvokeTclMethod(rtPtr, "write", bufObj, NULL, &resObj) != TCL_OK) {
ForwardSetObjError(paramPtr, resObj);
@@ -2546,14 +2574,15 @@ ForwardProc(
*/
int bytec; /* Number of returned bytes */
- unsigned char *bytev; /* Array of returned bytes */
+ unsigned char *bytev;
+ /* Array of returned bytes */
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
paramPtr->transform.size = bytec;
if (bytec > 0) {
- paramPtr->transform.buf = ckalloc (bytec);
+ paramPtr->transform.buf = ckalloc(bytec);
memcpy(paramPtr->transform.buf, bytev, (size_t)bytec);
} else {
paramPtr->transform.buf = NULL;
@@ -2580,7 +2609,7 @@ ForwardProc(
paramPtr->transform.size = bytec;
if (bytec > 0) {
- paramPtr->transform.buf = ckalloc (bytec);
+ paramPtr->transform.buf = ckalloc(bytec);
memcpy(paramPtr->transform.buf, bytev, (size_t)bytec);
} else {
paramPtr->transform.buf = NULL;
@@ -2600,14 +2629,15 @@ ForwardProc(
*/
int bytec; /* Number of returned bytes */
- unsigned char *bytev; /* Array of returned bytes */
+ unsigned char *bytev;
+ /* Array of returned bytes */
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
paramPtr->transform.size = bytec;
if (bytec > 0) {
- paramPtr->transform.buf = ckalloc (bytec);
+ paramPtr->transform.buf = ckalloc(bytec);
memcpy(paramPtr->transform.buf, bytev, (size_t)bytec);
} else {
paramPtr->transform.buf = NULL;
@@ -2627,7 +2657,8 @@ ForwardProc(
if (InvokeTclMethod(rtPtr, "limit?", NULL, NULL, &resObj) != TCL_OK) {
ForwardSetObjError(paramPtr, resObj);
paramPtr->limit.max = -1;
- } else if (Tcl_GetIntFromObj(interp, resObj, &paramPtr->limit.max) != TCL_OK) {
+ } else if (Tcl_GetIntFromObj(interp, resObj,
+ &paramPtr->limit.max) != TCL_OK) {
ForwardSetObjError(paramPtr, MarshallError(interp));
paramPtr->limit.max = -1;
}
@@ -2673,7 +2704,7 @@ static void
SrcExitProc(
ClientData clientData)
{
- ForwardingEvent *evPtr = (ForwardingEvent *) clientData;
+ ForwardingEvent *evPtr = clientData;
ForwardingResult *resultPtr;
ForwardParam *paramPtr;
@@ -2734,265 +2765,270 @@ ForwardSetObjError(
/*
*----------------------------------------------------------------------
*
- * TimerKill --
+ * TimerKill --
*
- * Timer management. Removes the internal timer
- * if it exists.
+ * Timer management. Removes the internal timer if it exists.
*
- * Sideeffects:
- * See above.
+ * Side effects:
+ * See above.
*
- * Result:
- * None.
+ * Result:
+ * None.
*
*----------------------------------------------------------------------
*/
static void
-TimerKill (ReflectedTransform* rtPtr)
+TimerKill(
+ ReflectedTransform *rtPtr)
{
- if (rtPtr->timer == (Tcl_TimerToken) NULL) return;
+ if (rtPtr->timer == NULL) {
+ return;
+ }
- /* Delete an existing flush-out timer, prevent it from firing on a
+ /*
+ * Delete an existing flush-out timer, prevent it from firing on a
* removed/dead channel.
*/
- Tcl_DeleteTimerHandler (rtPtr->timer);
- rtPtr->timer = (Tcl_TimerToken) NULL;
+ Tcl_DeleteTimerHandler(rtPtr->timer);
+ rtPtr->timer = NULL;
}
/*
*----------------------------------------------------------------------
*
- * TimerSetup --
+ * TimerSetup --
*
- * Timer management. Creates the internal timer
- * if it does not exist.
+ * Timer management. Creates the internal timer if it does not exist.
*
- * Sideeffects:
- * See above.
+ * Side effects:
+ * See above.
*
- * Result:
- * None.
+ * Result:
+ * None.
*
*----------------------------------------------------------------------
*/
static void
-TimerSetup (ReflectedTransform* rtPtr)
+TimerSetup(
+ ReflectedTransform *rtPtr)
{
- if (rtPtr->timer != (Tcl_TimerToken) NULL) return;
+ if (rtPtr->timer != NULL) {
+ return;
+ }
- rtPtr->timer = Tcl_CreateTimerHandler (FLUSH_DELAY, TimerRun,
- (ClientData) rtPtr);
+ rtPtr->timer = Tcl_CreateTimerHandler(FLUSH_DELAY, TimerRun, rtPtr);
}
/*
*----------------------------------------------------------------------
*
- * TimerRun --
+ * TimerRun --
*
- * Called by the notifier (-> timer) to flush out
- * information waiting in channel buffers.
+ * Called by the notifier (-> timer) to flush out information waiting in
+ * channel buffers.
*
- * Sideeffects:
- * As of 'Tcl_NotifyChannel'.
+ * Side effects:
+ * As of 'Tcl_NotifyChannel'.
*
- * Result:
- * None.
+ * Result:
+ * None.
*
*----------------------------------------------------------------------
*/
static void
-TimerRun (ClientData clientData)
+TimerRun(
+ ClientData clientData)
{
- ReflectedTransform* rtPtr = (ReflectedTransform*) clientData;
+ ReflectedTransform *rtPtr = clientData;
- rtPtr->timer = (Tcl_TimerToken) NULL;
- Tcl_NotifyChannel (rtPtr->chan, TCL_READABLE);
+ rtPtr->timer = NULL;
+ Tcl_NotifyChannel(rtPtr->chan, TCL_READABLE);
}
-
/*
*----------------------------------------------------------------------
*
- * ResultInit --
+ * ResultInit --
*
- * Initializes the specified buffer structure. The
- * structure will contain valid information for an
- * emtpy buffer.
+ * Initializes the specified buffer structure. The structure will contain
+ * valid information for an emtpy buffer.
*
- * Sideeffects:
- * See above.
+ * Side effects:
+ * See above.
*
- * Result:
- * None.
+ * Result:
+ * None.
*
*----------------------------------------------------------------------
*/
static void
-ResultInit (ResultBuffer* r) /* Reference to the structure to initialize */
+ResultInit(
+ ResultBuffer *rPtr) /* Reference to the structure to
+ * initialize. */
{
- r->used = 0;
- r->allocated = 0;
- r->buf = NULL;
+ rPtr->used = 0;
+ rPtr->allocated = 0;
+ rPtr->buf = NULL;
}
/*
*----------------------------------------------------------------------
*
- * ResultClear --
+ * ResultClear --
*
* Deallocates any memory allocated by 'ResultAdd'.
*
- * Sideeffects:
- * See above.
+ * Side effects:
+ * See above.
*
- * Result:
- * None.
+ * Result:
+ * None.
*
*----------------------------------------------------------------------
*/
static void
-ResultClear (ResultBuffer* r) /* Reference to the buffer to clear out */
+ResultClear(
+ ResultBuffer *rPtr) /* Reference to the buffer to clear out */
{
- r->used = 0;
+ rPtr->used = 0;
- if (!r->allocated) return;
+ if (!rPtr->allocated) {
+ return;
+ }
- Tcl_Free ((char*) r->buf);
- r->buf = NULL;
- r->allocated = 0;
+ Tcl_Free((char *) rPtr->buf);
+ rPtr->buf = NULL;
+ rPtr->allocated = 0;
}
/*
*----------------------------------------------------------------------
*
- * ResultAdd --
+ * ResultAdd --
*
- * Adds the bytes in the specified array to the
- * buffer, by appending it.
+ * Adds the bytes in the specified array to the buffer, by appending it.
*
- * Sideeffects:
- * See above.
+ * Side effects:
+ * See above.
*
- * Result:
- * None.
+ * Result:
+ * None.
*
*----------------------------------------------------------------------
*/
static void
-ResultAdd (r, buf, toWrite)
- ResultBuffer* r; /* The buffer to extend */
- unsigned char* buf; /* The buffer to read from */
- int toWrite; /* The number of bytes in 'buf' */
+ResultAdd(
+ ResultBuffer *rPtr, /* The buffer to extend */
+ unsigned char *buf, /* The buffer to read from */
+ int toWrite) /* The number of bytes in 'buf' */
{
- if ((r->used + toWrite + 1) > r->allocated) {
- /* Extension of the internal buffer is required.
+ if ((rPtr->used + toWrite + 1) > rPtr->allocated) {
+ /*
+ * Extension of the internal buffer is required.
* NOTE: Currently linear. Should be doubling to amortize.
*/
- if (r->allocated == 0) {
- r->allocated = toWrite + RB_INCREMENT;
- r->buf = UCHARP(Tcl_Alloc (r->allocated));
+ if (rPtr->allocated == 0) {
+ rPtr->allocated = toWrite + RB_INCREMENT;
+ rPtr->buf = UCHARP(Tcl_Alloc(rPtr->allocated));
} else {
- r->allocated += toWrite + RB_INCREMENT;
- r->buf = UCHARP(Tcl_Realloc((char*) r->buf, r->allocated));
+ rPtr->allocated += toWrite + RB_INCREMENT;
+ rPtr->buf = UCHARP(Tcl_Realloc((char *) rPtr->buf,
+ rPtr->allocated));
}
}
- /* now copy data */
- memcpy (r->buf + r->used, buf, toWrite);
- r->used += toWrite;
+ /*
+ * Now copy data.
+ */
+
+ memcpy(rPtr->buf + rPtr->used, buf, toWrite);
+ rPtr->used += toWrite;
}
/*
*----------------------------------------------------------------------
*
- * ResultCopy --
+ * ResultCopy --
*
- * Copies the requested number of bytes from the
- * buffer into the specified array and removes them
- * from the buffer afterward. Copies less if there
- * is not enough data in the buffer.
+ * Copies the requested number of bytes from the buffer into the
+ * specified array and removes them from the buffer afterward. Copies
+ * less if there is not enough data in the buffer.
*
- * Sideeffects:
- * See above.
+ * Side effects:
+ * See above.
*
- * Result:
- * The number of actually copied bytes,
- * possibly less than 'toRead'.
+ * Result:
+ * The number of actually copied bytes, possibly less than 'toRead'.
*
*----------------------------------------------------------------------
*/
static int
-ResultCopy (ResultBuffer* r, /* The buffer to read from */
- unsigned char* buf, /* The buffer to copy into */
- int toRead) /* Number of requested bytes */
+ResultCopy(
+ ResultBuffer *rPtr, /* The buffer to read from */
+ unsigned char *buf, /* The buffer to copy into */
+ int toRead) /* Number of requested bytes */
{
int copied;
- if (r->used == 0) {
- /* Nothing to copy in the case of an empty buffer.
+ if (rPtr->used == 0) {
+ /*
+ * Nothing to copy in the case of an empty buffer.
*/
copied = 0;
- goto done;
- }
+ } else if (rPtr->used == toRead) {
+ /*
+ * We have just enough. Copy everything to the caller.
+ */
- if (r->used == toRead) {
- /* We have just enough. Copy everything to the caller.
+ memcpy(buf, rPtr->buf, toRead);
+ rPtr->used = 0;
+ copied = toRead;
+ } else if (rPtr->used > toRead) {
+ /*
+ * The internal buffer contains more than requested. Copy the
+ * requested subset to the caller, and shift the remaining bytes down.
*/
- memcpy ((VOID*) buf, (VOID*) r->buf, toRead);
- r->used = 0;
- copied = toRead;
- goto done;
- }
+ memcpy(buf, rPtr->buf, toRead);
+ memmove(rPtr->buf, rPtr->buf + toRead, rPtr->used - toRead);
- if (r->used > toRead) {
- /* The internal buffer contains more than requested.
- * Copy the requested subset to the caller, and shift
- * the remaining bytes down.
+ rPtr->used -= toRead;
+ copied = toRead;
+ } else {
+ /*
+ * There is not enough in the buffer to satisfy the caller, so take
+ * everything.
*/
- memcpy ((VOID*) buf, (VOID*) r->buf, toRead);
- memmove ((VOID*) r->buf, (VOID*) (r->buf + toRead), r->used - toRead);
-
- r->used -= toRead;
- copied = toRead;
- goto done;
+ memcpy(buf, rPtr->buf, rPtr->used);
+ toRead = rPtr->used;
+ rPtr->used = 0;
+ copied = toRead;
}
- /* There is not enough in the buffer to satisfy the caller, so
- * take everything.
- */
-
- memcpy ((VOID*) buf, (VOID*) r->buf, r->used);
- toRead = r->used;
- r->used = 0;
- copied = toRead;
-
/* -- common postwork code ------- */
- done:
return copied;
}
-
static int
-TransformRead (
- ReflectedTransform* rtPtr,
- int* errorCodePtr,
- unsigned char* buf,
- int toRead)
+TransformRead(
+ ReflectedTransform *rtPtr,
+ int *errorCodePtr,
+ unsigned char *buf,
+ int toRead)
{
- Tcl_Obj* bufObj;
- Tcl_Obj* resObj;
+ Tcl_Obj *bufObj;
+ Tcl_Obj *resObj;
int bytec; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
@@ -3004,7 +3040,7 @@ TransformRead (
if (rtPtr->thread != Tcl_GetCurrentThread()) {
ForwardParam p;
- p.transform.buf = (char*) buf;
+ p.transform.buf = (char *) buf;
p.transform.size = toRead;
ForwardOpToOwnerThread(rtPtr, ForwardedInput, &p);
@@ -3013,41 +3049,38 @@ TransformRead (
PassReceivedError(rtPtr->chan, &p);
*errorCodePtr = EINVAL;
return 0;
- } else {
- *errorCodePtr = EOK;
}
- ResultAdd (&rtPtr->result, UCHARP(p.transform.buf), p.transform.size);
- ckfree (p.transform.buf);
- } else {
+ *errorCodePtr = EOK;
+ ResultAdd(&rtPtr->result, UCHARP(p.transform.buf), p.transform.size);
+ ckfree(p.transform.buf);
+ return 1;
+ }
#endif
- /* ASSERT: rtPtr->method & FLAG(METH_READ) */
- /* ASSERT: rtPtr->mode & TCL_READABLE */
- bufObj = Tcl_NewByteArrayObj((unsigned char *) buf, toRead);
- if (InvokeTclMethod(rtPtr, "read", bufObj, NULL, &resObj) != TCL_OK) {
- Tcl_SetChannelError(rtPtr->chan, resObj);
- Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
- *errorCodePtr = EINVAL;
- return 0;
- }
+ /* ASSERT: rtPtr->method & FLAG(METH_READ) */
+ /* ASSERT: rtPtr->mode & TCL_READABLE */
- bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
- ResultAdd (&rtPtr->result, bytev, bytec);
+ bufObj = Tcl_NewByteArrayObj((unsigned char *) buf, toRead);
+ if (InvokeTclMethod(rtPtr, "read", bufObj, NULL, &resObj) != TCL_OK) {
+ Tcl_SetChannelError(rtPtr->chan, resObj);
Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
-#ifdef TCL_THREADS
+ *errorCodePtr = EINVAL;
+ return 0;
}
-#endif
+ bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
+ ResultAdd(&rtPtr->result, bytev, bytec);
+ Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
return 1;
}
static int
-TransformWrite (
- ReflectedTransform* rtPtr,
- int* errorCodePtr,
- unsigned char* buf,
- int toWrite)
+TransformWrite(
+ ReflectedTransform *rtPtr,
+ int *errorCodePtr,
+ unsigned char *buf,
+ int toWrite)
{
Tcl_Obj *bufObj;
Tcl_Obj *resObj;
@@ -3063,7 +3096,7 @@ TransformWrite (
if (rtPtr->thread != Tcl_GetCurrentThread()) {
ForwardParam p;
- p.transform.buf = (char*) buf;
+ p.transform.buf = (char *) buf;
p.transform.size = toWrite;
ForwardOpToOwnerThread(rtPtr, ForwardedOutput, &p);
@@ -3072,15 +3105,15 @@ TransformWrite (
PassReceivedError(rtPtr->chan, &p);
*errorCodePtr = EINVAL;
return 0;
- } else {
- *errorCodePtr = EOK;
}
- res = Tcl_WriteRaw (rtPtr->parent,
- (char*) p.transform.buf, p.transform.size);
- ckfree (p.transform.buf);
- } else {
+ *errorCodePtr = EOK;
+ res = Tcl_WriteRaw(rtPtr->parent, (char *) p.transform.buf,
+ p.transform.size);
+ ckfree(p.transform.buf);
+ } else
#endif
+ {
/* ASSERT: rtPtr->method & FLAG(METH_WRITE) */
/* ASSERT: rtPtr->mode & TCL_WRITABLE */
@@ -3095,11 +3128,9 @@ TransformWrite (
*errorCodePtr = EOK;
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
- res = Tcl_WriteRaw (rtPtr->parent, (char*) bytev, bytec);
- Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
-#ifdef TCL_THREADS
+ res = Tcl_WriteRaw(rtPtr->parent, (char *) bytev, bytec);
+ Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
}
-#endif
if (res < 0) {
*errorCodePtr = EINVAL;
@@ -3109,14 +3140,12 @@ TransformWrite (
return 1;
}
-
-
static int
TransformDrain(
- ReflectedTransform* rtPtr,
- int* errorCodePtr)
+ ReflectedTransform *rtPtr,
+ int *errorCodePtr)
{
- Tcl_Obj* resObj;
+ Tcl_Obj *resObj;
int bytec; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
@@ -3134,14 +3163,14 @@ TransformDrain(
PassReceivedError(rtPtr->chan, &p);
*errorCodePtr = EINVAL;
return 0;
- } else {
- *errorCodePtr = EOK;
}
- ResultAdd (&rtPtr->result, UCHARP(p.transform.buf), p.transform.size);
- ckfree (p.transform.buf);
- } else {
+ *errorCodePtr = EOK;
+ ResultAdd(&rtPtr->result, UCHARP(p.transform.buf), p.transform.size);
+ ckfree(p.transform.buf);
+ } else
#endif
+ {
if (InvokeTclMethod(rtPtr, "drain", NULL, NULL, &resObj)!=TCL_OK) {
Tcl_SetChannelError(rtPtr->chan, resObj);
Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
@@ -3150,24 +3179,20 @@ TransformDrain(
}
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
- ResultAdd (&rtPtr->result, bytev, bytec);
+ ResultAdd(&rtPtr->result, bytev, bytec);
Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
-
-#ifdef TCL_THREADS
}
-#endif
rtPtr->readIsDrained = 1;
return 1;
}
-
static int
TransformFlush(
- ReflectedTransform* rtPtr,
- int* errorCodePtr,
- int op)
+ ReflectedTransform *rtPtr,
+ int *errorCodePtr,
+ int op)
{
Tcl_Obj* resObj;
int bytec; /* Number of returned bytes */
@@ -3188,19 +3213,19 @@ TransformFlush(
PassReceivedError(rtPtr->chan, &p);
*errorCodePtr = EINVAL;
return 0;
- } else {
- *errorCodePtr = EOK;
}
+ *errorCodePtr = EOK;
if (op == FLUSH_WRITE) {
- res = Tcl_WriteRaw (rtPtr->parent,
- (char*) p.transform.buf, p.transform.size);
+ res = Tcl_WriteRaw(rtPtr->parent, (char *) p.transform.buf,
+ p.transform.size);
} else {
res = 0;
}
ckfree(p.transform.buf);
- } else {
+ } else
#endif
+ {
if (InvokeTclMethod(rtPtr, "flush", NULL, NULL, &resObj)!=TCL_OK) {
Tcl_SetChannelError(rtPtr->chan, resObj);
Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
@@ -3210,15 +3235,13 @@ TransformFlush(
if (op == FLUSH_WRITE) {
bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
- res = Tcl_WriteRaw (rtPtr->parent, (char*) bytev, bytec);
+ res = Tcl_WriteRaw(rtPtr->parent, (char *) bytev, bytec);
} else {
res = 0;
}
Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
-
-#ifdef TCL_THREADS
}
-#endif
+
if (res < 0) {
*errorCodePtr = EINVAL;
return 0;
@@ -3228,8 +3251,8 @@ TransformFlush(
}
static void
-TransformClear (
- ReflectedTransform* rtPtr)
+TransformClear(
+ ReflectedTransform *rtPtr)
{
/*
* Are we in the correct thread?
@@ -3241,28 +3264,25 @@ TransformClear (
ForwardOpToOwnerThread(rtPtr, ForwardedClear, &p);
return;
- } else {
+ }
#endif
- /* ASSERT: rtPtr->method & FLAG(METH_READ) */
- /* ASSERT: rtPtr->mode & TCL_READABLE */
- (void) InvokeTclMethod(rtPtr, "clear", NULL, NULL, NULL);
+ /* ASSERT: rtPtr->method & FLAG(METH_READ) */
+ /* ASSERT: rtPtr->mode & TCL_READABLE */
-#ifdef TCL_THREADS
- }
-#endif
+ (void) InvokeTclMethod(rtPtr, "clear", NULL, NULL, NULL);
rtPtr->readIsDrained = 0;
- ResultClear (&rtPtr->result);
+ ResultClear(&rtPtr->result);
}
static int
-TransformLimit (
- ReflectedTransform* rtPtr,
- int* errorCodePtr,
- int* maxPtr)
+TransformLimit(
+ ReflectedTransform *rtPtr,
+ int *errorCodePtr,
+ int *maxPtr)
{
- Tcl_Obj* resObj;
+ Tcl_Obj *resObj;
Tcl_InterpState sr; /* State of handler interp */
/*
@@ -3279,11 +3299,11 @@ TransformLimit (
PassReceivedError(rtPtr->chan, &p);
*errorCodePtr = EINVAL;
return 0;
- } else {
- *errorCodePtr = EOK;
- *maxPtr = p.limit.max;
- return 1;
}
+
+ *errorCodePtr = EOK;
+ *maxPtr = p.limit.max;
+ return 1;
}
#endif
@@ -3337,7 +3357,7 @@ HaveVersion(
{
Tcl_ChannelTypeVersion actualVersion = Tcl_ChannelVersion(chanTypePtr);
- return (PTR2INT(actualVersion)) >= (PTR2INT(minimumVersion));
+ return PTR2INT(actualVersion) >= PTR2INT(minimumVersion);
}
/*
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 5ce7858..6485831 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -23,7 +23,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclNamesp.c,v 1.179 2008/10/15 06:17:04 nijtmans Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.180 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1182,7 +1182,7 @@ TclTeardownNamespace(
*/
if (nsPtr->deleteProc != NULL) {
- (*nsPtr->deleteProc)(nsPtr->clientData);
+ nsPtr->deleteProc(nsPtr->clientData);
}
nsPtr->deleteProc = NULL;
nsPtr->clientData = NULL;
@@ -2425,7 +2425,7 @@ Tcl_FindCommand(
Tcl_Command cmd;
if (cxtNsPtr->cmdResProc) {
- result = (*cxtNsPtr->cmdResProc)(interp, name,
+ result = cxtNsPtr->cmdResProc(interp, name,
(Tcl_Namespace *) cxtNsPtr, flags, &cmd);
} else {
result = TCL_CONTINUE;
@@ -2433,7 +2433,7 @@ Tcl_FindCommand(
while (result == TCL_CONTINUE && resPtr) {
if (resPtr->cmdResProc) {
- result = (*resPtr->cmdResProc)(interp, name,
+ result = resPtr->cmdResProc(interp, name,
(Tcl_Namespace *) cxtNsPtr, flags, &cmd);
}
resPtr = resPtr->nextPtr;
diff --git a/generic/tclNotify.c b/generic/tclNotify.c
index e6c4d40..53ef23e 100644
--- a/generic/tclNotify.c
+++ b/generic/tclNotify.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclNotify.c,v 1.28 2008/07/24 21:54:38 nijtmans Exp $
+ * RCS: @(#) $Id: tclNotify.c,v 1.29 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -535,7 +535,7 @@ Tcl_DeleteEvents(
prevPtr = NULL;
evPtr = tsdPtr->firstEventPtr;
while (evPtr != NULL) {
- if ((*proc)(evPtr, clientData) == 1) {
+ if (proc(evPtr, clientData) == 1) {
/*
* This event should be deleted. Unlink it.
*/
@@ -667,7 +667,7 @@ Tcl_ServiceEvent(
*/
Tcl_MutexUnlock(&(tsdPtr->queueMutex));
- result = (*proc)(evPtr, flags);
+ result = proc(evPtr, flags);
Tcl_MutexLock(&(tsdPtr->queueMutex));
if (result) {
@@ -931,7 +931,7 @@ Tcl_DoOneEvent(
for (sourcePtr = tsdPtr->firstEventSourcePtr; sourcePtr != NULL;
sourcePtr = sourcePtr->nextPtr) {
if (sourcePtr->setupProc) {
- (sourcePtr->setupProc)(sourcePtr->clientData, flags);
+ sourcePtr->setupProc(sourcePtr->clientData, flags);
}
}
tsdPtr->inTraversal = 0;
@@ -960,7 +960,7 @@ Tcl_DoOneEvent(
for (sourcePtr = tsdPtr->firstEventSourcePtr; sourcePtr != NULL;
sourcePtr = sourcePtr->nextPtr) {
if (sourcePtr->checkProc) {
- (sourcePtr->checkProc)(sourcePtr->clientData, flags);
+ sourcePtr->checkProc(sourcePtr->clientData, flags);
}
}
@@ -1070,13 +1070,13 @@ Tcl_ServiceAll(void)
for (sourcePtr = tsdPtr->firstEventSourcePtr; sourcePtr != NULL;
sourcePtr = sourcePtr->nextPtr) {
if (sourcePtr->setupProc) {
- (sourcePtr->setupProc)(sourcePtr->clientData, TCL_ALL_EVENTS);
+ sourcePtr->setupProc(sourcePtr->clientData, TCL_ALL_EVENTS);
}
}
for (sourcePtr = tsdPtr->firstEventSourcePtr; sourcePtr != NULL;
sourcePtr = sourcePtr->nextPtr) {
if (sourcePtr->checkProc) {
- (sourcePtr->checkProc)(sourcePtr->clientData, TCL_ALL_EVENTS);
+ sourcePtr->checkProc(sourcePtr->clientData, TCL_ALL_EVENTS);
}
}
diff --git a/generic/tclObj.c b/generic/tclObj.c
index c5fef11..ae3f909 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclObj.c,v 1.144 2008/10/16 22:34:19 nijtmans Exp $
+ * RCS: @(#) $Id: tclObj.c,v 1.145 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1024,7 +1024,7 @@ Tcl_DuplicateObj(
dupPtr->internalRep = objPtr->internalRep;
dupPtr->typePtr = typePtr;
} else {
- (*typePtr->dupIntRepProc)(objPtr, dupPtr);
+ typePtr->dupIntRepProc(objPtr, dupPtr);
}
}
return dupPtr;
@@ -1064,7 +1064,7 @@ Tcl_GetString(
Tcl_Panic("UpdateStringProc should not be invoked for type %s",
objPtr->typePtr->name);
}
- (*objPtr->typePtr->updateStringProc)(objPtr);
+ objPtr->typePtr->updateStringProc(objPtr);
return objPtr->bytes;
}
@@ -1104,7 +1104,7 @@ Tcl_GetStringFromObj(
Tcl_Panic("UpdateStringProc should not be invoked for type %s",
objPtr->typePtr->name);
}
- (*objPtr->typePtr->updateStringProc)(objPtr);
+ objPtr->typePtr->updateStringProc(objPtr);
}
if (lengthPtr != NULL) {
@@ -2206,7 +2206,7 @@ Tcl_GetLongFromObj(
mp_int big;
UNPACK_BIGNUM(objPtr, big);
- if ((size_t)(big.used) <= (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1)
+ if ((size_t) big.used <= (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1)
/ DIGIT_BIT) {
unsigned long value = 0, numBytes = sizeof(long);
long scratch;
@@ -2506,7 +2506,7 @@ Tcl_GetWideIntFromObj(
mp_int big;
UNPACK_BIGNUM(objPtr, big);
- if ((size_t)(big.used) <= (CHAR_BIT * sizeof(Tcl_WideInt)
+ if ((size_t) big.used <= (CHAR_BIT * sizeof(Tcl_WideInt)
+ DIGIT_BIT - 1) / DIGIT_BIT) {
Tcl_WideUInt value = 0;
unsigned long numBytes = sizeof(Tcl_WideInt);
@@ -2587,7 +2587,7 @@ FreeBignum(
UNPACK_BIGNUM(objPtr, toFree);
mp_clear(&toFree);
- if ((long)(objPtr->internalRep.ptrAndLongRep.value) < 0) {
+ if ((long) objPtr->internalRep.ptrAndLongRep.value < 0) {
ckfree((char *) objPtr->internalRep.ptrAndLongRep.ptr);
}
}
@@ -2927,11 +2927,12 @@ Tcl_SetBignumObj(
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_SetBignumObj");
}
- if ((size_t)(bignumValue->used)
+ if ((size_t) bignumValue->used
<= (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT) {
unsigned long value = 0, numBytes = sizeof(long);
long scratch;
- unsigned char *bytes = (unsigned char *)&scratch;
+ unsigned char *bytes = (unsigned char *) &scratch;
+
if (mp_to_unsigned_bin_n(bignumValue, bytes, &numBytes) != MP_OKAY) {
goto tooLargeForLong;
}
@@ -2951,12 +2952,13 @@ Tcl_SetBignumObj(
}
tooLargeForLong:
#ifndef NO_WIDE_TYPE
- if ((size_t)(bignumValue->used)
+ if ((size_t) bignumValue->used
<= (CHAR_BIT * sizeof(Tcl_WideInt) + DIGIT_BIT - 1) / DIGIT_BIT) {
Tcl_WideUInt value = 0;
unsigned long numBytes = sizeof(Tcl_WideInt);
Tcl_WideInt scratch;
unsigned char *bytes = (unsigned char *)&scratch;
+
if (mp_to_unsigned_bin_n(bignumValue, bytes, &numBytes) != MP_OKAY) {
goto tooLargeForWide;
}
diff --git a/generic/tclPanic.c b/generic/tclPanic.c
index dec5ed4..0a63076 100644
--- a/generic/tclPanic.c
+++ b/generic/tclPanic.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPanic.c,v 1.11 2008/04/27 22:21:31 dkf Exp $
+ * RCS: @(#) $Id: tclPanic.c,v 1.12 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -90,9 +90,9 @@ Tcl_PanicVA(
arg8 = va_arg(argList, char *);
if (panicProc != NULL) {
- (*panicProc)(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+ panicProc(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
} else if (platformPanicProc != NULL) {
- (*platformPanicProc)(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
+ platformPanicProc(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
arg8);
} else {
fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
diff --git a/generic/tclParse.c b/generic/tclParse.c
index 787b556..c730eaa 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclParse.c,v 1.72 2008/09/17 02:15:32 mistachkin Exp $
+ * RCS: @(#) $Id: tclParse.c,v 1.73 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -878,21 +878,21 @@ TclParseBackslash(
*/
if (isdigit(UCHAR(*p)) && (UCHAR(*p) < '8')) { /* INTL: digit */
- result = (unsigned char)(*p - '0');
+ result = UCHAR(*p - '0');
p++;
if ((numBytes == 2) || !isdigit(UCHAR(*p)) /* INTL: digit */
|| (UCHAR(*p) >= '8')) {
break;
}
count = 3;
- result = (unsigned char)((result << 3) + (*p - '0'));
+ result = UCHAR((result << 3) + (*p - '0'));
p++;
if ((numBytes == 3) || !isdigit(UCHAR(*p)) /* INTL: digit */
|| (UCHAR(*p) >= '8')) {
break;
}
count = 4;
- result = (unsigned char)((result << 3) + (*p - '0'));
+ result = UCHAR((result << 3) + (*p - '0'));
break;
}
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 3839429..436eea4 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPathObj.c,v 1.74 2008/10/16 22:34:19 nijtmans Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.75 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -1047,7 +1047,7 @@ Tcl_FSJoinPath(
int needsSep = 0;
if (fsPtr->filesystemSeparatorProc != NULL) {
- Tcl_Obj *sep = (*fsPtr->filesystemSeparatorProc)(res);
+ Tcl_Obj *sep = fsPtr->filesystemSeparatorProc(res);
if (sep != NULL) {
separator = TclGetString(sep)[0];
@@ -1961,7 +1961,7 @@ Tcl_FSGetNormalizedPath(
(fsPathPtr->nativePathPtr == NULL ? &clientData : NULL));
if (0 && (clientData != NULL)) {
fsPathPtr->nativePathPtr =
- (*fsPathPtr->fsRecPtr->fsPtr->dupInternalRepProc)(clientData);
+ fsPathPtr->fsRecPtr->fsPtr->dupInternalRepProc(clientData);
}
/*
@@ -2099,7 +2099,7 @@ Tcl_FSGetInternalRep(
return NULL;
}
- nativePathPtr = (*proc)(pathPtr);
+ nativePathPtr = proc(pathPtr);
srcFsPathPtr = PATHOBJ(pathPtr);
srcFsPathPtr->nativePathPtr = nativePathPtr;
}
@@ -2512,8 +2512,9 @@ FreeFsPathInternalRep(
if (fsPathPtr->nativePathPtr != NULL && fsPathPtr->fsRecPtr != NULL) {
Tcl_FSFreeInternalRepProc *freeProc =
fsPathPtr->fsRecPtr->fsPtr->freeInternalRepProc;
+
if (freeProc != NULL) {
- (*freeProc)(fsPathPtr->nativePathPtr);
+ freeProc(fsPathPtr->nativePathPtr);
fsPathPtr->nativePathPtr = NULL;
}
}
@@ -2572,9 +2573,10 @@ DupFsPathInternalRep(
&& srcFsPathPtr->nativePathPtr != NULL) {
Tcl_FSDupInternalRepProc *dupProc =
srcFsPathPtr->fsRecPtr->fsPtr->dupInternalRepProc;
+
if (dupProc != NULL) {
copyFsPathPtr->nativePathPtr =
- (*dupProc)(srcFsPathPtr->nativePathPtr);
+ dupProc(srcFsPathPtr->nativePathPtr);
} else {
copyFsPathPtr->nativePathPtr = NULL;
}
diff --git a/generic/tclPreserve.c b/generic/tclPreserve.c
index 3c991ea..9cc79a5 100644
--- a/generic/tclPreserve.c
+++ b/generic/tclPreserve.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPreserve.c,v 1.10 2007/03/21 18:02:51 dgp Exp $
+ * RCS: @(#) $Id: tclPreserve.c,v 1.11 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -229,7 +229,7 @@ Tcl_Release(
if (freeProc == TCL_DYNAMIC) {
ckfree((char *) clientData);
} else {
- (*freeProc)((char *) clientData);
+ freeProc((char *) clientData);
}
}
return;
@@ -297,7 +297,7 @@ Tcl_EventuallyFree(
if (freeProc == TCL_DYNAMIC) {
ckfree((char *) clientData);
} else {
- (*freeProc)((char *)clientData);
+ freeProc((char *)clientData);
}
}
diff --git a/generic/tclResult.c b/generic/tclResult.c
index b0a8836..40f0cba 100644
--- a/generic/tclResult.c
+++ b/generic/tclResult.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclResult.c,v 1.50 2008/10/16 22:34:19 nijtmans Exp $
+ * RCS: @(#) $Id: tclResult.c,v 1.51 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -368,7 +368,7 @@ Tcl_DiscardResult(
if (statePtr->freeProc == TCL_DYNAMIC) {
ckfree(statePtr->result);
} else {
- (*statePtr->freeProc)(statePtr->result);
+ statePtr->freeProc(statePtr->result);
}
}
}
@@ -434,7 +434,7 @@ Tcl_SetResult(
if (oldFreeProc == TCL_DYNAMIC) {
ckfree(oldResult);
} else {
- (*oldFreeProc)(oldResult);
+ oldFreeProc(oldResult);
}
}
@@ -526,7 +526,7 @@ Tcl_SetObjResult(
if (iPtr->freeProc == TCL_DYNAMIC) {
ckfree(iPtr->result);
} else {
- (*iPtr->freeProc)(iPtr->result);
+ iPtr->freeProc(iPtr->result);
}
iPtr->freeProc = 0;
}
@@ -579,7 +579,7 @@ Tcl_GetObjResult(
if (iPtr->freeProc == TCL_DYNAMIC) {
ckfree(iPtr->result);
} else {
- (*iPtr->freeProc)(iPtr->result);
+ iPtr->freeProc(iPtr->result);
}
iPtr->freeProc = 0;
}
@@ -861,7 +861,7 @@ Tcl_FreeResult(
if (iPtr->freeProc == TCL_DYNAMIC) {
ckfree(iPtr->result);
} else {
- (*iPtr->freeProc)(iPtr->result);
+ iPtr->freeProc(iPtr->result);
}
iPtr->freeProc = 0;
}
@@ -899,7 +899,7 @@ Tcl_ResetResult(
if (iPtr->freeProc == TCL_DYNAMIC) {
ckfree(iPtr->result);
} else {
- (*iPtr->freeProc)(iPtr->result);
+ iPtr->freeProc(iPtr->result);
}
iPtr->freeProc = 0;
}
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index b017347..6d5f96a 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -33,7 +33,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStringObj.c,v 1.73 2008/10/16 22:34:19 nijtmans Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.74 2008/10/26 18:34:04 dkf Exp $ */
#include "tclInt.h"
#include "tommath.h"
@@ -883,13 +883,12 @@ Tcl_AttemptSetObjLength(
*/
if (objPtr->bytes != tclEmptyStringRep) {
- newBytes = attemptckrealloc(objPtr->bytes,
- (unsigned)(length + 1));
+ newBytes = attemptckrealloc(objPtr->bytes, (unsigned) length+1);
if (newBytes == NULL) {
return 0;
}
} else {
- newBytes = attemptckalloc((unsigned) (length + 1));
+ newBytes = attemptckalloc((unsigned) length+1);
if (newBytes == NULL) {
return 0;
}
@@ -2027,7 +2026,7 @@ Tcl_AppendFormatToObj(
const char *bytes;
if (useShort) {
- pure = Tcl_NewIntObj((int)(s));
+ pure = Tcl_NewIntObj((int) s);
} else if (useWide) {
pure = Tcl_NewWideIntObj(w);
} else if (useBig) {
diff --git a/generic/tclTimer.c b/generic/tclTimer.c
index 1e1fd73..e254830 100644
--- a/generic/tclTimer.c
+++ b/generic/tclTimer.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclTimer.c,v 1.35 2008/10/16 22:34:19 nijtmans Exp $
+ * RCS: @(#) $Id: tclTimer.c,v 1.36 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -584,8 +584,8 @@ TimerHandlerEventProc(
* potential reentrancy problems.
*/
- (*nextPtrPtr) = timerHandlerPtr->nextPtr;
- (*timerHandlerPtr->proc)(timerHandlerPtr->clientData);
+ *nextPtrPtr = timerHandlerPtr->nextPtr;
+ timerHandlerPtr->proc(timerHandlerPtr->clientData);
ckfree((char *) timerHandlerPtr);
}
TimerSetupProc(NULL, TCL_TIMER_EVENTS);
@@ -743,7 +743,7 @@ TclServiceIdle(void)
if (tsdPtr->idleList == NULL) {
tsdPtr->lastIdlePtr = NULL;
}
- (*idlePtr->proc)(idlePtr->clientData);
+ idlePtr->proc(idlePtr->clientData);
ckfree((char *) idlePtr);
}
if (tsdPtr->idleList) {
diff --git a/generic/tclTrace.c b/generic/tclTrace.c
index 7876eab..e411488 100644
--- a/generic/tclTrace.c
+++ b/generic/tclTrace.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclTrace.c,v 1.53 2008/10/16 22:34:19 nijtmans Exp $
+ * RCS: @(#) $Id: tclTrace.c,v 1.54 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -238,7 +238,7 @@ Tcl_TraceObjCmd(
0, &typeIndex) != TCL_OK) {
return TCL_ERROR;
}
- return (traceSubCmds[typeIndex])(interp, optionIndex, objc, objv);
+ return traceSubCmds[typeIndex](interp, optionIndex, objc, objv);
}
case TRACE_INFO: {
/*
@@ -261,7 +261,7 @@ Tcl_TraceObjCmd(
0, &typeIndex) != TCL_OK) {
return TCL_ERROR;
}
- return (traceSubCmds[typeIndex])(interp, optionIndex, objc, objv);
+ return traceSubCmds[typeIndex](interp, optionIndex, objc, objv);
break;
}
@@ -305,9 +305,9 @@ Tcl_TraceObjCmd(
memcpy(copyObjv+1, objv, objc*sizeof(Tcl_Obj *));
copyObjv[4] = opsList;
if (optionIndex == TRACE_OLD_VARIABLE) {
- code = (traceSubCmds[2])(interp, TRACE_ADD, objc+1, copyObjv);
+ code = traceSubCmds[2](interp, TRACE_ADD, objc+1, copyObjv);
} else {
- code = (traceSubCmds[2])(interp, TRACE_REMOVE, objc+1, copyObjv);
+ code = traceSubCmds[2](interp, TRACE_REMOVE, objc+1, copyObjv);
}
Tcl_DecrRefCount(opsList);
return code;
@@ -1580,9 +1580,9 @@ TclCheckInterpTraces(
tcmdPtr->curFlags = traceFlags;
tcmdPtr->curCode = code;
}
- traceCode = (tracePtr->proc)(tracePtr->clientData,
- interp, curLevel, command, (Tcl_Command) cmdPtr,
- objc, objv);
+ traceCode = tracePtr->proc(tracePtr->clientData, interp,
+ curLevel, command, (Tcl_Command) cmdPtr, objc,
+ objv);
}
} else {
/*
@@ -2365,7 +2365,7 @@ Tcl_DeleteTrace(
*/
if (tracePtr->delProc != NULL) {
- (tracePtr->delProc)(tracePtr->clientData);
+ tracePtr->delProc(tracePtr->clientData);
}
/*
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 27a9248..3b8ddf5 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtil.c,v 1.106 2008/10/15 06:17:04 nijtmans Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.107 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -2129,9 +2129,9 @@ Tcl_DStringGetResult(
dsPtr->string = iPtr->result;
dsPtr->spaceAvl = dsPtr->length+1;
} else {
- dsPtr->string = (char *) ckalloc((unsigned) (dsPtr->length+1));
+ dsPtr->string = (char *) ckalloc((unsigned) dsPtr->length+1);
memcpy(dsPtr->string, iPtr->result, (unsigned) dsPtr->length+1);
- (*iPtr->freeProc)(iPtr->result);
+ iPtr->freeProc(iPtr->result);
}
dsPtr->spaceAvl = dsPtr->length+1;
iPtr->freeProc = NULL;
@@ -2140,7 +2140,7 @@ Tcl_DStringGetResult(
dsPtr->string = dsPtr->staticSpace;
dsPtr->spaceAvl = TCL_DSTRING_STATIC_SIZE;
} else {
- dsPtr->string = (char *) ckalloc((unsigned) (dsPtr->length + 1));
+ dsPtr->string = (char *) ckalloc((unsigned) dsPtr->length+1);
dsPtr->spaceAvl = dsPtr->length + 1;
}
memcpy(dsPtr->string, iPtr->result, (unsigned) dsPtr->length+1);
@@ -3052,7 +3052,7 @@ TclGetProcessGlobalValue(
Tcl_DStringLength(&native), &newValue);
Tcl_DStringFree(&native);
ckfree(pgvPtr->value);
- pgvPtr->value = ckalloc((unsigned int)
+ pgvPtr->value = ckalloc((unsigned)
Tcl_DStringLength(&newValue) + 1);
memcpy(pgvPtr->value, Tcl_DStringValue(&newValue),
(size_t) Tcl_DStringLength(&newValue) + 1);
@@ -3085,12 +3085,11 @@ TclGetProcessGlobalValue(
Tcl_MutexLock(&pgvPtr->mutex);
if ((NULL == pgvPtr->value) && (pgvPtr->proc)) {
pgvPtr->epoch++;
- (*(pgvPtr->proc))(&pgvPtr->value, &pgvPtr->numBytes,
- &pgvPtr->encoding);
+ pgvPtr->proc(&pgvPtr->value,&pgvPtr->numBytes,&pgvPtr->encoding);
if (pgvPtr->value == NULL) {
Tcl_Panic("PGV Initializer did not initialize");
}
- Tcl_CreateExitHandler(FreeProcessGlobalValue, (ClientData)pgvPtr);
+ Tcl_CreateExitHandler(FreeProcessGlobalValue, pgvPtr);
}
/*
@@ -3101,10 +3100,10 @@ TclGetProcessGlobalValue(
hPtr = Tcl_CreateHashEntry(cacheMap,
(char *) INT2PTR(pgvPtr->epoch), &dummy);
Tcl_MutexUnlock(&pgvPtr->mutex);
- Tcl_SetHashValue(hPtr, (ClientData) value);
+ Tcl_SetHashValue(hPtr, value);
Tcl_IncrRefCount(value);
}
- return (Tcl_Obj *) Tcl_GetHashValue(hPtr);
+ return Tcl_GetHashValue(hPtr);
}
/*
diff --git a/generic/tclVar.c b/generic/tclVar.c
index a68c5d2..dc35f69 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -16,7 +16,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.170 2008/10/15 06:17:03 nijtmans Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.171 2008/10/26 18:34:04 dkf Exp $
*/
#include "tclInt.h"
@@ -894,7 +894,7 @@ TclLookupSimpleVar(
&& !(flags & AVOID_RESOLVERS)) {
resPtr = iPtr->resolverPtr;
if (cxtNsPtr->varResProc) {
- result = (*cxtNsPtr->varResProc)(interp, varName,
+ result = cxtNsPtr->varResProc(interp, varName,
(Tcl_Namespace *) cxtNsPtr, flags, &var);
} else {
result = TCL_CONTINUE;
@@ -902,7 +902,7 @@ TclLookupSimpleVar(
while (result == TCL_CONTINUE && resPtr) {
if (resPtr->varResProc) {
- result = (*resPtr->varResProc)(interp, varName,
+ result = resPtr->varResProc(interp, varName,
(Tcl_Namespace *) cxtNsPtr, flags, &var);
}
resPtr = resPtr->nextPtr;
@@ -4941,7 +4941,7 @@ ObjFindNamespaceVar(
resPtr = iPtr->resolverPtr;
if (cxtNsPtr->varResProc) {
- result = (*cxtNsPtr->varResProc)(interp, name,
+ result = cxtNsPtr->varResProc(interp, name,
(Tcl_Namespace *) cxtNsPtr, flags, &var);
} else {
result = TCL_CONTINUE;
@@ -4949,7 +4949,7 @@ ObjFindNamespaceVar(
while (result == TCL_CONTINUE && resPtr) {
if (resPtr->varResProc) {
- result = (*resPtr->varResProc)(interp, name,
+ result = resPtr->varResProc(interp, name,
(Tcl_Namespace *) cxtNsPtr, flags, &var);
}
resPtr = resPtr->nextPtr;