Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
input.c: ungot spaces patch
- X-seq: zsh-workers 334
- From: P.Stephenson@xxxxxxxxxxxxx
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list)
- Subject: input.c: ungot spaces patch
- Date: Mon, 21 Aug 95 15:24:58 +0100
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@xxxxxxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author