* input.c: ungot spaces patch
@ 1995-08-21 14:24 P.Stephenson
0 siblings, 0 replies; only message in thread
From: P.Stephenson @ 1995-08-21 14:24 UTC (permalink / raw)
To: Zsh hackers list
Here's a fix to input.c which Zoltan discovered was necessary. The
problem is with the hack that the input code can put a bogus space at
the end of the input, which saves pushing it onto the stack.
Sometimes when putting a space back via inungetc() you actually need a
real space, if it was there originally, because of side effects. I
should have put this in input.c to begin with but didn't realise it
would have a noticeable effect.
If recompiling, only input.c is affected, so you could do 'make -t'
and 'rm input.o' to avoid the affect of patching zsh.h.
*** Src/input.c.os Mon Jul 3 14:31:16 1995
--- Src/input.c Mon Aug 21 14:57:05 1995
***************
*** 46,52 ****
* is to continue onto what's already in the input queue), INP_ALIAS (used
* as a mark to pop the alias stack), or INP_SPACE (a shorthand way of
* telling the input code to return a single space after the input string
! * is exhausted).
*
* Note that the input string is itself used as the input buffer: it is not
* copied, nor is it every written back to, so using a constant string
--- 46,54 ----
* is to continue onto what's already in the input queue), INP_ALIAS (used
* as a mark to pop the alias stack), or INP_SPACE (a shorthand way of
* telling the input code to return a single space after the input string
! * is exhausted). The code INP_OLDSPACE is used internally and should not be
! * set initially: it indicates that the INP_SPACE was just read and can be
! * reset by a call to inungetc().
*
* Note that the input string is itself used as the input buffer: it is not
* copied, nor is it every written back to, so using a constant string
***************
*** 119,125 ****
* as a hack by zle_tricky.c.
*/
inbufct--; /* counts as a character in rest of shell */
! inbufflags &= ~INP_SPACE; /* ready to back up if necessary */
return lastc = ' ';
}
/* Otherwise, see if we can pop the alias stack at this point. */
--- 121,128 ----
* as a hack by zle_tricky.c.
*/
inbufct--; /* counts as a character in rest of shell */
! inbufflags &= ~INP_SPACE; /* ready to back up if necessary... */
! inbufflags |= INP_OLDSPACE; /* ...O.K. to back up an INP_SPACE */
return lastc = ' ';
}
/* Otherwise, see if we can pop the alias stack at this point. */
***************
*** 323,334 ****
{
if (lexstop)
return;
! if (!inbufleft && c == ' ' && !(inbufflags & INP_SPACE)) {
/* Use the space hack. This is necessary because sometimes we need
* to back up the bogus space at the end of the line.
*/
inbufct++; /* don't increment inbufleft, not in inbuf */
inbufflags |= INP_SPACE;
return;
}
if (inbufptr != inbuf) {
--- 326,340 ----
{
if (lexstop)
return;
! if ((inbufflags & (INP_SPACE|INP_OLDSPACE)) == INP_OLDSPACE) {
/* Use the space hack. This is necessary because sometimes we need
* to back up the bogus space at the end of the line.
+ * We don't need to check c since the combination of flags only occurs
+ * if the last character got was a bogus space.
*/
inbufct++; /* don't increment inbufleft, not in inbuf */
inbufflags |= INP_SPACE;
+ inbufflags &= ~INP_OLDSPACE; /* not necessary but cleaner */
return;
}
if (inbufptr != inbuf) {
*** Src/zsh.h.os Mon Jul 3 13:32:01 1995
--- Src/zsh.h Mon Aug 21 14:30:16 1995
***************
*** 204,209 ****
--- 204,210 ----
#define INP_ALIAS 2 /* alias or history mark at end of word */
#define INP_CONT 4 /* continue onto previously stacked input */
#define INP_SPACE 8 /* return space after expanded alias */
+ #define INP_OLDSPACE 16 /* internal flag: INP_SPACE was swallowed */
/* linked list abstract data type */
--
Peter Stephenson <P.Stephenson@swansea.ac.uk> Tel: +44 1792 205678 extn. 4461
WWW: http://python.swan.ac.uk/~pypeters/ Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1995-08-21 15:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-08-21 14:24 input.c: ungot spaces patch P.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).