From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: BUG: using z parameter expansion flag in a completion function
Date: Tue, 23 May 2000 10:17:59 +0200 (MET DST) [thread overview]
Message-ID: <200005230817.KAA22676@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Felix Rosencrantz's message of Mon, 22 May 2000 20:13:03 -0700 (PDT)
Felix Rosencrantz wrote:
> There seems to be a bug when using the z parameter expansion flag in
> a completion function:
> host% bindkey -e; autoload -U compinit; compinit -D
> host% _tst () { compadd -- ${(z)history[1]} }
> host% compdef _tst tst
> host% tst a<TAB>
>
> Generates many of these error messages:
> BUG: attempt to free storage at invalid address
Oops, forgot to save/restore some variables.
The patch moves gotword() into the core, adding functions and
-pointers to save and restore wb/we seemed too silly.
Bye
Sven
Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.5
diff -u -r1.5 hist.c
--- Src/hist.c 2000/05/05 07:42:36 1.5
+++ Src/hist.c 2000/05/23 08:17:59
@@ -2059,6 +2059,7 @@
bufferwords(LinkList list, char *buf, int *index)
{
int num = 0, cur = -1, got = 0, ne = noerrs, ocs = cs;
+ int owb = wb, owe = we, oadx = addedx, ozp = zleparse;
char *p;
if (!list)
@@ -2131,10 +2132,14 @@
noaliases = 0;
strinend();
inpop();
- errflag = zleparse = 0;
+ errflag = 0;
+ zleparse = ozp;
noerrs = ne;
lexrestore();
cs = ocs;
+ wb = owb;
+ we = owe;
+ addedx = oadx;
if (index)
*index = cur;
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.3
diff -u -r1.3 init.c
--- Src/init.c 2000/04/30 18:51:58 1.3
+++ Src/init.c 2000/05/23 08:17:59
@@ -1025,8 +1025,6 @@
/**/
mod_export ZleVoidFn trashzleptr = noop_function;
/**/
-mod_export ZleVoidFn gotwordptr = noop_function;
-/**/
mod_export ZleVoidFn refreshptr = noop_function;
/**/
mod_export ZleVoidIntFn spaceinlineptr = noop_function_int;
@@ -1036,7 +1034,6 @@
#else /* !LINKED_XMOD_zshQszle */
mod_export ZleVoidFn trashzleptr = noop_function;
-mod_export ZleVoidFn gotwordptr = noop_function;
mod_export ZleVoidFn refreshptr = noop_function;
mod_export ZleVoidIntFn spaceinlineptr = noop_function_int;
# ifdef UNLINKED_XMOD_zshQszle
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.5
diff -u -r1.5 lex.c
--- Src/lex.c 2000/05/04 10:44:25 1.5
+++ Src/lex.c 2000/05/23 08:18:00
@@ -93,6 +93,11 @@
/**/
mod_export int addedx;
+/* wb and we hold the beginning/end position of the word we are completing. */
+
+/**/
+mod_export int wb, we;
+
/* 1 if aliases should not be expanded */
/**/
@@ -1481,6 +1486,19 @@
}
#endif
return 0;
+}
+
+/* Called below to report word positions. */
+
+/**/
+mod_export void
+gotword(void)
+{
+ we = ll + 1 - inbufct + (addedx == 2 ? 1 : 0);
+ if (cs <= we) {
+ wb = ll - wordbeg + addedx;
+ zleparse = 0;
+ }
}
/* expand aliases and reserved words */
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.9
diff -u -r1.9 zsh.h
--- Src/zsh.h 2000/05/15 18:48:21 1.9
+++ Src/zsh.h 2000/05/23 08:18:00
@@ -30,7 +30,6 @@
#define trashzle() trashzleptr()
#define zleread(X,Y,H) zlereadptr(X,Y,H)
#define spaceinline(X) spaceinlineptr(X)
-#define gotword() gotwordptr()
#define zrefresh() refreshptr()
#define compctlread(N,A,O,R) compctlreadptr(N,A,O,R)
Index: Src/Zle/zle.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle.h,v
retrieving revision 1.1.1.11
diff -u -r1.1.1.11 zle.h
--- Src/Zle/zle.h 1999/11/08 19:39:05 1.1.1.11
+++ Src/Zle/zle.h 2000/05/23 08:18:00
@@ -30,7 +30,6 @@
#undef trashzle
#undef zleread
#undef spaceinline
-#undef gotword
#undef zrefresh
typedef struct widget *Widget;
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.2
diff -u -r1.2 zle_main.c
--- Src/Zle/zle_main.c 2000/05/02 15:52:44 1.2
+++ Src/Zle/zle_main.c 2000/05/23 08:18:01
@@ -1039,7 +1039,6 @@
{
/* Set up editor entry points */
trashzleptr = trashzle;
- gotwordptr = gotword;
refreshptr = zrefresh;
spaceinlineptr = spaceinline;
zlereadptr = zleread;
@@ -1116,7 +1115,6 @@
/* editor entry points */
trashzleptr = noop_function;
- gotwordptr = noop_function;
refreshptr = noop_function;
spaceinlineptr = noop_function_int;
zlereadptr = fallback_zleread;
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.11
diff -u -r1.11 zle_tricky.c
--- Src/Zle/zle_tricky.c 2000/05/22 14:50:08 1.11
+++ Src/Zle/zle_tricky.c 2000/05/23 08:18:01
@@ -58,11 +58,6 @@
/**/
mod_export char **clwords;
-/* wb and we hold the beginning/end position of the word we are completing. */
-
-/**/
-mod_export int wb, we;
-
/* offs is the cursor position within the tokenized *
* current word after removing nulargs. */
@@ -1690,19 +1685,6 @@
popheap();
return ret;
-}
-
-/* This is called from the lexer to give us word positions. */
-
-/**/
-void
-gotword(void)
-{
- we = ll + 1 - inbufct + (addedx == 2 ? 1 : 0);
- if (cs <= we) {
- wb = ll - wordbeg + addedx;
- zleparse = 0;
- }
}
/**/
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
reply other threads:[~2000-05-23 8:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200005230817.KAA22676@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/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).