From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id LAA20018 for ; Mon, 13 May 1996 11:20:45 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id VAA12961; Sun, 12 May 1996 21:13:09 -0400 (EDT) Resent-Date: Sun, 12 May 1996 21:13:09 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199605130112.DAA00742@hzoli.ppp.cs.elte.hu> Subject: Re: Minor change for new isearch code To: wayne@tenor.clarinet.com (Wayne Davison) Date: Mon, 13 May 1996 03:12:19 +0200 (MET DST) Cc: zsh-workers@math.gatech.edu In-Reply-To: <199605121848.LAA03420@tenor.clari.net> from Wayne Davison at "May 12, 96 11:48:25 am" X-Mailer: ELM [version 2.4ME+ PL11 (25)] MIME-Version: 1.0 Content-Type: application/pgp; format=text; x-action=sign Content-Transfer-Encoding: 7bit Resent-Message-ID: <"SizcY3.0.RA3.aoebn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1059 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- Wayne Davison wrote: > Here's a minor tweak for the incremental search code based on my last > patch. It just makes the startup case where you begin the search from > somewhere in the history a little more efficient by using the metafied > history entry directly rather than building one from "line". This is not really a good idea. If I go back in the history, modify a line and start an isearch the modifications will disappear. That happens even without this patch when I delete in isearch mode or if I use send-break. The biggest probles with this happens when I add something to the end of a previous history line, start an isearch and abort it with send-break. It restores the original cursor position but not the original line so the cursor position becomes bigger than the length of the line. I think the patch below fixes these problems. I added a new META_HEAPDUP method to metafy for that (it is not necessary as META_DUP/free() can also be used here but it may be usefull in other places). Zoltan *** Src/zsh.h 1996/05/02 23:45:29 2.9 --- Src/zsh.h 1996/05/12 20:59:24 *************** *** 198,203 **** --- 198,204 ---- #define META_DUP 3 #define META_ALLOC 4 #define META_NOALLOC 5 + #define META_HEAPDUP 6 /**************************/ *** Src/utils.c 1996/05/12 02:11:53 2.19 --- Src/utils.c 1996/05/13 00:38:32 *************** *** 2794,2800 **** * sting should be at most PATH_MAX long. * * META_ALLOC: allocate memory for the new string with zalloc(). * * META_DUP: leave buf unchanged and allocate space for the return * ! * value even if buf does not contains special characters */ /**/ char * --- 2794,2801 ---- * sting should be at most PATH_MAX long. * * META_ALLOC: allocate memory for the new string with zalloc(). * * META_DUP: leave buf unchanged and allocate space for the return * ! * value even if buf does not contains special characters * ! * META_HEAPDUP: same as META_DUP, but uses the heap */ /**/ char * *************** *** 2813,2819 **** if (imeta(*e++)) meta++; ! if (meta || heap == META_DUP) { switch (heap) { case META_REALLOC: buf = zrealloc(buf, len + meta + 1); --- 2814,2820 ---- if (imeta(*e++)) meta++; ! if (meta || heap == META_DUP || heap == META_HEAPDUP) { switch (heap) { case META_REALLOC: buf = zrealloc(buf, len + meta + 1); *************** *** 2824,2829 **** --- 2825,2833 ---- case META_ALLOC: case META_DUP: buf = memcpy(zalloc(len + meta + 1), buf, len); + break; + case META_HEAPDUP: + buf = memcpy(halloc(len + meta + 1), buf, len); break; case META_STATIC: #ifdef DEBUG *** Src/zle_hist.c 1996/05/12 11:31:09 2.9 --- Src/zle_hist.c 1996/05/13 00:43:07 *************** *** 626,632 **** char *s, *ibuf = halloc(80), *sbuf = ibuf + FIRST_SEARCH_CHAR; int sbptr = 0, cmd, top_spot = 0, pos, sibuf = 80; int nomatch = 0, skip_line = 0, skip_pos = 0; ! int odir = dir, *obindtab = bindtab; strcpy(ibuf, ISEARCH_PROMPT); memcpy(ibuf + NORM_PROMPT_POS, (dir == 1) ? "fwd" : "bck", 3); --- 626,633 ---- char *s, *ibuf = halloc(80), *sbuf = ibuf + FIRST_SEARCH_CHAR; int sbptr = 0, cmd, top_spot = 0, pos, sibuf = 80; int nomatch = 0, skip_line = 0, skip_pos = 0; ! int odir = dir, *obindtab = bindtab, oldhistline = histline; ! char *oldline = metafy((char *) line, ll, META_HEAPDUP); strcpy(ibuf, ISEARCH_PROMPT); memcpy(ibuf + NORM_PROMPT_POS, (dir == 1) ? "fwd" : "bck", 3); *************** *** 708,714 **** if ((cmd = getkeycmd()) < 0 || cmd == z_sendbreak) { int i; get_isrch_spot(0, &histline, &pos, &i, &sbptr, &dir, &nomatch); ! s = qgetevent(histline); setline(s); cs = i; break; --- 709,718 ---- if ((cmd = getkeycmd()) < 0 || cmd == z_sendbreak) { int i; get_isrch_spot(0, &histline, &pos, &i, &sbptr, &dir, &nomatch); ! if (oldhistline != histline) ! s = qgetevent(histline); ! else ! s = oldline; setline(s); cs = i; break; *************** *** 734,740 **** statusline = ibuf; skip_pos = 1; } ! s = qgetevent(histline); if (!sbptr || (sbptr == 1 && sbuf[0] == '^')) { int i = cs; setline(s); --- 738,747 ---- statusline = ibuf; skip_pos = 1; } ! if (histline != oldhistline) ! s = qgetevent(histline); ! else ! s = oldline; if (!sbptr || (sbptr == 1 && sbuf[0] == '^')) { int i = cs; setline(s); -----BEGIN PGP SIGNATURE----- Version: 2.6.3i Charset: noconv iQCVAwUBMZaMLwupSCiLN749AQGYggP8CIkuEkL/rMNCHSsugl/17coQs6uQODVu 5WEKOaGlsRLHH0QatLc1sT0MbFxxfqmJfEniu79CBDZ0+34E0g/gs+5VzZSzAiO7 nlgJjUX1a1AarMfpeRNyiuU6wLFKSYi2tt7AcXCI2Vg3HAj7tx50QuQOAKn+Ptw2 qCgU7XCm1MQ= =GDGw -----END PGP SIGNATURE-----