Diff
Not logged in

Differences From Artifact [0c038d5268]:

To Artifact [76ecb3cdd4]:


345
346
347
348
349
350
351

352
353
354
355
356
357

358
359
360
361
362
363
364
    oldLength = Tcl_DStringLength(dsPtr);
    Tcl_DStringSetLength(dsPtr, oldLength + (uniLength + 1) * 4);
    string = Tcl_DStringValue(dsPtr) + oldLength;

    p = string;
    wEnd = uniStr + uniLength;


    /* Initialize the buffer so that some random data doesn't trick
     * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
     * Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its
     * prior non-stateful nature, this call to memset can also be removed.
     */
    memset(p, 0xff, Tcl_DStringLength(dsPtr) - oldLength);


    for (w = uniStr; w < wEnd; ) {
	p += Tcl_UniCharToUtf(*w, p);
	w++;
    }
    Tcl_DStringSetLength(dsPtr, oldLength + (p - string));








>






>







345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
    oldLength = Tcl_DStringLength(dsPtr);
    Tcl_DStringSetLength(dsPtr, oldLength + (uniLength + 1) * 4);
    string = Tcl_DStringValue(dsPtr) + oldLength;

    p = string;
    wEnd = uniStr + uniLength;

#if TCL_UTF_MAX < 4
    /* Initialize the buffer so that some random data doesn't trick
     * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
     * Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its
     * prior non-stateful nature, this call to memset can also be removed.
     */
    memset(p, 0xff, Tcl_DStringLength(dsPtr) - oldLength);
#endif

    for (w = uniStr; w < wEnd; ) {
	p += Tcl_UniCharToUtf(*w, p);
	w++;
    }
    Tcl_DStringSetLength(dsPtr, oldLength + (p - string));

396
397
398
399
400
401
402

403
404
405
406
407
408

409
410
411
412
413
414
415
    oldLength = Tcl_DStringLength(dsPtr);
    Tcl_DStringSetLength(dsPtr, oldLength + (uniLength + 1) * 3);
    string = Tcl_DStringValue(dsPtr) + oldLength;

    p = string;
    wEnd = uniStr + uniLength;


    /* Initialize the buffer so that some random data doesn't trick
     * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
	 * Because TCL_COMBINE is used here, memset() is required even when
	 * TCL_UTF_MAX == 4.
     */
    memset(p, 0xff, Tcl_DStringLength(dsPtr) - oldLength);


    for (w = uniStr; w < wEnd; ) {
	if (!len && ((*w & 0xFC00) != 0xDC00)) {
	    /* Special case for handling high surrogates. */
	    p += Tcl_UniCharToUtf(-1, p);
	}
	len = Tcl_UniCharToUtf(*w | TCL_COMBINE, p);







>






>







398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
    oldLength = Tcl_DStringLength(dsPtr);
    Tcl_DStringSetLength(dsPtr, oldLength + (uniLength + 1) * 3);
    string = Tcl_DStringValue(dsPtr) + oldLength;

    p = string;
    wEnd = uniStr + uniLength;

#if TCL_UTF_MAX < 4
    /* Initialize the buffer so that some random data doesn't trick
     * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs.
	 * Because TCL_COMBINE is used here, memset() is required even when
	 * TCL_UTF_MAX == 4.
     */
    memset(p, 0xff, Tcl_DStringLength(dsPtr) - oldLength);
#endif

    for (w = uniStr; w < wEnd; ) {
	if (!len && ((*w & 0xFC00) != 0xDC00)) {
	    /* Special case for handling high surrogates. */
	    p += Tcl_UniCharToUtf(-1, p);
	}
	len = Tcl_UniCharToUtf(*w | TCL_COMBINE, p);