From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 602 invoked from network); 12 Dec 1996 03:43:43 -0000 Received: from dns.primenet.com.au (203.24.36.40) by coral.primenet.com.au with SMTP; 12 Dec 1996 03:43:43 -0000 Received: (qmail 291 invoked from network); 11 Dec 1996 16:12:40 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by dns.primenet.com.au with SMTP; 11 Dec 1996 16:12:40 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id KAA11913; Wed, 11 Dec 1996 10:52:02 -0500 (EST) Resent-Date: Wed, 11 Dec 1996 10:52:02 -0500 (EST) Message-Id: <199612111552.QAA09712@hydra.ifh.de> To: zsh-workers@math.gatech.edu Subject: Re: Final demise of alias stack In-reply-to: "Peter Stephenson"'s message of "Wed, 11 Dec 1996 09:20:58 MET." <199612110820.JAA15929@sgi.ifh.de> Date: Wed, 11 Dec 1996 16:52:10 +0100 From: Peter Stephenson Resent-Message-ID: <"A1ppS1.0.1w2.TYjho"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2558 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu I wrote: > % alias foo='echo foo1 ' > % alias bar=foo > % alias rod=bar > % foo rod > foo1 bar > > the foo forces rod to be expanded, but only as far as bar; the bar does > not get expanded to foo. If this really is a bug, this is the fix (i.e. you get 'foo1 echo foo1' at the end and a second argument would also be eligible for alias substitution). The thing to do is to keep the more-alias status separate from the input buffer, consequently it seemed neater to have a separate status variable again (in fact, that's really the only alteration). *** Src/globals.h.alm Wed Dec 11 16:35:55 1996 --- Src/globals.h Wed Dec 11 16:36:54 1996 *************** *** 204,209 **** --- 204,213 ---- EXTERN int inbufflags; + /* flag that an alias should be expanded after expansion ending in space */ + + EXTERN int inalmore; + /* != 0 if this is a subshell */ EXTERN int subsh; *** Src/input.c.alm Wed Dec 11 09:36:15 1996 --- Src/input.c Wed Dec 11 16:40:02 1996 *************** *** 58,67 **** * inpop(), which effectively flushes any unread input as well as restoring * the previous input state. * ! * The flags INP_ALMORE is set when a popped alias ends in a space so that ! * the next word should also be alias expanded. The flag is reset in ! * exalias(). The internal flag INP_ALCONT shows that the stack element ! * was pushed by an alias expansion and should not be needed elsewhere. * * PWS 1996/12/10 */ --- 58,70 ---- * inpop(), which effectively flushes any unread input as well as restoring * the previous input state. * ! * The internal flag INP_ALCONT shows that the stack element was pushed ! * by an alias expansion; it should not be needed elsewhere. ! * ! * The global variable inalmore is set to indicate aliases should ! * continue to be expanded because the last alias expansion ended ! * in a space. It is only reset after a complete word was read ! * without expanding a new alias, in exalias(). * * PWS 1996/12/10 */ *************** *** 420,426 **** instacktop->bufptr = inbufptr; instacktop->bufleft = inbufleft; instacktop->bufct = inbufct; ! inbufflags &= ~(INP_ALCONT|INP_ALMORE); if (flags & (INP_ALIAS|INP_HIST)) { /* * Text is expansion for history or alias, so continue --- 423,429 ---- instacktop->bufptr = inbufptr; instacktop->bufleft = inbufleft; instacktop->bufct = inbufct; ! inbufflags &= ~INP_ALCONT; if (flags & (INP_ALIAS|INP_HIST)) { /* * Text is expansion for history or alias, so continue *************** *** 486,492 **** /* a real alias: mark it as unused. */ instacktop->alias->inuse = 0; if (*t && t[strlen(t) - 1] == ' ') { ! inbufflags |= INP_ALMORE; histbackword(); } } --- 489,495 ---- /* a real alias: mark it as unused. */ instacktop->alias->inuse = 0; if (*t && t[strlen(t) - 1] == ' ') { ! inalmore = 1; histbackword(); } } *** Src/lex.c.alm Wed Dec 11 16:40:16 1996 --- Src/lex.c Wed Dec 11 16:40:35 1996 *************** *** 1258,1264 **** /* Check for an alias */ an = noaliases ? NULL : (Alias) aliastab->getnode(aliastab, yytext); if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos || ! (inbufflags & INP_ALMORE))) { inpush(an->text, INP_ALIAS, an); /* remove from history if it begins with space */ if (isset(HISTIGNORESPACE) && an->text[0] == ' ') --- 1258,1264 ---- /* Check for an alias */ an = noaliases ? NULL : (Alias) aliastab->getnode(aliastab, yytext); if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos || ! inalmore)) { inpush(an->text, INP_ALIAS, an); /* remove from history if it begins with space */ if (isset(HISTIGNORESPACE) && an->text[0] == ' ') *************** *** 1279,1285 **** } else if (incond && yytext[0] == '!' && !yytext[1]) tok = BANG; } ! inbufflags &= ~INP_ALMORE; return 0; } --- 1279,1285 ---- } else if (incond && yytext[0] == '!' && !yytext[1]) tok = BANG; } ! inalmore = 0; return 0; } *** Src/zsh.h.alm Wed Dec 11 16:35:49 1996 --- Src/zsh.h Wed Dec 11 16:37:06 1996 *************** *** 197,204 **** #define INP_ALIAS (1<<1) /* expanding alias or history */ #define INP_HIST (1<<2) /* expanding history */ #define INP_CONT (1<<3) /* continue onto previously stacked input */ ! #define INP_ALMORE (1<<4) /* alias ended with space, continue expn. */ ! #define INP_ALCONT (1<<5) /* stack is continued from alias expn. */ /* Flags for metafy */ #define META_REALLOC 0 --- 197,203 ---- #define INP_ALIAS (1<<1) /* expanding alias or history */ #define INP_HIST (1<<2) /* expanding history */ #define INP_CONT (1<<3) /* continue onto previously stacked input */ ! #define INP_ALCONT (1<<4) /* stack is continued from alias expn. */ /* Flags for metafy */ #define META_REALLOC 0 -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413 Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.