Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zle interface improvement



The following files fail to patch (I'm using a dual P166-based Linux
system with an unpatched version of zsh 3.1.0):
globals.h
zsh.h
The rej files are attached... 

On Tue, 24 Dec 1996, Zefram wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> 
> This patch removes another source of variation in the module interface.
> Currently the ZLE entry points are only accessed via pointers if ZLE
> is not linked in: this means that a module (other than ZLE itself) that
> wants to call one of these functions needs to know whether ZLE is linked
> in or not.  This patch makes the pointers always be used, except from
> within the ZLE module itself -- the only module that can be sure these
> functions will always be in the same executable as itself.
> 
> There is a small extra overhead when ZLE is linked in.  But this is less
> overhead than we get from making ZLE a module, and the vast majority of
> calls to these functions are from within ZLE and so are not slowed down
> at all.
> 
>  -zefram
> 
>       *** Src/globals.h	1996/12/22 09:11:45	1.29
>       --- Src/globals.h	1996/12/24 01:10:18
>       ***************
>       *** 563,583 ****
>         /* flag for whether terminal has automargin (wraparound) capability */
>         EXTERN int hasam;
>         
>       ! #ifdef UNLINKED_XMOD_zle
>       ! # ifdef GLOBALS
>       ! void (*trashzleptr) _((void)) = noop_function;
>       ! unsigned char * (*zlereadptr) _((char *lp, char *rp)) = load_zleread;
>       ! void (*spaceinlineptr) _((int)) = noop_function_int;
>       ! void (*gotwordptr) _((void)) = noop_function;
>       ! void (*refreshptr) _((void)) = noop_function;
>       ! # else /* !GLOBALS */
>       ! extern void (*trashzleptr) _((void));
>       ! extern unsigned char * (*zlereadptr) _((char *lp, char *rp));
>       ! extern void (*spaceinlineptr) _((int));
>       ! extern void (*gotwordptr) _((void));
>       ! extern void (*refreshptr) _((void));
>       ! # endif /* !GLOBALS */
>       ! #endif /* UNLINKED_XMOD_zle */
>         
>         /* pid of process undergoing 'process substitution' */
>          
>       --- 563,577 ----
>         /* flag for whether terminal has automargin (wraparound) capability */
>         EXTERN int hasam;
>         
>       ! /* ZLE entry point pointers */
>       ! 
>       ! typedef void (*ZleVoidFn) _((void));
>       ! typedef void (*ZleVoidIntFn) _((int));
>       ! typedef unsigned char * (*ZleReadFn) _((char *, char *));
>       ! 
>       ! extern ZleVoidFn trashzleptr, gotwordptr, refreshptr;
>       ! extern ZleVoidIntFn spaceinlineptr;
>       ! extern ZleReadFn zlereadptr;
>         
>         /* pid of process undergoing 'process substitution' */
>          
>       *** Src/init.c	1996/12/22 09:11:45	1.29
>       --- Src/init.c	1996/12/24 01:22:50
>       ***************
>       *** 779,781 ****
>       --- 779,835 ----
>         #include "bltinmods.list"
>         #undef DOMOD
>         }
>       + 
>       + /* ZLE entry point pointers.  They are defined here because the initial *
>       +  * values depend on whether ZLE is linked in or not -- if it is, we     *
>       +  * avoid wasting space with the fallback functions.  No other source    *
>       +  * file needs to know which modules are linked in.                      */
>       + 
>       + #ifdef LINKED_XMOD_zle
>       + 
>       + ZleVoidFn trashzleptr;
>       + ZleVoidFn gotwordptr;
>       + ZleVoidFn refreshptr;
>       + ZleVoidIntFn spaceinlineptr;
>       + ZleReadFn zlereadptr;
>       + 
>       + #else /* !LINKED_XMOD_zle */
>       + 
>       + ZleVoidFn trashzleptr = noop_function;
>       + ZleVoidFn gotwordptr = noop_function;
>       + ZleVoidFn refreshptr = noop_function;
>       + ZleVoidIntFn spaceinlineptr = noop_function_int;
>       + ZleReadFn zlereadptr = fallback_zleread;
>       + 
>       + /**/
>       + void
>       + noop_function(void)
>       + {
>       +     /* do nothing */
>       + }
>       + 
>       + /**/
>       + void
>       + noop_function_int(int nothing)
>       + {
>       +     /* do nothing */
>       + }
>       + 
>       + /**/
>       + unsigned char *
>       + fallback_zleread(char *lp, char *rp)
>       + {
>       +     char *pptbuf;
>       +     int pptlen;
>       + 
>       + #ifdef UNLINKED_XMOD_zle
>       +     if (load_module("zle"))
>       + 	return zleread(lp, rp);
>       + #endif /* UNLINKED_XMOD_zle */
>       +     pptbuf = putprompt(lp, &pptlen, NULL, 1);
>       +     write(2, (WRITE_ARG_2_T)pptbuf, pptlen);
>       +     free(pptbuf);
>       +     return (unsigned char *)shingetline();
>       + }
>       + 
>       + #endif /* !LINKED_XMOD_zle */
>       *** Src/module.c	1996/12/24 00:15:31	1.16
>       --- Src/module.c	1996/12/24 01:14:07
>       ***************
>       *** 464,539 ****
>             return ret;
>         }
>         
>       - #ifdef UNLINKED_XMOD_zle
>       - typedef void (*Voidfn) _((void));
>       - 
>       - static struct symbols {
>       -     char *nam;
>       -     Voidfn *fn;
>       - } zle_syms[] = {
>       - #ifdef DLSYM_NEEDS_UNDERSCORE
>       -     { "_trashzle", &trashzleptr },
>       -     { "_zleread", (Voidfn *) &zlereadptr },
>       -     { "_spaceinline", (Voidfn *) &spaceinlineptr },
>       -     { "_gotword", &gotwordptr },
>       -     { "_refresh", &refreshptr },
>       -     { "_zle_init", NULL }
>       - #else
>       -     { "trashzle", &trashzleptr },
>       -     { "zleread", (Voidfn *) &zlereadptr },
>       -     { "spaceinline", (Voidfn *) &spaceinlineptr },
>       -     { "gotword", &gotwordptr },
>       -     { "refresh", &refreshptr },
>       -     { NULL, NULL }
>       - #endif
>       - };
>       - 
>       - /**/
>       - int
>       - load_zle_syms(void *handle)
>       - {
>       -     struct symbols *sym;
>       -     Voidfn fn;
>       - 
>       -     for (sym = zle_syms; sym->nam; sym++) {
>       - 	if (!handle || !(fn = (Voidfn) dlsym(handle, sym->nam))) {
>       - 	    zerr("unable to load zle: %s", dlerror(), 0);
>       - 	    return -1;
>       - 	}
>       - 	*sym->fn = fn;
>       -     }
>       -     return 0;
>       - }
>       - 
>       - /**/
>       - void
>       - noop_function(void)
>       - {
>       -     /* do nothing */
>       - }
>       - 
>       - /**/
>       - void
>       - noop_function_int(int nothing)
>       - {
>       -     /* do nothing */
>       - }
>       - 
>       - /**/
>       - unsigned char *
>       - load_zleread(char *lp, char *rp)
>       - {
>       -     if (load_module("zle"))
>       - 	return zleread(lp, rp);
>       -     else {
>       - 	char *pptbuf;
>       - 	int pptlen;
>       - 
>       - 	pptbuf = putprompt(lp, &pptlen, NULL, 1);
>       - 	write(2, (WRITE_ARG_2_T)pptbuf, pptlen);
>       - 	free(pptbuf);
>       - 	return (unsigned char *)shingetline();
>       -     }
>       - }
>       - #endif /* UNLINKED_XMOD_zle */
>         #endif /* DYNAMIC */
>       --- 464,467 ----
>       *** Src/zsh.h	1996/12/23 00:07:16	1.35
>       --- Src/zsh.h	1996/12/24 00:46:11
>       ***************
>       *** 40,52 ****
>         
>         #include "zshxmods.h"
>         
>       ! #if defined(UNLINKED_XMOD_zle) && !defined(IN_ZLE)
>         # define trashzle()      trashzleptr()
>         # define zleread(X,Y)    zlereadptr(X,Y)
>         # define spaceinline(X)  spaceinlineptr(X)
>         # define gotword()       gotwordptr()
>         # define refresh()       refreshptr()
>       ! #endif
>         
>         /* A few typical macros */
>         #define minimum(a,b)  ((a) < (b) ? (a) : (b))
>       --- 40,52 ----
>         
>         #include "zshxmods.h"
>         
>       ! #ifndef IN_ZLE
>         # define trashzle()      trashzleptr()
>         # define zleread(X,Y)    zlereadptr(X,Y)
>         # define spaceinline(X)  spaceinlineptr(X)
>         # define gotword()       gotwordptr()
>         # define refresh()       refreshptr()
>       ! #endif /* !IN_ZLE */
>         
>         /* A few typical macros */
>         #define minimum(a,b)  ((a) < (b) ? (a) : (b))
>       ***************
>       *** 1265,1273 ****
>         #include "signals.h"
>         #include "prototypes.h"
>         #include "globals.h"
>       - #if defined(LINKED_XMOD_zle) && !defined(MODULE)
>       - # include "zle.h"
>       - #endif
>         #include "hashtable.h"
>         
>         #endif /*!_ZSH_H*/
>       --- 1265,1270 ----
>       *** Src/Zle/zle.h	1996/12/22 04:50:56	1.2
>       --- Src/Zle/zle.h	1996/12/24 00:46:34
>       ***************
>       *** 32,38 ****
>         #ifndef _ZLE_H
>         #define _ZLE_H
>         
>       - #define IN_ZLE
>         #include "zsh.h"
>         
>         #ifdef ZLEGLOBALS
>       --- 32,37 ----
>       *** Src/Zle/zle_bindings.c	1996/12/22 01:13:39	1.1.1.1
>       --- Src/Zle/zle_bindings.c	1996/12/24 00:46:42
>       ***************
>       *** 29,34 ****
>       --- 29,35 ----
>          *
>          */
>         
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         struct zlecmd zlecmds[] =
>       *** Src/Zle/zle_hist.c	1996/12/22 01:13:39	1.1.1.1
>       --- Src/Zle/zle_hist.c	1996/12/24 00:46:48
>       ***************
>       *** 29,34 ****
>       --- 29,35 ----
>          *
>          */
>         
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         /**/
>       *** Src/Zle/zle_main.c	1996/12/23 00:07:22	1.4
>       --- Src/Zle/zle_main.c	1996/12/24 01:07:46
>       ***************
>       *** 45,50 ****
>       --- 45,51 ----
>          */
>         
>         #define ZLEGLOBALS
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         static int embindtab[256], eofchar, eofsent;
>       ***************
>       *** 1557,1566 ****
>         int
>         boot_zle(Module m)
>         {
>       ! #ifdef MODULE
>       !     if (load_zle_syms(m->handle))
>       ! 	return -1;
>       ! #endif
>             createcompctltable();   /* create hash table for compctls          */
>         
>             /* create hash tables for multi-character key bindings */
>       --- 1558,1570 ----
>         int
>         boot_zle(Module m)
>         {
>       !     /* Set up editor entry points */
>       !     trashzleptr = trashzle;
>       !     gotwordptr = gotword;
>       !     refreshptr = refresh;
>       !     spaceinlineptr = spaceinline;
>       !     zlereadptr = zleread;
>       ! 
>             createcompctltable();   /* create hash table for compctls          */
>         
>             /* create hash tables for multi-character key bindings */
>       *** Src/Zle/zle_misc.c	1996/12/22 01:13:39	1.1.1.1
>       --- Src/Zle/zle_misc.c	1996/12/24 00:47:00
>       ***************
>       *** 29,34 ****
>       --- 29,35 ----
>          *
>          */
>         
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         /**/
>       *** Src/Zle/zle_move.c	1996/12/22 01:13:39	1.1.1.1
>       --- Src/Zle/zle_move.c	1996/12/24 00:47:05
>       ***************
>       *** 29,34 ****
>       --- 29,35 ----
>          *
>          */
>         
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         static vimarkcs[27], vimarkline[27];
>       *** Src/Zle/zle_refresh.c	1996/12/22 01:13:39	1.1.1.1
>       --- Src/Zle/zle_refresh.c	1996/12/24 00:47:16
>       ***************
>       *** 29,34 ****
>       --- 29,35 ----
>          *
>          */
>         
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         #ifdef HAVE_SELECT
>       *** Src/Zle/zle_tricky.c	1996/12/22 22:26:34	1.4
>       --- Src/Zle/zle_tricky.c	1996/12/24 00:47:41
>       ***************
>       *** 29,34 ****
>       --- 29,35 ----
>          *
>          */
>         
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         /* The main part of ZLE maintains the line being edited as binary data, *
>       *** Src/Zle/zle_utils.c	1996/12/22 01:13:39	1.1.1.1
>       --- Src/Zle/zle_utils.c	1996/12/24 00:47:47
>       ***************
>       *** 29,34 ****
>       --- 29,35 ----
>          *
>          */
>         
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         /* make sure that the line buffer has at least sz chars */
>       *** Src/Zle/zle_vi.c	1996/12/22 01:13:39	1.1.1.1
>       --- Src/Zle/zle_vi.c	1996/12/24 00:47:53
>       ***************
>       *** 29,34 ****
>       --- 29,35 ----
>          *
>          */
>         
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         static int lastmult, lastbuf, lastgotmult, lastgotbuf, inrepeat, vichgrepeat;
>       *** Src/Zle/zle_word.c	1996/12/22 01:13:39	1.1.1.1
>       --- Src/Zle/zle_word.c	1996/12/24 00:47:58
>       ***************
>       *** 29,34 ****
>       --- 29,35 ----
>          *
>          */
>         
>       + #define IN_ZLE
>         #include "zle.h"
>         
>         /**/
> 
> -----BEGIN PGP SIGNATURE-----
> Version: 2.6.2
> 
> iQCVAwUBMr86UHD/+HJTpU/hAQEUdgP/b78wsD8yFozXeWx+cUzpdU6S+L6Ved3o
> SNhvySTqzQ0kXT3V17Ax3eJYVgoIg7c0KgYFjIwgRDptLVtR/rhLaq5boY0F626P
> 7bSKfE0IsrBZ9D2CwSzrDDtcNKbJ/DlVN7pduScxfv7Ewst1TqqPqTQDYPqiv4kM
> HzfgVJf/L2Q=
> =YlYF
> -----END PGP SIGNATURE-----
> 
> 
> 

Hasan Diwan
hdiwan@xxxxxxxxxxxxx
***************
*** 40,52 ****
  
  #include "zshxmods.h"
  
! #if defined(UNLINKED_XMOD_zle) && !defined(IN_ZLE)
  # define trashzle()      trashzleptr()
  # define zleread(X,Y)    zlereadptr(X,Y)
  # define spaceinline(X)  spaceinlineptr(X)
  # define gotword()       gotwordptr()
  # define refresh()       refreshptr()
! #endif
  
  /* A few typical macros */
  #define minimum(a,b)  ((a) < (b) ? (a) : (b))
--- 40,52 ----
  
  #include "zshxmods.h"
  
! #ifndef IN_ZLE
  # define trashzle()      trashzleptr()
  # define zleread(X,Y)    zlereadptr(X,Y)
  # define spaceinline(X)  spaceinlineptr(X)
  # define gotword()       gotwordptr()
  # define refresh()       refreshptr()
! #endif /* !IN_ZLE */
  
  /* A few typical macros */
  #define minimum(a,b)  ((a) < (b) ? (a) : (b))
***************
*** 1265,1273 ****
  #include "signals.h"
  #include "prototypes.h"
  #include "globals.h"
- #if defined(LINKED_XMOD_zle) && !defined(MODULE)
- # include "zle.h"
- #endif
  #include "hashtable.h"
  
  #endif /*!_ZSH_H*/
--- 1265,1270 ----
  #include "signals.h"
  #include "prototypes.h"
  #include "globals.h"
  #include "hashtable.h"
  
  #endif /*!_ZSH_H*/
***************
*** 563,583 ****
  /* flag for whether terminal has automargin (wraparound) capability */
  EXTERN int hasam;
  
! #ifdef UNLINKED_XMOD_zle
! # ifdef GLOBALS
! void (*trashzleptr) _((void)) = noop_function;
! unsigned char * (*zlereadptr) _((char *lp, char *rp)) = load_zleread;
! void (*spaceinlineptr) _((int)) = noop_function_int;
! void (*gotwordptr) _((void)) = noop_function;
! void (*refreshptr) _((void)) = noop_function;
! # else /* !GLOBALS */
! extern void (*trashzleptr) _((void));
! extern unsigned char * (*zlereadptr) _((char *lp, char *rp));
! extern void (*spaceinlineptr) _((int));
! extern void (*gotwordptr) _((void));
! extern void (*refreshptr) _((void));
! # endif /* !GLOBALS */
! #endif /* UNLINKED_XMOD_zle */
  
  /* pid of process undergoing 'process substitution' */
   
--- 563,577 ----
  /* flag for whether terminal has automargin (wraparound) capability */
  EXTERN int hasam;
  
! /* ZLE entry point pointers */
! 
! typedef void (*ZleVoidFn) _((void));
! typedef void (*ZleVoidIntFn) _((int));
! typedef unsigned char * (*ZleReadFn) _((char *, char *));
! 
! extern ZleVoidFn trashzleptr, gotwordptr, refreshptr;
! extern ZleVoidIntFn spaceinlineptr;
! extern ZleReadFn zlereadptr;
  
  /* pid of process undergoing 'process substitution' */
   


Messages sorted by: Reverse Date, Date, Thread, Author