Skip to content
Tcl Source Code History Of Ticket 32b6159246
Login

History Of Ticket 32b6159246

Artifacts Associated With Ticket 32b6159246

  1. Ticket change [9737d09940] (rid 141216) by anonymous on 2015-02-19 02:50:19:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      % lreplace {1 2 3} 2 0
      1 2 2 3
      
      It looks like TclCompileLreplaceCommand doesn't handle idx2 < idx1 properly.  Similar errors with >3 arguments too.
      
      Hopefully the following patch formats correctly - chiselapp's struggling to sync.
      
      Index: generic/tclCompCmdsGR.c
      ==================================================================
      --- generic/tclCompCmdsGR.c
      +++ generic/tclCompCmdsGR.c
      @@ -1498,10 +1498,14 @@
      
           tokenPtr = TokenAfter(tokenPtr);
           if (GetIndexFromToken(tokenPtr, &idx2) != TCL_OK) {
              return TCL_ERROR;
           }
      +
      +    if(idx2 != INDEX_END && idx2 < idx1) {
      +       idx2 = idx1-1;
      +    }
           
           /*
            * Work out what this [lreplace] is actually doing.
            */
      
      ==================================================================
      --- tests/lreplace.test
      +++ tests/lreplace.test
      @@ -135,14 +135,23 @@
       } {}
       # Note that this test will fail in 8.5
       test lreplace-4.2 {Bug ccc2c2cc98: lreplace edge case} {
           lreplace { } 1 1
       } {}
      +test lreplace-4.3 {lreplace edge case} {
      +    lreplace {1 2 3} 2 0
      +} {1 2 3}
      +test lreplace-4.4 {lreplace edge case} {
      +    lreplace {1 2 3 4 5} 3 1
      +} {1 2 3 4 5}
      +test lreplace-4.4 {lreplace edge case} {
      +    lreplace {1 2 3 4 5} 3 0 _
      +} {1 2 3 _ 4 5}
       
       # cleanup
       catch {unset foo}
       ::tcltest::cleanupTests
       return
       
       # Local Variables:
       # mode: tcl
       # End:
      
    5. foundin initialized to: "8.6.3"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "cb02a4a25e8da92f2790bc307bf01ef24ce6053e"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "47. Bytecode Compiler"
    15. title initialized to: "lreplace where idx2 < idx1 not compiled correctly"
    16. type initialized to: "Bug"
  2. Ticket change [d87dbcf07b] (rid 141217) by anonymous on 2015-02-19 02:55:27:

    1. comment changed to:
      % lreplace {1 2 3} 2 0
      1 2 2 3
      
      It looks like TclCompileLreplaceCommand doesn't handle idx2 < idx1 properly.  Similar errors with >3 arguments too.
      
      Hopefully the following patch formats correctly - chiselapp's struggling to sync.
      
      It passes the extra tests, but negative indices might still break.
      
      Of course, the case where numWords==4 and idx2<idx1 is the identity function, so it could be optimised further.
      
      
      Index: generic/tclCompCmdsGR.c
      ==================================================================
      --- generic/tclCompCmdsGR.c
      +++ generic/tclCompCmdsGR.c
      @@ -1498,10 +1498,14 @@
      
           tokenPtr = TokenAfter(tokenPtr);
           if (GetIndexFromToken(tokenPtr, &idx2) != TCL_OK) {
              return TCL_ERROR;
           }
      +
      +    if(idx2 != INDEX_END && idx2 < idx1) {
      +       idx2 = idx1-1;
      +    }
           
           /*
            * Work out what this [lreplace] is actually doing.
            */
      
      ==================================================================
      --- tests/lreplace.test
      +++ tests/lreplace.test
      @@ -135,14 +135,23 @@
       } {}
       # Note that this test will fail in 8.5
       test lreplace-4.2 {Bug ccc2c2cc98: lreplace edge case} {
           lreplace { } 1 1
       } {}
      +test lreplace-4.3 {lreplace edge case} {
      +    lreplace {1 2 3} 2 0
      +} {1 2 3}
      +test lreplace-4.4 {lreplace edge case} {
      +    lreplace {1 2 3 4 5} 3 1
      +} {1 2 3 4 5}
      +test lreplace-4.4 {lreplace edge case} {
      +    lreplace {1 2 3 4 5} 3 0 _
      +} {1 2 3 _ 4 5}
       
       # cleanup
       catch {unset foo}
       ::tcltest::cleanupTests
       return
       
       # Local Variables:
       # mode: tcl
       # End:
      
    2. icomment:
      also a little suspicious of the block at line 1554:
      
      	if (idx1 > 0 && idx2 > 0 && idx2 < idx1) {
      	    idx2 = idx1 - 1;
      	} else if (idx1 < 0 && idx2 < 0 && idx2 < idx1) {
      	    idx2 = idx1 - 1;
      	}
      
      I'm not 100% clear, but it looks strange idx1 or idx2 == 0 isn't handled.
      
    3. login: "anonymous"
    4. mimetype: "text/plain"
    5. username: "aspect"
  3. Ticket change [27edc149e1] (rid 141218) by dgp on 2015-02-19 03:11:38:

    1. assignee changed to: "dkf"
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. priority changed to: "8"
    5. severity changed to: "Important"
  4. Ticket change [4542fd032d] (rid 141219) by anonymous on 2015-02-19 06:37:43:

    1. icomment:
      Patch is now pushed to chiselapp:
      
      http://chiselapp.com/user/aspect/repository/tcl/timeline?r=aspect-lreplace-fix
      
    2. login: "anonymous"
    3. mimetype: "text/html"
    4. username: "aspect"
  5. Add attachment "aspect-lreplace-fix.fbun" [1553b72f15] (rid 141229) by anonymous on 2015-02-19 20:47:02.

  6. Ticket change [e885b011d4] (rid 141230) by anonymous on 2015-02-19 20:47:38:

    1. icomment:
      I attached a "fossil bundle" with this branch (minus the merge from trunk)
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
    4. username: "rkeene"
  7. Ticket change [d6ba3d8326] (rid 141246) by dgp on 2015-02-20 20:20:21:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2457074.34746884"
    3. closer changed to: "dgp"
    4. icomment: "Patch accepted for 8.6.4."
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"