From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16719 invoked from network); 12 May 1997 09:11:37 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 May 1997 09:11:37 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id EAA06818; Mon, 12 May 1997 04:54:44 -0400 (EDT) Resent-Date: Mon, 12 May 1997 04:54:44 -0400 (EDT) Message-Id: <199705120858.KAA24442@hydra.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Re: Core dump in 3.0.3-test5 In-reply-to: "Zoltan Hidvegi"'s message of "Mon, 12 May 1997 04:02:20 MET." <199705120802.EAA02116@hzoli.home> Date: Mon, 12 May 1997 10:58:10 +0200 From: Peter Stephenson Resent-Message-ID: <"QGTPX.0.Tg1.JhjTp"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3131 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Zoltan Hidvegi wrote: > > zagzig<1> mv zsh-3.0.3-test5 !#:^-tmp > > zsh: no such event: 1 > > zagzig<2> mv zsh-3.0.3-test5 !#:^-tmp > > mv zsh-3.0.3-test5 zsh-3.0.3-test5 tmp > > zsh: segmentation fault (core dumped) ./zsh > > Fix is below. You may not like this fix: There's another aspect to this, at least in 3.1.x after the latest history reorganisation. They symptom is that you get the previous line instead of the current one with any !# in completion. The short story is that I made non-interactive history expansions as in completion too different from the interactive sort. The following simplification will fix things up. It makes the counting of curhist more logical, too. *** Src/hist.c.has Fri May 9 11:29:08 1997 --- Src/hist.c Mon May 12 10:36:29 1997 *************** *** 44,50 **** #define HA_ACTIVE (1<<0) /* History mechanism is active */ #define HA_NOSTORE (1<<1) /* Don't store the line when finished */ #define HA_JUNKED (1<<2) /* Last history line was already junked */ - #define HA_NOINC (1<<3) /* Don't store, curhist not incremented */ extern int cs, ll; --- 44,49 ---- *************** *** 567,579 **** curhistent = gethistent(curhist); if (!curhistent->ftim) curhistent->ftim = time(NULL); if (interact && isset(SHINSTDIN) && !strin) { attachtty(mypgrp); - defev = curhist; - histactive = HA_ACTIVE; - curhist++; } else ! histactive = HA_NOINC; } /* compare current line with history entry using only text in words */ --- 566,578 ---- curhistent = gethistent(curhist); if (!curhistent->ftim) curhistent->ftim = time(NULL); + defev = curhist; + histactive = HA_ACTIVE; + curhist++; if (interact && isset(SHINSTDIN) && !strin) { attachtty(mypgrp); } else ! histactive |= HA_NOSTORE; } /* compare current line with history entry using only text in words */ *************** *** 638,649 **** int flag, save = 1; DPUTS(!chline, "BUG: chline is NULL in hend()"); ! if (histactive & (HA_NOSTORE|HA_NOINC)) { zfree(chline, hlinesz); zfree(chwords, chwordlen*sizeof(short)); chline = NULL; ! if (!(histactive & HA_NOINC)) ! curhist--; histactive = 0; return 1; } --- 637,647 ---- int flag, save = 1; DPUTS(!chline, "BUG: chline is NULL in hend()"); ! if (histactive & HA_NOSTORE) { zfree(chline, hlinesz); zfree(chwords, chwordlen*sizeof(short)); chline = NULL; ! curhist--; histactive = 0; return 1; } *************** *** 762,771 **** chwordpos--; /* make sure we're on a word start, not end */ /* If we're expanding an alias, we should overwrite the expansion * in the history. - * If we're in a string, we don't need the full history line - * and can overwrite also. */ ! if (((inbufflags & INP_ALIAS) || strin) && !(inbufflags & INP_HIST)) hwgetword = chwordpos; else hwgetword = -1; --- 760,767 ---- chwordpos--; /* make sure we're on a word start, not end */ /* If we're expanding an alias, we should overwrite the expansion * in the history. */ ! if ((inbufflags & INP_ALIAS) && !(inbufflags & INP_HIST)) hwgetword = chwordpos; else hwgetword = -1; -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413 Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.