From 3ffb3ad2f2f733fbee58e21dc6aab23827ab8d49 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 3 Sep 2003 10:15:32 +0000 Subject: 19014: add alias -s suf=handler --- Src/lex.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'Src/lex.c') diff --git a/Src/lex.c b/Src/lex.c index 40e42e857..a852de369 100644 --- a/Src/lex.c +++ b/Src/lex.c @@ -1510,7 +1510,7 @@ parse_subscript(char *s, int sub) mod_export int parse_subst_string(char *s) { - int c, l = strlen(s), err, olen; + int c, l = strlen(s), err, olen, lexstop_ret; if (!*s || !strcmp(s, nulstring)) return 0; @@ -1522,6 +1522,7 @@ parse_subst_string(char *s) bptr = tokstr = s; bsiz = l + 1; c = hgetc(); + lexstop_ret = lexstop; c = gettokstr(c, 1); err = errflag; strinend(); @@ -1603,17 +1604,32 @@ exalias(void) if (tok == STRING) { /* Check for an alias */ - an = (noaliases || unset(ALIASESOPT)) ? NULL : - (Alias) aliastab->getnode(aliastab, yytext); - if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos || - inalmore)) { - inpush(an->text, INP_ALIAS, an); - if (an->text[0] == ' ') - aliasspaceflag = 1; - lexstop = 0; - if (yytext == copy) - yytext = tokstr; - return 1; + if (!noaliases && isset(ALIASESOPT)) { + char *suf; + + an = (Alias) aliastab->getnode(aliastab, yytext); + if (an && !an->inuse && + ((an->flags & ALIAS_GLOBAL) || incmdpos || inalmore)) { + inpush(an->text, INP_ALIAS, an); + if (an->text[0] == ' ') + aliasspaceflag = 1; + lexstop = 0; + if (yytext == copy) + yytext = tokstr; + return 1; + } + if ((suf = strrchr(yytext, '.')) && suf[1] && + suf > yytext && suf[-1] != Meta && + (an = (Alias)sufaliastab->getnode(sufaliastab, suf+1)) && + !an->inuse && incmdpos) { + inpush(dupstring(yytext), INP_ALIAS, NULL); + inpush(" ", INP_ALIAS, NULL); + inpush(an->text, INP_ALIAS, an); + lexstop = 0; + if (yytext == copy) + yytext = tokstr; + return 1; + } } /* Then check for a reserved word */ -- cgit 1.4.1