Lines Matching refs:lp

118 #define	pushlevel(lp,c,s)	((lp->lexd.level>=lp->lexd.lex_max?stack_grow(lp):1) &&\
119 ((lp->lexd.lex_match[lp->lexd.level++]=lp->lexd.lastc),\
120 lp->lexd.lastc=(((s)<<CHAR_BIT)|(c))))
121 #define oldmode(lp) (lp->lexd.lastc>>CHAR_BIT)
122 #define endchar(lp) (lp->lexd.lastc&0xff)
123 #define setchar(lp,c) (lp->lexd.lastc = ((lp->lexd.lastc&~0xff)|(c)))
124 #define poplevel(lp) (lp->lexd.lastc=lp->lexd.lex_match[--lp->lexd.level])
141 static void refvar(Lex_t *lp, int type)
143 register Shell_t *shp = lp->sh;
145 off_t off = (fcseek(0)-(type+1))-(lp->lexd.first?lp->lexd.first:fcfirst());
147 if(lp->lexd.first)
149 off = (fcseek(0)-(type+1)) - lp->lexd.first;
150 r=kiaentity(lp,lp->lexd.first+lp->lexd.kiaoff+type,off-lp->lexd.kiaoff,'v',-1,-1,lp->current,'v',0,"");
157 if(lp->lexd.kiaoff < offset)
162 n = stktell(stkp)-lp->lexd.kiaoff;
163 begin = stkptr(stkp,lp->lexd.kiaoff);
168 begin = fcfirst()+(type+lp->lexd.kiaoff-offset);
169 n = off-lp->lexd.kiaoff;
172 r=kiaentity(lp,begin,n,'v',-1,-1,lp->current,'v',0,"");
175 sfprintf(lp->kiatmp,"p;%..64d;v;%..64d;%d;%d;r;\n",lp->current,r,shp->inlineno,shp->inlineno);
185 register Lex_t *lp = (Lex_t*)context;
186 register Shell_t *shp = lp->sh;
200 if(lp->lexd.nocopy)
202 if(lp->lexd.dolparen && lp->lexd.docword && lp->lexd.docend)
204 int n = size - (lp->lexd.docend-(char*)buff);
205 sfwrite(shp->strbuf,lp->lexd.docend,n);
206 lp->lexd.docextra += n;
208 lp->lexd.docend = sfsetbuf(iop,(Void_t*)iop,0);
210 lp->lexd.docend = fcfirst();
212 if(lp->lexd.first)
214 size -= (lp->lexd.first-(char*)buff);
215 buff = lp->lexd.first;
216 if(!lp->lexd.noarg)
217 lp->arg = (struct argnod*)stkseek(stkp,ARGVAL);
219 lp->lexd.kiaoff += ARGVAL;
222 if(size>0 && (lp->arg||lp->lexd.noarg))
225 lp->lexd.first = 0;
233 static int lexfill(Lex_t *lp)
239 savelex = *lp;
240 ap = lp->arg;
243 lp->arg = ap;
244 docextra = lp->lexd.docextra;
245 lp->lex = savelex.lex;
246 lp->lexd = savelex.lexd;
248 lp->lexd.first = 0;
249 aok= lp->aliasok;
250 ap = lp->arg;
251 memcpy(lp, &savelex, offsetof(Lex_t,lexd));
252 lp->arg = ap;
253 lp->aliasok = aok;
254 if(lp->lexd.docword && docextra)
256 lp->lexd.docextra = docextra;
257 lp->lexd.docend = fcseek(0)-1;
265 Lex_t *sh_lexopen(Lex_t *lp, Shell_t *sp, int mode)
267 if(!lp)
269 lp = (Lex_t*)newof(0,Lex_t,1,0);
270 lp->sh = sp;
272 fcnotify(lex_advance,lp);
273 lp->lex.intest = lp->lex.incase = lp->lex.skipword = lp->lexd.warn = 0;
274 lp->comp_assign = 0;
275 lp->lex.reservok = 1;
277 lp->lexd.warn=1;
280 lp->lexd.noarg = lp->lexd.level= lp->lexd.dolparen = lp->lexd.balance = 0;
281 lp->lexd.nocopy = lp->lexd.docword = lp->lexd.nest = lp->lexd.paren = 0;
282 lp->lexd.lex_state = lp->lexd.lastc=0;
283 lp->lexd.docend = 0;
284 lp->lexd.nested_tilde = 0;
286 lp->comsub = 0;
287 return(lp);
292 int sh_lex(Lex_t *lp)
294 Shell_t *shp = lp->sh;
298 register int tok = lextoken(lp);
300 if(tok==0 && (flag=lp->arg->argflag))
310 macro, split, expand, fmttoken(lp,tok,tokstr));
318 * A pointer to the current word is stored in lp->arg
321 int sh_lex(Lex_t* lp)
323 register Shell_t *shp = lp->sh;
327 int inlevel=lp->lexd.level, assignment=0, ingrave=0;
333 if(lp->lexd.paren)
335 lp->lexd.paren = 0;
336 return(lp->token=LPAREN);
338 if(lp->noreserv)
340 lp->lex.reservok = 0;
344 lp->assignok = SH_ASSIGN;
346 if(lp->lex.incase)
347 lp->assignok = 0;
349 lp->assignok |= lp->lex.reservok;
350 if(lp->comp_assign==2)
351 lp->comp_assign = lp->lex.reservok = 0;
352 lp->lexd.arith = (lp->lexd.nest==1);
353 if(lp->lexd.nest)
355 pushlevel(lp,lp->lexd.nest,ST_NONE);
356 lp->lexd.nest = 0;
357 mode = lp->lexd.lex_state;
359 else if(lp->lexd.docword)
363 lp->lexd.docword++;
364 lp->digits=(c=='#'?3:1);
368 lp->digits=2;
369 lp->lexd.docword=0;
374 if(!lp->lexd.dolparen)
376 lp->arg = 0;
378 lp->lexd.first = fcseek(0);
380 lp->lexd.first = 0;
382 lp->lastline = lp->sh->inlineno;
395 if((n=lexfill(lp)) > 0)
412 lp->token = -1;
413 sh_syntax(lp);
418 return(lp->token=EOFSYM);
419 if(mode >ST_NORM && lp->lexd.level>0)
421 switch(c=endchar(lp))
429 mode = oldmode(lp);
430 poplevel(lp);
443 lp->lexd.balance = c;
448 lp->lasttok = c;
449 lp->token = EOFSYM;
450 sh_syntax(lp);
452 lp->lexd.balance = c;
457 lp->lex.reservok = !lp->lex.intest;
458 if((n=lp->lexd.nocopy) && lp->lexd.dolparen)
459 lp->lexd.nocopy--;
463 if(c<=0 || lp->heredoc)
474 lp->lexd.nocopy = n;
476 return(lp->token=EOFSYM);
482 if(lp->heredoc)
484 if(!lp->lexd.dolparen)
485 lp->lexd.nocopy++;
487 if(here_copy(lp,lp->heredoc)<=0 && lp->lasttok)
489 lp->lasttok = IODOCSYM;
490 lp->token = EOFSYM;
491 lp->lastline = c;
492 sh_syntax(lp);
494 if(!lp->lexd.dolparen)
495 lp->lexd.nocopy--;
496 lp->heredoc = 0;
498 lp->lex.reservok = !lp->lex.intest;
499 lp->lex.skipword = 0;
503 lp->lex.last_quote = 0;
508 lp->comp_assign = 0;
509 return(lp->token='\n');
512 if(lp->lex.incase<=TEST_RE)
515 if(inlevel+1==lp->lexd.level)
517 if(lp->lex.intest)
527 if(lp->lex.testop2)
528 lp->lex.testop2 = 0;
531 lp->digits = (c=='>');
532 lp->lex.skipword = 1;
533 lp->aliasok = lp->lex.reservok;
534 if(lp->lex.incase<2)
535 lp->lex.reservok = 0;
540 lp->lex.reservok = !lp->lex.intest;
543 if(!lp->lexd.dolparen)
544 lp->lex.incase = 0;
545 return(lp->token=c);
547 lp->lex.testop1 = lp->lex.intest;
556 lp->lexd.docword=1;
559 if(lp->lex.intest)
561 lp->lexd.nest=1;
562 lp->lastline = shp->inlineno;
563 lp->lexd.lex_state = ST_NESTED;
565 return(sh_lex(lp));
570 return(lp->token=c);
575 if(!sh_isoption(SH_BASH) && !lp->nonstandard)
577 lp->nonstandard = 1;
580 lp->digits = -1;
595 lp->lex.reservok = 1;
596 lp->lex.skipword = 0;
602 lp->digits = 1;
607 lp->token = c = IORDWRSYMT;
608 if(lp->inexec)
609 sh_syntax(lp);
620 if(lp->inexec)
622 lp->token = c;
623 sh_syntax(lp);
631 lp->lex.incase = (c==BREAKCASESYM || c==FALLTHRUSYM);
635 if(lp->lexd.warn && (n=fcpeek(0))!=RPAREN && n!=' ' && n!='\t')
639 if(c==LPAREN && lp->comp_assign && !lp->lex.intest && !lp->lex.incase)
640 lp->comp_assign = 2;
642 lp->comp_assign = 0;
643 return(lp->token=c);
669 ap = lp->arg;
677 lp->arg = ap;
681 lp->lexd.first = 0;
689 else if(mode==ST_NESTED && lp->lexd.warn &&
690 endchar(lp)==RBRACE &&
697 if(!lp->lex.skipword)
698 lp->lex.reservok *= 2;
703 if(endchar(lp)==RBRACE)
705 lp->lexd.nested_tilde++;
711 if(!lp->lexd.dolparen)
712 lp->lexd.first = fcseek(0)-LEN;
713 else if(lp->lexd.docword)
714 lp->lexd.docend = fcseek(0)-LEN;
726 if(lp->lexd.nested_tilde)
727 lp->lexd.nested_tilde++;
728 else if(lp->lex.incase)
729 lp->lex.incase = TEST_RE;
732 if(lp->lexd.nested_tilde)
734 lp->lexd.nested_tilde--;
755 if(!lp->lexd.dolparen)
756 lp->lexd.first = fcseek(0);
757 else if(lp->lexd.docword)
758 lp->lexd.docend = fcseek(0);
759 if(c=='[' && lp->assignok>=SH_ASSIGN)
768 if(oldmode(lp)==ST_NONE && !lp->lexd.noarg) /* in ((...)) */
780 if(endchar(lp)!='$')
782 if(oldmode(lp)==ST_QUOTE) /* $' within "" or `` */
784 if(lp->lexd.warn)
791 if(lp->lexd.warn && lp->lex.last_quote && shp->inlineno > lp->lastline && fcpeek(-2)!='$')
792 errormsg(SH_DICT,ERROR_warn(0),e_lexlongquote,lp->lastline,lp->lex.last_quote);
793 lp->lex.last_quote = 0;
794 lp->lastline = shp->inlineno;
796 pushlevel(lp,'\'',mode);
801 else if(shp->inlineno > lp->lastline)
802 lp->lex.last_quote = '\'';
803 mode = oldmode(lp);
804 poplevel(lp);
808 if(endchar(lp)=='$')
816 if(lp->lexd.warn && (mode!=ST_QUOTE || endchar(lp)!='`'))
823 if(oldmode(lp)==ST_NONE && lp->lexd.arith) /* in ((...)) */
834 if(lp->lexd.warn && lp->lex.last_quote && shp->inlineno > lp->lastline)
835 errormsg(SH_DICT,ERROR_warn(0),e_lexlongquote,lp->lastline,lp->lex.last_quote);
836 lp->lex.last_quote=0;
837 lp->lastline = shp->inlineno;
838 pushlevel(lp,c,mode);
844 else if((n=endchar(lp))==c)
846 if(shp->inlineno > lp->lastline)
847 lp->lex.last_quote = c;
848 mode = oldmode(lp);
849 poplevel(lp);
859 if(lp->lexd.first)
860 lp->lexd.kiaoff = fcseek(0)-lp->lexd.first;
862 lp->lexd.kiaoff = stktell(stkp)+fcseek(0)-fcfirst();
864 pushlevel(lp,'$',mode);
870 mode = oldmode(lp);
871 poplevel(lp);
873 n = lp->digits;
874 wordflags |= comsub(lp,c);
875 lp->digits = n;
878 if((n=endchar(lp)) == '$')
882 mode = oldmode(lp);
883 poplevel(lp);
889 if(lp->kiafile)
890 refvar(lp,0);
892 if(lp->lexd.warn && c==LBRACT && !lp->lex.intest && !lp->lexd.arith && oldmode(lp)!= ST_NESTED)
895 mode = oldmode(lp);
896 poplevel(lp);
922 if(endchar(lp)==RBRACE)
924 setchar(lp,c);
929 if(c=='.' && endchar(lp)=='$')
934 switch(endchar(lp))
941 mode = oldmode(lp);
942 poplevel(lp);
957 setchar(lp,RBRACE);
969 setchar(lp,'0');
971 setchar(lp,'!');
983 if((n=endchar(lp)) == '$')
988 mode = oldmode(lp);
989 poplevel(lp);
990 if((n = endchar(lp)) != '`')
992 pushlevel(lp,RBRACE,mode);
995 setchar(lp,RBRACE);
999 if(oldmode(lp)==ST_QUOTE || oldmode(lp)==ST_NONE)
1016 if(lp->kiafile)
1017 refvar(lp,1);
1030 lp->token = n;
1031 sh_syntax(lp);
1033 else if(lp->lexd.warn)
1038 lp->lex.nestedbrace = 0;
1042 if((c=endchar(lp)) == '$')
1046 setchar(lp,RBRACE);
1058 n = endchar(lp);
1059 mode = oldmode(lp);
1060 poplevel(lp);
1063 lp->token = c;
1064 sh_syntax(lp);
1068 if(lp->lexd.warn && c!='/' && sh_lexstates[ST_NORM][c]!=S_BREAK && (c!='"' || mode==ST_QUOTE))
1076 if(lp->lexd.warn && endchar(lp)==RBRACE && !lp->lexd.nested_tilde)
1085 pushlevel(lp,RPAREN,mode);
1090 if(c==RBRACE && mode==ST_NESTED && lp->lex.nestedbrace)
1092 lp->lex.nestedbrace--;
1095 if(lp->lexd.level <= inlevel)
1097 if(lp->lexd.level==inlevel+1 && lp->lex.incase>=TEST_RE && !lp->lex.intest)
1102 n = endchar(lp);
1118 lp->lexd.nested_tilde = 0;
1121 if(lp->lexd.warn && n==RBRACE)
1127 if(lp->lexd.warn)
1131 mode = oldmode(lp);
1132 poplevel(lp);
1143 if(mode==ST_NONE && !lp->lexd.dolparen)
1145 lp->lex.reservok = 1;
1146 lp->lex.skipword = 0;
1147 return(lp->token=EXPRSYM);
1151 if(lp->lexd.warn)
1153 if(!(state=lp->lexd.first))
1160 lp->lexd.paren = 1;
1162 return(lp->token=LPAREN);
1168 lp->token = c;
1169 sh_syntax(lp);
1175 assignment = lp->assignok;
1189 if(lp->lex.reservok && !lp->lex.incase)
1202 if((n=endchar(lp))==RBRACT || n==RPAREN ||
1204 (oldmode(lp)==ST_NONE) ||
1205 (mode==ST_NAME && (lp->assignok||lp->lexd.level)))
1217 pushlevel(lp,RBRACT,mode);
1227 if(lp->lexd.dolparen)
1229 if(mode==ST_BEGIN && (lp->lex.reservok||lp->comsub))
1231 if(lp->comsub)
1232 return(lp->token=c);
1239 return(lp->token=c);
1243 else if(mode==ST_NESTED && endchar(lp)==RBRACE)
1245 lp->lex.nestedbrace++;
1250 if(lp->comsub && c==RBRACE)
1251 return(lp->token=c);
1254 isfirst = (lp->lexd.first&&fcseek(0)==lp->lexd.first+1);
1261 else if(lp->lex.reservok)
1264 if(lp->lex.reservok && state[n]==S_BREAK && isfirst)
1267 && !lp->lex.incase && !lp->lex.intest
1268 && !lp->lex.skipword)
1284 if(lp->lex.incase==TEST_RE)
1286 lp->lex.incase++;
1287 pushlevel(lp,RPAREN,ST_NORM);
1291 pushlevel(lp,RPAREN,mode);
1295 if(lp->lexd.warn && c=='[' && n=='^')
1303 lp->comp_assign = 0;
1310 if(lp->lexd.nocopy)
1312 lp->lexd.balance = 0;
1315 if(lp->lexd.dolparen)
1317 lp->lexd.balance = 0;
1318 if(lp->lexd.docword)
1319 nested_here(lp);
1320 lp->lexd.message = (wordflags&ARG_MESSAGE);
1321 return(lp->token=0);
1323 if(!(state=lp->lexd.first))
1326 if(!lp->arg)
1327 lp->arg = (struct argnod*)stkseek(stkp,ARGVAL);
1331 if(lp->lexd.balance)
1333 sfputc(stkp,lp->lexd.balance);
1334 lp->lexd.balance = 0;
1340 lp->lexd.first=0;
1347 c = sh_lex(lp);
1348 lp->digits = (n-'0');
1353 else if(n==RBRACE && lp->comsub)
1354 return(lp->token=n);
1361 else if(n>2 && state[0]=='{' && state[n-1]=='}' && !lp->lex.intest && !lp->lex.incase && (c=='<' || c== '>') && sh_isoption(SH_BRACEEXPAND))
1366 lp->arg = (struct argnod*)stkfreeze(stkp,1);
1367 return(lp->token=IOVNAME);
1376 lp->arg = (struct argnod*)stkfreeze(stkp,1);
1377 lp->lex.reservok = 1;
1378 return(lp->token=LABLSYM);
1380 if(assignment || (lp->lex.intest&&!lp->lex.incase) || mode==ST_NONE)
1392 lp->arg = sh_endword(shp,2);
1397 lp->arg = (struct argnod*)stkfreeze(stkp,1);
1398 lp->arg->argflag = (c?c:ARG_RAW);
1401 lp->arg = sh_endword(shp,-1);
1403 lp->arg = sh_endword(shp,0);
1404 state = lp->arg->argval;
1405 lp->comp_assign = assignment;
1407 lp->arg->argflag |= ARG_ASSIGN;
1408 else if(!lp->lex.skipword)
1409 lp->assignok = 0;
1410 lp->arg->argchn.cp = 0;
1411 lp->arg->argnxt.ap = 0;
1413 return(lp->token=EXPRSYM);
1414 if(lp->lex.intest)
1416 if(lp->lex.testop1)
1418 lp->lex.testop1 = 0;
1422 if(lp->lexd.warn && state[1]=='a')
1424 lp->digits = state[1];
1425 lp->token = TESTUNOP;
1429 lp->lex.testop1 = 1;
1430 lp->token = '!';
1434 lp->lex.testop2 = 1;
1435 lp->token = 0;
1437 return(lp->token);
1439 lp->lex.incase = 0;
1444 lp->lex.testop2 = lp->lex.intest = 0;
1445 lp->lex.reservok = 1;
1446 lp->token = ETESTSYM;
1447 return(lp->token);
1450 if(lp->lexd.warn && state[1]==0)
1454 if(lp->lex.testop2)
1456 if(lp->lexd.warn && (c&TEST_ARITH))
1459 lp->lex.incase = 1;
1461 lp->lex.incase = TEST_RE;
1462 lp->lex.testop2 = 0;
1463 lp->digits = c;
1464 lp->token = TESTBINOP;
1465 return(lp->token);
1470 return(lp->token=0);
1473 if(lp->lex.reservok /* && !lp->lex.incase*/ && n<=2)
1479 if(lp->lexd.warn && c=='{' && lp->lex.incase==2)
1481 if(lp->lex.incase==1 && c==RBRACE)
1482 lp->lex.incase = 0;
1483 return(lp->token=c);
1485 else if(!lp->lex.incase && c==LBRACT && state[1]==LBRACT)
1487 lp->lex.intest = lp->lex.testop1 = 1;
1488 lp->lex.testop2 = lp->lex.reservok = 0;
1489 return(lp->token=BTESTSYM);
1493 if(!lp->lex.skipword)
1495 if(n>1 && lp->lex.reservok==1 && mode==ST_NAME &&
1498 if(lp->lex.incase)
1500 if(lp->lex.incase >1)
1501 lp->lex.incase = 1;
1503 lp->lex.incase = 0;
1509 lp->lex.skipword = 1;
1510 lp->lex.incase = 2*(c==CASESYM);
1513 lp->lex.skipword = 0;
1515 lp->lex.reservok = 0;
1525 return(lp->token=c);
1527 if(!(wordflags&ARG_QUOTED) && (lp->lex.reservok||lp->aliasok))
1531 if(!lp->lex.incase && !assignment && fcpeek(0)!=LPAREN &&
1535 && (lp->aliasok!=2 || nv_isattr(np,BLT_DCL))
1540 setupalias(lp,state,np);
1542 lp->lex.reservok = 1;
1543 lp->assignok |= lp->lex.reservok;
1544 return(sh_lex(lp));
1547 lp->lex.reservok = 0;
1549 lp->lex.skipword = lp->lexd.docword = 0;
1550 return(lp->token=c);
1556 static int comsub(register Lex_t *lp, int endtok)
1559 register int line=lp->sh->inlineno;
1561 int off, messages=0, assignok=lp->assignok, csub;
1563 save = lp->lex;
1564 csub = lp->comsub;
1565 sh_lexopen(lp,lp->sh,1);
1566 lp->lexd.dolparen++;
1567 lp->lex.incase=0;
1568 pushlevel(lp,0,0);
1569 lp->comsub = (endtok==LBRACE);
1570 if(first=lp->lexd.first)
1576 n = sh_lex(lp);
1581 if(endtok==LPAREN && lp->lexd.paren)
1584 if(first==lp->lexd.first)
1590 lp->lexd.paren = 0;
1612 lp->lex.incase=1;
1614 lp->lex.incase=0;
1619 if(c==RBRACE && lp->lex.incase)
1620 lp->lex.incase=0;
1621 c=sh_lex(lp);
1625 if(endtok==LBRACE && !lp->lex.incase)
1627 lp->comsub = 0;
1636 lp->comsub = endtok==LBRACE;
1640 if(endtok==LPAREN && !lp->lex.incase)
1644 if(lp->lex.incase)
1645 lp->lex.incase=0;
1650 lp->lastline = line;
1651 lp->lasttok = endtok;
1652 sh_syntax(lp);
1658 lp->lexd.docextra = 0;
1659 sh_lex(lp);
1662 lp->lex.reservok = 0;
1663 messages |= lp->lexd.message;
1675 lp->lex.reservok = 1;
1680 poplevel(lp);
1681 lp->comsub = csub;
1682 lp->lastline = line;
1683 lp->lexd.dolparen--;
1684 lp->lex = save;
1685 lp->assignok = (endchar(lp)==RBRACT?assignok:0);
1686 if(lp->heredoc)
1687 errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax5,lp->sh->inlineno,lp->heredoc->ioname);
1695 static void nested_here(register Lex_t *lp)
1699 struct argnod *arg = lp->arg;
1700 Stk_t *stkp = lp->sh->stk;
1704 if(lp->lexd.docend)
1705 n = fcseek(0)-lp->lexd.docend;
1706 iop = newof(0,struct ionod,1,lp->lexd.docextra+n+ARGVAL);
1707 iop->iolst = lp->heredoc;
1709 if(lp->lexd.docextra)
1711 sfseek(lp->sh->strbuf,(Sfoff_t)0, SEEK_SET);
1712 sfmove(lp->sh->strbuf,stkp,lp->lexd.docextra,-1);
1713 sfseek(lp->sh->strbuf,(Sfoff_t)0, SEEK_SET);
1715 sfwrite(stkp,lp->lexd.docend,n);
1716 lp->arg = sh_endword(lp->sh,0);
1718 strcpy(iop->ioname,lp->arg->argval);
1720 if(lp->lexd.docword>1)
1722 lp->heredoc = iop;
1723 lp->arg = arg;
1724 lp->lexd.docword = 0;
1736 void sh_lexskip(Lex_t *lp,int close, register int copy, int state)
1739 lp->lexd.nest = close;
1740 lp->lexd.lex_state = state;
1741 lp->lexd.noarg = 1;
1743 fcnotify(lex_advance,lp);
1745 lp->lexd.nocopy++;
1746 sh_lex(lp);
1747 lp->lexd.noarg = 0;
1750 fcnotify(0,lp);
1751 if(!(cp=lp->lexd.first))
1754 sfwrite(lp->sh->stk,cp,copy);
1757 lp->lexd.nocopy--;
1790 static int here_copy(Lex_t *lp,register struct ionod *iop)
1795 register Sfio_t *sp=lp->sh->heredocs, *funlog;
1797 if(funlog=lp->sh->funlog)
1801 lp->sh->funlog = 0;
1804 here_copy(lp,iop->iolst);
1861 if(!lp->lexd.dolparen && c)
1865 if(!lp->lexd.dolparen && (c=sfwrite(sp,bufp,c))>0)
1879 c = lexfill(lp);
1890 else if(!lp->lexd.dolparen)
1903 lp->sh->inlineno++;
1906 if(!lp->lexd.dolparen)
1943 if(!lp->lexd.dolparen && (c=cp-bufp))
1949 if((c=lexfill(lp))<=0)
1964 lp->sh->inlineno++;
1967 if(!lp->lexd.dolparen && (n=cp-bufp))
1972 lp->sh->inlineno--;
1985 if(!lp->lexd.dolparen && nsave>0)
2017 lp->sh->inlineno++;
2018 if(!lp->lexd.dolparen && (n=(fcseek(0)-bufp)-n)>=0)
2038 lp->sh->funlog = funlog;
2039 if(lp->lexd.dolparen)
2049 static char *fmttoken(Lex_t *lp, register int sym, char *tok)
2055 return(lp->arg?lp->arg->argval:"?");
2056 if(lp->lex.intest && lp->arg && *lp->arg->argval)
2057 return(lp->arg->argval);
2109 void sh_syntax(Lex_t *lp)
2111 register Shell_t *shp = lp->sh;
2114 register int tok = lp->token;
2117 if((tok==EOFSYM) && lp->lasttok)
2119 tok = lp->lasttok;
2123 lp->lastline = shp->inlineno;
2124 tokstr = fmttoken(lp,tok,tokbuf);
2136 shp->inlineno = lp->inlineno;
2137 shp->st.firstline = lp->firstline;
2143 errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax1,lp->lastline,tokstr,cp);
2434 Lex_t *lp;
2455 register Lex_t *lp;
2458 lp = ap->lp;
2477 lp->aliasok = 1;
2490 static void setupalias(Lex_t *lp, const char *string,Namval_t *np)
2495 ap->lp = lp;
2500 if(lp->kiafile)
2503 r=kiaentity(lp,nv_name(np),-1,'p',0,0,lp->current,'a',0,"");
2504 sfprintf(lp->kiatmp,"p;%..64d;p;%..64d;%d;%d;e;\n",lp->current,r,lp->sh->inlineno,lp->sh->inlineno);
2514 lp->lexd.nocopy++;
2520 lp->lexd.nocopy--;
2526 static int stack_grow(Lex_t *lp)
2528 lp->lexd.lex_max += STACK_ARRAY;
2529 if(lp->lexd.lex_match)
2530 lp->lexd.lex_match = (int*)realloc((char*)lp->lexd.lex_match,sizeof(int)*lp->lexd.lex_max);
2532 lp->lexd.lex_match = (int*)malloc(sizeof(int)*STACK_ARRAY);
2533 return(lp->lexd.lex_match!=0);