Lines Matching full:vp
155 struct var *vp; in initvar() local
159 for (ip = varinit ; (vp = ip->var) != NULL ; ip++) { in initvar()
160 if (find_var(ip->text, &vpp, &vp->name_len) != NULL) in initvar()
162 vp->next = *vpp; in initvar()
163 *vpp = vp; in initvar()
164 vp->text = __DECONST(char *, ip->text); in initvar()
165 vp->flags = ip->flags | VSTRFIXED | VTEXTFIXED; in initvar()
166 vp->func = ip->func; in initvar()
318 struct var *vp, **vpp; in setvareq() local
325 vp = find_var(s, &vpp, &nlen); in setvareq()
326 if (vp != NULL) { in setvareq()
327 if (vp->flags & VREADONLY) { in setvareq()
330 error("%.*s: is read only", vp->name_len, vp->text); in setvareq()
339 if (vp->func && (flags & VNOFUNC) == 0) in setvareq()
340 (*vp->func)(s + vp->name_len + 1); in setvareq()
342 if ((vp->flags & (VTEXTFIXED|VSTACK)) == 0) in setvareq()
343 ckfree(vp->text); in setvareq()
345 vp->flags &= ~(VTEXTFIXED|VSTACK|VUNSET); in setvareq()
346 vp->flags |= flags; in setvareq()
347 vp->text = s; in setvareq()
357 if ((vp == &vmpath || (vp == &vmail && ! mpathset())) && in setvareq()
360 if ((vp->flags & VEXPORT) && localevar(s)) { in setvareq()
375 vp = ckmalloc(sizeof (*vp)); in setvareq()
376 vp->flags = flags; in setvareq()
377 vp->text = s; in setvareq()
378 vp->name_len = nlen; in setvareq()
379 vp->next = *vpp; in setvareq()
380 vp->func = NULL; in setvareq()
381 *vpp = vp; in setvareq()
382 if ((vp->flags & VEXPORT) && localevar(s)) { in setvareq()
547 struct var *vp; in environment() local
552 for (vp = *vpp ; vp ; vp = vp->next) in environment()
553 if ((vp->flags & (VEXPORT|VUNSET)) == VEXPORT) in environment()
558 for (vp = *vpp ; vp ; vp = vp->next) in environment()
559 if ((vp->flags & (VEXPORT|VUNSET)) == VEXPORT) in environment()
560 *ep++ = vp->text; in environment()
592 struct var *vp; in showvarscmd() local
602 for (vp = *vpp; vp; vp = vp->next) { in showvarscmd()
603 if (!(vp->flags & VUNSET)) in showvarscmd()
612 for (vp = *vpp; vp; vp = vp->next) { in showvarscmd()
613 if (!(vp->flags & VUNSET)) in showvarscmd()
614 vars[i++] = vp->text; in showvarscmd()
648 struct var *vp; in exportcmd() local
673 vp = find_var(name, NULL, NULL); in exportcmd()
674 if (vp != NULL) { in exportcmd()
675 vp->flags |= flag; in exportcmd()
676 if ((vp->flags & VEXPORT) && localevar(vp->text)) { in exportcmd()
677 change_env(vp->text, 1); in exportcmd()
688 for (vp = *vpp ; vp ; vp = vp->next) { in exportcmd()
689 if (vp->flags & flag) { in exportcmd()
696 if (!isassignment(vp->text)) in exportcmd()
701 if (values && !(vp->flags & VUNSET)) { in exportcmd()
702 outbin(vp->text, in exportcmd()
703 vp->name_len + 1, out1); in exportcmd()
704 out1qstr(vp->text + in exportcmd()
705 vp->name_len + 1); in exportcmd()
707 outbin(vp->text, vp->name_len, in exportcmd()
749 struct var *vp; in mklocal() local
756 vp = NULL; in mklocal()
758 vp = find_var(name, &vpp, NULL); in mklocal()
759 if (vp == NULL) { in mklocal()
764 vp = *vpp; /* the new variable */ in mklocal()
768 lvp->text = vp->text; in mklocal()
769 lvp->flags = vp->flags; in mklocal()
770 vp->flags |= VSTRFIXED|VTEXTFIXED; in mklocal()
771 if (name[vp->name_len] == '=') in mklocal()
775 lvp->vp = vp; in mklocal()
790 struct var *vp; in poplocalvars() local
796 vp = lvp->vp; in poplocalvars()
797 if (vp == NULL) { /* $- saved */ in poplocalvars()
802 vp->flags &= ~VREADONLY; in poplocalvars()
803 (void)unsetvar(vp->text); in poplocalvars()
805 islocalevar = (vp->flags | lvp->flags) & VEXPORT && in poplocalvars()
807 if ((vp->flags & VTEXTFIXED) == 0) in poplocalvars()
808 ckfree(vp->text); in poplocalvars()
809 vp->flags = lvp->flags; in poplocalvars()
810 vp->text = lvp->text; in poplocalvars()
811 if (vp->func) in poplocalvars()
812 (*vp->func)(vp->text + vp->name_len + 1); in poplocalvars()
814 change_env(vp->text, vp->flags & VEXPORT && in poplocalvars()
815 (vp->flags & VUNSET) == 0); in poplocalvars()
882 struct var *vp; in unsetvar() local
884 vp = find_var(s, &vpp, NULL); in unsetvar()
885 if (vp == NULL) in unsetvar()
887 if (vp->flags & VREADONLY) in unsetvar()
889 if (vp->text[vp->name_len + 1] != '\0') in unsetvar()
891 if ((vp->flags & VEXPORT) && localevar(vp->text)) { in unsetvar()
896 vp->flags &= ~VEXPORT; in unsetvar()
897 vp->flags |= VUNSET; in unsetvar()
898 if ((vp->flags & VSTRFIXED) == 0) { in unsetvar()
899 if ((vp->flags & VTEXTFIXED) == 0) in unsetvar()
900 ckfree(vp->text); in unsetvar()
901 *vpp = vp->next; in unsetvar()
902 ckfree(vp); in unsetvar()
930 * vppp is set to the pointer to vp, or the list head if vp isn't found
939 struct var *vp, **vpp; in find_var() local
953 for (vp = *vpp ; vp ; vpp = &vp->next, vp = *vpp) { in find_var()
954 if (vp->name_len != len) in find_var()
956 if (memcmp(vp->text, name, len) != 0) in find_var()
960 return vp; in find_var()