Skip to content
Tcl Source Code History Of Ticket 405995ffffffffff
Login

History Of Ticket 405995ffffffffff

Artifacts Associated With Ticket 405995ffffffffff

  1. Ticket change [a39b4c37da] (rid 110069) by nobody on 2001-03-05 11:34:35:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Tcl_Ungets puts the bytes into the beginning of the 
      buffer, not staring at bufPtr->nextAdded.
      
      diff -r tcl8.3.2/generic/tclIO.c 
      tcl8.3.2.new/generic/tclIO.c
      4553c4553
      <         bufPtr->buf[i] = str[i];
      ---
      >         bufPtr->buf[bufPtr->nextAdded++] = str[i];
      4555d4554
      <     bufPtr->nextAdded += len;
      
      
    4. foundin initialized to: "obsolete: 8.4a2"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "24. Channel Commands"
    10. title initialized to: "Tcl_Ungets filling buffer wrongly"
    11. type initialized to: "Bug"
  2. Ticket change [048f8cfe9c] (rid 120016) by andreas_kupries on 2001-07-17 01:51:46:

    1. assignee changed to: "andreas_kupries"
  3. Ticket change [9376a32dd4] (rid 105822) by andreas_kupries on 2001-07-20 01:24:31:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      Doesn't this have to take "atEnd" into account too ?
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  4. Ticket change [46a22ff0c8] (rid 99550) by jiangwu on 2004-02-03 02:41:54:

    1. icomment:
      Logged In: YES 
      user_id=966384
      
      I tried this patch on 8.4.4 and it seems to work.  Here is the 
      diff against 8.4.4:
      
      cvs diff -u tclIO.c
      Index: tclIO.c
      ==============================================
      =====================
      RCS file: /home/cvs/starvine/cvsroot/tcl/generic/tclIO.c,v
      retrieving revision 1.2
      diff -u -r1.2 tclIO.c
      --- tclIO.c     11 Oct 2003 07:02:47 -0000      1.2
      +++ tclIO.c     2 Feb 2004 19:36:55 -0000
      @@ -5041,9 +5041,8 @@
      
           bufPtr = AllocChannelBuffer(len);
           for (i = 0; i < len; i++) {
      -        bufPtr->buf[i] = str[i];
      +        bufPtr->buf[bufPtr->nextAdded++] = str[i];
           }
      -    bufPtr->nextAdded += len;
      
           if (statePtr->inQueueHead == (ChannelBuffer *) NULL) {
               bufPtr->nextPtr = (ChannelBuffer *) NULL;
      
      
      
    2. login: "jiangwu"
    3. mimetype: "text/plain"
    4. username: "jiangwu"
  5. Ticket change [326e895f0e] (rid 93608) by davygrvy on 2004-02-03 04:16:53:

    1. assignee changed to: "davygrvy"
  6. Ticket change [80796a4133] (rid 116874) by davygrvy on 2004-02-03 04:31:20:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      atEnd is handled by the splice operation below this code.
      
      Fix applied to HEAD: tclIO.c -r1.70
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  7. Ticket change [4cbad4271d] (rid 126939) by davygrvy on 2004-02-03 04:35:34:

    1. closedate changed to: "2004-02-02T21:35:34"
    2. closer changed to: "davygrvy"
    3. resolution changed to: "Fixed"
    4. status changed to: "Closed"
  8. Ticket change [693784f873] (rid 103210) by hobbs on 2004-02-03 04:42:08:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      If the fix is correct, why not backport it to 8.4 as well?
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  9. Ticket change [97bea819dc] (rid 110489) by dgp on 2004-02-03 04:56:24:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      
      Is there a test in the test suite
      that fails without the fix, and
      succeeds with it?
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  10. Ticket change [8865bb97ab] (rid 131857) by davygrvy on 2004-02-03 05:00:17:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      no there isn't
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  11. Ticket change [17ab7930d1] (rid 122537) by dkf on 2004-02-03 18:14:31:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Reopening until a test is written.  Sorry to be tedious, but
      it's the only way to stop silly mistakes in the future. 
      (BTW, if it is awkward to test this with normal commands,
      just slap some test code into tclTest.c and do it that way. :))
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
    5. username: "dkf"
  12. Ticket change [3ec0071ad7] (rid 121325) by dkf on 2004-02-03 18:14:55:

    1. closedate changed to: "2004-02-03T11:14:55"
    2. closer changed to: "dkf"
    3. priority changed to: "9 Immediate"
    4. status changed to: "Closed"
  13. Ticket change [6ecade9997] (rid 100202) by jiangwu on 2004-02-07 03:29:42:

    1. icomment:
      Logged In: YES 
      user_id=966384
      
      There are no way to test this using normal Tcl command.  
      Here is something I put together, which adds a "ungets" 
      subcommand to "testchannel", then added a single test to 
      the "io.test" to verify ungets.  This test fails without the fix 
      and succeeds with the fix:
      
      > cvs diff -u generic/tclTest.c tests/io.test
      Index: generic/tclTest.c
      ==============================================
      =====================
      RCS file: /home/cvs/starvine/cvsroot/tcl/generic/tclTest.c,v
      retrieving revision 1.2
      diff -u -r1.2 tclTest.c
      --- generic/tclTest.c   11 Oct 2003 07:02:48 -0000      1.2
      +++ generic/tclTest.c   6 Feb 2004 20:26:53 -0000
      @@ -291,6 +291,9 @@
       static Tcl_Channel     TestOpenFileChannelProc3 
      _ANSI_ARGS_((
                                  Tcl_Interp *interp, CONST char 
      *fileName,
                                  CONST char *modeString, int 
      permissions));
      +static int      UngetsChannelProc _ANSI_ARGS_((
      +                Tcl_Interp *interp, Tcl_Channel channel,
      +                CONST char *input, CONST char *addAtEnd));
       static int             TestpanicCmd _ANSI_ARGS_((ClientData 
      dummy,
                                  Tcl_Interp *interp, int argc, CONST char 
      **argv));
       static int             TestparserObjCmd _ANSI_ARGS_
      ((ClientData dummy,
      @@ -5158,6 +5161,46 @@
              return (NULL);
           }
       }
      +
      +
      +/*
      + *--------------------------------------------------------
      --------------
      + *
      + * UngetsChannelProc  --
      + *
      + *     Implements the "ungets ..." subcommand in 
      TestChannelCmd.  Calls
      + *  the "Tcl_Ungets" C API with the given arguments.
      + *
      + * Results:
      + *     A integer value, as returned by Tcl_Ungets.
      + *
      + * Side effects:
      + *     None.
      + *
      + *--------------------------------------------------------
      --------------
      + */
      +static int
      +UngetsChannelProc(interp, channel, input, addAtEnd)
      +    Tcl_Interp  *interp;                /* Interpreter for error 
      reporting */
      +    Tcl_Channel channel;                /* Channel to push the 
      data back */
      +    CONST char  *input;                 /* String to push back  
      */
      +    CONST char  *addAtEnd;              /* A integer flag, 1 or 
      0 for whether
      +                                           the string should be pushed 
      back to
      +                                           the end or the beginning */
      +{
      +    int inputLen = strlen(input);
      +    int len, addAtEndFlag;
      +
      +    if (Tcl_GetInt(interp, addAtEnd, &addAtEndFlag) == 
      TCL_ERROR) {
      +        Tcl_AppendResult(interp, "expecting an integer flag for 
      \"addAtEnd\"",
      +                         (char *) NULL);
      +        return TCL_ERROR;
      +    }
      +    len = Tcl_Ungets(channel, input, inputLen, addAtEndFlag);
      +    Tcl_SetObjResult(interp, Tcl_NewIntObj(len));
      +
      +    return TCL_OK;
      +}
       &#9792;
       /*
        *---------------------------------------------------------
      -------------
      @@ -5580,9 +5623,23 @@
              return Tcl_UnstackChannel(interp, chan);
           }
      
      +    if ((cmdName[0] == 'u') && (strncmp(cmdName, "ungets", 
      len) == 0)) {
      +       /*
      +        * Syntax: ungets channel string
      +        */
      +
      +        if (argc != 5) {
      +            Tcl_AppendResult(interp, "wrong # args: should be 
      \"", argv[0],
      +                             " ungets channel string atEnd\"", (char 
      *) NULL);
      +            return TCL_ERROR;
      +        }
      +
      +        return UngetsChannelProc(interp, chan, argv[3], argv
      [4]);
      +    }
      +
           Tcl_AppendResult(interp, "bad option \"", cmdName, "\": 
      should be ",
                   "cut, clearchannelhandlers, info, isshared, mode, 
      open, "
      -           "readable, splice, writable, transform, unstack",
      +           "readable, splice, writable, transform, unstack, 
      ungets",
                   (char *) NULL);
           return TCL_ERROR;
       }
      Index: tests/io.test
      ==============================================
      =====================
      RCS file: /home/cvs/starvine/cvsroot/tcl/tests/io.test,v
      retrieving revision 1.2
      diff -u -r1.2 io.test
      --- tests/io.test       11 Oct 2003 07:02:50 -0000      1.2
      +++ tests/io.test       6 Feb 2004 20:27:00 -0000
      @@ -7109,8 +7109,19 @@
           list $x $result
       } {1 {gets {} catch {error writing "stdout": invalid 
      argument}}}
      
      +# Test Tcl_Ungets
      
      -
      +test io-61.1 {testing Tcl_Ungets, push data back at 
      beginning} {testchannel} {
      +    set f [open $path(test1) w]
      +    puts $f "123456789"
      +    close $f
      +    set f [open $path(test1) r]
      +    gets $f
      +    testchannel ungets $f "123" 0
      +    set x [gets $f]
      +    close $f
      +    set x
      +} {123}
      
       # cleanup
       foreach file [list fooBar longfile script output test1 pipe 
      my_script foo \
      
      
      
    2. login: "jiangwu"
    3. mimetype: "text/plain"
    4. username: "jiangwu"