From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: cut'n'paste on IRIX
Date: Fri, 12 Mar 1999 15:02:26 +0100 [thread overview]
Message-ID: <9903121402.AA46034@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Andrej Borsenkow""'s message of "Fri, 12 Mar 1999 13:21:30 NFT." <001201be6c72$18aaa260$21c9ca95@mowp.siemens.ru>
"Andrej Borsenkow" wrote:
> Looks, like it is done in settyinfo(), that is (unconditionally) called from
> trashzle() that is called from zleread() after we've seen new line. (It is
> actually using tcsetattr() on our system)
OK, here's my first attempt. Unfortunately I can't test whether this fixes
the bug, since I don't have it. However, so far it hasn't blown anything
else. The only way to see if it does is by testing, so it will appear in
pws-12 and I'll wait for expostulations.
What now happens is that zleread() doesn't restore the tty when called in
the normal run of things from the main input routine, since that may want
more input, as in the case that caused the bug. Instead, the
end-of-history (that sounds rather alarming) routine is made responsible
for putting the terminal back. I've tried to arrange it so other calls to
trashzle() and zleread() do what they always did, which is why there are
three sets of flags --- one to zleread(), one to get hend() to restore the
terminal, one static flag between zleread() and trashzle(). I could
probably have made fewer changes, but it would have had possible side
effects such as the terminal not being restored when zle was temporarily
interrupted (e.g. by a background job exiting).
Now I'll probably find it doesn't fix the bug.
If it does work, it's a candidate for porting to 3.0.6.
--- Src/Zle/zle_main.c.trash Mon Mar 1 10:35:34 1999
+++ Src/Zle/zle_main.c Fri Mar 12 14:33:22 1999
@@ -394,11 +394,13 @@
return ret;
}
+static int no_restore_tty;
+
/* Read a line. It is returned metafied. */
/**/
unsigned char *
-zleread(char *lp, char *rp, int ha)
+zleread(char *lp, char *rp, int flags)
{
unsigned char *s;
int old_errno = errno;
@@ -451,7 +453,7 @@
pmpt_attr = txtchange;
rpromptbuf = promptexpand(rp, 1, NULL, NULL);
rpmpt_attr = txtchange;
- histallowed = ha;
+ histallowed = (flags & ZLRF_HISTORY);
PERMALLOC {
histline = curhist;
#ifdef HAVE_SELECT
@@ -486,6 +488,8 @@
if (tmout)
alarm(tmout);
zleactive = 1;
+ if (flags & ZLRF_NOSETTY)
+ no_restore_tty = 1;
resetneeded = 1;
errflag = retflag = 0;
lastcol = -1;
@@ -535,7 +539,7 @@
trashzle();
free(lpromptbuf);
free(rpromptbuf);
- zleactive = 0;
+ zleactive = no_restore_tty = 0;
alarm(0);
} LASTALLOC;
zsfree(curhistline);
@@ -754,7 +758,7 @@
PERMALLOC {
pushnode(bufstack, ztrdup(s));
} LASTALLOC;
- t = (char *) zleread(p1, p2, ops['h']);
+ t = (char *) zleread(p1, p2, ops['h'] ? ZLRF_HISTORY : 0);
if (!t || errflag) {
/* error in editing */
errflag = 0;
@@ -885,7 +889,8 @@
fprintf(shout, "%s", postedit);
fflush(shout);
resetneeded = 1;
- settyinfo(&shttyinfo);
+ if (!no_restore_tty)
+ settyinfo(&shttyinfo);
}
if (errflag)
kungetct = 0;
--- Src/hist.c.trash Fri Mar 12 13:56:08 1999
+++ Src/hist.c Fri Mar 12 14:53:25 1999
@@ -735,6 +735,8 @@
int flag, save = 1;
DPUTS(!chline, "BUG: chline is NULL in hend()");
+ if (histdone & HISTFLAG_SETTY)
+ settyinfo(&shttyinfo);
if (histactive & (HA_NOSTORE|HA_NOINC)) {
zfree(chline, hlinesz);
zfree(chwords, chwordlen*sizeof(short));
--- Src/input.c.trash Fri Mar 12 13:56:27 1999
+++ Src/input.c Fri Mar 12 14:47:05 1999
@@ -249,8 +249,21 @@
free(pptbuf);
}
ingetcline = shingetline();
- } else
- ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr, 1);
+ } else {
+ /*
+ * Since we may have to read multiple lines before getting
+ * a complete piece of input, we tell zle not to restore the
+ * original tty settings after reading each chunk. Instead,
+ * this is done when the history mechanism for the current input
+ * terminates, which is not until we have the whole input.
+ * This is supposed to minimise problems on systems that clobber
+ * typeahead when the terminal settings are altered.
+ * pws 1998/03/12
+ */
+ ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr,
+ ZLRF_HISTORY|ZLRF_NOSETTY);
+ histdone |= HISTFLAG_SETTY;
+ }
if (!ingetcline) {
return lexstop = 1;
}
--- Src/zsh.h.trash Fri Mar 12 13:55:43 1999
+++ Src/zsh.h Fri Mar 12 13:59:37 1999
@@ -1013,7 +1013,7 @@
#define HISTFLAG_DONE 1
#define HISTFLAG_NOEXEC 2
#define HISTFLAG_RECALL 4
-
+#define HISTFLAG_SETTY 8
/******************************************/
/* Definitions for programable completion */
@@ -1402,6 +1402,13 @@
#define ZSIG_TRAPPED (1<<0)
#define ZSIG_IGNORED (1<<1)
#define ZSIG_FUNC (1<<2)
+
+/**********************************/
+/* Flags to third argument of zle */
+/**********************************/
+
+#define ZLRF_HISTORY 0x01
+#define ZLRF_NOSETTY 0x02
/****************/
/* Entry points */
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
next prev parent reply other threads:[~1999-03-12 14:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-12 10:21 Debug / " Andrej Borsenkow
1999-03-12 10:34 ` Peter Stephenson
1999-03-12 14:02 ` Peter Stephenson [this message]
1999-03-15 8:19 ` PATCH: " Andrej Borsenkow
1999-03-15 9:38 ` PATCH: 3.1.5-pws-12: configuration changes Peter Stephenson
1999-03-12 14:33 ` Debug / cut'n'paste on IRIX Geoff Wing
1999-03-15 9:31 ` up-line-or-history and multiline input (was: RE: Debug / cut'n'paste on IRIX) Andrej Borsenkow
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=9903121402.AA46034@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--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).