summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclIOUtil.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 2031fb5..90f1e18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
-2012-02-?? Jan Nijtmans <nijtmans@users.sf.net>
+2012-02-29 Jan Nijtmans <nijtmans@users.sf.net>
- * generic/tclIOUtil.c: [Bug bug-3466099] BOM in Unicode
+ * generic/tclIOUtil.c: [Bug 3466099] BOM in Unicode
* generic/tclEncoding.c:
* tests/source.test
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index d5bb102..5a8d022 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -1755,7 +1755,9 @@ Tcl_FSEvalFile(interp, pathPtr)
* [Bug: 2040]
*/
Tcl_SetChannelOption(interp, chan, "-eofchar", "\32");
- /* Try to read utf-8 BOM, if available */
+ /* 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 \"",
@@ -1763,6 +1765,10 @@ Tcl_FSEvalFile(interp, pathPtr)
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);