summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdMZ.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r--generic/tclCmdMZ.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 885a0bc..df22261 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -1563,12 +1563,12 @@ StringIsCmd(
break;
case STR_IS_DOUBLE: {
/* TODO */
- if ((objPtr->typePtr == &tclDoubleType) ||
- (objPtr->typePtr == &tclIntType) ||
+ if (Tcl_FetchIntRep(objPtr, &tclDoubleType) ||
+ Tcl_FetchIntRep(objPtr, &tclIntType) ||
#ifndef TCL_WIDE_INT_IS_LONG
- (objPtr->typePtr == &tclWideIntType) ||
+ Tcl_FetchIntRep(objPtr, &tclWideIntType) ||
#endif
- (objPtr->typePtr == &tclBignumType)) {
+ Tcl_FetchIntRep(objPtr, &tclBignumType)) {
break;
}
string1 = TclGetStringFromObj(objPtr, &length1);
@@ -1601,11 +1601,11 @@ StringIsCmd(
}
goto failedIntParse;
case STR_IS_ENTIER:
- if ((objPtr->typePtr == &tclIntType) ||
+ if (Tcl_FetchIntRep(objPtr, &tclIntType) ||
#ifndef TCL_WIDE_INT_IS_LONG
- (objPtr->typePtr == &tclWideIntType) ||
+ Tcl_FetchIntRep(objPtr, &tclWideIntType) ||
#endif
- (objPtr->typePtr == &tclBignumType)) {
+ Tcl_FetchIntRep(objPtr, &tclBignumType)) {
break;
}
string1 = TclGetStringFromObj(objPtr, &length1);
@@ -1876,7 +1876,7 @@ StringMapCmd(
* inconsistencies (see test string-10.20 for illustration why!)
*/
- if (objv[objc-2]->typePtr == &tclDictType && objv[objc-2]->bytes == NULL){
+ if (Tcl_FetchIntRep(objv[objc-2], &tclDictType) && objv[objc-2]->bytes == NULL){
int i, done;
Tcl_DictSearch search;
@@ -2271,11 +2271,9 @@ StringReptCmd(
}
length2 = length1 * count;
- /*
- * Include space for the NUL.
- */
-
- string2 = attemptckalloc((unsigned) length2 + 1);
+ TclNewObj(resultPtr);
+ Tcl_InvalidateStringRep(resultPtr);
+ string2 = Tcl_InitStringRep(resultPtr, NULL, length2);
if (string2 == NULL) {
/*
* Alloc failed. Note that in this case we try to do an error message
@@ -2288,22 +2286,13 @@ StringReptCmd(
"string size overflow, out of memory allocating %u bytes",
length2 + 1));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
+ Tcl_DecrRefCount(resultPtr);
return TCL_ERROR;
}
for (index = 0; index < count; index++) {
memcpy(string2 + (length1 * index), string1, (size_t) length1);
}
- string2[length2] = '\0';
-
- /*
- * We have to directly assign this instead of using Tcl_SetStringObj (and
- * indirectly TclInitStringRep) because that makes another copy of the
- * data.
- */
-
- TclNewObj(resultPtr);
- resultPtr->bytes = string2;
- resultPtr->length = length2;
+ (void) Tcl_InitStringRep(resultPtr, NULL, length2);
Tcl_SetObjResult(interp, resultPtr);
done:
@@ -2628,8 +2617,8 @@ StringEqualCmd(
string1 = (char *) Tcl_GetByteArrayFromObj(objv[0], &length1);
string2 = (char *) Tcl_GetByteArrayFromObj(objv[1], &length2);
strCmpFn = (strCmpFn_t) memcmp;
- } else if ((objv[0]->typePtr == &tclStringType)
- && (objv[1]->typePtr == &tclStringType)) {
+ } else if (Tcl_FetchIntRep(objv[0], &tclStringType)
+ && Tcl_FetchIntRep(objv[1], &tclStringType)) {
/*
* Do a unicode-specific comparison if both of the args are of String
* type. In benchmark testing this proved the most efficient check
@@ -2778,8 +2767,8 @@ StringCmpCmd(
string1 = (char *) Tcl_GetByteArrayFromObj(objv[0], &length1);
string2 = (char *) Tcl_GetByteArrayFromObj(objv[1], &length2);
strCmpFn = (strCmpFn_t) memcmp;
- } else if ((objv[0]->typePtr == &tclStringType)
- && (objv[1]->typePtr == &tclStringType)) {
+ } else if (Tcl_FetchIntRep(objv[0], &tclStringType)
+ && Tcl_FetchIntRep(objv[1], &tclStringType)) {
/*
* Do a unicode-specific comparison if both of the args are of String
* type. In benchmark testing this proved the most efficient check