Skip to content
Tcl Source Code Artifact [69dd62ed33]
Login

Artifact [69dd62ed33]

Artifact 69dd62ed3324d502fcb4803192fd4ebc854ce3c1:

Ticket change [69dd62ed33] - New ticket [219282ffffffffff|219282ffff] <i>Tcl_SetChannelOption (-buffing, line) not working correctly</i>. by nobody on 2000-10-26 05:09:54.
D 2000-10-26T05:09:54
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s1923\sBug\nVersion:\s8.0.5\nSubmitDate:\s'1999-04-22'\nLastModified:\s'1999-11-07'\nSeverity:\sMED\nStatus:\sUnAssn\nSubmitter:\spat\nChangedBy:\shobbs\nOS:\sWindows\sNT\nOSVersion:\s4.00.1381\nMachine:\sX86\nFixedDate:\s'2000-10-25'\nClosedDate:\s'2000-10-25'\n\n\nName:Kenneth\sAtwell\n\nComments:\nAs\syou\scan\ssee,\sthe\sline\sbuffer\soption\sthat\sis\sselected\sto\snot\n\s\s\s\sfunctioning\scorrectly.\n\s\s\s\s\n\s\s\s\sI\sbelieve\sthis\sis\srelated\sto\s"\\n"\s(Unix)\sversus\s"\\r\\n"\s(DOS)\sline\n\s\s\s\sreturns.\s\sThe\sbuffer\ssent\sto\sMyChannelOutputProc()\sdoes\snot\scontain\sthe\n\s\s\s\sfull\sbuffer\swhen\sthe\soutput\sis\smulitple\slines\slong.\s\sIt\sappears\sthat\n\s\s\s\sbuffers\swith\smore\sEOLs\sare\struncated\sbefore\sbuffers\swith\sless\sEOLs.\n\nReproducibleScript:\nCompile\sand\slink\sthe\sfollowing\sC\sprogram\s(I\sused\sMS\sVisual\sC++\sv5).\s\sRun\n\s\s\s\sthe\sprogram.\s\sSorry\sabout\sthe\slength,\sbut\sI\shad\sto\sinclude\ssome\s(unused)\n\s\s\s\sboilerplate\sto\screate\sthe\schannel.\n\s\s\s\s\n\s\s\s\s----\n\s\s\s\s\n\s\s\s\s#include\s<stdlib.h>\n\s\s\s\s#include\s<string.h>\n\s\s\s\s#include\s<errno.h>\n\s\s\s\s#include\s<assert.h>\n\s\s\s\s#include\s"tcl.h"\n\s\s\s\s\n\s\s\s\sint\sMyChannelCloseProc\s(\sClientData\sinstanceData,\sTcl_Interp\s*interp\s)\n\s\s\s\s{\n\s\s\s\sreturn\s0;\n\s\s\s\s}\n\s\s\s\s\n\s\s\s\sint\sMyChannelInputProc\s(\sClientData\sinstanceData,\schar\s*buf,\sint\n\s\s\s\sbufSize,\sint\s*errorCodePtr\s)\n\s\s\s\s{\n\s\s\s\s*errorCodePtr\s=\sENODEV;\n\s\s\s\sreturn\s-1;\n\s\s\s\s}\n\s\s\s\s\n\s\s\s\sint\sMyChannelOutputProc\s(\sClientData\sinstanceData,\schar\s*buf,\sint\n\s\s\s\stoWrite,\sint\s*errorCodePtr\s)\n\s\s\s\s{\n\s\s\s\s/*\n\s\s\s\s\s*\sBUG:\s\s"buf"\sdoes\snot\salways\send\swith\sa\s'\\n',\sdespite\sthe\sfact\sthat\n\s\s\s\swe\n\s\s\s\s\s*\sselected\sline\sbuffering.\s\sThis\sbug\scan\sbe\scaught\sby\suncommenting\n\s\s\s\sthe\n\s\s\s\s\s*\sassert()\smacro\sbelow.\n\s\s\s\s\s*/\n\s\s\s\s\n\s\s\s\s/*\sassert\s(\s'\\n'\s==\sbuf\s[\stoWrite\s-\s1\s]\s);\s*/\n\s\s\s\s\n\s\s\s\schar\s*pszTmp\s=\s(\schar\s*\s)\smalloc\s(\stoWrite\s+\s1\s);\n\s\s\s\sassert\s(\spszTmp\s);\n\s\s\s\sstrncpy\s(\spszTmp,\sbuf,\stoWrite\s);\n\s\s\s\spszTmp\s[\stoWrite\s]\s=\s'\\0';\n\s\s\s\s\n\s\s\s\sprintf\s(\s"***BEGIN***\\n"\s);\n\s\s\s\sprintf\s(\spszTmp\s);\n\s\s\s\sprintf\s(\s"***END***\\n"\s);\n\s\s\s\s\n\s\s\s\sfree\s(\spszTmp\s);\n\s\s\s\sreturn\stoWrite;\n\s\s\s\s}\n\s\s\s\s\n\s\s\s\svoid\sMyChannelWatchProc\s(\sClientData\sinstanceData,\sint\smask\s)\n\s\s\s\s{\n\s\s\s\s}\n\s\s\s\s\n\s\s\s\sint\sMyChannelGetHandleProc\s(\sClientData\sinstanceData,\sint\sdirection,\n\s\s\s\sClientData\s*handlePtr\s)\n\s\s\s\s{\n\s\s\s\sreturn\sTCL_ERROR;\n\s\s\s\s}\n\s\s\s\s\n\s\s\s\sstatic\sTcl_ChannelType\sg_CommandWindowChannelType\s=\n\s\s\s\s{\n\s\s\s\s"my_channel_type",\s\s\s\s\s\s\s\s\s/*\sname\s*/\n\s\s\s\sNULL,\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s/*\sblock\smode\sproc\s*/\n\s\s\s\sMyChannelCloseProc,\s\s\s\s\s\s\s\s/*\sclose\sproc\s*/\n\s\s\s\sMyChannelInputProc,\s\s\s\s\s\s\s\s/*\sinput\sproc\s*/\n\s\s\s\sMyChannelOutputProc,\s\s\s\s\s\s\s/*\soutput\sproc\s*/\n\s\s\s\sNULL,\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s/*\sseek\sproc\s*/\n\s\s\s\sNULL,\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s/*\sset\soption\sproc\s*/\n\s\s\s\sNULL,\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s/*\sget\soption\sproc\s*/\n\s\s\s\sMyChannelWatchProc,\s\s\s\s\s\s\s\s/*\swatch\sproc\s*/\n\s\s\s\sMyChannelGetHandleProc\s\s\s\s\s/*\sget\shandle\sproc\s*/\n\s\s\s\s};\n\s\s\s\s\n\s\s\s\sstatic\sTcl_Channel\sg_CommandWindowChannel;\n\s\s\s\s\n\s\s\s\svoid\smain\s()\n\s\s\s\s{\n\s\s\s\sint\sresult;\n\s\s\s\s\n\s\s\s\sTcl_Interp\s*interp\s=\sTcl_CreateInterp\s();\n\s\s\s\sassert\s(\sinterp\s);\n\s\s\s\s\n\s\s\s\s/*\sCreate\sa\snew\stype\sof\sI/O\schannel.\s*/\n\s\s\s\s\n\s\s\s\sg_CommandWindowChannel\s=\sTcl_CreateChannel\s(\n\s\s\s\s&g_CommandWindowChannelType,\n\s\s\s\s\s"my_channel",\n\s\s\s\s\s(ClientData)\s0,\n\s\s\s\s\sTCL_WRITABLE\s);\n\s\s\s\s\n\s\s\s\s/*\sSet\sSTDIN,\sSTDOUT,\sand\sSTDERR\sto\suse\sthis\schannel.\s*/\n\s\s\s\s\n\s\s\s\sTcl_SetStdChannel\s(\sg_CommandWindowChannel,\sTCL_STDOUT\s);\n\s\s\s\s\n\s\s\s\s/*\sSet\sthe\schannel\sbuffering.\s\sOuput\swill\soccur\sat\sEOLs.\s*/\n\s\s\s\s\n\s\s\s\sresult\s=\sTcl_SetChannelOption\s(\sinterp,\sg_CommandWindowChannel,\n\s\s\s\s"-buffering",\s"line"\s);\n\s\s\s\sassert\s(\sTCL_OK\s==\sresult\s);\n\s\s\s\s\n\s\s\s\s/*\sTest\sthe\snew\schannel\swith\sa\ssimple\sputs*/\n\s\s\s\s\n\s\s\s\sresult\s=\sTcl_Eval\s(\sinterp,\s"puts\s\\"This\sline\sprints\scorrectly.\\""\s);\n\s\s\s\sassert\s(\sTCL_OK\s==\sresult\s);\n\s\s\s\s\n\s\s\s\s/*\sThis\snext\scommand\sresults\sin\san\serror\s*/\n\s\s\s\s\n\s\s\s\sresult\s=\sTcl_Eval\s(\sinterp,\s"foo"\s);\n\s\s\s\sassert\s(\sTCL_ERROR\s==\sresult\s);\n\s\s\s\s\n\s\s\s\s/*\sNow\stry\sto\sprint\sout\s$errorInfo\s*/\n\s\s\s\s\n\s\s\s\sresult\s=\sTcl_Eval\s(\sinterp,\s"puts\s$errorInfo"\s);\n\s\s\s\sassert\s(\sTCL_OK\s==\sresult\s);\n\s\s\s\s}\n\nObservedBehavior:\nThe\soutput\sof\sthe\sprogram\sis:\n\s\s\s\s\n\s\s\s\s***BEGIN***\n\s\s\s\sThis\sline\sprints\scorrectly.\n\s\s\s\s***END***\n\s\s\s\s***BEGIN***\n\s\s\s\sinvalid\scommand\sname\s"foo"\n\s\s\s\s\s\s\s\swhile\sexecuting\n\s\s\s\s"fo***END***\n\s\s\s\s***BEGIN***\n\s\s\s\so"\n\s\s\s\s***END***\n\nDesiredBehavior:\nCorrect\soutput\swould\sbe:\n\s\s\s\s\n\s\s\s\s***BEGIN***\n\s\s\s\sThis\sline\sprints\scorrectly.\n\s\s\s\s***END***\n\s\s\s\s***BEGIN***\n\s\s\s\sinvalid\scommand\sname\s"foo"\n\s\s\s\s\s\s\s\swhile\sexecuting\n\s\s\s\s"foo"\n\s\s\s\s***END***\n\n\n\n
J foundin final:\s8.0.5
J priority 5\sMedium
J resolution None
J status Open
J submitter nobody
J subsystem 62.\s(unused)
J title Tcl_SetChannelOption\s(-buffing,\sline)\snot\sworking\scorrectly
J type Bug
K 219282ffffffffffffffffffffffffffffffffff
U nobody
Z c71bf94910e1880d9bc4e4927916e0a0