From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-request@euclid.skiles.gatech.edu Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.6/8.7.3) with ESMTP id AAA07981 for ; Tue, 26 Nov 1996 00:26:57 +1100 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id IAA17626; Mon, 25 Nov 1996 08:21:53 -0500 (EST) Resent-Date: Mon, 25 Nov 1996 08:21:53 -0500 (EST) Message-Id: <199611251322.OAA26377@hydra.ifh.de> X-Authentication-Warning: hydra.ifh.de: Host pws@localhost didn't use HELO protocol To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Re: big key binding patch In-reply-to: "Zefram"'s message of "Sun, 24 Nov 1996 15:30:04 MET." <19811.199611241530@stone.dcs.warwick.ac.uk> Date: Mon, 25 Nov 1996 14:22:20 +0100 From: Peter Stephenson Resent-Message-ID: <"P1JHN1.0.KJ4.nrPco"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2470 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu This key binding overhaul was certainly necessary. There's one bug: the str Key element doesn't get set to null in addkeybindentry(), causing `already free' error messages later. However, is the zfree(cur->str) immediately after the addkeybindentry() in bin_bindkey() still required? It's not quite clear to me since the test at the end of addkeybindentry() is different (and so is the free, but that must be essentially cosmetic). There's also some not-bugs with uninitialized variables that gcc complains about which I've fixed anyway (that's the current policy, not clear how necessary it really is but it eliminates a source of complaints). I still had -pedantic turned on when I first compiled this and gcc doesn't like having to initialise the keybindtab elements of list[] in unbindzlefunc() at load time. That probably needs fixing (if there are any genuinely pedantic compilers around) but I couldn't think of a portable fix without more verbose code. *** Src/zle_main.c~ Mon Nov 25 09:24:14 1996 --- Src/zle_main.c Mon Nov 25 14:00:26 1996 *************** *** 937,943 **** Key addkeybindentry(int *tab, HashTable keytab, char *str, int len) { ! Key ret; int p, added=0; char *buf = zalloc(len*2 + 1); --- 937,943 ---- Key addkeybindentry(int *tab, HashTable keytab, char *str, int len) { ! Key ret = NULL; int p, added=0; char *buf = zalloc(len*2 + 1); *************** *** 958,965 **** if(p == len) ret = ky; } ! if(ret->func == z_sendstring) free(ret->str); return ret; } --- 958,967 ---- if(p == len) ret = ky; } ! if(ret->func == z_sendstring) { free(ret->str); + ret->str = NULL; + } return ret; } *************** *** 1052,1058 **** while (*argv) { Key ky = NULL; char *s, *smeta; ! int func, len; if (ops['u'] || ops['U']) { /* unbind all references to given function */ --- 1054,1060 ---- while (*argv) { Key ky = NULL; char *s, *smeta; ! int func = 0, len; if (ops['u'] || ops['U']) { /* unbind all references to given function */ *************** *** 1301,1308 **** void unbindzlefunc(int ifunc, int notall) { ! int i, *tab; ! HashTable keytab; struct { int *tab; HashTable keytab; --- 1303,1310 ---- void unbindzlefunc(int ifunc, int notall) { ! int i, *tab = 0; ! HashTable keytab = NULL; struct { int *tab; HashTable keytab; -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413 Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.