zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Re: big key binding patch
Date: Mon, 25 Nov 1996 14:22:20 +0100	[thread overview]
Message-ID: <199611251322.OAA26377@hydra.ifh.de> (raw)
In-Reply-To: "Zefram"'s message of "Sun, 24 Nov 1996 15:30:04 MET." <19811.199611241530@stone.dcs.warwick.ac.uk>

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 <pws@ifh.de>       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.


  reply	other threads:[~1996-11-25 13:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-24 15:30 Zefram
1996-11-25 13:22 ` Peter Stephenson [this message]
1996-11-25 16:02   ` Zefram
1996-11-25 18:57     ` Thorsten Meinecke
1996-11-25 22:05       ` Zefram
1996-11-26  8:46         ` Zefram
1996-11-26 12:03 Duncan Sinclair
1996-11-26 12:10 ` Zefram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199611251322.OAA26377@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).