Tcl Source Code

Check-in [9819e2fe99]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[ba921a8d98] Make sure [string cat] includes all data from all bytearrays.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-branch
Files: files | file ages | folders
SHA3-256: 9819e2fe99858d32177d88975877c21a0f1e6c41647d70e6965f1a76b55762c9
User & Date: dgp 2018-07-26 16:14:44
Context
2018-07-26
18:15
merge test cases from 8.6 check-in: c46f02dc09 user: sebres tags: core-8-branch
16:14
[ba921a8d98] Make sure [string cat] includes all data from all bytearrays. check-in: 9819e2fe99 user: dgp tags: core-8-branch
15:51
New test for [Bug ba921a8d98]. check-in: d498578df4 user: dgp tags: core-8-6-branch
2018-07-25
01:43
Resolve inadvertent fork check-in: fc9e243e02 user: kbk tags: core-8-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclStringObj.c.

3067
3068
3069
3070
3071
3072
3073







3074
3075
3076
3077
3078
3079
3080
3081
3082
3083

3084
3085
3086
3087
3088
3089
3090
....
3219
3220
3221
3222
3223
3224
3225
3226







3227
3228
3229
3230
3231
3232
3233
	int numBytes;
	ov = objv;
	oc = objc;
	do {
	    Tcl_Obj *objPtr = *ov++;








	    Tcl_GetByteArrayFromObj(objPtr, &numBytes); /* PANIC? */

	    if (numBytes) {
		last = objc - oc;
		if (length == 0) {
		    first = last;
		} else if (numBytes > INT_MAX - length) {
		    goto overflow;
		}
		length += numBytes;

	    }
	} while (--oc);
    } else if (allowUniChar && requestUniChar) {
	/*
	 * Result will be pure Tcl_UniChar array. Pre-size it.
	 */

................................................................................
	} else {
	    objResultPtr = Tcl_NewByteArrayObj(NULL, length);
	    dst = Tcl_SetByteArrayLength(objResultPtr, length);
	}
	while (objc--) {
	    Tcl_Obj *objPtr = *objv++;

	    if (objPtr->bytes == NULL) {







		int more;
		unsigned char *src = Tcl_GetByteArrayFromObj(objPtr, &more);
		memcpy(dst, src, (size_t) more);
		dst += more;
	    }
	}
    } else if (allowUniChar && requestUniChar) {






>
>
>
>
>
>
>
|

|
|
|
|
|
|
|
|
>







 







<
>
>
>
>
>
>
>







3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
....
3227
3228
3229
3230
3231
3232
3233

3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
	int numBytes;
	ov = objv;
	oc = objc;
	do {
	    Tcl_Obj *objPtr = *ov++;

	    /*
	     * Every argument is either a bytearray with a ("pure")
	     * value we know we can safely use, or it is an empty string.
	     * We don't need to count bytes for the empty strings.
	     */

	    if (TclIsPureByteArray(objPtr)) {
		Tcl_GetByteArrayFromObj(objPtr, &numBytes); /* PANIC? */

		if (numBytes) {
		    last = objc - oc;
		    if (length == 0) {
			first = last;
		    } else if (numBytes > INT_MAX - length) {
			goto overflow;
		    }
		    length += numBytes;
		}
	    }
	} while (--oc);
    } else if (allowUniChar && requestUniChar) {
	/*
	 * Result will be pure Tcl_UniChar array. Pre-size it.
	 */

................................................................................
	} else {
	    objResultPtr = Tcl_NewByteArrayObj(NULL, length);
	    dst = Tcl_SetByteArrayLength(objResultPtr, length);
	}
	while (objc--) {
	    Tcl_Obj *objPtr = *objv++;


	    /*
	     * Every argument is either a bytearray with a ("pure")
	     * value we know we can safely use, or it is an empty string.
	     * We don't need to copy bytes from the empty strings.
	     */

	    if (TclIsPureByteArray(objPtr)) {
		int more;
		unsigned char *src = Tcl_GetByteArrayFromObj(objPtr, &more);
		memcpy(dst, src, (size_t) more);
		dst += more;
	    }
	}
    } else if (allowUniChar && requestUniChar) {

Changes to tests/string.test.

2302
2303
2304
2305
2306
2307
2308



2309
2310
2311
2312
2313
2314
2315
    set f [encoding convertto utf-8 {}]
} -cleanup {
    unset e f
} -body {
    tcl::unsupported::representation [run {string cat $e $f $e $f [list x]}]
} -match glob -result {*no string representation}
}




}

# cleanup
rename MemStress {}
rename makeByteArray {}
rename makeUnicode {}






>
>
>







2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
    set f [encoding convertto utf-8 {}]
} -cleanup {
    unset e f
} -body {
    tcl::unsupported::representation [run {string cat $e $f $e $f [list x]}]
} -match glob -result {*no string representation}
}
test string-30.1.$noComp {[Bug ba921a8d98]} {
    run {string cat [set data [binary format a* hello]] [encoding convertto $data] [unset data]}
} hellohello

}

# cleanup
rename MemStress {}
rename makeByteArray {}
rename makeUnicode {}