• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/ksh-23/ksh/src/cmd/ksh93/bltins/

Lines Matching refs:np

183 					Namval_t *np = nv_search((char*)PATHNOD,tdata.sh->var_tree,HASH_BUCKET);
184 nv_putval(np,nv_getval(np),NV_RDONLY);
460 static void print_value(Sfio_t *iop, Namval_t *np, struct tdata *tp)
464 if(nv_isnull(np))
466 if(!np->nvflag)
470 else if(nv_istable(np))
477 cp = name = nv_name(np);
489 tp->sh->prefix = nv_name(np)+1;
492 tp->sh->namespace = np;
495 print_scan(iop,NV_NOSCOPE,nv_dict(np),aflag=='+',tp);
507 sfputr(iop,nv_name(np),aflag=='+'?'\n':'=');
510 if(nv_isarray(np) && nv_arrayptr(np))
512 nv_outnode(np,iop,-1,0);
517 if(nv_isvtree(np))
518 nv_onattr(np,NV_EXPORT);
519 if(!(name = nv_getval(np)))
521 if(!nv_isvtree(np))
558 register Namval_t *np;
572 if((np=nv_search(name,shp->bltin_tree,0)) && nv_isattr(np,BLT_SPC))
576 np = sh_fsearch(shp,name,NV_ADD|HASH_NOSCOPE);
579 np = nv_open(name,sh_subfuntree(1),NV_NOARRAY|NV_IDENT|NV_NOSCOPE);
589 np = 0;
591 np = sh_fsearch(shp,name,HASH_NOSCOPE);
592 if(!np)
594 if(np=nv_search(name,troot,0))
596 if(!is_afunction(np))
597 np = 0;
602 if(np && ((flag&NV_LTOU) || !nv_isnull(np) || nv_isattr(np,NV_LTOU)))
606 print_namval(sfstdout,np,tp->aflag=='+',tp);
612 nv_onattr(np,flag|NV_FUNCTION);
614 nv_offattr(np,flag);
621 if(!np)
625 np = nv_search(stkptr(shp->stk,offset),troot,0);
628 if(np && np->nvalue.cp)
629 np->nvalue.rp->help = tp->help;
636 np = nv_search(name,troot,NV_ADD);
637 path_alias(np,path_absolute(shp,nv_name(np),NIL(Pathcomp_t*)));
640 np = nv_open(name,troot,nvflags|((nvflags&NV_ASSIGN)?0:NV_ARRAY)|((iarray|(nvflags&(NV_REF|NV_NOADD)==NV_REF))?NV_FARRAY:0));
641 if(!np)
643 if(nv_isnull(np) && !nv_isarray(np) && nv_isattr(np,NV_NOFREE))
644 nv_offattr(np,NV_NOFREE);
645 else if(tp->tp && !nv_isattr(np,NV_MINIMAL|NV_EXPORT) && (mp=(Namval_t*)np->nvenv) && (ap=nv_arrayptr(mp)) && (ap->nelem&ARRAY_TREE))
646 errormsg(SH_DICT,ERROR_exit(1),e_typecompat,nv_name(np));
647 else if((ap=nv_arrayptr(np)) && nv_aindex(np)>0 && ap->nelem==1 && nv_getval(np)==Empty)
650 _nv_unset(np,0);
654 errormsg(SH_DICT,ERROR_exit(1),"cannot change associative array %s to index array",nv_name(np));
655 else if( (iarray||(flag&NV_ARRAY)) && nv_isvtree(np) && !nv_type(np))
656 _nv_unset(np,NV_EXPORT);
659 if(!nv_istable(np))
660 nv_attribute(np,sfstdout,tp->prefix,1);
661 print_value(sfstdout,np,tp);
666 if(troot!=shp->var_tree && (nv_isnull(np) || !print_namval(sfstdout,np,0,tp)))
674 if(!nv_isarray(np) && !strchr(name,'=') && !(shp->envlist && nv_onlist(shp->envlist,name)))
676 if(comvar || (shp->last_root==shp->var_tree && (tp->tp || (!shp->st.real_fun && (nvflags&NV_STATIC)) || (!(flag&(NV_EXPORT|NV_RDONLY)) && nv_isattr(np,(NV_EXPORT|NV_IMPORT))==(NV_EXPORT|NV_IMPORT)))))
678 _nv_unset(np,0);
686 nv_atypeindex(np,tp->tname+1);
687 else if(nv_isnull(np))
688 nv_onattr(np,NV_ARRAY|(comvar?NV_NOFREE:0));
693 nv_putsub(np, (char*)0, 0);
700 Namarr_t *ap=nv_arrayptr(np);
705 _nv_unset(np,NV_RDONLY);
706 nv_onattr(np,NV_NOFREE);
709 nv_setarray(np,nv_associative);
711 else if(comvar && !nv_isvtree(np) && !nv_rename(np,flag|NV_COMVAR))
712 nv_setvtree(np);
716 nv_rename(np, flag);
717 nv_close(np);
720 if(tp->tp && nv_type(np)!=tp->tp)
722 nv_settype(np,tp->tp,tp->aflag=='-'?0:NV_APPEND);
723 flag = (np->nvflag&NV_NOCHANGE);
730 curflag = np->nvflag;
736 errormsg(SH_DICT,ERROR_exit(1),e_mapchararg,nv_name(np));
737 cp = (char*)nv_mapchar(np,0);
738 if(fp=nv_mapchar(np,tp->wctname))
744 nv_disc(np,fp,NV_POP);
747 nv_offattr(np,flag&(NV_LTOU|NV_UTOL));
752 nv_disc(np,fp,NV_LAST);
753 nv_onattr(np,flag&(NV_LTOU|NV_UTOL));
759 if((flag&NV_EXPORT) && (strchr(name,'.') || nv_isvtree(np)))
763 nv_offattr(np,NV_IMPORT);
781 errormsg(SH_DICT,ERROR_exit(1),e_readonly,nv_name(np));
787 sh_assignok(np,1);
789 nv_setattr(np,newflag&~NV_ASSIGN);
794 if(tp->argnum==1 && newflag==NV_INTEGER && nv_isattr(np,NV_INTEGER))
796 if(np->nvfun && !nv_isarray(np) && name[len-1]=='.')
798 nv_newattr (np, newflag&~NV_ASSIGN,tp->argnum);
800 np->nvname = oldname;
803 if(tp->help && !nv_isattr(np,NV_MINIMAL|NV_EXPORT))
805 np->nvenv = tp->help;
806 nv_onattr(np,NV_EXPORT);
816 if(nv_isattr(np,NV_PARAM) && shp->st.prevst)
822 nv_onattr(np,NV_REF|NV_FUNCT);
824 nv_setref(np,hp,NV_VARNAME);
827 nv_unref(np);
829 nv_close(np);
969 register Namval_t *np;
1078 if(np = sh_addbuiltin(arg, addr,pointerof(dlete)))
1080 if(dlete || nv_isattr(np,BLT_SPC))
1084 nv_onattr(np,liblist[n].attr);
1090 if(!addr && (np = nv_search(arg,context->shp->bltin_tree,0)))
1092 if(nv_isattr(np,BLT_SPC))
1094 addr = (Shbltin_f)np->nvalue.bfp;
1096 if(!dlete && !addr && !(np=sh_addbuiltin(arg,(Shbltin_f)0 ,0)))
1156 register Namval_t *np;
1210 np = 0;
1215 np = sh_fsearch(shp,name,nflag?HASH_NOSCOPE:0);
1216 if(!np)
1218 np=nv_open(name,troot,NV_NOADD|nflag);
1225 if(np)
1227 if(is_abuiltin(np) || nv_isattr(np,NV_RDONLY))
1229 if(nv_isattr(np,NV_RDONLY))
1230 errormsg(SH_DICT,ERROR_warn(0),e_readonly, nv_name(np));
1234 isfun = is_afunction(np);
1239 if((ap=nv_arrayptr(np)) && !ap->fixed && name[strlen(name)-1]==']' && !nv_getsub(np))
1241 if(nv_isarray(np) && name[strlen(name)-1]==']' && !nv_getsub(np))
1249 np=sh_assignok(np,0);
1251 if(!nv_isnull(np) || nv_size(np) || nv_isattr(np,~(NV_MINIMAL|NV_NOFREE)))
1252 _nv_unset(np,0);
1254 nv_delete(np,dp,NV_NOFREE);
1255 else if(isfun && !(np->nvalue.rp && np->nvalue.rp->running))
1256 nv_delete(np,troot,0);
1259 else if(shp->var_tree==troot && shp->var_tree!=shp->var_base && nv_search((char*)np,shp->var_tree,HASH_BUCKET|HASH_NOSCOPE))
1260 nv_delete(np,shp->var_tree,0);
1263 nv_close(np);
1274 * print out the name and value of a name-value pair <np>
1277 static int print_namval(Sfio_t *file,register Namval_t *np,register int flag, struct tdata *tp)
1284 if(tp->noref && nv_isref(np))
1286 if(nv_isattr(np,NV_NOPRINT|NV_INTEGER)==NV_NOPRINT)
1288 if(is_abuiltin(np) && strcmp(np->nvname,".sh.tilde"))
1289 sfputr(file,nv_name(np),'\n');
1292 if(nv_istable(np))
1294 print_value(file,np,tp);
1297 isfun = is_afunction(np);
1300 outname = (*tp->prefix=='t' && (!nv_isnull(np) || nv_isattr(np,NV_FLOAT|NV_RDONLY|NV_BINARY|NV_RJUST|NV_NOPRINT)));
1309 nv_attribute(np,tp->outfile,tp->prefix,tp->aflag);
1318 if(nv_isattr(np,NV_NOFREE))
1320 if(!flag && !np->nvalue.ip)
1322 else if(!flag && !nv_isattr(np,NV_FPOSIX))
1324 cp = nv_name(np);
1328 if(nv_isattr(np,NV_FPOSIX))
1330 if(np->nvalue.ip && np->nvalue.rp->hoffset>=0)
1331 fname = np->nvalue.rp->fname;
1336 if(tp->pflag && np->nvalue.ip && np->nvalue.rp->hoffset>=0)
1337 sfprintf(file," #line %d %s\n",np->nvalue.rp->lineno,fname?sh_fmtq(fname):"");
1343 if(nv_isattr(np,NV_FTMP))
1352 if(iop && sfseek(iop,(Sfoff_t)np->nvalue.rp->hoffset,SEEK_SET)>=0)
1353 sfmove(iop,file, nv_size(np), -1);
1359 return(nv_size(np)+1);
1361 if(nv_arrayptr(np))
1365 print_value(file,np,tp);
1368 if(nv_isvtree(np))
1369 nv_onattr(np,NV_EXPORT);
1370 if(cp=nv_getval(np))
1374 sfputr(file,nv_name(np),-1);
1380 if(nv_isref(np) && nv_refsub(np))
1383 sfprintf(file,"[%s]\n", sh_fmtq(nv_refsub(np)));
1387 sfputr(file,nv_isvtree(np)?cp:sh_fmtq(cp),'\n');
1395 sfputr(file,nv_name(np),'\n');
1409 * print the attributes of name value pair give by <np>
1411 static void print_attribute(register Namval_t *np,void *data)
1414 nv_attribute(np,dp->outfile,dp->prefix,dp->aflag);
1425 register Namval_t *np;
1455 if((np=nv_search(*argv++,root,0)) && np!=onp && (!nv_isnull(np) || np->nvfun || nv_isattr(np,~NV_NOFREE)))
1457 onp = np;
1460 char *newname = nv_name(np);
1467 if(nv_aindex(np)>=0)
1478 print_namval(file,np,option,tp);
1479 if(!is_abuiltin(np) && nv_isvtree(np))
1481 name = nv_name(np);
1492 static void pushname(Namval_t *np,void *data)
1495 *tp->argnam++ = nv_name(np);