Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Segfault in zsh 4.1.0-dev-7 using select
- X-seq: zsh-workers 18252
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Segfault in zsh 4.1.0-dev-7 using select
- Date: Mon, 17 Feb 2003 12:35:09 +0000
- In-reply-to: "Peter Stephenson"'s message of "Mon, 17 Feb 2003 11:38:36 GMT." <18418.1045481916@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
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@xxxxxxx> 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.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author