summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-10-27 19:39:49 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-10-27 19:39:49 (GMT)
commitec332750d28a86537a3fc721decc3bb74d850dc9 (patch)
tree1265709e60aa38ed6a1ffd00d7660d9f17e13cce /generic/tclStringObj.c
parente4a82e14e114848e09bb17073c531eba791aacee (diff)
downloadtcl-ec332750d28a86537a3fc721decc3bb74d850dc9.zip
tcl-ec332750d28a86537a3fc721decc3bb74d850dc9.tar.gz
tcl-ec332750d28a86537a3fc721decc3bb74d850dc9.tar.bz2
Start bringing all `string cat` operations into one place so it can be coded
correctly one time instead of badly multiple times.
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 2930fa1..1828d20 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -2598,6 +2598,46 @@ TclGetStringStorage(
*sizePtr = stringPtr->allocated;
return objPtr->bytes;
}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TclStringCatObjv --
+ *
+ * Performs the [string cat] function.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * Writes to *objPtrPtr the address of Tcl_Obj that is concatenation
+ * of all objc values in objv.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+int
+TclStringCatObjv(
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj * const objv[],
+ Tcl_Obj **objPtrPtr)
+{
+ Tcl_Obj *objResultPtr;
+
+ /* assert (objc >= 2) */
+
+ objResultPtr = *objv++; objc--;
+ if (Tcl_IsShared(objResultPtr)) {
+ objResultPtr = Tcl_DuplicateObj(objResultPtr);
+ }
+ while (objc--) {
+ Tcl_AppendObjToObj(objResultPtr, *objv++);
+ }
+ *objPtrPtr = objResultPtr;
+ return TCL_OK;
+}
+
/*
*---------------------------------------------------------------------------
*