diff options
author | dgp <dgp@users.sourceforge.net> | 2016-04-19 17:29:39 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-04-19 17:29:39 (GMT) |
commit | 460dcd4bf3f9fadbd240dfcf2831278cb264e3bf (patch) | |
tree | b00f7f86b33280c023fbe908510435241ef9f314 /generic/tkOption.c | |
parent | 7e7435a12f36a5146680ece7bff1f4f48f407944 (diff) | |
parent | bcb71c3efaadfc55dcd742522aaf331a40b9a7ec (diff) | |
download | tk-little.zip tk-little.tar.gz tk-little.tar.bz2 |
Merge 8.6.5 release.little
Diffstat (limited to 'generic/tkOption.c')
-rw-r--r-- | generic/tkOption.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/generic/tkOption.c b/generic/tkOption.c index 75dc3b9..24e7fb3 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -560,7 +560,7 @@ Tk_GetOption( count -= levelPtr[-1].bases[currentStack]; } - if (currentStack && CLASS) { + if (currentStack & CLASS) { nodeId = winClassId; } else { nodeId = winNameId; @@ -1080,7 +1080,7 @@ ReadOptionFile( * TK_MAX_PRIO. */ { const char *realName; - char *buffer; + Tcl_Obj *buffer; int result, bufferSize; Tcl_Channel chan; Tcl_DString newName; @@ -1108,24 +1108,10 @@ ReadOptionFile( return TCL_ERROR; } - /* - * Compute size of file by seeking to the end of the file. This will - * overallocate if we are performing CRLF translation. - */ - - bufferSize = (int) Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_END); - Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_SET); - - if (bufferSize < 0) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "error seeking to end of file \"%s\": %s", - fileName, Tcl_PosixError(interp))); - Tcl_Close(NULL, chan); - return TCL_ERROR; - } - - buffer = ckalloc(bufferSize + 1); - bufferSize = Tcl_Read(chan, buffer, bufferSize); + buffer = Tcl_NewObj(); + Tcl_IncrRefCount(buffer); + Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8"); + bufferSize = Tcl_ReadChars(chan, buffer, -1, 0); if (bufferSize < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading file \"%s\": %s", @@ -1134,9 +1120,8 @@ ReadOptionFile( return TCL_ERROR; } Tcl_Close(NULL, chan); - buffer[bufferSize] = 0; - result = AddFromString(interp, tkwin, buffer, priority); - ckfree(buffer); + result = AddFromString(interp, tkwin, Tcl_GetString(buffer), priority); + Tcl_DecrRefCount(buffer); return result; } |