home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / tcl / 2461 < prev    next >
Encoding:
Text File  |  1993-01-23  |  4.2 KB  |  168 lines

  1. Path: sparky!uunet!stanford.edu!agate!sprite.Berkeley.EDU!ouster
  2. From: ouster@sprite.Berkeley.EDU (John Ousterhout)
  3. Newsgroups: comp.lang.tcl
  4. Subject: Re: Possible bug in lreplace
  5. Date: 22 Jan 1993 22:08:02 GMT
  6. Organization: U.C. Berkeley Sprite Project
  7. Lines: 155
  8. Distribution: world
  9. Message-ID: <1jpr82$5l6@agate.berkeley.edu>
  10. References: <1993Jan7.205040.19153@bnr.ca>
  11. NNTP-Posting-Host: tyranny.berkeley.edu
  12.  
  13. In article <1993Jan7.205040.19153@bnr.ca>, jamensky@bnr.ca (Mark Jamensky) writes:
  14. |>   The problem is exhibited as follows in Tcl version 6.4:
  15. |> 
  16. |> set l1 { a b "c c" d e f}
  17. |> 
  18. |> lreplace $l1 2 2
  19. |> returns: a b d e f
  20. |> 
  21. |> lreplace $l1 3 3
  22. |> returns: a b "c c e f
  23. |> 
  24. |>   For some reason the second quote gets removed.  Has anyone else seen this and
  25. |> if so is there a patch?
  26. |> 
  27. |>   Thanks in advance.
  28. |> 
  29. |> --            | Bell-Northern Research - Ottawa | Conform or be cast out.
  30. |> Mark Jamensky | jamensky@bnr.ca  (613) 765-4942 | - Rush
  31.  
  32. Here's a patch to tclCmdIL.c that fixes this problem, plus a similar
  33. problem that occurs in "linsert".
  34.  
  35. *** /tmp/,RCSt1150338    Fri Jan 22 14:05:27 1993
  36. --- tclCmdIL.c    Fri Jan 22 14:03:35 1993
  37. ***************
  38. *** 705,711 ****
  39.       char **argv;            /* Argument strings. */
  40.   {
  41.       char *p, *element, savedChar;
  42. !     int i, index, count, result, size, brace;
  43.   
  44.       if (argc < 4) {
  45.       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  46. --- 705,711 ----
  47.       char **argv;            /* Argument strings. */
  48.   {
  49.       char *p, *element, savedChar;
  50. !     int i, index, count, result, size;
  51.   
  52.       if (argc < 4) {
  53.       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  54. ***************
  55. *** 722,731 ****
  56.        */
  57.   
  58.       size = 0;
  59. -     brace = 0;
  60.       element = argv[1];
  61.       for (count = 0, p = argv[1]; (count < index) && (*p != 0); count++) {
  62. !     result = TclFindElement(interp, p, &element, &p, &size, &brace);
  63.       if (result != TCL_OK) {
  64.           return result;
  65.       }
  66. --- 722,730 ----
  67.        */
  68.   
  69.       size = 0;
  70.       element = argv[1];
  71.       for (count = 0, p = argv[1]; (count < index) && (*p != 0); count++) {
  72. !     result = TclFindElement(interp, p, &element, &p, &size, (int *) NULL);
  73.       if (result != TCL_OK) {
  74.           return result;
  75.       }
  76. ***************
  77. *** 736,743 ****
  78.       char *end;
  79.   
  80.       end = element+size;
  81. !     if (brace) {
  82. !         end++;
  83.       }
  84.       savedChar = *end;
  85.       *end = 0;
  86. --- 735,744 ----
  87.       char *end;
  88.   
  89.       end = element+size;
  90. !     if (element != argv[1]) {
  91. !         while ((*end != 0) && !isspace(*end)) {
  92. !         end++;
  93. !         }
  94.       }
  95.       savedChar = *end;
  96.       *end = 0;
  97. ***************
  98. *** 963,969 ****
  99.       char **argv;            /* Argument strings. */
  100.   {
  101.       char *p1, *p2, *element, savedChar, *dummy;
  102. !     int i, first, last, count, result, size, brace;
  103.   
  104.       if (argc < 4) {
  105.       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  106. --- 964,970 ----
  107.       char **argv;            /* Argument strings. */
  108.   {
  109.       char *p1, *p2, *element, savedChar, *dummy;
  110. !     int i, first, last, count, result, size;
  111.   
  112.       if (argc < 4) {
  113.       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  114. ***************
  115. *** 993,1002 ****
  116.        */
  117.   
  118.       size = 0;
  119. -     brace = 0;
  120.       element = argv[1];
  121.       for (count = 0, p1 = argv[1]; (count < first) && (*p1 != 0); count++) {
  122. !     result = TclFindElement(interp, p1, &element, &p1, &size, &brace);
  123.       if (result != TCL_OK) {
  124.           return result;
  125.       }
  126. --- 994,1003 ----
  127.        */
  128.   
  129.       size = 0;
  130.       element = argv[1];
  131.       for (count = 0, p1 = argv[1]; (count < first) && (*p1 != 0); count++) {
  132. !     result = TclFindElement(interp, p1, &element, &p1, &size,
  133. !         (int *) NULL);
  134.       if (result != TCL_OK) {
  135.           return result;
  136.       }
  137. ***************
  138. *** 1020,1031 ****
  139.       }
  140.   
  141.       /*
  142. !      * Add the elements up through "first" to the result.
  143.        */
  144.   
  145.       p1 = element+size;
  146. !     if (brace) {
  147. !     p1++;
  148.       }
  149.       savedChar = *p1;
  150.       *p1 = 0;
  151. --- 1021,1036 ----
  152.       }
  153.   
  154.       /*
  155. !      * Add the elements before "first" to the result.  Be sure to
  156. !      * include quote or brace characters that might terminate the
  157. !      * last of these elements.
  158.        */
  159.   
  160.       p1 = element+size;
  161. !     if (element != argv[1]) {
  162. !     while ((*p1 != 0) && !isspace(*p1)) {
  163. !         p1++;
  164. !     }
  165.       }
  166.       savedChar = *p1;
  167.       *p1 = 0;
  168.