summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-03-21 12:57:21 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-03-21 12:57:21 (GMT)
commit3fd7f1aa143d5095721daf36be1497966e1fae79 (patch)
tree9014214209e8dfdc937f9d44b2cd8857c988f961 /generic
parentcbce4bcf9f419d300baf4ff553be97adc49702fb (diff)
downloadtcl-3fd7f1aa143d5095721daf36be1497966e1fae79.zip
tcl-3fd7f1aa143d5095721daf36be1497966e1fae79.tar.gz
tcl-3fd7f1aa143d5095721daf36be1497966e1fae79.tar.bz2
Formatting/indenting
Diffstat (limited to 'generic')
-rwxr-xr-xgeneric/tclArithSeries.c58
-rw-r--r--generic/tclIO.c101
-rw-r--r--generic/tclObj.c6
-rw-r--r--generic/tclTest.c561
-rw-r--r--generic/tclTestObj.c25
-rw-r--r--generic/tclTestProcBodyObj.c2
6 files changed, 377 insertions, 376 deletions
diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c
index a29b589..48e9f80 100755
--- a/generic/tclArithSeries.c
+++ b/generic/tclArithSeries.c
@@ -106,9 +106,9 @@ ArithSeriesIndexDbl(
{
ArithSeriesDbl *dblRepPtr = (ArithSeriesDbl*)arithSeriesRepPtr;
if (arithSeriesRepPtr->isDouble) {
- double d = dblRepPtr->start + (index * dblRepPtr->step);
+ double d = dblRepPtr->start + (index * dblRepPtr->step);
unsigned n = (dblRepPtr->precision > 0 ? dblRepPtr->precision : 0);
- return ArithRound(d, n);
+ return ArithRound(d, n);
} else {
return (double)(arithSeriesRepPtr->start + (index * arithSeriesRepPtr->step));
}
@@ -277,8 +277,7 @@ DupArithSeriesInternalRep(
static void
FreeArithSeriesInternalRep(Tcl_Obj *arithSeriesObjPtr) /* Free any allocated memory */
{
- ArithSeries *arithSeriesRepPtr =
- (ArithSeries *)arithSeriesObjPtr->internalRep.twoPtrValue.ptr1;
+ ArithSeries *arithSeriesRepPtr = (ArithSeries *)arithSeriesObjPtr->internalRep.twoPtrValue.ptr1;
if (arithSeriesRepPtr->elements) {
Tcl_Size i;
@@ -319,7 +318,9 @@ NewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_Wide
ArithSeries *arithSeriesRepPtr;
length = len>=0 ? len : -1;
- if (length < 0) length = -1;
+ if (length < 0) {
+ length = -1;
+ }
TclNewObj(arithSeriesObj);
@@ -337,8 +338,9 @@ NewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_Wide
arithSeriesObj->internalRep.twoPtrValue.ptr1 = arithSeriesRepPtr;
arithSeriesObj->internalRep.twoPtrValue.ptr2 = NULL;
arithSeriesObj->typePtr = &tclArithSeriesType;
- if (length > 0)
+ if (length > 0) {
Tcl_InvalidateStringRep(arithSeriesObj);
+ }
return arithSeriesObj;
}
@@ -621,7 +623,9 @@ TclArithSeriesObjIndex(
*
*----------------------------------------------------------------------
*/
-Tcl_Size TclArithSeriesObjLength(Tcl_Obj *arithSeriesObj)
+Tcl_Size
+TclArithSeriesObjLength(
+ Tcl_Obj *arithSeriesObj)
{
ArithSeries *arithSeriesRepPtr = (ArithSeries*)
arithSeriesObj->internalRep.twoPtrValue.ptr1;
@@ -655,7 +659,7 @@ ArithSeriesObjStep(
Tcl_Obj *stepObj;
if (arithSeriesObj->typePtr != &tclArithSeriesType) {
- Tcl_Panic("ArithSeriesObjStep called with a not ArithSeries Obj.");
+ Tcl_Panic("ArithSeriesObjStep called with a not ArithSeries Obj.");
}
arithSeriesRepPtr = ArithSeriesGetInternalRep(arithSeriesObj);
if (arithSeriesRepPtr->isDouble) {
@@ -767,7 +771,7 @@ TclArithSeriesObjRange(
((arithSeriesObj->refCount > 1))) {
Tcl_Obj *newSlicePtr;
if (TclNewArithSeriesObj(interp, &newSlicePtr,
- arithSeriesRepPtr->isDouble, startObj, endObj,
+ arithSeriesRepPtr->isDouble, startObj, endObj,
stepObj, NULL) != TCL_OK) {
newSlicePtr = NULL;
}
@@ -901,9 +905,7 @@ TclArithSeriesGetElements(
*objcPtr = objc;
} else {
if (interp != NULL) {
- Tcl_SetObjResult(
- interp,
- Tcl_ObjPrintf("value is not an arithseries"));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("value is not an arithseries", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "UNKNOWN", (void *)NULL);
}
return TCL_ERROR;
@@ -1046,12 +1048,10 @@ TclArithSeriesObjReverse(
static void
UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObjPtr)
{
- ArithSeries *arithSeriesRepPtr =
- (ArithSeries*)arithSeriesObjPtr->internalRep.twoPtrValue.ptr1;
+ ArithSeries *arithSeriesRepPtr = (ArithSeries*)arithSeriesObjPtr->internalRep.twoPtrValue.ptr1;
char *p;
- Tcl_Obj *elemObj;
- Tcl_Size i;
- Tcl_Size length = 0;
+ Tcl_Obj *eleObj;
+ Tcl_Size i, bytlen = 0;
Tcl_Size slen;
/*
@@ -1061,7 +1061,7 @@ UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObjPtr)
for (i = 0; i < arithSeriesRepPtr->len; i++) {
double d = ArithSeriesIndexDbl(arithSeriesRepPtr, i);
slen = d>0 ? log10(d)+1 : d<0 ? log10((0-d))+2 : 1;
- length += slen;
+ bytlen += slen;
}
} else {
for (i = 0; i < arithSeriesRepPtr->len; i++) {
@@ -1069,35 +1069,35 @@ UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObjPtr)
char tmp[TCL_DOUBLE_SPACE+2];
tmp[0] = 0;
Tcl_PrintDouble(NULL,d,tmp);
- if ((length + strlen(tmp)) > TCL_SIZE_MAX) {
+ if ((bytlen + strlen(tmp)) > TCL_SIZE_MAX) {
break; // overflow
}
- length += strlen(tmp);
+ bytlen += strlen(tmp);
}
}
- length += arithSeriesRepPtr->len; // Space for each separator
+ bytlen += arithSeriesRepPtr->len; // Space for each separator
/*
* Pass 2: generate the string repr.
*/
- p = Tcl_InitStringRep(arithSeriesObjPtr, NULL, length);
+ p = Tcl_InitStringRep(arithSeriesObjPtr, NULL, bytlen);
if (p == NULL) {
- Tcl_Panic("Unable to allocate string size %d", length);
+ Tcl_Panic("Unable to allocate string size %d", bytlen);
}
for (i = 0; i < arithSeriesRepPtr->len; i++) {
- elemObj = TclArithSeriesObjIndex(NULL, arithSeriesObjPtr, i);
- char *str = Tcl_GetStringFromObj(elemObj, &slen);
- if (((p - arithSeriesObjPtr->bytes)+slen) > length) {
+ eleObj = TclArithSeriesObjIndex(NULL, arithSeriesObjPtr, i);
+ char *str = TclGetStringFromObj(eleObj, &slen);
+ if (((p - arithSeriesObjPtr->bytes)+slen) > bytlen) {
break;
}
strncpy(p, str, slen);
p[slen] = ' ';
p += slen+1;
- Tcl_DecrRefCount(elemObj);
+ Tcl_DecrRefCount(eleObj);
}
- if (length > 0) arithSeriesObjPtr->bytes[length-1] = '\0';
- arithSeriesObjPtr->length = length-1;
+ if (bytlen > 0) arithSeriesObjPtr->bytes[bytlen-1] = '\0';
+ arithSeriesObjPtr->length = bytlen-1;
}
/*
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 15e0785..8f53bb9 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -28,7 +28,7 @@ typedef struct ChannelHandler {
int mask; /* Mask of desired events. */
Tcl_ChannelProc *proc; /* Procedure to call in the type of
* Tcl_CreateChannelHandler. */
- void *clientData; /* Argument to pass to procedure. */
+ void *clientData; /* Argument to pass to procedure. */
struct ChannelHandler *nextPtr;
/* Next one in list of registered handlers. */
} ChannelHandler;
@@ -50,11 +50,12 @@ typedef struct ChannelHandler {
*/
typedef struct NextChannelHandler {
- ChannelHandler *nextHandlerPtr; /* The next handler to be invoked in
- * this invocation. */
+ ChannelHandler *nextHandlerPtr;
+ /* The next handler to be invoked in
+ * this invocation. */
struct NextChannelHandler *nestedHandlerPtr;
- /* Next nested invocation of
- * Tcl_NotifyChannel. */
+ /* Next nested invocation of
+ * Tcl_NotifyChannel. */
} NextChannelHandler;
/*
@@ -103,7 +104,7 @@ typedef struct CopyState {
Tcl_Interp *interp; /* Interp that started the copy. */
Tcl_Obj *cmdPtr; /* Command to be invoked at completion. */
Tcl_Size bufSize; /* Size of appended buffer. */
- char buffer[TCLFLEXARRAY]; /* Copy buffer, this must be the last
+ char buffer[TCLFLEXARRAY]; /* Copy buffer, this must be the last
* field. */
} CopyState;
@@ -141,10 +142,11 @@ static Tcl_ThreadDataKey dataKey;
*/
typedef struct CloseCallback {
- Tcl_CloseProc *proc; /* The procedure to call. */
+ Tcl_CloseProc *proc; /* The procedure to call. */
void *clientData; /* Arbitrary one-word data to pass
- * to the callback. */
- struct CloseCallback *nextPtr; /* For chaining close callbacks. */
+ * to the callback. */
+ struct CloseCallback *nextPtr;
+ /* For chaining close callbacks. */
} CloseCallback;
/*
@@ -626,7 +628,7 @@ TclFinalizeIOSubsystem(void)
continue;
}
if (!GotFlag(statePtr, CHANNEL_INCLOSE | CHANNEL_CLOSED )
- || GotFlag(statePtr, BG_FLUSH_SCHEDULED)) {
+ || GotFlag(statePtr, BG_FLUSH_SCHEDULED)) {
ResetFlag(statePtr, BG_FLUSH_SCHEDULED);
active = 1;
break;
@@ -654,7 +656,7 @@ TclFinalizeIOSubsystem(void)
*/
(void) Tcl_SetChannelOption(NULL, (Tcl_Channel) chanPtr,
- "-blocking", "on");
+ "-blocking", "on");
}
if ((chanPtr == (Channel *) tsdPtr->stdinChannel) ||
@@ -2476,13 +2478,13 @@ Tcl_GetChannelHandle(
int
Tcl_RemoveChannelMode(
- Tcl_Interp* interp, /* The interp for an error message. Allowed to be NULL. */
+ Tcl_Interp *interp, /* The interp for an error message. Allowed to be NULL. */
Tcl_Channel chan, /* The channel which is modified. */
- int mode) /* The access mode to drop from the channel */
+ int mode) /* The access mode to drop from the channel */
{
const char* emsg;
ChannelState *statePtr = ((Channel *) chan)->state;
- /* State of actual channel. */
+ /* State of actual channel. */
if ((mode != TCL_READABLE) && (mode != TCL_WRITABLE)) {
emsg = "Illegal mode value.";
@@ -3613,7 +3615,7 @@ Tcl_Close(
Tcl_SetErrno(stickyError);
if (interp != NULL) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj(Tcl_PosixError(interp), -1));
+ Tcl_NewStringObj(Tcl_PosixError(interp), -1));
}
return TCL_ERROR;
}
@@ -4355,7 +4357,7 @@ WillRead(
*/
if (FlushChannel(NULL, chanPtr, 0) != 0) {
- return -1;
+ return -1;
}
}
return 0;
@@ -4393,7 +4395,7 @@ Write(
/* State info for channel */
char *nextNewLine = NULL;
int endEncoding, needNlFlush = 0;
- int saved = 0, total = 0, flushed = 0;
+ Tcl_Size saved = 0, total = 0, flushed = 0;
char safe[BUFFER_PADDING];
int encodingError = 0;
@@ -4707,7 +4709,7 @@ Tcl_GetsObj(
* newline in the available input.
*/
- TclGetStringFromObj(objPtr, &oldLength);
+ (void)TclGetStringFromObj(objPtr, &oldLength);
oldFlags = statePtr->inputEncodingFlags;
oldState = statePtr->inputEncodingState;
oldRemoved = BUFFER_PADDING;
@@ -5577,7 +5579,7 @@ FilterInputBytes(
}
extra = rawLen - gsPtr->rawRead;
memcpy(nextPtr->buf + (BUFFER_PADDING - extra),
- raw + gsPtr->rawRead, (size_t) extra);
+ raw + gsPtr->rawRead, extra);
nextPtr->nextRemoved -= extra;
bufPtr->nextAdded -= extra;
}
@@ -6380,11 +6382,7 @@ ReadChars(
dst, dstLimit, &srcRead, &dstDecoded, &numChars);
if (code == TCL_CONVERT_UNKNOWN || code == TCL_CONVERT_SYNTAX
- || (
- code == TCL_CONVERT_MULTIBYTE
- && GotFlag(statePtr, CHANNEL_EOF
- ))
- ) {
+ || (code == TCL_CONVERT_MULTIBYTE && GotFlag(statePtr, CHANNEL_EOF))) {
SetFlag(statePtr, CHANNEL_ENCODING_ERROR);
code = TCL_OK;
}
@@ -6759,23 +6757,28 @@ TranslateInputEOL(
int numBytes = crFound - src;
memmove(dst, src, numBytes);
- dst += numBytes; dstLen -= numBytes;
- src += numBytes; srcLen -= numBytes;
+ dst += numBytes;
+ dstLen -= numBytes;
+ src += numBytes;
+ srcLen -= numBytes;
if (srcLen == 1) {
/* valid src bytes end in \r */
if (eof) {
*dst++ = '\r';
- src++; srcLen--;
+ src++;
+ srcLen--;
} else {
lesser = 0;
break;
}
} else if (src[1] == '\n') {
*dst++ = '\n';
- src += 2; srcLen -= 2;
+ src += 2;
+ srcLen -= 2;
} else {
*dst++ = '\r';
- src++; srcLen--;
+ src++;
+ srcLen--;
}
dstLen--;
lesser = (dstLen < srcLen) ? dstLen : srcLen;
@@ -6791,7 +6794,10 @@ TranslateInputEOL(
int lesser;
if (GotFlag(statePtr, INPUT_SAW_CR) && srcLen) {
- if (*src == '\n') { src++; srcLen--; }
+ if (*src == '\n') {
+ src++;
+ srcLen--;
+ }
ResetFlag(statePtr, INPUT_SAW_CR);
}
lesser = (dstLen < srcLen) ? dstLen : srcLen;
@@ -6800,12 +6806,15 @@ TranslateInputEOL(
memmove(dst, src, numBytes);
dst[numBytes] = '\n';
- dst += numBytes + 1; dstLen -= numBytes + 1;
- src += numBytes + 1; srcLen -= numBytes + 1;
+ dst += numBytes + 1;
+ dstLen -= numBytes + 1;
+ src += numBytes + 1;
+ srcLen -= numBytes + 1;
if (srcLen == 0) {
SetFlag(statePtr, INPUT_SAW_CR);
} else if (*src == '\n') {
- src++; srcLen--;
+ src++;
+ srcLen--;
}
lesser = (dstLen < srcLen) ? dstLen : srcLen;
}
@@ -8824,19 +8833,18 @@ UpdateInterest(
TclChannelPreserve((Tcl_Channel)chanPtr);
statePtr->timerChanPtr = chanPtr;
statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME,
- ChannelTimerProc, chanPtr);
+ ChannelTimerProc, chanPtr);
}
}
}
if (!statePtr->timer
- && mask & TCL_WRITABLE
- && GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
-
+ && mask & TCL_WRITABLE
+ && GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
TclChannelPreserve((Tcl_Channel)chanPtr);
statePtr->timerChanPtr = chanPtr;
statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME,
- ChannelTimerProc,chanPtr);
+ ChannelTimerProc,chanPtr);
}
@@ -8880,9 +8888,8 @@ ChannelTimerProc(
Tcl_Preserve(statePtr);
statePtr->timer = NULL;
if (statePtr->interestMask & TCL_WRITABLE
- && GotFlag(statePtr, CHANNEL_NONBLOCKING)
- && !GotFlag(statePtr, BG_FLUSH_SCHEDULED)
- ) {
+ && GotFlag(statePtr, CHANNEL_NONBLOCKING)
+ && !GotFlag(statePtr, BG_FLUSH_SCHEDULED)) {
/*
* Restart the timer in case a channel handler reenters the event loop
* before UpdateInterest gets called by Tcl_NotifyChannel.
@@ -8894,9 +8901,9 @@ ChannelTimerProc(
/* The channel may have just been closed from within Tcl_NotifyChannel */
if (!GotFlag(statePtr, CHANNEL_INCLOSE)) {
if (!GotFlag(statePtr, CHANNEL_NEED_MORE_DATA)
- && (statePtr->interestMask & TCL_READABLE)
- && (statePtr->inQueueHead != NULL)
- && IsBufferReady(statePtr->inQueueHead)) {
+ && (statePtr->interestMask & TCL_READABLE)
+ && (statePtr->inQueueHead != NULL)
+ && IsBufferReady(statePtr->inQueueHead)) {
/*
* Restart the timer in case a channel handler reenters the event loop
* before UpdateInterest gets called by Tcl_NotifyChannel.
@@ -9929,7 +9936,7 @@ CopyData(
* - Fail below with a read error
*/
if (size < 0 && Tcl_GetErrno() == EILSEQ) {
- Tcl_GetStringFromObj(bufObj, &sizePart);
+ TclGetStringFromObj(bufObj, &sizePart);
if (sizePart > 0) {
size = sizePart;
}
@@ -9966,8 +9973,8 @@ CopyData(
if ((size == 0) && Tcl_Eof(inChan) && !(cmdPtr && (mask == 0))) {
break;
}
- if (cmdPtr && (!Tcl_Eof(inChan) || (mask == 0)) &&
- !(mask & TCL_READABLE)) {
+ if (cmdPtr && (!Tcl_Eof(inChan) || (mask == 0))
+ && !(mask & TCL_READABLE)) {
if (mask & TCL_WRITABLE) {
Tcl_DeleteChannelHandler(outChan, CopyEventProc, csPtr);
}
diff --git a/generic/tclObj.c b/generic/tclObj.c
index f321399..f3e1f7f 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -2261,7 +2261,7 @@ TclSetBooleanFromAny(
badBoolean:
if (interp != NULL) {
Tcl_Size length;
- const char *str = Tcl_GetStringFromObj(objPtr, &length);
+ const char *str = TclGetStringFromObj(objPtr, &length);
Tcl_Obj *msg;
TclNewLiteralStringObj(msg, "expected boolean value but got \"");
@@ -2280,7 +2280,7 @@ ParseBoolean(
int newBool;
char lowerCase[6];
Tcl_Size i, length;
- const char *str = Tcl_GetStringFromObj(objPtr, &length);
+ const char *str = TclGetStringFromObj(objPtr, &length);
if ((length < 1) || (length > 5)) {
/*
@@ -4493,7 +4493,7 @@ TclHashObjKey(
{
Tcl_Obj *objPtr = (Tcl_Obj *)keyPtr;
Tcl_Size length;
- const char *string = Tcl_GetStringFromObj(objPtr, &length);
+ const char *string = TclGetStringFromObj(objPtr, &length);
TCL_HASH_TYPE result = 0;
/*
diff --git a/generic/tclTest.c b/generic/tclTest.c
index e656985..ddc6024 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -540,6 +540,9 @@ static const char version[] = TCL_PATCH_LEVEL "+" STRINGIFY(TCL_VERSION_UUID)
#ifdef STATIC_BUILD
".static"
#endif
+#if TCL_UTF_MAX < 4
+ ".utf-16"
+#endif
;
int
@@ -715,7 +718,7 @@ Tcltest_Init(
Tcl_CreateObjCommand(interp, "testnumutfchars",
TestNumUtfCharsCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testgetunichar",
- TestGetUniCharCmd, NULL, NULL);
+ TestGetUniCharCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testfindfirst",
TestFindFirstCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testfindlast",
@@ -886,18 +889,17 @@ TestasyncCmd(
asyncPtr = (TestAsyncHandler *)ckalloc(sizeof(TestAsyncHandler));
asyncPtr->command = (char *)ckalloc(strlen(argv[2]) + 1);
strcpy(asyncPtr->command, argv[2]);
- Tcl_MutexLock(&asyncTestMutex);
+ Tcl_MutexLock(&asyncTestMutex);
asyncPtr->id = nextId;
nextId++;
- asyncPtr->handler = Tcl_AsyncCreate(AsyncHandlerProc,
- INT2PTR(asyncPtr->id));
+ asyncPtr->handler = Tcl_AsyncCreate(AsyncHandlerProc, INT2PTR(asyncPtr->id));
asyncPtr->nextPtr = firstHandler;
firstHandler = asyncPtr;
- Tcl_MutexUnlock(&asyncTestMutex);
+ Tcl_MutexUnlock(&asyncTestMutex);
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(asyncPtr->id));
} else if (strcmp(argv[1], "delete") == 0) {
if (argc == 2) {
- Tcl_MutexLock(&asyncTestMutex);
+ Tcl_MutexLock(&asyncTestMutex);
while (firstHandler != NULL) {
asyncPtr = firstHandler;
firstHandler = asyncPtr->nextPtr;
@@ -905,7 +907,7 @@ TestasyncCmd(
ckfree(asyncPtr->command);
ckfree(asyncPtr);
}
- Tcl_MutexUnlock(&asyncTestMutex);
+ Tcl_MutexUnlock(&asyncTestMutex);
return TCL_OK;
}
if (argc != 3) {
@@ -914,7 +916,7 @@ TestasyncCmd(
if (Tcl_GetInt(interp, argv[2], &id) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_MutexLock(&asyncTestMutex);
+ Tcl_MutexLock(&asyncTestMutex);
for (prevPtr = NULL, asyncPtr = firstHandler; asyncPtr != NULL;
prevPtr = asyncPtr, asyncPtr = asyncPtr->nextPtr) {
if (asyncPtr->id != id) {
@@ -930,7 +932,7 @@ TestasyncCmd(
ckfree(asyncPtr);
break;
}
- Tcl_MutexUnlock(&asyncTestMutex);
+ Tcl_MutexUnlock(&asyncTestMutex);
} else if (strcmp(argv[1], "mark") == 0) {
if (argc != 5) {
goto wrongNumArgs;
@@ -957,7 +959,7 @@ TestasyncCmd(
if (Tcl_GetInt(interp, argv[2], &id) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_MutexLock(&asyncTestMutex);
+ Tcl_MutexLock(&asyncTestMutex);
for (asyncPtr = firstHandler; asyncPtr != NULL;
asyncPtr = asyncPtr->nextPtr) {
if (asyncPtr->id == id) {
@@ -972,7 +974,7 @@ TestasyncCmd(
break;
}
}
- Tcl_MutexUnlock(&asyncTestMutex);
+ Tcl_MutexUnlock(&asyncTestMutex);
} else {
Tcl_AppendResult(interp, "bad option \"", argv[1],
"\": must be create, delete, int, mark, or marklater", (void *)NULL);
@@ -984,7 +986,7 @@ TestasyncCmd(
static int
AsyncHandlerProc(
void *clientData, /* If of TestAsyncHandler structure.
- * in global list. */
+ * in global list. */
Tcl_Interp *interp, /* Interpreter in which command was
* executed, or NULL. */
int code) /* Current return code from command. */
@@ -997,16 +999,16 @@ AsyncHandlerProc(
Tcl_MutexLock(&asyncTestMutex);
for (asyncPtr = firstHandler; asyncPtr != NULL;
- asyncPtr = asyncPtr->nextPtr) {
- if (asyncPtr->id == id) {
- break;
- }
+ asyncPtr = asyncPtr->nextPtr) {
+ if (asyncPtr->id == id) {
+ break;
+ }
}
Tcl_MutexUnlock(&asyncTestMutex);
if (!asyncPtr) {
- /* Woops - this one was deleted between the AsyncMark and now */
- return TCL_OK;
+ /* Woops - this one was deleted between the AsyncMark and now */
+ return TCL_OK;
}
TclFormatInt(string, code);
@@ -1054,11 +1056,11 @@ AsyncThreadProc(
Tcl_Sleep(1);
Tcl_MutexLock(&asyncTestMutex);
for (asyncPtr = firstHandler; asyncPtr != NULL;
- asyncPtr = asyncPtr->nextPtr) {
- if (asyncPtr->id == id) {
- Tcl_AsyncMark(asyncPtr->handler);
- break;
- }
+ asyncPtr = asyncPtr->nextPtr) {
+ if (asyncPtr->id == id) {
+ Tcl_AsyncMark(asyncPtr->handler);
+ break;
+ }
}
Tcl_MutexUnlock(&asyncTestMutex);
Tcl_ExitThread(TCL_OK);
@@ -1869,9 +1871,9 @@ TestdoubledigitsObjCmd(
}
}
if (status != TCL_OK
- || Tcl_GetIntFromObj(interp, objv[2], &ndigits) != TCL_OK
- || Tcl_GetIndexFromObj(interp, objv[3], options, "conversion type",
- TCL_EXACT, &type) != TCL_OK) {
+ || Tcl_GetIntFromObj(interp, objv[2], &ndigits) != TCL_OK
+ || Tcl_GetIndexFromObj(interp, objv[3], options, "conversion type",
+ TCL_EXACT, &type) != TCL_OK) {
fprintf(stderr, "bad value? %g\n", d);
return TCL_ERROR;
}
@@ -2064,8 +2066,10 @@ static void SpecialFree(
*------------------------------------------------------------------------
*/
typedef int
-UtfTransformFn(Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, int flags, Tcl_EncodingState *statePtr,
- char *dst, Tcl_Size dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr);
+UtfTransformFn(Tcl_Interp *interp, Tcl_Encoding encoding, const char *src,
+ Tcl_Size srcLen, int flags, Tcl_EncodingState *statePtr, char *dst,
+ Tcl_Size dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr);
+
static int UtfExtWrapper(
Tcl_Interp *interp, UtfTransformFn *transformer, int objc, Tcl_Obj *const objv[])
{
@@ -2097,14 +2101,12 @@ static int UtfExtWrapper(
Tcl_WideInt wide;
if (objc < 7 || objc > 10) {
- Tcl_WrongNumArgs(interp,
- 2,
- objv,
- "encoding srcbytes flags state dstlen ?srcreadvar? ?dstwrotevar? ?dstcharsvar?");
- return TCL_ERROR;
+ Tcl_WrongNumArgs(interp, 2, objv,
+ "encoding srcbytes flags state dstlen ?srcreadvar? ?dstwrotevar? ?dstcharsvar?");
+ return TCL_ERROR;
}
if (Tcl_GetEncodingFromObj(interp, objv[2], &encoding) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
/* Flags may be specified as list of integers and keywords */
@@ -2119,13 +2121,8 @@ static int UtfExtWrapper(
flags |= flag;
} else {
int idx;
- if (Tcl_GetIndexFromObjStruct(interp,
- flagObjs[i],
- flagMap,
- sizeof(flagMap[0]),
- "flag",
- 0,
- &idx) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, flagObjs[i], flagMap, sizeof(flagMap[0]),
+ "flag", 0, &idx) != TCL_OK) {
return TCL_ERROR;
}
flags |= flagMap[idx].flag;
@@ -2134,16 +2131,16 @@ static int UtfExtWrapper(
/* Assumes state is integer if not "" */
if (Tcl_GetWideIntFromObj(interp, objv[5], &wide) == TCL_OK) {
- encState = (Tcl_EncodingState)(size_t)wide;
- encStatePtr = &encState;
+ encState = (Tcl_EncodingState)(size_t)wide;
+ encStatePtr = &encState;
} else if (Tcl_GetCharLength(objv[5]) == 0) {
- encStatePtr = NULL;
+ encStatePtr = NULL;
} else {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[6], &dstLen) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
srcReadVar = NULL;
dstWroteVar = NULL;
@@ -2155,12 +2152,12 @@ static int UtfExtWrapper(
}
if (objc > 8) {
/* Ditto for dstWrote */
- if (Tcl_GetCharLength(objv[8])) {
- dstWroteVar = objv[8];
- }
+ if (Tcl_GetCharLength(objv[8])) {
+ dstWroteVar = objv[8];
+ }
if (objc > 9) {
- if (Tcl_GetCharLength(objv[9])) {
- dstCharsVar = objv[9];
+ if (Tcl_GetCharLength(objv[9])) {
+ dstCharsVar = objv[9];
}
}
}
@@ -2189,69 +2186,60 @@ static int UtfExtWrapper(
memmove(bufPtr + dstLen, "\xAB\xCD\xEF\xAB", 4); /* overflow detection */
bytes = Tcl_GetByteArrayFromObj(objv[3], &srcLen); /* Last! to avoid shimmering */
result = (*transformer)(interp, encoding, (const char *)bytes, srcLen, flags,
- encStatePtr, (char *) bufPtr, dstLen,
- srcReadVar ? &srcRead : NULL,
- &dstWrote,
- dstCharsVar ? &dstChars : NULL);
+ encStatePtr, (char *) bufPtr, dstLen,
+ srcReadVar ? &srcRead : NULL,
+ &dstWrote,
+ dstCharsVar ? &dstChars : NULL);
if (memcmp(bufPtr + bufLen - 4, "\xAB\xCD\xEF\xAB", 4)) {
- Tcl_SetResult(interp,
- "Tcl_ExternalToUtf wrote past output buffer",
- TCL_STATIC);
- result = TCL_ERROR;
+ Tcl_SetResult(interp,
+ "Tcl_ExternalToUtf wrote past output buffer",
+ TCL_STATIC);
+ result = TCL_ERROR;
} else if (result != TCL_ERROR) {
- Tcl_Obj *resultObjs[3];
- switch (result) {
- case TCL_OK:
- resultObjs[0] = Tcl_NewStringObj("ok", TCL_INDEX_NONE);
- break;
- case TCL_CONVERT_MULTIBYTE:
- resultObjs[0] = Tcl_NewStringObj("multibyte", TCL_INDEX_NONE);
- break;
- case TCL_CONVERT_SYNTAX:
- resultObjs[0] = Tcl_NewStringObj("syntax", TCL_INDEX_NONE);
- break;
- case TCL_CONVERT_UNKNOWN:
- resultObjs[0] = Tcl_NewStringObj("unknown", TCL_INDEX_NONE);
- break;
- case TCL_CONVERT_NOSPACE:
- resultObjs[0] = Tcl_NewStringObj("nospace", TCL_INDEX_NONE);
- break;
- default:
- resultObjs[0] = Tcl_NewIntObj(result);
- break;
- }
- result = TCL_OK;
- resultObjs[1] =
- encStatePtr ? Tcl_NewWideIntObj((Tcl_WideInt)(size_t)encState) : Tcl_NewObj();
- resultObjs[2] = Tcl_NewByteArrayObj(bufPtr, dstLen);
- if (srcReadVar) {
- if (Tcl_ObjSetVar2(interp,
- srcReadVar,
- NULL,
- Tcl_NewIntObj(srcRead),
- TCL_LEAVE_ERR_MSG) == NULL) {
+ Tcl_Obj *resultObjs[3];
+ switch (result) {
+ case TCL_OK:
+ resultObjs[0] = Tcl_NewStringObj("ok", TCL_INDEX_NONE);
+ break;
+ case TCL_CONVERT_MULTIBYTE:
+ resultObjs[0] = Tcl_NewStringObj("multibyte", TCL_INDEX_NONE);
+ break;
+ case TCL_CONVERT_SYNTAX:
+ resultObjs[0] = Tcl_NewStringObj("syntax", TCL_INDEX_NONE);
+ break;
+ case TCL_CONVERT_UNKNOWN:
+ resultObjs[0] = Tcl_NewStringObj("unknown", TCL_INDEX_NONE);
+ break;
+ case TCL_CONVERT_NOSPACE:
+ resultObjs[0] = Tcl_NewStringObj("nospace", TCL_INDEX_NONE);
+ break;
+ default:
+ resultObjs[0] = Tcl_NewIntObj(result);
+ break;
+ }
+ result = TCL_OK;
+ resultObjs[1] =
+ encStatePtr ? Tcl_NewWideIntObj((Tcl_WideInt)(size_t)encState) : Tcl_NewObj();
+ resultObjs[2] = Tcl_NewByteArrayObj(bufPtr, dstLen);
+ if (srcReadVar) {
+ if (Tcl_ObjSetVar2(interp, srcReadVar, NULL, Tcl_NewIntObj(srcRead),
+ TCL_LEAVE_ERR_MSG) == NULL) {
result = TCL_ERROR;
}
}
- if (dstWroteVar) {
- if (Tcl_ObjSetVar2(interp,
- dstWroteVar,
- NULL,
- Tcl_NewIntObj(dstWrote),
- TCL_LEAVE_ERR_MSG) == NULL) {
+ if (dstWroteVar) {
+ if (Tcl_ObjSetVar2(interp, dstWroteVar, NULL, Tcl_NewIntObj(dstWrote),
+ TCL_LEAVE_ERR_MSG) == NULL) {
result = TCL_ERROR;
}
}
- if (dstCharsVar) {
- if (Tcl_ObjSetVar2(interp,
- dstCharsVar,
- NULL,
- Tcl_NewIntObj(dstChars),
- TCL_LEAVE_ERR_MSG) == NULL) {
+ if (dstCharsVar) {
+ if (Tcl_ObjSetVar2(interp, dstCharsVar, NULL, Tcl_NewIntObj(dstChars),
+ TCL_LEAVE_ERR_MSG) == NULL) {
result = TCL_ERROR;
}
}
- Tcl_SetObjResult(interp, Tcl_NewListObj(3, resultObjs));
+ Tcl_SetObjResult(interp, Tcl_NewListObj(3, resultObjs));
}
ckfree(bufPtr);
@@ -2359,13 +2347,13 @@ TestencodingObjCmd(
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(Tcl_GetEncodingNulLength(encoding)));
+ Tcl_NewIntObj(Tcl_GetEncodingNulLength(encoding)));
Tcl_FreeEncoding(encoding);
- break;
+ break;
case ENC_EXTTOUTF:
- return UtfExtWrapper(interp,Tcl_ExternalToUtf,objc,objv);
+ return UtfExtWrapper(interp,Tcl_ExternalToUtf,objc,objv);
case ENC_UTFTOEXT:
- return UtfExtWrapper(interp,Tcl_UtfToExternal,objc,objv);
+ return UtfExtWrapper(interp,Tcl_UtfToExternal,objc,objv);
}
return TCL_OK;
}
@@ -3294,7 +3282,7 @@ TestlinkCmd(
}
flag = writable ? 0 : TCL_LINK_READ_ONLY;
if (Tcl_LinkVar(interp, "wide", &wideVar,
- TCL_LINK_WIDE_INT | flag) != TCL_OK) {
+ TCL_LINK_WIDE_INT | flag) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_GetBoolean(interp, argv[7], &writable) != TCL_OK) {
@@ -3688,12 +3676,12 @@ TestlinkCmd(
static int
TestlinkarrayCmd(
TCL_UNUSED(void *),
- Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *LinkOption[] = {
- "update", "remove", "create", NULL
+ "update", "remove", "create", NULL
};
enum LinkOptionEnum { LINK_UPDATE, LINK_REMOVE, LINK_CREATE };
static const char *LinkType[] = {
@@ -3891,10 +3879,10 @@ TestlistrepCmd(
ListObjGetRep(objv[2], &listRep);
listRepObjs[0] = Tcl_NewStringObj("store", -1);
listRepObjs[1] = Tcl_NewListObj(12, NULL);
- Tcl_ListObjAppendElement(
- interp, listRepObjs[1], Tcl_NewStringObj("memoryAddress", -1));
- Tcl_ListObjAppendElement(
- interp, listRepObjs[1], Tcl_ObjPrintf("%p", listRep.storePtr));
+ Tcl_ListObjAppendElement(interp, listRepObjs[1],
+ Tcl_NewStringObj("memoryAddress", -1));
+ Tcl_ListObjAppendElement(interp, listRepObjs[1],
+ Tcl_ObjPrintf("%p", listRep.storePtr));
APPEND_FIELD(listRepObjs[1], listRep.storePtr, firstUsed);
APPEND_FIELD(listRepObjs[1], listRep.storePtr, numUsed);
APPEND_FIELD(listRepObjs[1], listRep.storePtr, numAllocated);
@@ -3903,14 +3891,12 @@ TestlistrepCmd(
if (listRep.spanPtr) {
listRepObjs[2] = Tcl_NewStringObj("span", -1);
listRepObjs[3] = Tcl_NewListObj(8, NULL);
- Tcl_ListObjAppendElement(interp,
- listRepObjs[3],
- Tcl_NewStringObj("memoryAddress", -1));
- Tcl_ListObjAppendElement(
- interp, listRepObjs[3], Tcl_ObjPrintf("%p", listRep.spanPtr));
+ Tcl_ListObjAppendElement(interp, listRepObjs[3],
+ Tcl_NewStringObj("memoryAddress", -1));
+ Tcl_ListObjAppendElement(interp, listRepObjs[3],
+ Tcl_ObjPrintf("%p", listRep.spanPtr));
APPEND_FIELD(listRepObjs[3], listRep.spanPtr, spanStart);
- APPEND_FIELD(
- listRepObjs[3], listRep.spanPtr, spanLength);
+ APPEND_FIELD(listRepObjs[3], listRep.spanPtr, spanLength);
APPEND_FIELD(listRepObjs[3], listRep.spanPtr, refCount);
}
resultObj = Tcl_NewListObj(listRep.spanPtr ? 4 : 2, listRepObjs);
@@ -4613,7 +4599,7 @@ TestregexpObjCmd(
* instead of the first character after the match.
*/
- if (end >= 0) {
+ if (end != TCL_INDEX_NONE) {
end--;
}
@@ -5742,6 +5728,7 @@ TestbytestringObjCmd(
if (p == NULL) {
return TCL_ERROR;
}
+
if (x.m != 1) {
Tcl_AppendResult(interp, "Tcl_GetBytesFromObj() overwrites variable", (void *)NULL);
return TCL_ERROR;
@@ -6440,19 +6427,19 @@ TestChannelCmd(
}
if ((cmdName[0] == 'm') && (strncmp(cmdName, "mremove-rd", len) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "channel name required", (void *)NULL);
- return TCL_ERROR;
- }
+ if (argc != 3) {
+ Tcl_AppendResult(interp, "channel name required", (void *)NULL);
+ return TCL_ERROR;
+ }
return Tcl_RemoveChannelMode(interp, chan, TCL_READABLE);
}
if ((cmdName[0] == 'm') && (strncmp(cmdName, "mremove-wr", len) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "channel name required", (void *)NULL);
- return TCL_ERROR;
- }
+ if (argc != 3) {
+ Tcl_AppendResult(interp, "channel name required", (void *)NULL);
+ return TCL_ERROR;
+ }
return Tcl_RemoveChannelMode(interp, chan, TCL_WRITABLE);
}
@@ -6880,39 +6867,39 @@ TestSocketCmd(
len = strlen(cmdName);
if ((cmdName[0] == 't') && (strncmp(cmdName, "testflags", len) == 0)) {
- Tcl_Channel hChannel;
- int modePtr;
- int testMode;
- TcpState *statePtr;
- /* Set test value in the socket driver
- */
- /* Check for argument "channel name"
- */
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " testflags channel flags\"", (void *)NULL);
- return TCL_ERROR;
- }
- hChannel = Tcl_GetChannel(interp, argv[2], &modePtr);
- if ( NULL == hChannel ) {
- Tcl_AppendResult(interp, "unknown channel:", argv[2], (void *)NULL);
- return TCL_ERROR;
- }
- statePtr = (TcpState *)Tcl_GetChannelInstanceData(hChannel);
- if ( NULL == statePtr) {
- Tcl_AppendResult(interp, "No channel instance data:", argv[2],
- (void *)NULL);
- return TCL_ERROR;
- }
- if (Tcl_GetBoolean(interp, argv[3], &testMode) != TCL_OK) {
- return TCL_ERROR;
- }
- if (testMode) {
- statePtr->flags |= TCP_ASYNC_TEST_MODE;
- } else {
- statePtr->flags &= ~TCP_ASYNC_TEST_MODE;
- }
- return TCL_OK;
+ Tcl_Channel hChannel;
+ int modePtr;
+ int testMode;
+ TcpState *statePtr;
+ /* Set test value in the socket driver
+ */
+ /* Check for argument "channel name"
+ */
+ if (argc < 4) {
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " testflags channel flags\"", (void *)NULL);
+ return TCL_ERROR;
+ }
+ hChannel = Tcl_GetChannel(interp, argv[2], &modePtr);
+ if ( NULL == hChannel ) {
+ Tcl_AppendResult(interp, "unknown channel:", argv[2], (void *)NULL);
+ return TCL_ERROR;
+ }
+ statePtr = (TcpState *)Tcl_GetChannelInstanceData(hChannel);
+ if ( NULL == statePtr) {
+ Tcl_AppendResult(interp, "No channel instance data:", argv[2],
+ (void *)NULL);
+ return TCL_ERROR;
+ }
+ if (Tcl_GetBoolean(interp, argv[3], &testMode) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (testMode) {
+ statePtr->flags |= TCP_ASYNC_TEST_MODE;
+ } else {
+ statePtr->flags &= ~TCP_ASYNC_TEST_MODE;
+ }
+ return TCL_OK;
}
Tcl_AppendResult(interp, "bad option \"", cmdName, "\": should be "
@@ -6949,20 +6936,20 @@ TestServiceModeCmd(
{
int newmode, oldmode;
if (argc > 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " ?newmode?\"", (void *)NULL);
- return TCL_ERROR;
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " ?newmode?\"", (void *)NULL);
+ return TCL_ERROR;
}
oldmode = (Tcl_GetServiceMode() != TCL_SERVICE_NONE);
if (argc == 2) {
- if (Tcl_GetInt(interp, argv[1], &newmode) == TCL_ERROR) {
- return TCL_ERROR;
- }
- if (newmode == 0) {
- Tcl_SetServiceMode(TCL_SERVICE_NONE);
- } else {
- Tcl_SetServiceMode(TCL_SERVICE_ALL);
- }
+ if (Tcl_GetInt(interp, argv[1], &newmode) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ if (newmode == 0) {
+ Tcl_SetServiceMode(TCL_SERVICE_NONE);
+ } else {
+ Tcl_SetServiceMode(TCL_SERVICE_ALL);
+ }
}
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(oldmode));
return TCL_OK;
@@ -7714,7 +7701,7 @@ TestUtfPrevCmd(
if (TCL_OK != Tcl_GetIntForIndex(interp, objv[2], numBytes, &offset)) {
return TCL_ERROR;
}
- if (offset < 0) {
+ if (offset == TCL_INDEX_NONE) {
offset = 0;
}
if (offset > numBytes) {
@@ -8043,20 +8030,20 @@ NREUnwind_callback(
void *cStackPtr = TclGetCStackPtr();
if (data[0] == INT2PTR(-1)) {
- Tcl_NRAddCallback(interp, NREUnwind_callback, cStackPtr, INT2PTR(-1),
- INT2PTR(-1), NULL);
+ Tcl_NRAddCallback(interp, NREUnwind_callback, cStackPtr, INT2PTR(-1),
+ INT2PTR(-1), NULL);
} else if (data[1] == INT2PTR(-1)) {
- Tcl_NRAddCallback(interp, NREUnwind_callback, data[0], cStackPtr,
- INT2PTR(-1), NULL);
+ Tcl_NRAddCallback(interp, NREUnwind_callback, data[0], cStackPtr,
+ INT2PTR(-1), NULL);
} else if (data[2] == INT2PTR(-1)) {
- Tcl_NRAddCallback(interp, NREUnwind_callback, data[0], data[1],
- cStackPtr, NULL);
+ Tcl_NRAddCallback(interp, NREUnwind_callback, data[0], data[1],
+ cStackPtr, NULL);
} else {
- Tcl_Obj *idata[3];
- idata[0] = Tcl_NewWideIntObj(((char *) data[1] - (char *) data[0]));
- idata[1] = Tcl_NewWideIntObj(((char *) data[2] - (char *) data[0]));
- idata[2] = Tcl_NewWideIntObj(((char *) cStackPtr - (char *) data[0]));
- Tcl_SetObjResult(interp, Tcl_NewListObj(3, idata));
+ Tcl_Obj *idata[3];
+ idata[0] = Tcl_NewWideIntObj(((char *) data[1] - (char *) data[0]));
+ idata[1] = Tcl_NewWideIntObj(((char *) data[2] - (char *) data[0]));
+ idata[2] = Tcl_NewWideIntObj(((char *) cStackPtr - (char *) data[0]));
+ Tcl_SetObjResult(interp, Tcl_NewListObj(3, idata));
}
return TCL_OK;
}
@@ -8074,7 +8061,7 @@ TestNREUnwind(
*/
Tcl_NRAddCallback(interp, NREUnwind_callback, INT2PTR(-1), INT2PTR(-1),
- INT2PTR(-1), NULL);
+ INT2PTR(-1), NULL);
return TCL_OK;
}
@@ -8438,13 +8425,13 @@ TestparseargsCmd(
Tcl_Size count = objc;
Tcl_Obj **remObjv, *result[3];
const Tcl_ArgvInfo argTable[] = {
- {TCL_ARGV_CONSTANT, "-bool", INT2PTR(1), &foo, "booltest", NULL},
- TCL_ARGV_AUTO_REST, TCL_ARGV_AUTO_HELP, TCL_ARGV_TABLE_END
+ {TCL_ARGV_CONSTANT, "-bool", INT2PTR(1), &foo, "booltest", NULL},
+ TCL_ARGV_AUTO_REST, TCL_ARGV_AUTO_HELP, TCL_ARGV_TABLE_END
};
foo = 0;
if (Tcl_ParseArgsObjv(interp, argTable, &count, objv, &remObjv)!=TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
result[0] = Tcl_NewWideIntObj(foo);
result[1] = Tcl_NewWideIntObj(count);
@@ -8469,7 +8456,7 @@ InterpCmdResolver(
Interp *iPtr = (Interp *) interp;
CallFrame *varFramePtr = iPtr->varFramePtr;
Proc *procPtr = (varFramePtr->isProcCallFrame & FRAME_IS_PROC) ?
- varFramePtr->procPtr : NULL;
+ varFramePtr->procPtr : NULL;
Namespace *callerNsPtr = varFramePtr->nsPtr;
Tcl_Command resolvedCmdPtr = NULL;
@@ -8479,74 +8466,74 @@ InterpCmdResolver(
* B) the caller's namespace is "ctx1" or "ctx2"
*/
if ( (name[0] == 'z') && (name[1] == '\0') ) {
- Namespace *ns2NsPtr = (Namespace *) Tcl_FindNamespace(interp, "::ns2", NULL, 0);
-
- if (procPtr != NULL
- && ((procPtr->cmdPtr->nsPtr == iPtr->globalNsPtr)
- || (ns2NsPtr != NULL && procPtr->cmdPtr->nsPtr == ns2NsPtr)
- )
- ) {
- /*
- * Case A)
- *
- * - The context, in which this resolver becomes active, is
- * determined by the name of the caller proc, which has to be
- * named "x".
- *
- * - To determine the name of the caller proc, the proc is taken
- * from the topmost stack frame.
- *
- * - Note that the context is NOT provided during byte-code
- * compilation (e.g. in TclProcCompileProc)
- *
- * When these conditions hold, this function resolves the
- * passed-in cmd literal into a cmd "y", which is taken from the
- * the global namespace (for simplicity).
- */
-
- const char *callingCmdName =
- Tcl_GetCommandName(interp, (Tcl_Command) procPtr->cmdPtr);
-
- if ( callingCmdName[0] == 'x' && callingCmdName[1] == '\0' ) {
- resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
- }
- } else if (callerNsPtr != NULL) {
- /*
- * Case B)
- *
- * - The context, in which this resolver becomes active, is
- * determined by the name of the parent namespace, which has
- * to be named "ctx1" or "ctx2".
- *
- * - To determine the name of the parent namesace, it is taken
- * from the 2nd highest stack frame.
- *
- * - Note that the context can be provided during byte-code
- * compilation (e.g. in TclProcCompileProc)
- *
- * When these conditions hold, this function resolves the
- * passed-in cmd literal into a cmd "y" or "Y" depending on the
- * context. The resolved procs are taken from the the global
- * namespace (for simplicity).
- */
-
- CallFrame *parentFramePtr = varFramePtr->callerPtr;
- const char *context = parentFramePtr != NULL ? parentFramePtr->nsPtr->name : "(NULL)";
-
- if (strcmp(context, "ctx1") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
- resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
- /* fprintf(stderr, "... y ==> %p\n", resolvedCmdPtr);*/
-
- } else if (strcmp(context, "ctx2") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
- resolvedCmdPtr = Tcl_FindCommand(interp, "Y", NULL, TCL_GLOBAL_ONLY);
- /*fprintf(stderr, "... Y ==> %p\n", resolvedCmdPtr);*/
- }
- }
-
- if (resolvedCmdPtr != NULL) {
- *rPtr = resolvedCmdPtr;
- return TCL_OK;
- }
+ Namespace *ns2NsPtr = (Namespace *) Tcl_FindNamespace(interp, "::ns2", NULL, 0);
+
+ if (procPtr != NULL
+ && ((procPtr->cmdPtr->nsPtr == iPtr->globalNsPtr)
+ || (ns2NsPtr != NULL && procPtr->cmdPtr->nsPtr == ns2NsPtr)
+ )
+ ) {
+ /*
+ * Case A)
+ *
+ * - The context, in which this resolver becomes active, is
+ * determined by the name of the caller proc, which has to be
+ * named "x".
+ *
+ * - To determine the name of the caller proc, the proc is taken
+ * from the topmost stack frame.
+ *
+ * - Note that the context is NOT provided during byte-code
+ * compilation (e.g. in TclProcCompileProc)
+ *
+ * When these conditions hold, this function resolves the
+ * passed-in cmd literal into a cmd "y", which is taken from the
+ * the global namespace (for simplicity).
+ */
+
+ const char *callingCmdName =
+ Tcl_GetCommandName(interp, (Tcl_Command) procPtr->cmdPtr);
+
+ if ( callingCmdName[0] == 'x' && callingCmdName[1] == '\0' ) {
+ resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
+ }
+ } else if (callerNsPtr != NULL) {
+ /*
+ * Case B)
+ *
+ * - The context, in which this resolver becomes active, is
+ * determined by the name of the parent namespace, which has
+ * to be named "ctx1" or "ctx2".
+ *
+ * - To determine the name of the parent namesace, it is taken
+ * from the 2nd highest stack frame.
+ *
+ * - Note that the context can be provided during byte-code
+ * compilation (e.g. in TclProcCompileProc)
+ *
+ * When these conditions hold, this function resolves the
+ * passed-in cmd literal into a cmd "y" or "Y" depending on the
+ * context. The resolved procs are taken from the the global
+ * namespace (for simplicity).
+ */
+
+ CallFrame *parentFramePtr = varFramePtr->callerPtr;
+ const char *context = parentFramePtr != NULL ? parentFramePtr->nsPtr->name : "(NULL)";
+
+ if (strcmp(context, "ctx1") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
+ resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
+ /* fprintf(stderr, "... y ==> %p\n", resolvedCmdPtr);*/
+
+ } else if (strcmp(context, "ctx2") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
+ resolvedCmdPtr = Tcl_FindCommand(interp, "Y", NULL, TCL_GLOBAL_ONLY);
+ /*fprintf(stderr, "... Y ==> %p\n", resolvedCmdPtr);*/
+ }
+ }
+
+ if (resolvedCmdPtr != NULL) {
+ *rPtr = resolvedCmdPtr;
+ return TCL_OK;
+ }
}
return TCL_CONTINUE;
}
@@ -8577,9 +8564,9 @@ HashVarFree(
Tcl_Var var)
{
if (VarHashRefCount(var) < 2) {
- ckfree(var);
+ ckfree(var);
} else {
- VarHashRefCount(var)--;
+ VarHashRefCount(var)--;
}
}
@@ -8591,7 +8578,7 @@ MyCompiledVarFree(
Tcl_DecrRefCount(resVarInfo->nameObj);
if (resVarInfo->var) {
- HashVarFree(resVarInfo->var);
+ HashVarFree(resVarInfo->var);
}
ckfree(vInfoPtr);
}
@@ -8611,27 +8598,27 @@ MyCompiledVarFetch(
Tcl_HashEntry *hPtr;
if (var != NULL) {
- if (!(((Var *) var)->flags & VAR_DEAD_HASH)) {
- /*
- * The cached variable is valid, return it.
- */
+ if (!(((Var *) var)->flags & VAR_DEAD_HASH)) {
+ /*
+ * The cached variable is valid, return it.
+ */
- return var;
- }
+ return var;
+ }
- /*
- * The variable is not valid anymore. Clean it up.
- */
+ /*
+ * The variable is not valid anymore. Clean it up.
+ */
- HashVarFree(var);
+ HashVarFree(var);
}
hPtr = Tcl_CreateHashEntry((Tcl_HashTable *) &iPtr->globalNsPtr->varTable,
- (char *)resVarInfo->nameObj, &isNewVar);
+ resVarInfo->nameObj, &isNewVar);
if (hPtr) {
- var = (Tcl_Var) TclVarHashGetValue(hPtr);
+ var = (Tcl_Var) TclVarHashGetValue(hPtr);
} else {
- var = NULL;
+ var = NULL;
}
resVarInfo->var = var;
@@ -8674,7 +8661,7 @@ TestInterpResolverCmd(
Tcl_Obj *const objv[])
{
static const char *const table[] = {
- "down", "up", NULL
+ "down", "up", NULL
};
int idx;
#define RESOLVER_KEY "testInterpResolver"
@@ -8691,20 +8678,20 @@ TestInterpResolverCmd(
}
}
if (Tcl_GetIndexFromObj(interp, objv[1], table, "operation", TCL_EXACT,
- &idx) != TCL_OK) {
- return TCL_ERROR;
+ &idx) != TCL_OK) {
+ return TCL_ERROR;
}
switch (idx) {
case 1: /* up */
- Tcl_AddInterpResolvers(interp, RESOLVER_KEY, InterpCmdResolver,
- InterpVarResolver, InterpCompiledVarResolver);
- break;
+ Tcl_AddInterpResolvers(interp, RESOLVER_KEY, InterpCmdResolver,
+ InterpVarResolver, InterpCompiledVarResolver);
+ break;
case 0: /*down*/
- if (!Tcl_RemoveInterpResolvers(interp, RESOLVER_KEY)) {
- Tcl_AppendResult(interp, "could not remove the resolver scheme",
- (void *)NULL);
- return TCL_ERROR;
- }
+ if (!Tcl_RemoveInterpResolvers(interp, RESOLVER_KEY)) {
+ Tcl_AppendResult(interp, "could not remove the resolver scheme",
+ (void *)NULL);
+ return TCL_ERROR;
+ }
}
return TCL_OK;
}
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 9f31cff..8a9dc7b 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -13,6 +13,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
+
#undef BUILD_tcl
#ifndef USE_TCL_STUBS
# define USE_TCL_STUBS
@@ -54,17 +55,24 @@ static Tcl_ObjCmdProc TeststringobjCmd;
#define VARPTR_KEY "TCLOBJTEST_VARPTR"
#define NUMBER_OF_OBJECT_VARS 20
-static void VarPtrDeleteProc(void *clientData, TCL_UNUSED(Tcl_Interp *))
+static void
+VarPtrDeleteProc(
+ void *clientData,
+ TCL_UNUSED(Tcl_Interp *))
{
int i;
Tcl_Obj **varPtr = (Tcl_Obj **) clientData;
for (i = 0; i < NUMBER_OF_OBJECT_VARS; i++) {
- if (varPtr[i]) Tcl_DecrRefCount(varPtr[i]);
+ if (varPtr[i]) {
+ Tcl_DecrRefCount(varPtr[i]);
+ }
}
ckfree(varPtr);
}
-static Tcl_Obj **GetVarPtr(Tcl_Interp *interp)
+static Tcl_Obj **
+GetVarPtr(
+ Tcl_Interp *interp)
{
Tcl_InterpDeleteProc *proc;
@@ -408,7 +416,7 @@ TestbooleanobjCmd(
return TCL_ERROR;
}
if (Tcl_GetBooleanFromObj(interp, varPtr[varIndex],
- &boolValue) != TCL_OK) {
+ &boolValue) != TCL_OK) {
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
@@ -508,7 +516,7 @@ TestdoubleobjCmd(
return TCL_ERROR;
}
if (Tcl_GetDoubleFromObj(interp, varPtr[varIndex],
- &doubleValue) != TCL_OK) {
+ &doubleValue) != TCL_OK) {
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
@@ -947,7 +955,7 @@ TestlistobjCmd(
case LISTOBJ_REPLACE:
if (objc < 5) {
Tcl_WrongNumArgs(interp, 2, objv,
- "varIndex start count ?element...?");
+ "varIndex start count ?element...?");
return TCL_ERROR;
}
if (Tcl_GetIntForIndex(interp, objv[3], TCL_INDEX_NONE, &first) != TCL_OK
@@ -959,7 +967,7 @@ TestlistobjCmd(
}
Tcl_ResetResult(interp);
return Tcl_ListObjReplace(interp, varPtr[varIndex], first, count,
- objc-5, objv+5);
+ objc-5, objv+5);
case LISTOBJ_INDEXMEMCHECK:
if (objc != 3) {
@@ -1016,8 +1024,7 @@ TestlistobjCmd(
* Hence this explicit test.
*/
if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "varIndex listIndex");
+ Tcl_WrongNumArgs(interp, 2, objv, "varIndex listIndex");
return TCL_ERROR;
}
if (Tcl_GetIntForIndex(interp, objv[3], TCL_INDEX_NONE, &first) != TCL_OK) {
diff --git a/generic/tclTestProcBodyObj.c b/generic/tclTestProcBodyObj.c
index 2139b81..a86499e 100644
--- a/generic/tclTestProcBodyObj.c
+++ b/generic/tclTestProcBodyObj.c
@@ -146,7 +146,7 @@ RegisterCommand(
if (cmdTablePtr->exportIt) {
snprintf(buf, sizeof(buf), "namespace eval %s { namespace export %s }",
namesp, cmdTablePtr->cmdName);
- if (Tcl_EvalEx(interp, buf, -1, 0) != TCL_OK) {
+ if (Tcl_EvalEx(interp, buf, TCL_INDEX_NONE, 0) != TCL_OK) {
return TCL_ERROR;
}
}