Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | [Bug 3466099] BOM in Unicode |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ad684faec98e7bffad97497176c68c11 |
User & Date: | jan.nijtmans 2012-02-29 21:56:20 |
Context
2012-02-29
| ||
22:41 | oops, that's no utf-8 BOM ;-( check-in: 86923ce939 user: jan.nijtmans tags: trunk | |
21:56 | [Bug 3466099] BOM in Unicode check-in: ad684faec9 user: jan.nijtmans tags: trunk | |
21:34 | [Bug 3466099] BOM in Unicode check-in: ca6c454087 user: jan.nijtmans tags: core-8-5-branch | |
2012-02-23
| ||
21:10 | Add tests relating to bug 1115587. The bug itself still exists at this point. check-in: fc453fd101 user: dkf tags: trunk | |
Changes
Changes to ChangeLog.
1 2 3 4 5 6 7 | 2012-02-23 Donal K. Fellows <[email protected]> * tests/reg.test (14.21-23): Add tests relating to bug 1115587. Actual bug is characterised by test marked with 'knownBug'. 2012-02-17 Jan Nijtmans <[email protected]> | > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | 2012-02-29 Jan Nijtmans <[email protected]> * generic/tclIOUtil.c: [Bug 3466099] BOM in Unicode * generic/tclEncoding.c: * tests/source.test 2012-02-23 Donal K. Fellows <[email protected]> * tests/reg.test (14.21-23): Add tests relating to bug 1115587. Actual bug is characterised by test marked with 'knownBug'. 2012-02-17 Jan Nijtmans <[email protected]> |
︙ | ︙ |
Changes to generic/tclEncoding.c.
︙ | ︙ | |||
975 976 977 978 979 980 981 | * *------------------------------------------------------------------------ */ int Tcl_SetSystemEncoding( Tcl_Interp *interp, /* Interp for error reporting, if not NULL. */ | | | | 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 | * *------------------------------------------------------------------------ */ int Tcl_SetSystemEncoding( Tcl_Interp *interp, /* Interp for error reporting, if not NULL. */ const char *name) /* The name of the desired encoding, or NULL/"" * to reset to default encoding. */ { Tcl_Encoding encoding; Encoding *encodingPtr; if (!name || !*name) { Tcl_MutexLock(&encodingMutex); encoding = defaultEncoding; encodingPtr = (Encoding *) encoding; encodingPtr->refCount++; Tcl_MutexUnlock(&encodingMutex); } else { encoding = Tcl_GetEncoding(interp, name); |
︙ | ︙ |
Changes to generic/tclIOUtil.c.
︙ | ︙ | |||
1725 1726 1727 1728 1729 1730 1731 | Tcl_Close(interp,chan); return result; } } objPtr = Tcl_NewObj(); Tcl_IncrRefCount(objPtr); | > > > | > > > > > > > > > > > > | 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 | Tcl_Close(interp,chan); return result; } } objPtr = Tcl_NewObj(); Tcl_IncrRefCount(objPtr); /* Try to read first character of stream, so we can * check for utf-8 BOM to be handled especially. */ if (Tcl_ReadChars(chan, objPtr, 1, 0) < 0) { Tcl_Close(interp, chan); Tcl_AppendResult(interp, "couldn't read file \"", Tcl_GetString(pathPtr), "\": ", Tcl_PosixError(interp), NULL); goto end; } 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) { |
︙ | ︙ | |||
1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 | const char *encodingName) /* If non-NULL, then use this encoding for the * file. NULL means use the system encoding. */ { Tcl_StatBuf statBuf; Tcl_Obj *oldScriptFile, *objPtr; Interp *iPtr; Tcl_Channel chan; if (Tcl_FSGetNormalizedPath(interp, pathPtr) == NULL) { return TCL_ERROR; } if (Tcl_FSStat(pathPtr, &statBuf) == -1) { Tcl_SetErrno(errno); | > | 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 | const char *encodingName) /* If non-NULL, then use this encoding for the * file. NULL means use the system encoding. */ { Tcl_StatBuf statBuf; Tcl_Obj *oldScriptFile, *objPtr; Interp *iPtr; Tcl_Channel chan; const char *string; if (Tcl_FSGetNormalizedPath(interp, pathPtr) == NULL) { return TCL_ERROR; } if (Tcl_FSStat(pathPtr, &statBuf) == -1) { Tcl_SetErrno(errno); |
︙ | ︙ | |||
1835 1836 1837 1838 1839 1840 1841 | Tcl_Close(interp,chan); return TCL_ERROR; } } objPtr = Tcl_NewObj(); Tcl_IncrRefCount(objPtr); | > > > | > > > > > > > > > > > > > | 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 | Tcl_Close(interp,chan); return TCL_ERROR; } } objPtr = Tcl_NewObj(); Tcl_IncrRefCount(objPtr); /* Try to read first character of stream, so we can * check for utf-8 BOM to be handled especially. */ if (Tcl_ReadChars(chan, objPtr, 1, 0) < 0) { Tcl_Close(interp, chan); Tcl_AppendResult(interp, "couldn't read file \"", Tcl_GetString(pathPtr), "\": ", Tcl_PosixError(interp), NULL); Tcl_DecrRefCount(objPtr); return TCL_ERROR; } 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); Tcl_DecrRefCount(objPtr); return TCL_ERROR; } if (Tcl_Close(interp, chan) != TCL_OK) { Tcl_DecrRefCount(objPtr); return TCL_ERROR; } |
︙ | ︙ |
Changes to tests/source.test.
︙ | ︙ | |||
103 104 105 106 107 108 109 110 111 112 113 114 115 116 | set sourcefile [makeFile {} _non_existent_] removeFile _non_existent_ } -body { list [catch {source $sourcefile} msg] $msg $::errorCode } -match listGlob -result [list 1 \ {couldn't read file "*_non_existent_": no such file or directory} \ {POSIX ENOENT {no such file or directory}}] test source-3.1 {return in middle of source file} -setup { set sourcefile [makeFile { set x new-x return allDone set y new-y } source.file] | > > > > > > > > > > > > > | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | set sourcefile [makeFile {} _non_existent_] removeFile _non_existent_ } -body { list [catch {source $sourcefile} msg] $msg $::errorCode } -match listGlob -result [list 1 \ {couldn't read file "*_non_existent_": no such file or directory} \ {POSIX ENOENT {no such file or directory}}] test source-2.7 {utf-8 with BOM} -setup { set sourcefile [makeFile {} source.file] } -body { set out [open $sourcefile w] fconfigure $out -encoding utf-8 puts $out "\ufffeset y new-y" close $out set y old-y source -encoding utf-8 $sourcefile return $y } -cleanup { removeFile $sourcefile } -result {new-y} test source-3.1 {return in middle of source file} -setup { set sourcefile [makeFile { set x new-x return allDone set y new-y } source.file] |
︙ | ︙ |