summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2017-06-06 12:56:37 (GMT)
committerdgp <dgp@users.sourceforge.net>2017-06-06 12:56:37 (GMT)
commit93784caa4d5d0a0dc6fb02b30f273b4e95a73489 (patch)
treef04e33e69199170a967cd90574dd26b0941c10bc
parent47558a128c45f7915b69e10652573089efc3a897 (diff)
downloadtcl-93784caa4d5d0a0dc6fb02b30f273b4e95a73489.zip
tcl-93784caa4d5d0a0dc6fb02b30f273b4e95a73489.tar.gz
tcl-93784caa4d5d0a0dc6fb02b30f273b4e95a73489.tar.bz2
A few more tweaks to streamline and clarify.bug_716b427f76
-rw-r--r--generic/tclStringObj.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index b78394e..aae52ba 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -2851,12 +2851,16 @@ TclStringCatObjv(
int oc, length = 0, binary = 1, first = 0, last = 0;
int allowUniChar = 1, requestUniChar = 0;
+ /* assert ( objc >= 0 ) */
+
if (objc <= 1) {
/* Only one or no objects; return first or empty */
*objPtrPtr = objc ? objv[0] : Tcl_NewObj();
return TCL_OK;
}
+ /* assert ( objc >= 2 ) */
+
/*
* Analyze to determine what representation result should be.
* GOALS: Avoid shimmering & string rep generation.
@@ -2914,7 +2918,7 @@ TclStringCatObjv(
first = last;
}
if ((length += numBytes) < 0) {
- break; /* overflow */
+ goto overflow;
}
}
}
@@ -2935,7 +2939,7 @@ TclStringCatObjv(
first = last;
}
if ((length += numChars) < 0) {
- break; /* overflow */
+ goto overflow;
}
}
}
@@ -2955,27 +2959,19 @@ TclStringCatObjv(
first = last;
}
if ((length += numBytes) < 0) {
- break; /* overflow */
+ goto overflow;
}
}
} while (--oc);
}
- if (last == first || length == 0) {
+ if (last == first /*|| length == 0 */) {
/* Only one non-empty value or zero length; return first */
+ /* NOTE: (length == 0) implies (last == first) */
*objPtrPtr = objv[first];
return TCL_OK;
}
- if (length < 0) {
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "max size for a Tcl value (%d bytes) exceeded", INT_MAX));
- Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
- }
- return TCL_ERROR;
- }
-
objv += first; objc = (last - first + 1);
if (binary) {
@@ -3106,6 +3102,14 @@ TclStringCatObjv(
}
*objPtrPtr = objResultPtr;
return TCL_OK;
+
+ overflow:
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "max size for a Tcl value (%d bytes) exceeded", INT_MAX));
+ Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ }
+ return TCL_ERROR;
}
/*