zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: Segfault in zsh 4.1.0-dev-7 using select
Date: Mon, 17 Feb 2003 12:35:09 +0000	[thread overview]
Message-ID: <13591.1045485309@csr.com> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Mon, 17 Feb 2003 11:38:36 GMT." <18418.1045481916@csr.com>

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.
**********************************************************************


      reply	other threads:[~2003-02-17 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-16 15:01 Mikael Magnusson
2003-02-17 11:38 ` Peter Stephenson
2003-02-17 12:35   ` Peter Stephenson [this message]

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=13591.1045485309@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.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).