summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordas <das>2008-06-30 01:10:46 (GMT)
committerdas <das>2008-06-30 01:10:46 (GMT)
commitcbaf6674f8bc12e306ec3cd5754b8127692f84e7 (patch)
tree9ce2151c36a0c989afdd8bf904e72e1acc12d81f /generic
parentf843ecd2f7b202e1c63288e271d352785ad601df (diff)
downloadtcl-cbaf6674f8bc12e306ec3cd5754b8127692f84e7.zip
tcl-cbaf6674f8bc12e306ec3cd5754b8127692f84e7.tar.gz
tcl-cbaf6674f8bc12e306ec3cd5754b8127692f84e7.tar.bz2
formatting, whitespace
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdIL.c88
-rw-r--r--generic/tclExecute.c148
2 files changed, 122 insertions, 114 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 5a43d91..c73f41f 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.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: tclCmdIL.c,v 1.141 2008/06/29 23:12:59 ferrieux Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.142 2008/06/30 01:10:46 das Exp $
*/
#include "tclInt.h"
@@ -1278,7 +1278,7 @@ TclInfoFrame(
for (i=0 ; i<efiPtr->length ; i++) {
lv[lc++] = Tcl_NewStringObj(efiPtr->fields[i].name, -1);
if (efiPtr->fields[i].proc) {
- lv[lc++] =
+ lv[lc++] =
efiPtr->fields[i].proc(efiPtr->fields[i].clientData);
} else {
lv[lc++] = efiPtr->fields[i].clientData;
@@ -2338,12 +2338,12 @@ Tcl_LrangeObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "list first last");
return TCL_ERROR;
}
-
+
result = TclListObjLength(interp, objv[1], &listLen);
if (result != TCL_OK) {
return result;
}
-
+
result = TclGetIntForIndexM(interp, objv[2], /*endValue*/ listLen - 1,
&first);
if (result != TCL_OK) {
@@ -2352,7 +2352,7 @@ Tcl_LrangeObjCmd(
if (first < 0) {
first = 0;
}
-
+
result = TclGetIntForIndexM(interp, objv[3], /*endValue*/ listLen - 1,
&last);
if (result != TCL_OK) {
@@ -2362,32 +2362,42 @@ Tcl_LrangeObjCmd(
last = (listLen - 1);
}
- if (first>last) {
- /* returning an empty list is easy */
+ if (first > last) {
+ /*
+ * Returning an empty list is easy.
+ */
+
return TCL_OK;
}
- result=TclListObjGetElements(interp, objv[1], &listLen, &elemPtrs);
+ result = TclListObjGetElements(interp, objv[1], &listLen, &elemPtrs);
if (result != TCL_OK) {
return result;
}
-
- if (Tcl_IsShared(objv[1])||(((List *) objv[1]->internalRep.twoPtrValue.ptr1)->refCount > 1))
- {
- Tcl_SetObjResult(interp,
- Tcl_NewListObj(last - first + 1, &(elemPtrs[first])));
- }
- else
- {
- /* in-place is possible */
- if (last<(listLen-1))
- Tcl_ListObjReplace(interp,objv[1], last+1, listLen-1-last, 0, NULL);
- /* this one is not conditioned on (first>0) in order to
- * preserve the string-canonizing effect of [lrange 0 end] */
- Tcl_ListObjReplace(interp,objv[1], 0, first, 0, NULL);
- Tcl_SetObjResult(interp,objv[1]);
+
+ if (Tcl_IsShared(objv[1]) ||
+ (((List *) objv[1]->internalRep.twoPtrValue.ptr1)->refCount > 1)) {
+ Tcl_SetObjResult(interp, Tcl_NewListObj(last - first + 1,
+ &(elemPtrs[first])));
+ } else {
+ /*
+ * In-place is possible.
+ */
+
+ if (last < (listLen - 1)) {
+ Tcl_ListObjReplace(interp, objv[1], last + 1, listLen - 1 - last,
+ 0, NULL);
}
+ /*
+ * This one is not conditioned on (first>0) in order to
+ * preserve the string-canonizing effect of [lrange 0 end].
+ */
+
+ Tcl_ListObjReplace(interp, objv[1], 0, first, 0, NULL);
+ Tcl_SetObjResult(interp, objv[1]);
+ }
+
return TCL_OK;
}
@@ -3174,7 +3184,7 @@ Tcl_LsearchObjCmd(
}
for (i = offset; i < listc; i++) {
match = 0;
- if (sortInfo.indexc != 0) {
+ if (sortInfo.indexc != 0) {
itemPtr = SelectObjFromSublist(listv[i], &sortInfo);
if (sortInfo.resultCode != TCL_OK) {
if (listPtr != NULL) {
@@ -3188,7 +3198,7 @@ Tcl_LsearchObjCmd(
} else {
itemPtr = listv[i];
}
-
+
switch ((enum modes) mode) {
case SORTED:
case EXACT:
@@ -3490,7 +3500,7 @@ Tcl_LsortObjCmd(
sortInfo.indexc = 0;
sortInfo.unique = 0;
sortInfo.interp = interp;
- sortInfo.resultCode = TCL_OK;
+ sortInfo.resultCode = TCL_OK;
cmdPtr = NULL;
unique = 0;
indices = 0;
@@ -3649,7 +3659,7 @@ Tcl_LsortObjCmd(
goto done;
}
sortInfo.numElements = length;
-
+
indexc = sortInfo.indexc;
sortMode = sortInfo.sortMode;
if ((sortMode == SORTMODE_ASCII_NC)
@@ -3657,7 +3667,7 @@ Tcl_LsortObjCmd(
/*
* For this function's purpose all string-based modes are equivalent
*/
-
+
sortMode = SORTMODE_ASCII;
}
@@ -3666,7 +3676,7 @@ Tcl_LsortObjCmd(
* contain a sorted sublist of length 2**i. Use one extra subList at the
* end, always at NULL, to indicate the end of the lists.
*/
-
+
for (j=0 ; j<=NUM_LISTS ; j++) {
subList[j] = NULL;
}
@@ -3694,7 +3704,7 @@ Tcl_LsortObjCmd(
/*
* Determine the "value" of this object for sorting purposes
*/
-
+
if (sortMode == SORTMODE_ASCII) {
elementArray[i].index.strValuePtr = TclGetString(indexPtr);
} else if (sortMode == SORTMODE_INTEGER) {
@@ -3719,14 +3729,14 @@ Tcl_LsortObjCmd(
* Determine the representation of this element in the result: either
* the objPtr itself, or its index in the original list.
*/
-
+
elementArray[i].objPtr = (indices ? INT2PTR(i) : listObjPtrs[i]);
/*
* Merge this element in the pre-existing sublists (and merge together
* sublists when we have two of the same size).
*/
-
+
elementArray[i].nextPtr = NULL;
elementPtr = &elementArray[i];
for (j=0 ; subList[j] ; j++) {
@@ -3742,7 +3752,7 @@ Tcl_LsortObjCmd(
/*
* Merge all sublists
*/
-
+
elementPtr = subList[0];
for (j=1 ; j<NUM_LISTS ; j++) {
elementPtr = MergeLists(subList[j], elementPtr, &sortInfo);
@@ -3752,12 +3762,12 @@ Tcl_LsortObjCmd(
/*
* Now store the sorted elements in the result list.
*/
-
+
if (sortInfo.resultCode == TCL_OK) {
List *listRepPtr;
Tcl_Obj **newArray, *objPtr;
int i;
-
+
resultPtr = Tcl_NewListObj(sortInfo.numElements, NULL);
listRepPtr = (List *) resultPtr->internalRep.twoPtrValue.ptr1;
newArray = &listRepPtr->elements;
@@ -3807,7 +3817,7 @@ Tcl_LsortObjCmd(
* Side effects:
* If infoPtr->unique is set then infoPtr->numElements may be updated.
* Possibly others, if a user-defined comparison command does something
- * weird.
+ * weird.
*
* Note:
* If infoPtr->unique is set, the merge assumes that there are no
@@ -3819,7 +3829,7 @@ Tcl_LsortObjCmd(
* eliminate all repeats in the general case where they are already
* present in either the left or right list. A general code would need to
* skip adjacent initial repeats in the left and right lists before
- * comparing their initial elements, at each step.
+ * comparing their initial elements, at each step.
*----------------------------------------------------------------------
*/
@@ -3951,14 +3961,14 @@ SortCompare(
* Once an error has occurred, skip any future comparisons so as
* to preserve the error message in sortInterp->result.
*/
-
+
return 0;
}
objPtr1 = elemPtr1->index.objValuePtr;
objPtr2 = elemPtr2->index.objValuePtr;
-
+
paramObjv[0] = objPtr1;
paramObjv[1] = objPtr2;
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index f00b01a..5587b48 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.374 2008/06/29 23:05:56 ferrieux Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.375 2008/06/30 01:10:46 das Exp $
*/
#include "tclInt.h"
@@ -1888,7 +1888,7 @@ TclExecuteByteCode(
* Check for asynchronous handlers [Bug 746722]; we do the check every
* ASYNC_CHECK_COUNT_MASK instruction, of the form (2**n-<1).
*/
- int localResult;
+ int localResult;
if (TclAsyncReady(iPtr)) {
DECACHE_STACK_INFO();
@@ -1900,13 +1900,13 @@ TclExecuteByteCode(
}
}
- DECACHE_STACK_INFO();
+ DECACHE_STACK_INFO();
localResult = Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG);
CACHE_STACK_INFO();
if (localResult == TCL_ERROR) {
- result = TCL_ERROR;
- goto checkForCatch;
+ result = TCL_ERROR;
+ goto checkForCatch;
}
if (TclLimitReady(iPtr->limit)) {
@@ -2122,42 +2122,43 @@ TclExecuteByteCode(
int opnd, length, appendLen = 0;
char *bytes, *p;
Tcl_Obj **currPtr;
- int onlyb ;
+ int onlyb = 1;
opnd = TclGetUInt1AtPtr(pc+1);
/*
* Detect only-bytearray-or-null case
*/
- onlyb = 1;
+
for (currPtr=&OBJ_AT_DEPTH(opnd-1); currPtr<=&OBJ_AT_TOS; currPtr++) {
if (((*currPtr)->typePtr != &tclByteArrayType)
- &&((*currPtr)->bytes != tclEmptyStringRep))
- {onlyb=0;break;}
+ && ((*currPtr)->bytes != tclEmptyStringRep)) {
+ onlyb = 0;
+ break;
+ }
}
/*
* Compute the length to be appended.
*/
- if (onlyb)
- {
- for (currPtr=&OBJ_AT_DEPTH(opnd-2); currPtr<=&OBJ_AT_TOS; currPtr++) {
- if ((*currPtr)->bytes == tclEmptyStringRep)
- continue; /* don't shimmer nulls */
+ if (onlyb) {
+ for (currPtr = &OBJ_AT_DEPTH(opnd-2); currPtr <= &OBJ_AT_TOS;
+ currPtr++) {
+ if ((*currPtr)->bytes != tclEmptyStringRep) {
Tcl_GetByteArrayFromObj(*currPtr, &length);
appendLen += length;
}
}
- else
- {
- for (currPtr=&OBJ_AT_DEPTH(opnd-2); currPtr<=&OBJ_AT_TOS; currPtr++) {
- bytes = TclGetStringFromObj(*currPtr, &length);
- if (bytes != NULL) {
- appendLen += length;
+ } else {
+ for (currPtr = &OBJ_AT_DEPTH(opnd-2); currPtr <= &OBJ_AT_TOS;
+ currPtr++) {
+ bytes = TclGetStringFromObj(*currPtr, &length);
+ if (bytes != NULL) {
+ appendLen += length;
+ }
}
}
- }
/*
* If nothing is to be appended, just return the first object by
@@ -2181,71 +2182,68 @@ TclExecuteByteCode(
*/
objResultPtr = OBJ_AT_DEPTH(opnd-1);
- if (!onlyb)
- {
- bytes = TclGetStringFromObj(objResultPtr, &length);
+ if (!onlyb) {
+ bytes = TclGetStringFromObj(objResultPtr, &length);
#if !TCL_COMPILE_DEBUG
- if (bytes != tclEmptyStringRep && !Tcl_IsShared(objResultPtr)) {
- TclFreeIntRep(objResultPtr);
- objResultPtr->typePtr = NULL;
- objResultPtr->bytes = ckrealloc(bytes, (length + appendLen + 1));
- objResultPtr->length = length + appendLen;
- p = TclGetString(objResultPtr) + length;
- currPtr = &OBJ_AT_DEPTH(opnd - 2);
- } else {
+ if (bytes != tclEmptyStringRep && !Tcl_IsShared(objResultPtr)) {
+ TclFreeIntRep(objResultPtr);
+ objResultPtr->typePtr = NULL;
+ objResultPtr->bytes = ckrealloc(bytes, (length + appendLen+1));
+ objResultPtr->length = length + appendLen;
+ p = TclGetString(objResultPtr) + length;
+ currPtr = &OBJ_AT_DEPTH(opnd - 2);
+ } else
#endif
- p = (char *) ckalloc((unsigned) (length + appendLen + 1));
- TclNewObj(objResultPtr);
- objResultPtr->bytes = p;
- objResultPtr->length = length + appendLen;
- currPtr = &OBJ_AT_DEPTH(opnd - 1);
-#if !TCL_COMPILE_DEBUG
- }
-#endif
-
- /*
- * Append the remaining characters.
- */
-
- for (; currPtr <= &OBJ_AT_TOS; currPtr++) {
- bytes = TclGetStringFromObj(*currPtr, &length);
- if (bytes != NULL) {
- memcpy(p, bytes, (size_t) length);
- p += length;
+ {
+ p = (char *) ckalloc((unsigned) (length + appendLen + 1));
+ TclNewObj(objResultPtr);
+ objResultPtr->bytes = p;
+ objResultPtr->length = length + appendLen;
+ currPtr = &OBJ_AT_DEPTH(opnd - 1);
}
- }
- *p = '\0';
- } else {
+ /*
+ * Append the remaining characters.
+ */
+ for (; currPtr <= &OBJ_AT_TOS; currPtr++) {
+ bytes = TclGetStringFromObj(*currPtr, &length);
+ if (bytes != NULL) {
+ memcpy(p, bytes, (size_t) length);
+ p += length;
+ }
+ }
+ *p = '\0';
+ } else {
bytes = (char *) Tcl_GetByteArrayFromObj(objResultPtr, &length);
#if !TCL_COMPILE_DEBUG
- if (!Tcl_IsShared(objResultPtr)) {
- bytes = (char *) Tcl_SetByteArrayLength(objResultPtr,length+appendLen);
- p = bytes + length;
- currPtr = &OBJ_AT_DEPTH(opnd - 2);
- } else {
-#endif
- TclNewObj(objResultPtr);
- bytes = (char *) Tcl_SetByteArrayLength(objResultPtr,length+appendLen);
- p = bytes;
- currPtr = &OBJ_AT_DEPTH(opnd - 1);
-#if !TCL_COMPILE_DEBUG
- }
+ if (!Tcl_IsShared(objResultPtr)) {
+ bytes = (char *) Tcl_SetByteArrayLength(objResultPtr,
+ length + appendLen);
+ p = bytes + length;
+ currPtr = &OBJ_AT_DEPTH(opnd - 2);
+ } else
#endif
-
- /*
- * Append the remaining characters.
- */
-
- for (; currPtr <= &OBJ_AT_TOS; currPtr++) {
- if ((*currPtr)->bytes == tclEmptyStringRep)
- continue; /* don't shimmer nulls */
- bytes = (char *) Tcl_GetByteArrayFromObj(*currPtr, &length);
+ {
+ TclNewObj(objResultPtr);
+ bytes = (char *) Tcl_SetByteArrayLength(objResultPtr,
+ length + appendLen);
+ p = bytes;
+ currPtr = &OBJ_AT_DEPTH(opnd - 1);
+ }
+
+ /*
+ * Append the remaining characters.
+ */
+
+ for (; currPtr <= &OBJ_AT_TOS; currPtr++) {
+ if ((*currPtr)->bytes != tclEmptyStringRep) {
+ bytes = (char *) Tcl_GetByteArrayFromObj(*currPtr,&length);
memcpy(p, bytes, (size_t) length);
p += length;
}
- }
+ }
+ }
TRACE_WITH_OBJ(("%u => ", opnd), objResultPtr);
NEXT_INST_V(2, opnd, 1);