zsh-workers
 help / color / mirror / code / Atom feed
* Final demise of alias stack
@ 1996-12-10 14:32 Peter Stephenson
  1996-12-10 16:32 ` Richard Coleman
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 1996-12-10 14:32 UTC (permalink / raw)
  To: Zsh hackers list

Here's the pay off after yesterday's bugfix for aliases.  It should
make the system a lot smoother and easier to understand.  It requires
yesterday's patch to be applied first.

1) The alias stack (alstack) has bitten the dust.  Instead of the
three stacks (input, alias, popped alias) there is now just the input
stack.  This removes the arbitrary limit MAXAL (was 20) on alias
expansions.  (That never did you any good, it just failed silently
when it got to the limit.)  Because the input stack is the alias
stack, popping of aliases is now coincident with popping of the input
stack instead of being an afterthought (last week's inpopalias()).
The alias is passed as an additional argument to inpush().  Use of
alstackind to test whether expanding an alias is replaced by
(inbufflags & INP_ALIAS).  inbufflags is now global.

2) The alstat variable is also absorbed into inbufflags:  not
necessary, but seems natural in view of the above.

3) I suppose the following (wrong) behaviour has been around for some
time:

% alias foo='echo foo1 '
% foo foo bar foo
foo1 echo foo1 bar echo foo1

This is correct up to the final `echo foo1' which should have stayed as
`foo' because there was a `bar' between the space-terminated alias and
the next alias.  I have corrected this.  The expand-next-alias
behaviour is now reset in exalias(), which seems as good a place as
any.

(Note that this mechanism only expands one level of aliases:  if the
resulting alias is itself an alias it will not be expanded.  I have
kept this, but is it a bug?)

4) Also, history expansion is marked specially on the input stack.
This makes the tests in hist.c (formally (inalstack == 1 &&
!alstack[0]), now (inbufflags & INP_HIST)) simpler and more obvious.

5) I think I've incidentally fixed the following bug:

% setopt histverify
% echo \!\!
!!
% echo !:1
% echo !\!

(the first ! should be quoted, too.)  This is the hunk with hwbegin()
in hist.c.  Zoltan, is this right?

begin 644 alias_patch.dif.gz
M'XL("(1PK3(``VYO7V%L<W1A8VLR+F1I9@#M/6ESVT:6GY5?T?+L1*0$R@1O
M2J.D%$=QO*/(*EO99&N<\D!@4\0$!#@$:%F./;]]W]$G""KRE7@VHW(<$6R\
M[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MG:^0Q@*KA;$9F$_G[OO2F8[Z*6`]AP,E'?2UGFY@)X&EX_GB&F!Z;0BL3\#,
MQ1[Z;7-,6U5MLWV]S7=BFGJ?L!>,PYXCWR:Y?_'XG&]8,![1WI'HD2+28Q#R
M#Y5!+1Y$!W3,0BA<[;0IS3V/7B;SU=SY9TRT\3!GIB.\?EG_JQH.'"<J%2$!
MXY.G52I`R&`X8NUM/&LD.O0VWXZ'Y%:)9,-@I^9&,&>[WCVK`#VL^TY=I-I1
1SNP`T*L<J?\#[P)*LLIJ```V
`
end

-- 
Peter Stephenson <pws@ifh.de>       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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Final demise of alias stack
  1996-12-10 14:32 Final demise of alias stack Peter Stephenson
@ 1996-12-10 16:32 ` Richard Coleman
  1996-12-11  8:20   ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Coleman @ 1996-12-10 16:32 UTC (permalink / raw)
  To: Peter Stephenson, zsh-workers

> (Note that this mechanism only expands one level of aliases:  if the
> resulting alias is itself an alias it will not be expanded.  I have
> kept this, but is it a bug?)

Peter,  I haven't tried the patch yet, but are you saying that

alias ls='/usr/local/bin'
alias ll='ls -l'

won't expand all the way?  Is that right?

rc


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Final demise of alias stack
  1996-12-10 16:32 ` Richard Coleman
@ 1996-12-11  8:20   ` Peter Stephenson
  1996-12-11 15:52     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 1996-12-11  8:20 UTC (permalink / raw)
  To: Zsh hackers list

> > (Note that this mechanism only expands one level of aliases:  if the
> > resulting alias is itself an alias it will not be expanded.  I have
> > kept this, but is it a bug?)
> 
> Peter,  I haven't tried the patch yet, but are you saying that
> 
> alias ls='/usr/local/bin'
> alias ll='ls -l'
> 
> won't expand all the way?  Is that right?

Sorry, I phrased that a bit loosely.  The remark only applied to aliases
which end in space and are therefore supposed to force alias expansion
on the next word.  In other words,

% 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.  This is the behaviour at least as far back as
2.5.0 and no-one has complained, but I suspect it's an oversight rather
than a feature and I'd be happy to try and fix it.

-- 
Peter Stephenson <pws@ifh.de>       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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Final demise of alias stack
  1996-12-11  8:20   ` Peter Stephenson
@ 1996-12-11 15:52     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 1996-12-11 15:52 UTC (permalink / raw)
  To: zsh-workers

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 <pws@ifh.de>       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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1996-12-12  3:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-12-10 14:32 Final demise of alias stack Peter Stephenson
1996-12-10 16:32 ` Richard Coleman
1996-12-11  8:20   ` Peter Stephenson
1996-12-11 15:52     ` Peter 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).