Lines Matching refs:vp

94 	struct tbl *vp, **vpp = l->vars.tbls, *vq;  in popblock()  local
101 if ((vp = *vpp++) != NULL && (vp->flag&SPECIAL)) { in popblock()
102 if ((vq = global(vp->name))->flag & ISSET) in popblock()
150 register struct tbl *vp; in varsearch() local
154 if ((vp = ktsearch(&l->vars, vn, h)) != NULL) in varsearch()
161 vp = NULL; in varsearch()
163 *vpp = vp; in varsearch()
184 struct tbl *vp; in array_index_calc() local
189 varsearch(e->loc, &vp, vn, hash(vn)); in array_index_calc()
191 if (vp && (vp->flag & (DEFINED | ASSOC | ARRAY)) == in array_index_calc()
196 cp = shf_smprintf("%s%s", str_val(vp), p); in array_index_calc()
228 struct tbl *vp; in global() local
245 vp = &vtemp; in global()
246 vp->flag = DEFINED; in global()
247 vp->type = 0; in global()
248 vp->areap = ATEMP; in global()
249 *vp->name = c; in global()
253 setstr(vp, l->argv[c], KSH_RETURN_ERROR); in global()
254 vp->flag |= RDONLY; in global()
257 vp->flag |= RDONLY; in global()
260 vp->flag |= ISSET|INTEGER; in global()
263 vp->val.i = kshpid; in global()
267 if ((vp->val.i = j_async()) == 0) in global()
268 vp->flag &= ~(ISSET|INTEGER); in global()
271 vp->val.i = exstat & 0xFF; in global()
274 vp->val.i = l->argc; in global()
277 vp->flag &= ~INTEGER; in global()
278 vp->val.s = getoptions(); in global()
281 vp->flag &= ~(ISSET|INTEGER); in global()
285 l = varsearch(e->loc, &vp, vn, h); in global()
286 if (vp != NULL) { in global()
288 vp = arraysearch(vp, val); in global()
291 vp = ktenter(&l->vars, vn, h); in global()
293 vp = arraysearch(vp, val); in global()
294 vp->flag |= DEFINED; in global()
296 vp->flag |= SPECIAL; in global()
301 return (vp); in global()
310 struct tbl *vp; in local() local
323 vp = &vtemp; in local()
324 vp->flag = DEFINED|RDONLY; in local()
325 vp->type = 0; in local()
326 vp->areap = ATEMP; in local()
329 vp = ktenter(&l->vars, vn, h); in local()
330 if (copy && !(vp->flag & DEFINED)) { in local()
335 vp->flag |= vq->flag & in local()
339 vp->type = vq->type; in local()
340 vp->u2.field = vq->u2.field; in local()
344 vp = arraysearch(vp, val); in local()
345 vp->flag |= DEFINED; in local()
347 vp->flag |= SPECIAL; in local()
352 return (vp); in local()
358 str_val(struct tbl *vp) in str_val() argument
362 if ((vp->flag&SPECIAL)) in str_val()
363 getspec(vp); in str_val()
364 if (!(vp->flag&ISSET)) in str_val()
367 else if (!(vp->flag&INTEGER)) in str_val()
369 s = vp->val.s + vp->type; in str_val()
380 const char *digits = (vp->flag & UCASEV_AL) ? in str_val()
384 if (vp->flag & INT_U) in str_val()
385 n = vp->val.u; in str_val()
387 n = (vp->val.i < 0) ? -vp->val.u : vp->val.u; in str_val()
388 base = (vp->type == 0) ? 10U : (unsigned int)vp->type; in str_val()
415 if (!(vp->flag & INT_U) && vp->val.i < 0) in str_val()
418 if (vp->flag & (RJUST|LJUST)) in str_val()
420 s = formatstr(vp, s); in str_val()
482 struct tbl *vp = &vtemp; in setint() local
483 vp->flag = (ISSET|INTEGER); in setint()
484 vp->type = 0; in setint()
485 vp->areap = ATEMP; in setint()
486 vp->val.i = n; in setint()
488 setstr(vq, str_val(vp), KSH_RETURN_ERROR); in setint()
497 getint(struct tbl *vp, mksh_ari_u *nump, bool arith) in getint() argument
503 if (vp->flag & SPECIAL) in getint()
504 getspec(vp); in getint()
506 if (!(vp->flag & ISSET) || (!(vp->flag & INTEGER) && vp->val.s == NULL)) in getint()
508 if (vp->flag & INTEGER) { in getint()
509 nump->i = vp->val.i; in getint()
510 return (vp->type); in getint()
512 s = vp->val.s + vp->type; in getint()
534 !(vp->flag & ZEROFIL)) { in getint()
595 setint_v(struct tbl *vq, struct tbl *vp, bool arith) in setint_v() argument
600 if ((base = getint(vp, &num, arith)) == -1) in setint_v()
627 formatstr(struct tbl *vp, const char *s) in formatstr() argument
635 if (vp->flag & (RJUST|LJUST)) { in formatstr()
636 if (!vp->u2.field) in formatstr()
638 vp->u2.field = olen; in formatstr()
639 nlen = vp->u2.field; in formatstr()
644 if (vp->flag & (RJUST|LJUST)) { in formatstr()
647 if (vp->flag & RJUST) { in formatstr()
658 if (vp->flag & ZEROFIL && vp->flag & INTEGER) { in formatstr()
666 if (vp->u2.field <= n) in formatstr()
673 while (slen > vp->u2.field) in formatstr()
675 if (vp->u2.field - slen) in formatstr()
676 memset(p + n, (vp->flag & ZEROFIL) ? '0' : ' ', in formatstr()
677 vp->u2.field - slen); in formatstr()
679 shf_snprintf(p + vp->u2.field - slen, in formatstr()
680 psiz - (vp->u2.field - slen), in formatstr()
686 if (vp->flag & ZEROFIL) in formatstr()
690 vp->u2.field, vp->u2.field, s); in formatstr()
695 if (vp->flag & UCASEV_AL) { in formatstr()
698 } else if (vp->flag & LCASEV) { in formatstr()
710 exportprep(struct tbl *vp, const char *val) in exportprep() argument
713 char *op = (vp->flag&ALLOC) ? vp->val.s : NULL; in exportprep()
716 namelen = strlen(vp->name); in exportprep()
719 vp->flag |= ALLOC; in exportprep()
721 xp = alloc(namelen + 1 + vallen, vp->areap); in exportprep()
722 memcpy(vp->val.s = xp, vp->name, namelen); in exportprep()
726 vp->type = xp - vp->val.s; in exportprep()
728 afree(op, vp->areap); in exportprep()
739 struct tbl *vp; in typeset() local
817 varsearch(e->loc, &vp, tvar, hash(tvar)); in typeset()
818 if (vp == NULL) in typeset()
820 qval = str_val(vp); in typeset()
857 varsearch(e->loc, &vp, qval, hash(qval)); in typeset()
859 if (vp && ((vp->flag & (ARRAY | ASSOC)) == ASSOC)) in typeset()
860 qval = str_val(vp); in typeset()
870 vp = (set & LOCAL) ? local(tvar, tobool(set & LOCAL_COPY)) : in typeset()
872 if (new_refflag == SRF_DISABLE && (vp->flag & (ARRAY|ASSOC)) == ASSOC) in typeset()
873 vp->flag &= ~ASSOC; in typeset()
875 if (vp->flag & ARRAY) { in typeset()
879 for (a = vp->u.array; a; ) { in typeset()
886 vp->u.array = NULL; in typeset()
887 vp->flag &= ~ARRAY; in typeset()
889 vp->flag |= ASSOC; in typeset()
894 vpbase = (vp->flag & ARRAY) ? global(arrayname(tvar)) : vp; in typeset()
920 fake_assign = (t->flag & ISSET) && (!val || t != vp) && in typeset()
944 if ((set & INTEGER) && base > 0 && (!val || t != vp)) in typeset()
977 tval = shf_smprintf("%s%s", str_val(vp), val); in typeset()
982 if (vp->flag&INTEGER) { in typeset()
984 setstr(vp, val, KSH_UNWIND_ERROR | 0x4); in typeset()
987 vp->type = base; in typeset()
990 setstr(vp, val, KSH_RETURN_ERROR | 0x4); in typeset()
1000 return (vp); in typeset()
1009 unset(struct tbl *vp, int flags) in unset() argument
1011 if (vp->flag & ALLOC) in unset()
1012 afree(vp->val.s, vp->areap); in unset()
1013 if ((vp->flag & ARRAY) && (flags & 1)) { in unset()
1017 for (a = vp->u.array; a; ) { in unset()
1024 vp->u.array = NULL; in unset()
1027 vp->flag &= ~(ALLOC|ISSET); in unset()
1031 vp->flag &= SPECIAL | ((flags & 1) ? 0 : ARRAY|DEFINED); in unset()
1032 if (vp->flag & SPECIAL) in unset()
1034 unsetspec(vp); in unset()
1117 struct tbl *vp, **vpp; in makenv() local
1124 if ((vp = *vpp++) != NULL && in makenv()
1125 (vp->flag&(ISSET|EXPORT)) == (ISSET|EXPORT)) { in makenv()
1128 uint32_t h = hash(vp->name); in makenv()
1132 vp2 = ktsearch(&l2->vars, vp->name, h); in makenv()
1136 if ((vp->flag&INTEGER)) { in makenv()
1139 val = str_val(vp); in makenv()
1140 vp->flag &= ~(INTEGER|RDONLY|SPECIAL); in makenv()
1142 setstr(vp, val, KSH_RETURN_ERROR); in makenv()
1144 XPput(denv, vp->val.s); in makenv()
1182 getspec(struct tbl *vp) in getspec() argument
1188 switch ((st = special(vp->name))) { in getspec()
1222 vp->flag &= ~SPECIAL; in getspec()
1226 setstr(vp, buf, KSH_RETURN_ERROR | 0x4); in getspec()
1227 vp->flag |= SPECIAL; in getspec()
1242 if (vp->flag & ISSET) { in getspec()
1252 vp->flag &= ~SPECIAL; in getspec()
1253 setint_n(vp, num.i, 0); in getspec()
1254 vp->flag |= SPECIAL; in getspec()
1258 setspec(struct tbl *vp) in setspec() argument
1264 switch ((st = special(vp->name))) { in setspec()
1267 sethistfile(str_val(vp)); in setspec()
1271 setctypes(s = str_val(vp), C_IFS); in setspec()
1276 s = str_val(vp); in setspec()
1291 s = str_val(vp); in setspec()
1301 if (vp->flag & IMPORT) { in setspec()
1303 unspecial(vp->name); in setspec()
1304 vp->flag &= ~SPECIAL; in setspec()
1314 vp->flag &= ~SPECIAL; in setspec()
1315 if (getint(vp, &num, false) == -1) { in setspec()
1316 s = str_val(vp); in setspec()
1318 errorf("%s: %s: %s", vp->name, "bad number", s); in setspec()
1321 vp->flag |= SPECIAL; in setspec()
1371 unsetspec(struct tbl *vp) in unsetspec() argument
1381 switch (special(vp->name)) { in unsetspec()
1409 unspecial(vp->name); in unsetspec()
1419 arraysearch(struct tbl *vp, uint32_t val) in arraysearch() argument
1424 vp->flag = (vp->flag | (ARRAY | DEFINED)) & ~ASSOC; in arraysearch()
1427 return (vp); in arraysearch()
1428 prev = vp; in arraysearch()
1429 curr = vp->u.array; in arraysearch()
1441 len = strlen(vp->name); in arraysearch()
1443 news = alloc(offsetof(struct tbl, name[0]) + ++len, vp->areap); in arraysearch()
1444 memcpy(news->name, vp->name, len); in arraysearch()
1446 news->flag = (vp->flag & ~(ALLOC|DEFINED|ISSET|SPECIAL)) | AINDEX; in arraysearch()
1447 news->type = vp->type; in arraysearch()
1448 news->areap = vp->areap; in arraysearch()
1449 news->u2.field = vp->u2.field; in arraysearch()
1504 struct tbl *vp, *vq; in set_array() local
1518 vp = global(ccp); in set_array()
1521 if ((vp->flag&RDONLY)) in set_array()
1526 unset(vp, 1); in set_array()
1528 arraysearch(vp, 0); in set_array()
1537 for (vq = vp; vq; vq = vq->u.array) { in set_array()
1569 vq = arraysearch(vp, j); in set_array()