int exalias(void) { Reswd rw; hwend(); if (interact && isset(SHINSTDIN) && !strin && !incasepat && tok == STRING && !nocorrect && !(inbufflags & INP_ALIAS) && (isset(CORRECTALL) || (isset(CORRECT) && incmdpos))) spckword(&tokstr, 1, incmdpos, 1); if (!tokstr) { zshlextext = tokstrings[tok]; if (tok == NEWLIN) return 0; return checkalias(); } else { VARARR(char, copy, (strlen(tokstr) + 1)); if (has_token(tokstr)) { char *p, *t; zshlextext = p = copy; for (t = tokstr; (*p++ = itok(*t) ? ztokens[*t++ - Pound] : *t++);); } else zshlextext = tokstr; if ((lexflags & LEXFLAGS_ZLE) && !(inbufflags & INP_ALIAS)) { int zp = lexflags; gotword(); if ((zp & LEXFLAGS_ZLE) && !lexflags) { if (zshlextext == copy) zshlextext = tokstr; return 0; } } if (tok == STRING) { /* Check for an alias */ if ((zshlextext != copy || !isset(POSIXALIASES)) && checkalias()) { if (zshlextext == copy) zshlextext = tokstr; return 1; } /* Then check for a reserved word */ if ((incmdpos || (unset(IGNOREBRACES) && unset(IGNORECLOSEBRACES) && zshlextext[0] == '}' && !zshlextext[1])) && (rw = (Reswd) reswdtab->getnode(reswdtab, zshlextext))) { tok = rw->token; inrepeat_ = (tok == REPEAT); if (tok == DINBRACK) incond = 1; } else if (incond && !strcmp(zshlextext, "]]")) { tok = DOUTBRACK; incond = 0; } else if (incond == 1 && zshlextext[0] == '!' && !zshlextext[1]) tok = BANG; } inalmore = 0; if (zshlextext == copy) zshlextext = tokstr; } return 0; }
int exalias(void) { Alias an; Reswd rw; hwend(); if (interact && isset(SHINSTDIN) && !strin && !incasepat && tok == STRING && !nocorrect && !(inbufflags & INP_ALIAS) && (isset(CORRECTALL) || (isset(CORRECT) && incmdpos))) spckword(&tokstr, 1, incmdpos, 1); if (!tokstr) { yytext = tokstrings[tok]; return 0; } else { VARARR(char, copy, (strlen(tokstr) + 1)); if (has_token(tokstr)) { char *p, *t; yytext = p = copy; for (t = tokstr; (*p++ = itok(*t) ? ztokens[*t++ - Pound] : *t++);); } else yytext = tokstr; if (zleparse && !(inbufflags & INP_ALIAS)) { int zp = zleparse; gotword(); if (zp == 1 && !zleparse) { if (yytext == copy) yytext = tokstr; return 0; } } if (tok == STRING) { /* Check for an alias */ 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 */ if ((incmdpos || (unset(IGNOREBRACES) && yytext[0] == '}' && !yytext[1])) && (rw = (Reswd) reswdtab->getnode(reswdtab, yytext))) { tok = rw->token; if (tok == DINBRACK) incond = 1; } else if (incond && !strcmp(yytext, "]]")) { tok = DOUTBRACK; incond = 0; } else if (incond == 1 && yytext[0] == '!' && !yytext[1]) tok = BANG; } inalmore = 0; if (yytext == copy) yytext = tokstr; } return 0; }