<i>channel reads prematurely from stdin on Windows</i> status still Open with 4 other changes
by
.
D 2025-11-13T08:29:57.563
J icomment Thank\syou\sfor\syour\spatch.\r\n\r\nFirst\sI\stested\sif\sthe\sprogram\sreads\scharacter-by-character\sinput\r\ncorrectly\sby\sadding\r\n\r\n\s\s\s\sHANDLE\shStdin\s=\sGetStdHandle(STD_INPUT_HANDLE);\r\n\s\s\s\sDWORD\smode;\r\n\s\s\s\sGetConsoleMode(hStdin,\s&mode);\r\n\s\s\s\sSetConsoleMode(hStdin,\smode\s&\s~ENABLE_LINE_INPUT);\r\n\r\nto\sthe\stest\sprogram.\sIt\sworks\scorrectly,\sgenerating\sone\scallback\sfor\r\nevery\scharacter\sseparately.\sHowever,\spressing\se.g.\sthe\sALT\skey\salso\r\ngenerates\sa\scallback,\sand\sthen\sthe\sread\sfunction\swill\sblock.\r\n\r\nIf\sI\sdon't\schange\sthe\smode\sand\skeep\sENABLE_LINE_INPUT\sto\sread\sline-by-line,\r\nthen\sthe\scallback\sfunction\sis\salready\scalled\safter\styping\sthe\sfirst\scharacter,\r\nand\sthe\sread\sfunction\swill\sblock.\r\n\r\nFor\sthe\spurpose\sof\stkinter,\sit\sis\sactually\ssufficient\sif\swe\scan\sread\r\ncharacter-by-character\scorrectly.\sIt\swould\sbe\sgreat\sif\sreading\r\ncharacter-by-character\scan\sbe\sfixed\sin\sTcl\s9.\sPython\scurrently\sstill\suses\r\nTcl\s8.6,\sbut\sthe\sPython\sdevelopers\salso\sseem\seager\sto\smove\sto\sTcl\s9,\sso\sI\r\nassume\swe\sdon't\sneed\sto\sworry\sabout\sTcl\s8.6.
J login anonymous
J mimetype text/x-markdown
J username mdehoon
K 1d0618000674abdf701021d69eaa858cbccf14a4
U anonymous
Z 362b27fd51631eb95365c2dc9a02ccf3