Check-in [645fb65227]
Not logged in

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

Overview
Comment:Prevent possible build order problem, due to missing dde/registry dll's. Make sure that Tcl_WinTChar2Utf() never produces intermediate null-bytes.
Timelines: family | ancestors | descendants | both | core-8-branch
Files: files | file ages | folders
SHA3-256: 645fb65227bbf8575a0380390744c8c72768508d991c992dbf1aa16a6254c6f2
User & Date: jan.nijtmans 2018-09-22 10:09:23.651
Context
2018-09-22
10:21
Merge 8.6 check-in: 4523c31275 user: jan.nijtmans tags: core-8-branch
10:09
Prevent possible build order problem, due to missing dde/registry dll's. Make sure that Tcl_WinTChar... check-in: 645fb65227 user: jan.nijtmans tags: core-8-branch
2018-09-13
20:37
missing type-cast check-in: 236d98718e user: jan.nijtmans tags: core-8-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclStubInit.c.
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272









273
274
275
276
277
278
279
     * UTF-8 as used by Tcl. Every sequence of 0xC0 followed by 0x80 will
     * be translated to two 0xfffd characters. This results in a test-failure
     * of the registry-6.20 test-case. The simplest solution is to search for
     * those two 0xfffd characters and replace them by a \u0000 character. */
    while (p < wp + size - 1) {
	if (p[0] == 0xfffd && p[1] == 0xfffd) {
	    memmove(p+1, p+2, sizeof(WCHAR) * (p - wp + size - 2));
	    p[0] = 0;
	    ++p; --size;
	}
	++p;
    }
    Tcl_DStringSetLength(dsPtr, 2*size);
    wp[size] = 0;
    return (char *) wp;
}

char *
Tcl_WinTCharToUtf(
    const char *string,
    int len,
    Tcl_DString *dsPtr)
{
    char *p;
    int size;

    if (len > 0) {
	len /= 2;
    }
    size = WideCharToMultiByte(CP_UTF8, 0, string, len, 0, 0, NULL, NULL);
    Tcl_DStringInit(dsPtr);
    Tcl_DStringSetLength(dsPtr, size+1);
    p = (char *)Tcl_DStringValue(dsPtr);
    WideCharToMultiByte(CP_UTF8, 0, string, len, p, size, NULL, NULL);
    if (len == -1) --size; /* account for 0-byte at string end */









    Tcl_DStringSetLength(dsPtr, size);
    p[size] = 0;
    return p;
}

#if defined(TCL_WIDE_INT_IS_LONG)
/* On Cygwin64, long is 64-bit while on Win64 long is 32-bit. Therefore







|















|







|
|


>
>
>
>
>
>
>
>
>







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
     * UTF-8 as used by Tcl. Every sequence of 0xC0 followed by 0x80 will
     * be translated to two 0xfffd characters. This results in a test-failure
     * of the registry-6.20 test-case. The simplest solution is to search for
     * those two 0xfffd characters and replace them by a \u0000 character. */
    while (p < wp + size - 1) {
	if (p[0] == 0xfffd && p[1] == 0xfffd) {
	    memmove(p+1, p+2, sizeof(WCHAR) * (p - wp + size - 2));
	    p[0] = '\0';
	    ++p; --size;
	}
	++p;
    }
    Tcl_DStringSetLength(dsPtr, 2*size);
    wp[size] = 0;
    return (char *) wp;
}

char *
Tcl_WinTCharToUtf(
    const char *string,
    int len,
    Tcl_DString *dsPtr)
{
    char *p, *r;
    int size;

    if (len > 0) {
	len /= 2;
    }
    size = WideCharToMultiByte(CP_UTF8, 0, string, len, 0, 0, NULL, NULL);
    Tcl_DStringInit(dsPtr);
    Tcl_DStringSetLength(dsPtr, size+8); /* Add some spare, in case of NULL-bytes */
    r = p = (char *)Tcl_DStringValue(dsPtr);
    WideCharToMultiByte(CP_UTF8, 0, string, len, p, size, NULL, NULL);
    if (len == -1) --size; /* account for 0-byte at string end */
    while (r < p+size) {
	if (!*r) {
	    /* Output contains '\0'-byte, but Tcl expect two-bytes: C0 80 */
	    memmove(r+2, r+1, p-r+size-1);
	    memcpy(r++, "\xC0\x80", 2);
	    Tcl_DStringSetLength(dsPtr, ++size + 1);
	}
	++r;
    }
    Tcl_DStringSetLength(dsPtr, size);
    p[size] = 0;
    return p;
}

#if defined(TCL_WIDE_INT_IS_LONG)
/* On Cygwin64, long is 64-bit while on Win64 long is 32-bit. Therefore
Changes to win/Makefile.in.
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492

libraries:

doc:

tclzipfile: ${TCL_ZIP_FILE}

${TCL_ZIP_FILE}:  ${ZIP_INSTALL_OBJS}
	rm -rf ${TCL_VFS_ROOT}
	mkdir -p ${TCL_VFS_PATH}
	$(COPY) -a $(TOP_DIR)/library/* ${TCL_VFS_PATH}
	$(COPY) ${DDE_DLL_FILE} ${TCL_VFS_PATH}/dde
	$(COPY) ${REG_DLL_FILE} ${TCL_VFS_PATH}/reg
	cd  ${TCL_VFS_ROOT} ; ${NATIVE_ZIP} ${ZIP_PROG_OPTIONS} ../${TCL_ZIP_FILE} ${ZIP_PROG_VFSSEARCH}








|







478
479
480
481
482
483
484
485
486
487
488
489
490
491
492

libraries:

doc:

tclzipfile: ${TCL_ZIP_FILE}

${TCL_ZIP_FILE}:  ${ZIP_INSTALL_OBJS} ${DDE_DLL_FILE} ${REG_DLL_FILE}
	rm -rf ${TCL_VFS_ROOT}
	mkdir -p ${TCL_VFS_PATH}
	$(COPY) -a $(TOP_DIR)/library/* ${TCL_VFS_PATH}
	$(COPY) ${DDE_DLL_FILE} ${TCL_VFS_PATH}/dde
	$(COPY) ${REG_DLL_FILE} ${TCL_VFS_PATH}/reg
	cd  ${TCL_VFS_ROOT} ; ${NATIVE_ZIP} ${ZIP_PROG_OPTIONS} ../${TCL_ZIP_FILE} ${ZIP_PROG_VFSSEARCH}

Changes to win/tclWin32Dll.c.
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520









521
522
523
524
525
526
527
     * UTF-8 as used by Tcl. Every sequence of 0xC0 followed by 0x80 will
     * be translated to two 0xfffd characters. This results in a test-failure
     * of the registry-6.20 test-case. The simplest solution is to search for
     * those two 0xfffd characters and replace them by a \u0000 character. */
    while (p < wp + size - 1) {
	if (p[0] == 0xfffd && p[1] == 0xfffd) {
	    memmove(p+1, p+2, sizeof(TCHAR) * (p - wp + size - 2));
	    p[0] = 0;
	    ++p; --size;
	}
	++p;
    }
    Tcl_DStringSetLength(dsPtr, 2*size);
    wp[size] = 0;
    return wp;
}

char *
Tcl_WinTCharToUtf(
    const TCHAR *string,	/* Source string in Unicode. */
    int len,			/* Source string length in bytes, or -1 for
				 * platform-specific string length. */
    Tcl_DString *dsPtr)		/* Uninitialized or free DString in which the
				 * converted string is stored. */
{
    char *p;
    int size;

    if (len > 0) {
	len /= 2;
    }
    size = WideCharToMultiByte(CP_UTF8, 0, string, len, 0, 0, NULL, NULL);
    Tcl_DStringInit(dsPtr);
    Tcl_DStringSetLength(dsPtr, size+1);
    p = (char *)Tcl_DStringValue(dsPtr);
    WideCharToMultiByte(CP_UTF8, 0, string, len, p, size, NULL, NULL);
    if (len == -1) --size; /* account for 0-byte at string end */









    Tcl_DStringSetLength(dsPtr, size);
    p[size] = 0;
    return p;
}

/*
 *------------------------------------------------------------------------







|

















|







|
|


>
>
>
>
>
>
>
>
>







484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
     * UTF-8 as used by Tcl. Every sequence of 0xC0 followed by 0x80 will
     * be translated to two 0xfffd characters. This results in a test-failure
     * of the registry-6.20 test-case. The simplest solution is to search for
     * those two 0xfffd characters and replace them by a \u0000 character. */
    while (p < wp + size - 1) {
	if (p[0] == 0xfffd && p[1] == 0xfffd) {
	    memmove(p+1, p+2, sizeof(TCHAR) * (p - wp + size - 2));
	    p[0] = '\0';
	    ++p; --size;
	}
	++p;
    }
    Tcl_DStringSetLength(dsPtr, 2*size);
    wp[size] = 0;
    return wp;
}

char *
Tcl_WinTCharToUtf(
    const TCHAR *string,	/* Source string in Unicode. */
    int len,			/* Source string length in bytes, or -1 for
				 * platform-specific string length. */
    Tcl_DString *dsPtr)		/* Uninitialized or free DString in which the
				 * converted string is stored. */
{
    char *p, *r;
    int size;

    if (len > 0) {
	len /= 2;
    }
    size = WideCharToMultiByte(CP_UTF8, 0, string, len, 0, 0, NULL, NULL);
    Tcl_DStringInit(dsPtr);
    Tcl_DStringSetLength(dsPtr, size+8); /* Add some spare, in case of NULL-bytes */
    r = p = (char *)Tcl_DStringValue(dsPtr);
    WideCharToMultiByte(CP_UTF8, 0, string, len, p, size, NULL, NULL);
    if (len == -1) --size; /* account for 0-byte at string end */
    while (r < p+size) {
	if (!*r) {
	    /* Output contains '\0'-byte, but Tcl expect two-bytes: C0 80 */
	    memmove(r+2, r+1, p-r+size-1);
	    memcpy(r++, "\xC0\x80", 2);
	    Tcl_DStringSetLength(dsPtr, ++size + 1);
	}
	++r;
    }
    Tcl_DStringSetLength(dsPtr, size);
    p[size] = 0;
    return p;
}

/*
 *------------------------------------------------------------------------