home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!agate!sprite.Berkeley.EDU!ouster
- From: ouster@sprite.Berkeley.EDU (John Ousterhout)
- Newsgroups: comp.lang.tcl
- Subject: Re: Possible bug in lreplace
- Date: 22 Jan 1993 22:08:02 GMT
- Organization: U.C. Berkeley Sprite Project
- Lines: 155
- Distribution: world
- Message-ID: <1jpr82$5l6@agate.berkeley.edu>
- References: <1993Jan7.205040.19153@bnr.ca>
- NNTP-Posting-Host: tyranny.berkeley.edu
-
- In article <1993Jan7.205040.19153@bnr.ca>, jamensky@bnr.ca (Mark Jamensky) writes:
- |> The problem is exhibited as follows in Tcl version 6.4:
- |>
- |> set l1 { a b "c c" d e f}
- |>
- |> lreplace $l1 2 2
- |> returns: a b d e f
- |>
- |> lreplace $l1 3 3
- |> returns: a b "c c e f
- |>
- |> For some reason the second quote gets removed. Has anyone else seen this and
- |> if so is there a patch?
- |>
- |> Thanks in advance.
- |>
- |> -- | Bell-Northern Research - Ottawa | Conform or be cast out.
- |> Mark Jamensky | jamensky@bnr.ca (613) 765-4942 | - Rush
-
- Here's a patch to tclCmdIL.c that fixes this problem, plus a similar
- problem that occurs in "linsert".
-
- *** /tmp/,RCSt1150338 Fri Jan 22 14:05:27 1993
- --- tclCmdIL.c Fri Jan 22 14:03:35 1993
- ***************
- *** 705,711 ****
- char **argv; /* Argument strings. */
- {
- char *p, *element, savedChar;
- ! int i, index, count, result, size, brace;
-
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- --- 705,711 ----
- char **argv; /* Argument strings. */
- {
- char *p, *element, savedChar;
- ! int i, index, count, result, size;
-
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- ***************
- *** 722,731 ****
- */
-
- size = 0;
- - brace = 0;
- element = argv[1];
- for (count = 0, p = argv[1]; (count < index) && (*p != 0); count++) {
- ! result = TclFindElement(interp, p, &element, &p, &size, &brace);
- if (result != TCL_OK) {
- return result;
- }
- --- 722,730 ----
- */
-
- size = 0;
- element = argv[1];
- for (count = 0, p = argv[1]; (count < index) && (*p != 0); count++) {
- ! result = TclFindElement(interp, p, &element, &p, &size, (int *) NULL);
- if (result != TCL_OK) {
- return result;
- }
- ***************
- *** 736,743 ****
- char *end;
-
- end = element+size;
- ! if (brace) {
- ! end++;
- }
- savedChar = *end;
- *end = 0;
- --- 735,744 ----
- char *end;
-
- end = element+size;
- ! if (element != argv[1]) {
- ! while ((*end != 0) && !isspace(*end)) {
- ! end++;
- ! }
- }
- savedChar = *end;
- *end = 0;
- ***************
- *** 963,969 ****
- char **argv; /* Argument strings. */
- {
- char *p1, *p2, *element, savedChar, *dummy;
- ! int i, first, last, count, result, size, brace;
-
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- --- 964,970 ----
- char **argv; /* Argument strings. */
- {
- char *p1, *p2, *element, savedChar, *dummy;
- ! int i, first, last, count, result, size;
-
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- ***************
- *** 993,1002 ****
- */
-
- size = 0;
- - brace = 0;
- element = argv[1];
- for (count = 0, p1 = argv[1]; (count < first) && (*p1 != 0); count++) {
- ! result = TclFindElement(interp, p1, &element, &p1, &size, &brace);
- if (result != TCL_OK) {
- return result;
- }
- --- 994,1003 ----
- */
-
- size = 0;
- element = argv[1];
- for (count = 0, p1 = argv[1]; (count < first) && (*p1 != 0); count++) {
- ! result = TclFindElement(interp, p1, &element, &p1, &size,
- ! (int *) NULL);
- if (result != TCL_OK) {
- return result;
- }
- ***************
- *** 1020,1031 ****
- }
-
- /*
- ! * Add the elements up through "first" to the result.
- */
-
- p1 = element+size;
- ! if (brace) {
- ! p1++;
- }
- savedChar = *p1;
- *p1 = 0;
- --- 1021,1036 ----
- }
-
- /*
- ! * Add the elements before "first" to the result. Be sure to
- ! * include quote or brace characters that might terminate the
- ! * last of these elements.
- */
-
- p1 = element+size;
- ! if (element != argv[1]) {
- ! while ((*p1 != 0) && !isspace(*p1)) {
- ! p1++;
- ! }
- }
- savedChar = *p1;
- *p1 = 0;
-