Ticket UUID: | b58e6897034fc5292c9d36ba8099d9a835c98172 | |||
Title: | Return value of `Tcl_Flush` | |||
Type: | Bug | Version: | Tcl 8.6.7 | |
Submitter: | dram | Created on: | 2017-10-19 10:55:18 | |
Subsystem: | - New Builtin Commands | Assigned To: | jan.nijtmans | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2017-10-25 07:32:21 | |
Resolution: | Fixed | Closed By: | dram | |
Closed on: | 2017-10-25 07:32:21 | |||
Description: |
It seems that return value description of `Tcl_Flush` in document[1] is not consistent with the implementation, it says result will be `TCL_OK` or `TCL_ERROR`, but sometimes `-1` is returned. e.g.: ``` #include <tcl.h> int main() { Tcl_Interp *interp = Tcl_CreateInterp(); Tcl_Channel channel = Tcl_GetStdChannel(TCL_STDIN); printf("TCL_OK = %d\n", TCL_OK); printf("TCL_ERROR = %d\n", TCL_ERROR); printf("Tcl_Flush(stdin) = %d\n", Tcl_Flush(channel)); Tcl_DeleteInterp(interp); return 0; } ``` Output: ``` TCL_OK = 0 TCL_ERROR = 1 Tcl_Flush(stdin) = -1 ``` [1] https://tcl.tk/man/tcl8.6/TclLib/OpenFileChnl.htm#M19 | |||
User Comments: |
dram added on 2017-10-25 07:32:21:
Fix confirmed, thanks. jan.nijtmans added on 2017-10-23 12:11:09: Good catch! In this case there is no reason to distingish the channel being non-writable with other errors, since the actual error situation is expected to be returned in errno anyway in both cases. It looks like an ancient copy/paste error, since a lot of other functions where CheckChannelErrors() is used return -1 for error. Therefore: agreed with the analyses. Should be fixed now in core-8-6-branch and trunk. Thanks! |