From 10182c766bf6096ab2ffc25ba73babe6955dff0a Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 25 Feb 2009 10:23:58 +0000 Subject: c.f. 26586: rename yylex to zshlex and yytext to zshlextext --- ChangeLog | 6 +- Src/builtin.c | 2 +- Src/lex.c | 52 ++++++++-------- Src/parse.c | 196 +++++++++++++++++++++++++++++----------------------------- 4 files changed, 130 insertions(+), 126 deletions(-) diff --git a/ChangeLog b/ChangeLog index 514bdccf8..0d9395ced 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,10 @@ 2009-02-20 Peter Stephenson + * c.f. 26586: Src/builtin.c, Src/lex.c, Src/parse.c: rename yylex + to zshlex and yytext to zshlextext to avoid possible clashes + in linked libraries. + * 26584: configure.ac, Src/Modules/tcp.h: use bind/netdb.h where appropriate. @@ -11228,5 +11232,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.4577 $ +* $Revision: 1.4578 $ ***************************************************** diff --git a/Src/builtin.c b/Src/builtin.c index b402d56e2..c1509759a 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5780,7 +5780,7 @@ bin_test(char *name, char **argv, UNUSED(Options ops), int func) condlex = testlex; testlex(); prog = parse_cond(); - condlex = yylex; + condlex = zshlex; if (errflag) { errflag = 0; diff --git a/Src/lex.c b/Src/lex.c index b66630acc..5637a2106 100644 --- a/Src/lex.c +++ b/Src/lex.c @@ -38,7 +38,7 @@ mod_export char ztokens[] = "#$^*()$=|{}[]`<>>?~`,'\"\\\\"; /* parts of the current token */ /**/ -char *yytext; +char *zshlextext; /**/ mod_export char *tokstr; /**/ @@ -49,7 +49,7 @@ mod_export int tokfd; /* * Line number at which the first character of a token was found. * We always set this in gettok(), which is always called from - * yylex() unless we have reached an error. So it is always + * zshlex() unless we have reached an error. So it is always * valid when parsing. It is not useful during execution * of the parsed structure. */ @@ -198,7 +198,7 @@ struct lexstack { int tok; int isnewlin; char *tokstr; - char *yytext; + char *zshlextext; char *bptr; int bsiz; int len; @@ -257,7 +257,7 @@ lexsave(void) ls->tok = tok; ls->isnewlin = isnewlin; ls->tokstr = tokstr; - ls->yytext = yytext; + ls->zshlextext = zshlextext; ls->bptr = bptr; ls->bsiz = bsiz; ls->len = len; @@ -319,7 +319,7 @@ lexrestore(void) tok = lstack->tok; isnewlin = lstack->isnewlin; tokstr = lstack->tokstr; - yytext = lstack->yytext; + zshlextext = lstack->zshlextext; bptr = lstack->bptr; bsiz = lstack->bsiz; len = lstack->len; @@ -356,7 +356,7 @@ lexrestore(void) /**/ void -yylex(void) +zshlex(void) { if (tok == LEXERR) return; @@ -405,7 +405,7 @@ ctxtlex(void) { static int oldpos; - yylex(); + zshlex(); switch (tok) { case SEPER: case NEWLIN: @@ -1720,7 +1720,7 @@ exalias(void) spckword(&tokstr, 1, incmdpos, 1); if (!tokstr) { - yytext = tokstrings[tok]; + zshlextext = tokstrings[tok]; return 0; } else { @@ -1729,19 +1729,19 @@ exalias(void) if (has_token(tokstr)) { char *p, *t; - yytext = p = copy; + zshlextext = p = copy; for (t = tokstr; (*p++ = itok(*t) ? ztokens[*t++ - Pound] : *t++);); } else - yytext = tokstr; + zshlextext = tokstr; if (zleparse && !(inbufflags & INP_ALIAS)) { int zp = zleparse; gotword(); if (zp == 1 && !zleparse) { - if (yytext == copy) - yytext = tokstr; + if (zshlextext == copy) + zshlextext = tokstr; return 0; } } @@ -1751,47 +1751,47 @@ exalias(void) if (!noaliases && isset(ALIASESOPT)) { char *suf; - an = (Alias) aliastab->getnode(aliastab, yytext); + an = (Alias) aliastab->getnode(aliastab, zshlextext); if (an && !an->inuse && ((an->node.flags & ALIAS_GLOBAL) || incmdpos || inalmore)) { inpush(an->text, INP_ALIAS, an); if (an->text[0] == ' ') aliasspaceflag = 1; lexstop = 0; - if (yytext == copy) - yytext = tokstr; + if (zshlextext == copy) + zshlextext = tokstr; return 1; } - if ((suf = strrchr(yytext, '.')) && suf[1] && - suf > yytext && suf[-1] != Meta && + if ((suf = strrchr(zshlextext, '.')) && suf[1] && + suf > zshlextext && suf[-1] != Meta && (an = (Alias)sufaliastab->getnode(sufaliastab, suf+1)) && !an->inuse && incmdpos) { - inpush(dupstring(yytext), INP_ALIAS, NULL); + inpush(dupstring(zshlextext), INP_ALIAS, NULL); inpush(" ", INP_ALIAS, NULL); inpush(an->text, INP_ALIAS, an); lexstop = 0; - if (yytext == copy) - yytext = tokstr; + if (zshlextext == copy) + zshlextext = tokstr; return 1; } } /* Then check for a reserved word */ if ((incmdpos || - (unset(IGNOREBRACES) && yytext[0] == '}' && !yytext[1])) && - (rw = (Reswd) reswdtab->getnode(reswdtab, yytext))) { + (unset(IGNOREBRACES) && zshlextext[0] == '}' && !zshlextext[1])) && + (rw = (Reswd) reswdtab->getnode(reswdtab, zshlextext))) { tok = rw->token; if (tok == DINBRACK) incond = 1; - } else if (incond && !strcmp(yytext, "]]")) { + } else if (incond && !strcmp(zshlextext, "]]")) { tok = DOUTBRACK; incond = 0; - } else if (incond == 1 && yytext[0] == '!' && !yytext[1]) + } else if (incond == 1 && zshlextext[0] == '!' && !zshlextext[1]) tok = BANG; } inalmore = 0; - if (yytext == copy) - yytext = tokstr; + if (zshlextext == copy) + zshlextext = tokstr; } return 0; } diff --git a/Src/parse.c b/Src/parse.c index 59459870a..f0a66ea12 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -448,7 +448,7 @@ parse_event(void) tok = ENDINPUT; incmdpos = 1; aliasspaceflag = 0; - yylex(); + zshlex(); init_parse(); if (!par_event()) { @@ -467,7 +467,7 @@ par_event(void) while (tok == SEPER) { if (isnewlin > 0) return 0; - yylex(); + zshlex(); } if (tok == ENDINPUT) return 0; @@ -481,15 +481,15 @@ par_event(void) } else if (tok == SEPER) { set_list_code(p, Z_SYNC, c); if (isnewlin <= 0) - yylex(); + zshlex(); r = 1; } else if (tok == AMPER) { set_list_code(p, Z_ASYNC, c); - yylex(); + zshlex(); r = 1; } else if (tok == AMPERBANG) { set_list_code(p, (Z_ASYNC | Z_DISOWN), c); - yylex(); + zshlex(); r = 1; } } @@ -525,7 +525,7 @@ parse_list(void) tok = ENDINPUT; incmdpos = 1; - yylex(); + zshlex(); init_parse(); par_list(&c); if (tok != ENDINPUT) { @@ -601,7 +601,7 @@ par_list(int *complex) rec: while (tok == SEPER) - yylex(); + zshlex(); p = ecadd(0); c = 0; @@ -616,7 +616,7 @@ par_list(int *complex) (Z_ASYNC | Z_DISOWN)), c); incmdpos = 1; do { - yylex(); + zshlex(); } while (tok == SEPER); lp = p; goto rec; @@ -669,9 +669,9 @@ par_sublist(int *complex) int qtok = tok, sl; cmdpush(tok == DBAR ? CS_CMDOR : CS_CMDAND); - yylex(); + zshlex(); while (tok == SEPER) - yylex(); + zshlex(); sl = par_sublist(complex); set_sublist_code(p, (sl ? (qtok == DBAR ? WC_SUBLIST_OR : WC_SUBLIST_AND) : @@ -700,11 +700,11 @@ par_sublist2(int *complex) if (tok == COPROC) { *complex = 1; f |= WC_SUBLIST_COPROC; - yylex(); + zshlex(); } else if (tok == BANG) { *complex = 1; f |= WC_SUBLIST_NOT; - yylex(); + zshlex(); } if (!par_pline(complex) && !f) return -1; @@ -732,9 +732,9 @@ par_pline(int *complex) if (tok == BAR) { *complex = 1; cmdpush(CS_PIPE); - yylex(); + zshlex(); while (tok == SEPER) - yylex(); + zshlex(); ecbuf[p] = WCB_PIPE(WC_PIPE_MID, (line >= 0 ? line + 1 : 0)); ecispace(p + 1, 1); ecbuf[p + 1] = ecused - 1 - p; @@ -756,9 +756,9 @@ par_pline(int *complex) *complex = 1; cmdpush(CS_ERRPIPE); - yylex(); + zshlex(); while (tok == SEPER) - yylex(); + zshlex(); ecbuf[p] = WCB_PIPE(WC_PIPE_MID, (line >= 0 ? line + 1 : 0)); ecispace(p + 1, 1); ecbuf[p + 1] = ecused - 1 - p; @@ -856,7 +856,7 @@ par_cmd(int *complex) case DINPAR: ecadd(WCB_ARITH()); ecstr(tokstr); - yylex(); + zshlex(); break; case TIME: { @@ -917,23 +917,23 @@ par_for(int *complex) incmdpos = 0; infor = tok == FOR ? 2 : 0; - yylex(); + zshlex(); if (tok == DINPAR) { - yylex(); + zshlex(); if (tok != DINPAR) YYERRORV(oecused); ecstr(tokstr); - yylex(); + zshlex(); if (tok != DINPAR) YYERRORV(oecused); ecstr(tokstr); - yylex(); + zshlex(); if (tok != DOUTPAR) YYERRORV(oecused); ecstr(tokstr); infor = 0; incmdpos = 1; - yylex(); + zshlex(); type = WC_FOR_COND; } else { int np = 0, n, posix_in, ona = noaliases, onc = nocorrect; @@ -948,7 +948,7 @@ par_for(int *complex) for (;;) { n++; ecstr(tokstr); - yylex(); + zshlex(); if (tok != STRING || !strcmp(tokstr, "in") || sel) break; if (!isident(tokstr) || errflag) @@ -964,10 +964,10 @@ par_for(int *complex) ecbuf[np] = n; posix_in = isnewlin; while (isnewlin) - yylex(); + zshlex(); if (tok == STRING && !strcmp(tokstr, "in")) { incmdpos = 0; - yylex(); + zshlex(); np = ecadd(0); n = par_wordlist(); if (tok != SEPER) @@ -976,38 +976,38 @@ par_for(int *complex) type = (sel ? WC_SELECT_LIST : WC_FOR_LIST); } else if (!posix_in && tok == INPAR) { incmdpos = 0; - yylex(); + zshlex(); np = ecadd(0); n = par_nl_wordlist(); if (tok != OUTPAR) YYERRORV(oecused); ecbuf[np] = n; incmdpos = 1; - yylex(); + zshlex(); type = (sel ? WC_SELECT_LIST : WC_FOR_LIST); } else type = (sel ? WC_SELECT_PPARAM : WC_FOR_PPARAM); } incmdpos = 1; while (tok == SEPER) - yylex(); + zshlex(); if (tok == DOLOOP) { - yylex(); + zshlex(); par_save_list(complex); if (tok != DONE) YYERRORV(oecused); - yylex(); + zshlex(); } else if (tok == INBRACE) { - yylex(); + zshlex(); par_save_list(complex); if (tok != OUTBRACE) YYERRORV(oecused); - yylex(); + zshlex(); } else if (csh || isset(CSHJUNKIELOOPS)) { par_save_list(complex); if (tok != ZEND) YYERRORV(oecused); - yylex(); + zshlex(); } else if (unset(SHORTLOOPS)) { YYERRORV(oecused); } else @@ -1035,7 +1035,7 @@ par_case(int *complex) p = ecadd(0); incmdpos = 0; - yylex(); + zshlex(); if (tok != STRING) YYERRORV(oecused); ecstr(tokstr); @@ -1044,9 +1044,9 @@ par_case(int *complex) ona = noaliases; onc = nocorrect; noaliases = nocorrect = 1; - yylex(); + zshlex(); while (tok == SEPER) - yylex(); + zshlex(); if (!(tok == STRING && !strcmp(tokstr, "in")) && tok != INBRACE) { noaliases = ona; @@ -1058,17 +1058,17 @@ par_case(int *complex) incmdpos = 0; noaliases = ona; nocorrect = onc; - yylex(); + zshlex(); for (;;) { char *str; while (tok == SEPER) - yylex(); + zshlex(); if (tok == OUTBRACE) break; if (tok == INPAR) - yylex(); + zshlex(); if (tok != STRING) YYERRORV(oecused); if (!strcmp(tokstr, "esac")) @@ -1078,11 +1078,11 @@ par_case(int *complex) incmdpos = 1; type = WC_CASE_OR; for (;;) { - yylex(); + zshlex(); if (tok == OUTPAR) { incasepat = 0; incmdpos = 1; - yylex(); + zshlex(); break; } else if (tok == BAR) { char *str2; @@ -1157,10 +1157,10 @@ par_case(int *complex) YYERRORV(oecused); incasepat = 1; incmdpos = 0; - yylex(); + zshlex(); } incmdpos = 1; - yylex(); + zshlex(); ecbuf[p] = WCB_CASE(WC_CASE_HEAD, ecused - 1 - p); } @@ -1184,13 +1184,13 @@ par_if(int *complex) for (;;) { xtok = tok; cmdpush(xtok == IF ? CS_IF : CS_ELIF); - yylex(); + zshlex(); if (xtok == FI) break; if (xtok == ELSE) break; while (tok == SEPER) - yylex(); + zshlex(); if (!(xtok == IF || xtok == ELIF)) { cmdpop(); YYERRORV(oecused); @@ -1200,14 +1200,14 @@ par_if(int *complex) par_save_list(complex); incmdpos = 1; while (tok == SEPER) - yylex(); + zshlex(); xtok = FI; nc = cmdstack[cmdsp - 1] == CS_IF ? CS_IFTHEN : CS_ELIFTHEN; if (tok == THEN) { usebrace = 0; cmdpop(); cmdpush(nc); - yylex(); + zshlex(); par_save_list(complex); ecbuf[pp] = WCB_IF(type, ecused - 1 - pp); incmdpos = 1; @@ -1216,14 +1216,14 @@ par_if(int *complex) usebrace = 1; cmdpop(); cmdpush(nc); - yylex(); + zshlex(); par_save_list(complex); if (tok != OUTBRACE) { cmdpop(); YYERRORV(oecused); } ecbuf[pp] = WCB_IF(type, ecused - 1 - pp); - yylex(); + zshlex(); incmdpos = 1; if (tok == SEPER) break; @@ -1245,9 +1245,9 @@ par_if(int *complex) pp = ecadd(0); cmdpush(CS_ELSE); while (tok == SEPER) - yylex(); + zshlex(); if (tok == INBRACE && usebrace) { - yylex(); + zshlex(); par_save_list(complex); if (tok != OUTBRACE) { cmdpop(); @@ -1261,7 +1261,7 @@ par_if(int *complex) } } ecbuf[pp] = WCB_IF(WC_IF_ELSE, ecused - 1 - pp); - yylex(); + zshlex(); cmdpop(); } ecbuf[p] = WCB_IF(WC_IF_HEAD, ecused - 1 - p); @@ -1280,28 +1280,28 @@ par_while(int *complex) int type = (tok == UNTIL ? WC_WHILE_UNTIL : WC_WHILE_WHILE); p = ecadd(0); - yylex(); + zshlex(); par_save_list(complex); incmdpos = 1; while (tok == SEPER) - yylex(); + zshlex(); if (tok == DOLOOP) { - yylex(); + zshlex(); par_save_list(complex); if (tok != DONE) YYERRORV(oecused); - yylex(); + zshlex(); } else if (tok == INBRACE) { - yylex(); + zshlex(); par_save_list(complex); if (tok != OUTBRACE) YYERRORV(oecused); - yylex(); + zshlex(); } else if (isset(CSHJUNKIELOOPS)) { par_save_list(complex); if (tok != ZEND) YYERRORV(oecused); - yylex(); + zshlex(); } else YYERRORV(oecused); @@ -1321,31 +1321,31 @@ par_repeat(int *complex) p = ecadd(0); incmdpos = 0; - yylex(); + zshlex(); if (tok != STRING) YYERRORV(oecused); ecstr(tokstr); incmdpos = 1; - yylex(); + zshlex(); while (tok == SEPER) - yylex(); + zshlex(); if (tok == DOLOOP) { - yylex(); + zshlex(); par_save_list(complex); if (tok != DONE) YYERRORV(oecused); - yylex(); + zshlex(); } else if (tok == INBRACE) { - yylex(); + zshlex(); par_save_list(complex); if (tok != OUTBRACE) YYERRORV(oecused); - yylex(); + zshlex(); } else if (isset(CSHJUNKIELOOPS)) { par_save_list(complex); if (tok != ZEND) YYERRORV(oecused); - yylex(); + zshlex(); } else if (unset(SHORTLOOPS)) { YYERRORV(oecused); } else @@ -1368,20 +1368,20 @@ par_subsh(int *complex) p = ecadd(0); /* Extra word only needed for always block */ pp = ecadd(0); - yylex(); + zshlex(); par_list(complex); ecadd(WCB_END()); if (tok != ((otok == INPAR) ? OUTPAR : OUTBRACE)) YYERRORV(oecused); incmdpos = 1; - yylex(); + zshlex(); /* Optional always block. No intervening SEPERs allowed. */ if (otok == INBRACE && tok == STRING && !strcmp(tokstr, "always")) { ecbuf[pp] = WCB_TRY(ecused - 1 - pp); incmdpos = 1; do { - yylex(); + zshlex(); } while (tok == SEPER); if (tok != INBRACE) @@ -1389,16 +1389,16 @@ par_subsh(int *complex) cmdpop(); cmdpush(CS_ALWAYS); - yylex(); + zshlex(); par_save_list(complex); while (tok == SEPER) - yylex(); + zshlex(); incmdpos = 1; if (tok != OUTBRACE) YYERRORV(oecused); - yylex(); + zshlex(); ecbuf[p] = WCB_TRY(ecused - 1 - p); } else { ecbuf[p] = (otok == INPAR ? WCB_SUBSH(ecused - 1 - p) : @@ -1422,7 +1422,7 @@ par_funcdef(void) lineno = 0; nocorrect = 1; incmdpos = 0; - yylex(); + zshlex(); p = ecadd(0); ecadd(0); @@ -1435,7 +1435,7 @@ par_funcdef(void) } ecstr(tokstr); num++; - yylex(); + zshlex(); } ecadd(0); ecadd(0); @@ -1443,9 +1443,9 @@ par_funcdef(void) nocorrect = 0; if (tok == INOUTPAR) - yylex(); + zshlex(); while (tok == SEPER) - yylex(); + zshlex(); ecnfunc++; ecssub = so = ecsoffs; @@ -1453,7 +1453,7 @@ par_funcdef(void) ecnpats = 0; if (tok == INBRACE) { - yylex(); + zshlex(); par_list(&c); if (tok != OUTBRACE) { lineno += oldlineno; @@ -1461,7 +1461,7 @@ par_funcdef(void) ecssub = oecssub; YYERRORV(oecused); } - yylex(); + zshlex(); } else if (unset(SHORTLOOPS)) { lineno += oldlineno; ecnpats = onp; @@ -1494,7 +1494,7 @@ par_time(void) { int p, f, c = 0; - yylex(); + zshlex(); p = ecadd(0); ecadd(0); @@ -1519,13 +1519,13 @@ par_dinbrack(void) incond = 1; incmdpos = 0; - yylex(); + zshlex(); par_cond(); if (tok != DOUTBRACK) YYERRORV(oecused); incond = 0; incmdpos = 1; - yylex(); + zshlex(); } /* @@ -1594,7 +1594,7 @@ par_simple(int *complex, int nr) type2 = WC_ASSIGN_NEW; ecstr(tokstr); cmdpush(CS_ARRAY); - yylex(); + zshlex(); n = par_nl_wordlist(); ecbuf[p] = WCB_ASSIGN(WC_ASSIGN_ARRAY, type2, n); cmdpop(); @@ -1604,7 +1604,7 @@ par_simple(int *complex, int nr) isnull = 0; } else break; - yylex(); + zshlex(); } if (tok == AMPER || tok == AMPERBANG) YYERROR(oecused); @@ -1630,7 +1630,7 @@ par_simple(int *complex, int nr) char *toksave = tokstr; char *idstring = dupstrpfx(tokstr+1, eptr-tokstr-1); redir_var = 1; - yylex(); + zshlex(); if (IS_REDIROP(tok) && tokfd == -1) { @@ -1652,7 +1652,7 @@ par_simple(int *complex, int nr) { ecstr(tokstr); argc++; - yylex(); + zshlex(); } } else if (IS_REDIROP(tok)) { *complex = c = 1; @@ -1670,9 +1670,9 @@ par_simple(int *complex, int nr) lineno = 0; incmdpos = 1; cmdpush(CS_FUNCDEF); - yylex(); + zshlex(); while (tok == SEPER) - yylex(); + zshlex(); ecispace(p + 1, 1); ecbuf[p + 1] = argc; @@ -1688,7 +1688,7 @@ par_simple(int *complex, int nr) if (tok == INBRACE) { int c = 0; - yylex(); + zshlex(); par_list(&c); if (tok != OUTBRACE) { cmdpop(); @@ -1697,7 +1697,7 @@ par_simple(int *complex, int nr) ecssub = oecssub; YYERROR(oecused); } - yylex(); + zshlex(); } else { int ll, sl, pl, c = 0; @@ -1784,7 +1784,7 @@ par_redir(int *rp, char *idstring) nocorrect = 1; type = redirtab[tok - OUTANG]; fd1 = tokfd; - yylex(); + zshlex(); if (tok != STRING && tok != ENVSTRING) YYERROR(ecused); incmdpos = oldcmdpos; @@ -1828,7 +1828,7 @@ par_redir(int *rp, char *idstring) (*hd)->pc = r; (*hd)->str = tokstr; - yylex(); + zshlex(); return ncodes; } case REDIR_WRITE: @@ -1852,7 +1852,7 @@ par_redir(int *rp, char *idstring) type = tokstr[0] == Inang ? REDIR_INPIPE : REDIR_OUTPIPE; break; } - yylex(); + zshlex(); /* If we ever to change the number of codes, we have to change * the definition of WC_REDIR_WORDS. */ @@ -1895,7 +1895,7 @@ par_wordlist(void) while (tok == STRING) { ecstr(tokstr); num++; - yylex(); + zshlex(); } return num; } @@ -1915,18 +1915,18 @@ par_nl_wordlist(void) ecstr(tokstr); num++; } - yylex(); + zshlex(); } return num; } /* - * condlex is yylex for normal parsing, but is altered to allow + * condlex is zshlex for normal parsing, but is altered to allow * the test builtin to use par_cond. */ /**/ -void (*condlex) _((void)) = yylex; +void (*condlex) _((void)) = zshlex; /* * cond : cond_1 { SEPER } [ DBAR { SEPER } cond ] @@ -2200,7 +2200,7 @@ yyerror(int noerr) int t0; char *t; - if ((t = dupstring(yytext))) + if ((t = dupstring(zshlextext))) untokenize(t); for (t0 = 0; t0 != 20; t0++) -- cgit 1.4.1