Tcl Source Code

Check-in [ced33be881]
Login

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

Overview
Comment:oops, that's no utf-8 BOM ;-(
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-4-branch
Files: files | file ages | folders
SHA1: ced33be881fd8c726f5f0990a45469d612dac9a3
User & Date: jan.nijtmans 2012-02-29 22:35:27
Context
2012-03-04
16:36
Patch from the cygwin folks check-in: 8cbc14c4dd user: jan.nijtmans tags: core-8-4-branch
2012-02-29
22:38
oops, that's no utf-8 BOM ;-( check-in: d2c359a194 user: jan.nijtmans tags: core-8-5-branch
22:35
oops, that's no utf-8 BOM ;-( check-in: ced33be881 user: jan.nijtmans tags: core-8-4-branch
21:17
[Bug 3466099] BOM in Unicode check-in: e17fc0e07b user: jan.nijtmans tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclIOUtil.c.

1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
    }
    string = Tcl_GetString(objPtr);
    /*
     * If first character is not a BOM, append the remaining characters,
     * otherwise replace them [Bug 3466099].
     */
    if (Tcl_ReadChars(chan, objPtr, -1,
	    memcmp(string, "\xef\xbf\xbe", 3)) < 0) {
	Tcl_Close(interp, chan);
	Tcl_AppendResult(interp, "couldn't read file \"",
		Tcl_GetString(pathPtr), "\": ", Tcl_PosixError(interp), NULL);
	goto end;
    }
    if (Tcl_Close(interp, chan) != TCL_OK) {
        goto end;







|







1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
    }
    string = Tcl_GetString(objPtr);
    /*
     * If first character is not a BOM, append the remaining characters,
     * otherwise replace them [Bug 3466099].
     */
    if (Tcl_ReadChars(chan, objPtr, -1,
	    memcmp(string, "\xef\xbb\xbf", 3)) < 0) {
	Tcl_Close(interp, chan);
	Tcl_AppendResult(interp, "couldn't read file \"",
		Tcl_GetString(pathPtr), "\": ", Tcl_PosixError(interp), NULL);
	goto end;
    }
    if (Tcl_Close(interp, chan) != TCL_OK) {
        goto end;

Changes to tests/source.test.

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

test source-2.7 {utf-8 with BOM} -setup {
    set sourcefile [makeFile {} source.file]
    set saveencoding [encoding system]
} -body {
    encoding system utf-8
    set out [open $sourcefile w]
    puts $out "\ufffeset y new-y"
    close $out
    set y old-y
    source $sourcefile
    return $y
} -cleanup {
    removeFile $sourcefile
    encoding system $saveencoding







|







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

test source-2.7 {utf-8 with BOM} -setup {
    set sourcefile [makeFile {} source.file]
    set saveencoding [encoding system]
} -body {
    encoding system utf-8
    set out [open $sourcefile w]
    puts $out "\ufeffset y new-y"
    close $out
    set y old-y
    source $sourcefile
    return $y
} -cleanup {
    removeFile $sourcefile
    encoding system $saveencoding