• Home
  • Raw
  • Download

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
243 vp = &vtemp; in global()
244 vp->flag = DEFINED; in global()
245 vp->type = 0; in global()
246 vp->areap = ATEMP; in global()
247 *vp->name = c; in global()
251 setstr(vp, l->argv[c], KSH_RETURN_ERROR); in global()
252 vp->flag |= RDONLY; in global()
253 return (vp); in global()
255 vp->flag |= RDONLY; in global()
257 return (vp); in global()
258 vp->flag |= ISSET|INTEGER; in global()
261 vp->val.i = kshpid; in global()
265 if ((vp->val.i = j_async()) == 0) in global()
266 vp->flag &= ~(ISSET|INTEGER); in global()
269 vp->val.i = exstat & 0xFF; in global()
272 vp->val.i = l->argc; in global()
275 vp->flag &= ~INTEGER; in global()
276 vp->val.s = getoptions(); in global()
279 vp->flag &= ~(ISSET|INTEGER); in global()
281 return (vp); in global()
283 l = varsearch(e->loc, &vp, n, h); in global()
284 if (vp != NULL) in global()
285 return (array ? arraysearch(vp, val) : vp); in global()
286 vp = ktenter(&l->vars, n, h); in global()
288 vp = arraysearch(vp, val); in global()
289 vp->flag |= DEFINED; in global()
291 vp->flag |= SPECIAL; in global()
292 return (vp); in global()
302 struct tbl *vp; in local() local
313 vp = &vtemp; in local()
314 vp->flag = DEFINED|RDONLY; in local()
315 vp->type = 0; in local()
316 vp->areap = ATEMP; in local()
317 return (vp); in local()
319 vp = ktenter(&l->vars, n, h); in local()
320 if (copy && !(vp->flag & DEFINED)) { in local()
325 vp->flag |= vq->flag & in local()
329 vp->type = vq->type; in local()
330 vp->u2.field = vq->u2.field; in local()
334 vp = arraysearch(vp, val); in local()
335 vp->flag |= DEFINED; in local()
337 vp->flag |= SPECIAL; in local()
338 return (vp); in local()
343 str_val(struct tbl *vp) in str_val() argument
347 if ((vp->flag&SPECIAL)) in str_val()
348 getspec(vp); in str_val()
349 if (!(vp->flag&ISSET)) in str_val()
352 else if (!(vp->flag&INTEGER)) in str_val()
354 s = vp->val.s + vp->type; in str_val()
365 const char *digits = (vp->flag & UCASEV_AL) ? in str_val()
369 if (vp->flag & INT_U) in str_val()
370 n = vp->val.u; in str_val()
372 n = (vp->val.i < 0) ? -vp->val.u : vp->val.u; in str_val()
373 base = (vp->type == 0) ? 10U : (unsigned int)vp->type; in str_val()
400 if (!(vp->flag & INT_U) && vp->val.i < 0) in str_val()
403 if (vp->flag & (RJUST|LJUST)) in str_val()
405 s = formatstr(vp, s); in str_val()
467 struct tbl *vp = &vtemp; in setint() local
468 vp->flag = (ISSET|INTEGER); in setint()
469 vp->type = 0; in setint()
470 vp->areap = ATEMP; in setint()
471 vp->val.i = n; in setint()
473 setstr(vq, str_val(vp), KSH_RETURN_ERROR); in setint()
482 getint(struct tbl *vp, mksh_ari_u *nump, bool arith) in getint() argument
488 if (vp->flag & SPECIAL) in getint()
489 getspec(vp); in getint()
491 if (!(vp->flag & ISSET) || (!(vp->flag & INTEGER) && vp->val.s == NULL)) in getint()
493 if (vp->flag & INTEGER) { in getint()
494 nump->i = vp->val.i; in getint()
495 return (vp->type); in getint()
497 s = vp->val.s + vp->type; in getint()
519 !(vp->flag & ZEROFIL)) { in getint()
580 setint_v(struct tbl *vq, struct tbl *vp, bool arith) in setint_v() argument
585 if ((base = getint(vp, &num, arith)) == -1) in setint_v()
612 formatstr(struct tbl *vp, const char *s) in formatstr() argument
620 if (vp->flag & (RJUST|LJUST)) { in formatstr()
621 if (!vp->u2.field) in formatstr()
623 vp->u2.field = olen; in formatstr()
624 nlen = vp->u2.field; in formatstr()
629 if (vp->flag & (RJUST|LJUST)) { in formatstr()
632 if (vp->flag & RJUST) { in formatstr()
643 if (vp->flag & ZEROFIL && vp->flag & INTEGER) { in formatstr()
651 if (vp->u2.field <= n) in formatstr()
658 while (slen > vp->u2.field) in formatstr()
660 if (vp->u2.field - slen) in formatstr()
661 memset(p + n, (vp->flag & ZEROFIL) ? '0' : ' ', in formatstr()
662 vp->u2.field - slen); in formatstr()
664 shf_snprintf(p + vp->u2.field - slen, in formatstr()
665 psiz - (vp->u2.field - slen), in formatstr()
671 if (vp->flag & ZEROFIL) in formatstr()
675 vp->u2.field, vp->u2.field, s); in formatstr()
680 if (vp->flag & UCASEV_AL) { in formatstr()
683 } else if (vp->flag & LCASEV) { in formatstr()
695 exportprep(struct tbl *vp, const char *val) in exportprep() argument
698 char *op = (vp->flag&ALLOC) ? vp->val.s : NULL; in exportprep()
701 namelen = strlen(vp->name); in exportprep()
704 vp->flag |= ALLOC; in exportprep()
706 xp = alloc(namelen + 1 + vallen, vp->areap); in exportprep()
707 memcpy(vp->val.s = xp, vp->name, namelen); in exportprep()
711 vp->type = xp - vp->val.s; in exportprep()
714 afree(op, vp->areap); in exportprep()
725 struct tbl *vp; in typeset() local
803 varsearch(e->loc, &vp, tvar, hash(tvar)); in typeset()
804 if (vp == NULL) in typeset()
806 qval = str_val(vp); in typeset()
843 varsearch(e->loc, &vp, qval, hash(qval)); in typeset()
845 if (vp && ((vp->flag & (ARRAY | ASSOC)) == ASSOC)) in typeset()
846 qval = str_val(vp); in typeset()
856 vp = (set & LOCAL) ? local(tvar, tobool(set & LOCAL_COPY)) : in typeset()
858 if (new_refflag == SRF_DISABLE && (vp->flag & (ARRAY|ASSOC)) == ASSOC) in typeset()
859 vp->flag &= ~ASSOC; in typeset()
861 if (vp->flag & ARRAY) { in typeset()
865 for (a = vp->u.array; a; ) { in typeset()
872 vp->u.array = NULL; in typeset()
873 vp->flag &= ~ARRAY; in typeset()
875 vp->flag |= ASSOC; in typeset()
880 vpbase = (vp->flag & ARRAY) ? global(arrayname(tvar)) : vp; in typeset()
906 fake_assign = (t->flag & ISSET) && (!val || t != vp) && in typeset()
930 if ((set & INTEGER) && base > 0 && (!val || t != vp)) in typeset()
964 tval = shf_smprintf("%s%s", str_val(vp), val); in typeset()
969 if (vp->flag&INTEGER) { in typeset()
971 setstr(vp, val, KSH_UNWIND_ERROR | 0x4); in typeset()
974 vp->type = base; in typeset()
977 setstr(vp, val, KSH_RETURN_ERROR | 0x4); in typeset()
988 return (vp); in typeset()
997 unset(struct tbl *vp, int flags) in unset() argument
999 if (vp->flag & ALLOC) in unset()
1000 afree(vp->val.s, vp->areap); in unset()
1001 if ((vp->flag & ARRAY) && (flags & 1)) { in unset()
1005 for (a = vp->u.array; a; ) { in unset()
1012 vp->u.array = NULL; in unset()
1015 vp->flag &= ~(ALLOC|ISSET); in unset()
1019 vp->flag &= SPECIAL | ((flags & 1) ? 0 : ARRAY|DEFINED); in unset()
1020 if (vp->flag & SPECIAL) in unset()
1022 unsetspec(vp); in unset()
1105 struct tbl *vp, **vpp; in makenv() local
1112 if ((vp = *vpp++) != NULL && in makenv()
1113 (vp->flag&(ISSET|EXPORT)) == (ISSET|EXPORT)) { in makenv()
1116 uint32_t h = hash(vp->name); in makenv()
1120 vp2 = ktsearch(&l2->vars, vp->name, h); in makenv()
1124 if ((vp->flag&INTEGER)) { in makenv()
1127 val = str_val(vp); in makenv()
1128 vp->flag &= ~(INTEGER|RDONLY|SPECIAL); in makenv()
1130 setstr(vp, val, KSH_RETURN_ERROR); in makenv()
1132 XPput(denv, vp->val.s); in makenv()
1170 getspec(struct tbl *vp) in getspec() argument
1176 switch ((st = special(vp->name))) { in getspec()
1210 vp->flag &= ~SPECIAL; in getspec()
1214 setstr(vp, buf, KSH_RETURN_ERROR | 0x4); in getspec()
1215 vp->flag |= SPECIAL; in getspec()
1230 if (vp->flag & ISSET) { in getspec()
1240 vp->flag &= ~SPECIAL; in getspec()
1241 setint_n(vp, num.i, 0); in getspec()
1242 vp->flag |= SPECIAL; in getspec()
1246 setspec(struct tbl *vp) in setspec() argument
1252 switch ((st = special(vp->name))) { in setspec()
1255 sethistfile(str_val(vp)); in setspec()
1259 setctypes(s = str_val(vp), C_IFS); in setspec()
1265 s = str_val(vp); in setspec()
1282 s = str_val(vp); in setspec()
1292 if (vp->flag & IMPORT) { in setspec()
1294 unspecial(vp->name); in setspec()
1295 vp->flag &= ~SPECIAL; in setspec()
1305 vp->flag &= ~SPECIAL; in setspec()
1306 if (getint(vp, &num, false) == -1) { in setspec()
1307 s = str_val(vp); in setspec()
1309 errorf("%s: %s: %s", vp->name, "bad number", s); in setspec()
1312 vp->flag |= SPECIAL; in setspec()
1362 unsetspec(struct tbl *vp) in unsetspec() argument
1372 switch (special(vp->name)) { in unsetspec()
1401 unspecial(vp->name); in unsetspec()
1411 arraysearch(struct tbl *vp, uint32_t val) in arraysearch() argument
1416 vp->flag = (vp->flag | (ARRAY | DEFINED)) & ~ASSOC; in arraysearch()
1419 return (vp); in arraysearch()
1420 prev = vp; in arraysearch()
1421 curr = vp->u.array; in arraysearch()
1433 len = strlen(vp->name); in arraysearch()
1435 news = alloc(offsetof(struct tbl, name[0]) + ++len, vp->areap); in arraysearch()
1436 memcpy(news->name, vp->name, len); in arraysearch()
1438 news->flag = (vp->flag & ~(ALLOC|DEFINED|ISSET|SPECIAL)) | AINDEX; in arraysearch()
1439 news->type = vp->type; in arraysearch()
1440 news->areap = vp->areap; in arraysearch()
1441 news->u2.field = vp->u2.field; in arraysearch()
1496 struct tbl *vp, *vq; in set_array() local
1510 vp = global(ccp); in set_array()
1513 if ((vp->flag&RDONLY)) in set_array()
1518 unset(vp, 1); in set_array()
1520 arraysearch(vp, 0); in set_array()
1529 for (vq = vp; vq; vq = vq->u.array) { in set_array()
1561 vq = arraysearch(vp, j); in set_array()