* Segfault in zsh 4.1.0-dev-7 using select
@ 2003-02-16 15:01 Mikael Magnusson
2003-02-17 11:38 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2003-02-16 15:01 UTC (permalink / raw)
To: zsh-workers
Hi, this command makes zsh segfault for me, using version 4.1.0-dev-7
(also tried in -dev-6, and it works fine in 4.0.4 and 4.0.6)
select a in foo bar;do echo $a;done
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Segfault in zsh 4.1.0-dev-7 using select
2003-02-16 15:01 Segfault in zsh 4.1.0-dev-7 using select Mikael Magnusson
@ 2003-02-17 11:38 ` Peter Stephenson
2003-02-17 12:35 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2003-02-17 11:38 UTC (permalink / raw)
To: Mikael Magnusson, zsh-workers
Mikael Magnusson wrote:
> Hi, this command makes zsh segfault for me, using version 4.1.0-dev-7
> (also tried in -dev-6, and it works fine in 4.0.4 and 4.0.6)
> select a in foo bar;do echo $a;done
Thanks for spotting this, it's entirely my fault. When I added `for
vara varb in val1a val1b ...' I tried not to screw up select, but did
anyway (and obviously didn't test it). The new syntax isn't appropriate
for select.
I've also made select accept an EOF from the keyboard instead of
printing `use 'exit' to exit', which doesn't make any sense except at
the main prompt. This ought really to be an argument to zleread().
Index: Src/loop.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/loop.c,v
retrieving revision 1.8
diff -u -r1.8 loop.c
--- Src/loop.c 25 Feb 2002 09:21:14 -0000 1.8
+++ Src/loop.c 17 Feb 2003 11:34:34 -0000
@@ -202,7 +202,7 @@
wordcode code = state->pc[-1];
char *str, *s, *name;
LinkNode n;
- int i, usezle;
+ int i, usezle, oignoreeof = opts[IGNOREEOF];
FILE *inp;
size_t more;
LinkList args;
@@ -238,6 +238,7 @@
inp = fdopen(dup(usezle ? SHTTY : 0), "r");
more = selectlist(args, 0);
loop = state->pc;
+ opts[IGNOREEOF] = 0;
for (;;) {
for (;;) {
if (empty(bufstack)) {
@@ -301,6 +302,7 @@
fclose(inp);
loops--;
state->pc = end;
+ opts[IGNOREEOF] = oignoreeof;
return lastval;
}
Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.39
diff -u -r1.39 parse.c
--- Src/parse.c 6 Oct 2002 18:38:14 -0000 1.39
+++ Src/parse.c 17 Feb 2003 11:34:34 -0000
@@ -923,18 +923,19 @@
yylex();
type = WC_FOR_COND;
} else {
- int np, n, posix_in, ona = noaliases, onc = nocorrect;
+ int np = 0, n, posix_in, ona = noaliases, onc = nocorrect;
infor = 0;
if (tok != STRING || !isident(tokstr))
YYERRORV(oecused);
- np = ecadd(0);
+ if (!sel)
+ np = ecadd(0);
n = 0;
incmdpos = 1;
noaliases = nocorrect = 1;
for (;;) {
n++;
ecstr(tokstr);
- yylex();
+ yylex();
if (tok != STRING || !strcmp(tokstr, "in") || sel)
break;
if (!isident(tokstr) || errflag)
@@ -946,7 +947,8 @@
}
noaliases = ona;
nocorrect = onc;
- ecbuf[np] = n;
+ if (!sel)
+ ecbuf[np] = n;
posix_in = isnewlin;
while (isnewlin)
yylex();
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Segfault in zsh 4.1.0-dev-7 using select
2003-02-17 11:38 ` Peter Stephenson
@ 2003-02-17 12:35 ` Peter Stephenson
0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2003-02-17 12:35 UTC (permalink / raw)
To: zsh-workers
Peter Stephenson wrote:
> I've also made select accept an EOF from the keyboard instead of
> printing `use 'exit' to exit', which doesn't make any sense except at
> the main prompt. This ought really to be an argument to zleread().
As below. There's now only supposed to be one reference to the
IGNOREEOF option (apart from option processing, obviously), at the point
where we call zle for input in the main loop. I think this is slightly
neater --- mostly for future uses of zleread(), since there isn't that
much in it at the moment.
Index: Src/input.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/input.c,v
retrieving revision 1.6
diff -u -r1.6 input.c
--- Src/input.c 31 Jan 2002 14:44:15 -0000 1.6
+++ Src/input.c 17 Feb 2003 12:29:40 -0000
@@ -269,8 +269,10 @@
* typeahead when the terminal settings are altered.
* pws 1998/03/12
*/
- ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr,
- ZLRF_HISTORY|ZLRF_NOSETTY);
+ int flags = ZLRF_HISTORY|ZLRF_NOSETTY;
+ if (isset(IGNOREEOF))
+ flags |= ZLRF_IGNOREEOF;
+ ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr, flags);
histdone |= HISTFLAG_SETTY;
}
if (!ingetcline) {
Index: Src/loop.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/loop.c,v
retrieving revision 1.9
diff -u -r1.9 loop.c
--- Src/loop.c 17 Feb 2003 11:42:05 -0000 1.9
+++ Src/loop.c 17 Feb 2003 12:29:40 -0000
@@ -202,7 +202,7 @@
wordcode code = state->pc[-1];
char *str, *s, *name;
LinkNode n;
- int i, usezle, oignoreeof = opts[IGNOREEOF];
+ int i, usezle;
FILE *inp;
size_t more;
LinkList args;
@@ -238,7 +238,6 @@
inp = fdopen(dup(usezle ? SHTTY : 0), "r");
more = selectlist(args, 0);
loop = state->pc;
- opts[IGNOREEOF] = 0;
for (;;) {
for (;;) {
if (empty(bufstack)) {
@@ -302,7 +301,6 @@
fclose(inp);
loops--;
state->pc = end;
- opts[IGNOREEOF] = oignoreeof;
return lastval;
}
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.43
diff -u -r1.43 zsh.h
--- Src/zsh.h 4 Dec 2002 13:57:51 -0000 1.43
+++ Src/zsh.h 17 Feb 2003 12:29:40 -0000
@@ -1747,6 +1747,7 @@
#define ZLRF_HISTORY 0x01 /* OK to access the history list */
#define ZLRF_NOSETTY 0x02 /* Don't set tty before return */
+#define ZLRF_IGNOREEOF 0x04 /* Ignore an EOF from the keyboard */
/****************/
/* Entry points */
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.30
diff -u -r1.30 zle_main.c
--- Src/Zle/zle_main.c 14 Feb 2003 19:03:14 -0000 1.30
+++ Src/Zle/zle_main.c 17 Feb 2003 12:29:40 -0000
@@ -616,7 +616,7 @@
an infinite loop. The simple way around this was to add
the counter (icnt) so that this happens 20 times and than
the shell gives up (yes, this is a bit dirty...). */
- if (isset(IGNOREEOF) && icnt++ < 20)
+ if ((zlereadflags & ZLRF_IGNOREEOF) && icnt++ < 20)
continue;
stopmsg = 1;
zexit(1, 0);
@@ -681,7 +681,8 @@
reselectkeymap();
selectlocalmap(NULL);
bindk = getkeycmd();
- if (!ll && isfirstln && unset(IGNOREEOF) && c == eofchar) {
+ if (!ll && isfirstln && !(zlereadflags & ZLRF_IGNOREEOF) &&
+ c == eofchar) {
eofsent = 1;
break;
}
@@ -865,7 +866,7 @@
int wflags = w->flags;
if (keybuf[0] == eofchar && !keybuf[1] &&
- !ll && isfirstln && isset(IGNOREEOF)) {
+ !ll && isfirstln && (zlereadflags & ZLRF_IGNOREEOF)) {
showmsg((!islogin) ? "zsh: use 'exit' to exit." :
"zsh: use 'logout' to logout.");
ret = 1;
@@ -986,7 +987,7 @@
struct value vbuf;
Value v;
Param pm = 0;
- int create = 0, ifl, ieof;
+ int create = 0, ifl;
int type = PM_SCALAR, obreaks = breaks, haso = 0;
char *p1 = NULL, *p2 = NULL;
FILE *oshout = NULL;
@@ -1145,10 +1146,7 @@
if (OPT_ISSET(ops,'h'))
hbegin(2);
isfirstln = OPT_ISSET(ops,'e');
- ieof = opts[IGNOREEOF];
- opts[IGNOREEOF] = 0;
t = (char *) zleread(p1, p2, OPT_ISSET(ops,'h') ? ZLRF_HISTORY : 0);
- opts[IGNOREEOF] = ieof;
if (OPT_ISSET(ops,'h'))
hend(NULL);
isfirstln = ifl;
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-02-17 12:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-16 15:01 Segfault in zsh 4.1.0-dev-7 using select Mikael Magnusson
2003-02-17 11:38 ` Peter Stephenson
2003-02-17 12:35 ` Peter Stephenson
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).