Lines Matching defs:shp
212 Shell_t *shp = sh_getinterp();
213 register struct sh_type *sp = (struct sh_type*)shp->mktype;
216 if(sp->numnodes==0 && !nv_isnull(np) && shp->last_table)
219 Dt_t *root = nv_dict(shp->last_table);
238 Dt_t *root = nv_dict(shp->last_table);
295 Shell_t *shp = sh_getinterp();
298 char *trap=shp->st.trap[SH_DEBUGTRAP];
299 char *prefix = shp->prefix;
310 shtp.previous = shp->mktype;
311 shp->mktype=(void*)&shtp;
319 if(shp->namespace && nv_dict(shp->namespace)==shp->var_tree)
325 if(shp->prefix)
332 shp->used_pos = 0;
335 shp->prefix = 0;
336 cp = sh_mactrim(shp,arg->argval,(flags&NV_NOREF)?-3:-1);
337 shp->prefix = prefix;
350 cp = sh_mactrim(shp,fp->fornam,-1);
353 error_info.line = fp->fortyp-shp->st.firstline;
356 if(shp->fn_depth && (Namval_t*)tp->com.comnamp==SYSTYPESET)
360 shp->prefix = 0;
361 np = nv_open(prefix,shp->var_tree,flag);
362 shp->prefix = prefix;
374 np = nv_open(cp,shp->var_tree,flag|NV_ASSIGN);
379 if(typ && !array && (!shp->prefix || nv_isnull(np) || nv_isarray(np)))
424 Dt_t *last_root = shp->last_root;
425 char **argv = sh_argbuild(shp,&argc,&tp->com,0);
426 shp->last_root = last_root;
428 if(shp->mktype && shp->dot_depth==0 && np==((struct sh_type*)shp->mktype)->nodes[0])
430 shp->mktype = 0;
451 sh_debug(shp,trap,name,(char*)0,argv,(arg->argflag&ARG_APPEND)|ARG_ASSIGN);
454 sh_trace(shp,NIL(char**),0);
476 shp->prefix = cp;
485 shp->prefix = prefix;
498 np = nv_open(cp,shp->var_tree,flag);
526 shp->prefix = stakfreeze(1);
530 shp->prefix = stakcopy(nv_name(np));
532 shp->prefix = cp;
533 shp->last_table = 0;
534 if(shp->prefix)
536 if(*shp->prefix=='_' && shp->prefix[1]=='.' && nv_isref(L_ARGNOD))
538 sfprintf(stkstd,"%s%s",nv_name(L_ARGNOD->nvalue.nrp->np),shp->prefix+1);
539 shp->prefix = stkfreeze(stkstd,1);
545 nr.root = shp->last_root;
546 nr.table = shp->last_table;
552 if(shp->prefix)
559 shp->prefix = prefix;
584 np = nv_open(cp,shp->var_tree,flags);
587 if(shp->used_pos)
608 sh_trace(shp,NIL(char**),0);
624 sh_debug(shp,trap,name,sub,av,append);
631 nv_open(shtp.nodes[0]->nvname,shp->var_tree,NV_ASSIGN|NV_VARNAME|NV_NOADD|NV_NOFAIL);
634 shp->mktype = shtp.previous;
636 shp->prefix = 0;
716 Shell_t *shp = sh_getinterp();
726 if(root==shp->var_tree)
754 if(root==shp->var_tree)
780 if((rp=shp->st.real_fun) && !rp->sdict && (flags&NV_STATIC))
782 Dt_t *dp = dtview(shp->var_tree,(Dt_t*)0);
785 dtview(shp->var_tree,rp->sdict);
787 if(np = nv_search(name,shp->var_tree,0))
790 if(shp->var_tree->walk==shp->var_base || (shp->var_tree->walk!=shp->var_tree && shp->namespace && nv_dict(shp->namespace)==shp->var_tree->walk))
792 if(shp->var_tree->walk==shp->var_base)
796 if(!(nq = nv_search((char*)np,shp->var_base,HASH_BUCKET)))
799 shp->last_root = shp->var_tree->walk;
803 root = shp->var_tree->walk;
813 if(shp->var_tree->walk)
814 root = shp->var_tree->walk;
822 if(np && shp->var_tree->walk==shp->var_tree)
825 nv_delete(np,shp->var_tree,0);
828 if(!np || shp->var_tree->walk!=root)
833 if(!np && !noscope && *name!='.' && shp->namespace && root==shp->var_tree)
834 root = nv_dict(shp->namespace);
844 root = shp->last_root;
856 if(shp->namespace && root==nv_dict(shp->namespace))
859 shp->last_table = shp->namespace;
876 shp->argaddr = 0;
886 shp->last_root = root;
887 shp->last_table = nv_reftable(np);
946 shp->last_root = root;
971 sh_arith(shp,sp+1);
1081 n = sh_arith(shp,sp+1);
1152 shp->last_table = 0;
1249 Shell_t *shp = sh_getinterp();
1265 shp->last_table = 0;
1267 root = shp->var_tree;
1268 shp->last_root = root;
1269 if(root==shp->fun_tree)
1281 root = shp->var_tree;
1294 shp->last_table = nv_reftable(np);
1300 else if(shp->prefix && (flags&NV_ASSIGN))
1302 name = cp = copystack(shp->prefix,name,(const char*)0);
1306 if(root==shp->alias_tree)
1311 if(shp->subshell && c=='=')
1326 if(root==shp->var_tree)
1327 root = shp->var_base;
1328 shp->last_table = 0;
1344 shp->last_table = xp->last_table;
1345 shp->last_root = xp->last_root;
1379 xp->last_table = shp->last_table;
1380 xp->last_root = shp->last_root;
1410 if(np && shp->mktype)
1424 char *sub=0, *prefix= shp->prefix;
1428 shp->prefix = 0;
1429 if((flags&NV_STATIC) && !shp->mktype)
1433 shp->prefix = prefix;
1460 if(nv_search((char*)np,shp->var_base,HASH_BUCKET))
1461 shp->last_root = shp->var_base;
1465 shp->prefix = prefix;
1502 Shell_t *shp = sh_getinterp();
1518 shp->argaddr = 0;
1519 if(shp->subshell && !nv_local)
1529 sh_envput(shp->env,np);
1580 ld = sh_arith(shp,sp);
1600 d = sh_arith(shp,sp);
1644 ll = (Sflong_t)sh_arith(shp,sp);
1688 Sfdouble_t ld = sh_arith(shp,sp);
1727 sfprintf(shp->strbuf,"%.*Lg",LDBL_DIG,*((Sfdouble_t*)sp));
1729 sfprintf(shp->strbuf,"%.*g",DBL_DIG,*((double*)sp));
1734 sfprintf(shp->strbuf,"%I*lu",sizeof(Sfulong_t),*((Sfulong_t*)sp));
1736 sfprintf(shp->strbuf,"%lu",(unsigned long)((flags&NV_SHORT)?*((uint16_t*)sp):*((uint32_t*)sp)));
1741 sfprintf(shp->strbuf,"%I*ld",sizeof(Sflong_t),*((Sflong_t*)sp));
1743 sfprintf(shp->strbuf,"%ld",(long)((flags&NV_SHORT)?*((int16_t*)sp):*((int32_t*)sp)));
1745 sp = sfstruse(shp->strbuf);
1887 sh_envput(shp->env,np);
2097 Shell_t *shp = sh_getinterp();
2100 env_delete(shp->env,"_");
2101 er = env_get(shp->env);
2105 nv_scan(shp->var_tree, attstore,(void*)0,0,(NV_RDONLY|NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER));
2119 Shell_t *shp = sh_getinterp();
2120 data.sh = shp;
2126 namec = nv_scan(shp->var_tree,nullscan,(void*)0,NV_EXPORT,NV_EXPORT);
2127 namec += shp->nenv;
2129 data.argnam = (er+=2) + shp->nenv;
2130 if(shp->nenv)
2131 memcpy((void*)er,environ,shp->nenv*sizeof(char*));
2132 nv_scan(shp->var_tree, pushnam,&data,NV_EXPORT, NV_EXPORT);
2135 nv_scan(shp->var_tree, attstore,&data,0,(NV_RDONLY|NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER));
2212 void sh_scope(Shell_t *shp, struct argnod *envlist, int fun)
2214 register Dt_t *newscope, *newroot=shp->var_base;
2217 if(shp->namespace)
2219 newroot = nv_dict(shp->namespace);
2220 dtview(newroot,(Dt_t*)shp->var_base);
2226 dtview(newscope,(Dt_t*)shp->var_tree);
2227 shp->var_tree = newscope;
2231 shp->var_tree = dtview(newscope,0);
2233 if((rp=shp->st.real_fun) && rp->sdict)
2240 shp->var_tree = newscope;
2296 static void table_unset(Shell_t *shp, register Dt_t *root, int flags, Dt_t *oroot)
2305 int subshell = shp->subshell;
2306 shp->subshell = 0;
2312 else if(shp->test&4)
2316 shp->subshell = subshell;
2320 sh_envput(shp->env,nq);
2323 shp->last_root = root;
2324 shp->last_table = 0;
2353 Shell_t *shp = sh_getinterp();
2369 npv = nv_open(name,shp->var_tree,NV_NOARRAY|NV_VARNAME|NV_NOADD);
2371 if(npv && npv!=shp->namespace)
2374 if(rp->fname && shp->fpathdict && (rq = (struct Ufunction*)nv_search(rp->fname,shp->fpathdict,0)))
2380 dtdelete(shp->fpathdict,rq);
2383 while(rq = (struct Ufunction*)dtnext(shp->fpathdict,rq));
2402 if(shp->subshell)
2451 env_delete(shp->env,nv_name(np));
2467 Namval_t *sh_scoped(Shell_t *shp, register Namval_t *np)
2469 if(!dtvnext(shp->var_tree))
2471 return(dtsearch(shp->var_tree,np));
2548 Shell_t *shp = sh_getinterp();
2551 if(shp->argaddr)
2555 shp->argaddr = 0;
2562 shp->argaddr = 0;
2568 if((xp= (struct optimize*)fp) && xp->ptr==shp->argaddr)
2574 op->ptr = shp->argaddr;
2585 op->next = (struct optimize*)shp->optlist;
2586 shp->optlist = (void*)op;
2592 void sh_optclear(Shell_t *shp, void *old)
2595 for(op=(struct optimize*)shp->optlist; op; op = opnext)
2606 shp->optlist = old;
2626 Shell_t *shp = sh_getinterp();
2630 if(!nv_local && shp->argaddr)
2639 shp->last_table = nv_reftable(np);
2671 sfprintf(shp->strbuf,format,nv_size(np),ld);
2682 sfprintf(shp->strbuf,format,nv_size(np),d);
2684 return(sfstruse(shp->strbuf));
2715 sfprintf(shp->strbuf,"%I*u",sizeof(ll),ll);
2716 return(sfstruse(shp->strbuf));
2750 Shell_t *shp = sh_getinterp();
2755 if(!nv_local && shp->argaddr)
2824 r = sh_arith(shp,str);
2836 Shell_t *shp = sh_getinterp();
2844 char *prefix = shp->prefix,*sub;
2859 env_delete(shp->env,nv_name(np));
2861 sh_envput(shp->env,np);
2946 shp->prefix = prefix;
2976 Shell_t *shp = sh_getinterp();
2978 if(!shp->var_tree)
2985 else if((np = nv_search(name,shp->var_tree,0)) && nv_isattr(np,NV_EXPORT))
3008 Shell_t *shp = sh_getinterp();
3012 np = nv_open(name,shp->var_tree,NV_EXPORT|NV_IDENT|NV_NOARRAY|NV_ASSIGN);
3024 Shell_t *shp = sh_getinterp();
3028 np = nv_open(name,shp->var_tree,NV_EXPORT|NV_IDENT|NV_NOARRAY|NV_ASSIGN);
3081 Shell_t *shp = sh_getinterp();
3085 Namval_t *last_table = shp->last_table;
3086 Dt_t *last_root = shp->last_root;
3088 char *nvenv=0,*prefix=shp->prefix;
3090 if(nv_isattr(np,NV_PARAM) && shp->st.prevst)
3092 if(!(hp=(Dt_t*)shp->st.prevst->save_tree))
3093 hp = dtvnext(shp->var_tree);
3108 shp->prefix = 0;
3110 hp = shp->var_tree;
3114 if(shp->namespace)
3115 hp = nv_dict(shp->namespace);
3118 hp = shp->var_base;
3120 else if(shp->last_root)
3121 hp = shp->last_root;
3124 shp->prefix = prefix;
3133 sfprintf(shp->strbuf,"%s[%d]%c",nv_name(np),index,0);
3135 if(mp = nv_open(sfstruse(shp->strbuf),shp->var_tree,NV_VARNAME|NV_ADD|NV_ARRAY))
3159 shp->prev_table = shp->last_table;
3160 shp->prev_root = shp->last_root;
3161 shp->last_table = last_table;
3162 shp->last_root = last_root;
3202 Shell_t *shp = sh_getinterp();
3205 Dt_t *root = shp->last_root, *hpnext=0;
3221 if((nr=nv_open(cp, hp?hp:shp->var_tree, flags|NV_NOSCOPE|NV_NOADD|NV_NOFAIL)) ||
3222 (hpnext && dtvnext(hpnext)==shp->var_base && (nr=nv_open(cp,hpnext,flags|NV_NOSCOPE|NV_NOADD|NV_NOFAIL))))
3225 hp = shp->last_root;
3228 hp = hp?shp->var_base:shp->var_tree;
3231 if(shp->namespace && nv_dict(shp->namespace)==hp)
3254 shp->last_root = 0;
3256 if(shp->last_root)
3257 hp = shp->last_root;
3259 if(shp->last_root == shp->var_tree && root!=shp->var_tree)
3265 shp->instance = 1;
3289 shp->instance = 0;
3290 shp->last_root = root;
3305 np->nvalue.nrp->table = shp->last_table;
3322 Shell_t *shp = sh_getinterp();
3325 sp = &shp->st;
3328 if ((struct sh_scoped*)shp->topscope != shp->st.self)
3329 topmost = (struct sh_scoped*)shp->topscope;
3331 topmost = &(shp->st);
3353 Shell_t *shp = sh_getinterp();
3354 Shscope_t *old = (Shscope_t*)shp->st.self;
3355 *shp->st.self = shp->st;
3356 shp->st = *((struct sh_scoped*)scope);
3357 shp->var_tree = scope->var_tree;
3358 SH_PATHNAMENOD->nvalue.cp = shp->st.filename;
3359 SH_FUNNAMENOD->nvalue.cp = shp->st.funname;
3363 void sh_unscope(Shell_t *shp)
3365 register Dt_t *root = shp->var_tree;
3367 table_unset(shp,root,NV_RDONLY|NV_NOSCOPE,dp);
3368 if(shp->st.real_fun && dp==shp->st.real_fun->sdict)
3371 shp->st.real_fun->sdict->view = dp;
3373 shp->var_tree=dp;
3455 Shell_t *shp = sh_getinterp();
3465 if(shp->namespace && is_afunction(np))
3467 char *name = nv_name(shp->namespace);
3480 Namval_t *nq= shp->last_table, *mp= (Namval_t*)np->nvenv;
3481 if(np==shp->last_table)
3482 shp->last_table = 0;
3484 sfprintf(shp->strbuf,"%s[%s]",nv_name(mp),np->nvname);
3486 sfprintf(shp->strbuf,"%s.%s",nv_name(mp),np->nvname);
3487 shp->last_table = nq;
3488 return(sfstruse(shp->strbuf));
3492 shp->last_table = nv_parent(np);
3494 shp->last_table = nv_create(np,0, NV_LAST,(Namfun_t*)0);
3501 if(np==shp->last_table)
3502 shp->last_table = 0;
3506 if(!(table=shp->last_table) || *np->nvname=='.' || table==shp->namespace || np==table)
3519 sfprintf(shp->strbuf,"%s.%s",cp,np->nvname);
3522 sfprintf(shp->strbuf,"%s",np->nvname);
3525 nv_arrfixed(np,shp->strbuf,1,(char*)0);
3527 return(sfstruse(shp->strbuf));
3532 Shell_t *shp = sh_getinterp();
3533 return(shp->last_table);