Lines Matching defs:shp

59 	Shell_t		*shp;		/* pointer to shell interpreter */
114 void *sh_macopen(Shell_t *shp)
118 mp->shp = shp;
125 char *sh_mactry(Shell_t *shp,register char *string)
130 int savexit = shp->savexit;
135 string = sh_mactrim(shp,string,0);
137 shp->savexit = savexit;
150 char *sh_mactrim(Shell_t *shp, char *str, register int mode)
152 register Mac_t *mp = (Mac_t*)shp->mac_context;
153 Stk_t *stkp = shp->stk;
159 shp->argaddr = 0;
167 if(mp->ifsp=nv_getval(sh_scoped(shp,IFSNOD)))
192 int sh_macexpand(Shell_t* shp, register struct argnod *argp, struct argnod **arghead,int flag)
196 register Mac_t *mp = (Mac_t*)shp->mac_context;
197 char **saveargaddr = shp->argaddr;
199 Stk_t *stkp = shp->stk;
202 if(mp->ifsp=nv_getval(sh_scoped(shp,IFSNOD)))
206 if((flag&ARG_OPTIMIZE) && !shp->indebug)
207 shp->argaddr = (char**)&argp->argchn.ap;
209 shp->argaddr = 0;
239 if(shp->argaddr)
246 if(flags==1 && shp->argaddr)
249 shp->argaddr = saveargaddr;
258 void sh_machere(Shell_t *shp,Sfio_t *infile, Sfio_t *outfile, char *string)
263 register Mac_t *mp = (Mac_t*)shp->mac_context;
264 Lex_t *lp = (Lex_t*)mp->shp->lex_context;
267 Stk_t *stkp = shp->stk;
270 shp->argaddr = 0;
274 mp->ifsp = nv_getval(sh_scoped(shp,IFSNOD));
402 char *sh_macpat(Shell_t *shp,register struct argnod *arg, int flags)
412 sh_macexpand(shp,arg,NIL(struct argnod**),flags|ARG_ARRAYOK);
431 Lex_t *lp = (Lex_t*)mp->shp->lex_context;
439 Stk_t *stkp = mp->shp->stk;
614 tilde_expand2(mp->shp,tilde);
749 tilde_expand2(mp->shp,tilde);
798 Stk_t *stkp = mp->shp->stk;
842 #define MAX_OFFSETS (sizeof(shp->offsets)/sizeof(shp->offsets[0]))
849 static char *getdolarg(Shell_t *shp, int n, int *size)
851 register int c=S_DELIM, d=shp->ifstable['\\'];
852 register unsigned char *first,*last,*cp = (unsigned char*)shp->cur_line;
853 register int m=shp->offsets[0],delim=0;
864 cp += shp->offsets[m+1];
866 shp->ifstable['\\'] = 0;
867 shp->ifstable[0] = S_EOF;
871 while(shp->ifstable[*cp++]==S_SPACE);
874 shp->offsets[m] = (first-(unsigned char*)shp->cur_line);
875 while((c=shp->ifstable[*cp++])==0);
878 while((c=shp->ifstable[*cp++])==S_SPACE);
890 shp->ifstable['\\'] = d;
891 if(m > shp->offsets[0])
892 shp->offsets[0] = m;
904 static char *prefix(Shell_t *shp, char *id)
911 np = nv_search(id, shp->var_tree,0);
919 shp->argaddr = 0;
950 int loc = stktell(mp->shp->stk);
972 int sh_macfun(Shell_t *shp, const char *name, int offset)
975 np = nv_bfsearch(name,shp->fun_tree,&nq,(char**)0);
987 tp->com.comline = shp->inlineno;
990 stkseek(shp->stk,offset);
991 comsubst((Mac_t*)shp->mac_context,tp,2);
1032 Lex_t *lp = (Lex_t*)mp->shp->lex_context;
1037 Stk_t *stkp = mp->shp->stk;
1082 v = special(mp->shp,c);
1087 if(mp->shp->cur_line)
1094 dolmax = mp->shp->st.dolc+1;
1111 mp->shp->argaddr = 0;
1121 v = special(mp->shp,c);
1123 else if(mp->shp->cur_line)
1125 mp->shp->used_pos = 1;
1129 else if(c <= mp->shp->st.dolc)
1131 mp->shp->used_pos = 1;
1132 v = mp->shp->st.dolv[c];
1149 mp->shp->argaddr=0;
1226 if(mp->shp->cur_line && *id=='R' && strcmp(id,"REPLY")==0)
1228 mp->shp->argaddr=0;
1234 if(mp->shp->argaddr)
1236 np = nv_open(id,mp->shp->var_tree,flag|NV_NOFAIL);
1242 if(sh_macfun(mp->shp,id,offset))
1304 if((type==M_VNAME||type==M_SUBNAME) && mp->shp->argaddr && strcmp(nv_name(np),id))
1305 mp->shp->argaddr = 0;
1325 nv_typename(nq,mp->shp->strbuf);
1327 nv_attribute(np,mp->shp->strbuf,"typeset",1);
1328 v = sfstruse(mp->shp->strbuf);
1332 else if(mp->shp->cur_line && np==REPLYNOD)
1333 v = mp->shp->cur_line;
1372 if(mp->shp->argaddr)
1393 mp->shp->last_root = mp->shp->var_tree;
1394 id = prefix(mp->shp,id);
1431 if(mp->shp->cur_line)
1434 c = mp->shp->offsets[0];
1438 c = mp->shp->st.dolc;
1539 v = special(mp->shp,dolg=0);
1541 else if(mp->shp->cur_line)
1549 v = mp->shp->st.dolv[dolg=type];
1734 sfprintf(mp->shp->strbuf,"[%s]",nv_getsub(np));
1735 v = sfstruse(mp->shp->strbuf);
1764 if(mp->shp->cur_line)
1776 v = mp->shp->st.dolv[dolg];
1843 if(mp->shp->subshell)
1861 sfprintf(mp->shp->strbuf,"%s[%s]\0",nv_name(np),nv_getsub(np));
1862 id = sfstruse(mp->shp->strbuf);
1897 Stk_t *stkp = mp->shp->stk;
1899 struct slnod *saveslp = mp->shp->st.staklist;
1908 mp->shp->argaddr = 0;
1910 mp->shp->st.staklist=0;
1916 t = sh_dolparen((Lex_t*)mp->shp->lex_context);
1923 num = sh_arith(sh_mactrim(mp->shp,t->ar.arexpr->argval,3));
1928 sfprintf(mp->shp->strbuf,"%.*Lg",LDBL_DIG,num);
1930 sfprintf(mp->shp->strbuf,"%lld",(Sflong_t)num);
1932 sfprintf(mp->shp->strbuf,"%Lg",num);
1933 str = sfstruse(mp->shp->strbuf);
1935 mp->shp->st.staklist = saveslp;
1961 c = mp->shp->inlineno;
1962 mp->shp->inlineno = error_info.line+mp->shp->st.firstline;
1963 t = (Shnode_t*)sh_parse(mp->shp, sp,SH_EOF|SH_NL);
1964 mp->shp->inlineno = c;
1983 fd = sh_redirect(mp->shp,ip,3);
1989 if(sp=mp->shp->sftable[fd])
2004 sh_freeup(mp->shp);
2005 mp->shp->st.staklist = saveslp;
2014 np = sh_scoped(mp->shp,IFSNOD);
2063 else if(!mp->quote && mp->split && mp->shp->ifstable['\n'])
2086 if(mp->shp->spid)
2087 job_wait(mp->shp->spid);
2088 if(--newlines>0 && mp->shp->ifstable['\n']==S_DELIM)
2112 Stk_t *stkp=mp->shp->stk;
2166 state = mp->shp->ifstable;
2265 if(mp->shp->ifstable[ESCAPE]==S_ESC)
2266 mp->shp->ifstable[ESCAPE] = 0;
2282 Stk_t *stkp = mp->shp->stk;
2290 mp->shp->argaddr = 0;
2416 Shell_t *shp = ((Shbltin_t*)context)->shp;
2417 char *cp = sh_tilde(shp,argv[1]);
2428 static void tilde_expand2(Shell_t *shp, register int offset)
2430 char shtilde[10], *av[3], *ptr=stkfreeze(shp->stk,1);
2435 np = nv_open(shtilde,shp->fun_tree, NV_VARNAME|NV_NOARRAY|NV_NOASSIGN|NV_NOFAIL);
2453 stkset(shp->stk,ptr, offset);
2464 sfwrite(shp->stk,ptr,n);
2467 sfputr(shp->stk,av[1],0);
2480 static char *sh_tilde(Shell_t *shp,register const char *string)
2491 if(!(cp=nv_getval(sh_scoped(shp,HOME))))
2498 cp = nv_getval(sh_scoped(shp,PWDNOD));
2500 cp = nv_getval(sh_scoped(shp,OLDPWDNOD));
2517 static char *special(Shell_t *shp,register int c)
2520 shp->argaddr = 0;
2525 return(shp->st.dolc>0?shp->st.dolv[1]:NIL(char*));
2528 if(shp->cur_line)
2530 getdolarg(shp,MAX_ARGN,(int*)0);
2531 return(ltos(shp->offsets[0]));
2534 return(ltos(shp->st.dolc));
2536 if(shp->bckpid)
2537 return(ltos(shp->bckpid));
2541 return(ltos(shp->pid));
2544 return(sh_argdolminus(shp->arg_context));
2546 return(ltos(shp->savexit));
2548 if(sh_isstate(SH_PROFILE) || shp->fn_depth==0 || !shp->st.cmdname)
2549 return(shp->shname);
2551 return(shp->st.cmdname);