• Home
  • Raw
  • Download

Lines Matching refs:vp

97 	struct tbl *vp, **vpp = l->vars.tbls, *vq;  in popblock()  local
104 if ((vp = *vpp++) != NULL && (vp->flag&SPECIAL)) { in popblock()
105 if ((vq = global(vp->name))->flag & ISSET) in popblock()
153 register struct tbl *vp; in varsearch() local
157 if ((vp = ktsearch(&l->vars, vn, h)) != NULL) in varsearch()
164 vp = NULL; in varsearch()
166 *vpp = vp; in varsearch()
187 struct tbl *vp; in array_index_calc() local
192 varsearch(e->loc, &vp, vn, hash(vn)); in array_index_calc()
194 if (vp && (vp->flag & (DEFINED | ASSOC | ARRAY)) == in array_index_calc()
199 cp = shf_smprintf(Tf_ss, str_val(vp), p); in array_index_calc()
238 struct tbl *vp; in isglobal() local
255 vp = vtemp; in isglobal()
256 vp->flag = DEFINED; in isglobal()
257 vp->type = 0; in isglobal()
258 vp->areap = ATEMP; in isglobal()
262 shf_snprintf(vp->name, 12, Tf_d, c); in isglobal()
265 setstr(vp, l->argv[c], in isglobal()
269 vp->name[0] = '\0'; in isglobal()
270 vp->flag |= RDONLY; in isglobal()
273 vp->name[0] = c; in isglobal()
274 vp->name[1] = '\0'; in isglobal()
275 vp->flag |= RDONLY; in isglobal()
278 vp->flag |= ISSET|INTEGER; in isglobal()
281 vp->val.i = kshpid; in isglobal()
285 if ((vp->val.i = j_async()) == 0) in isglobal()
286 vp->flag &= ~(ISSET|INTEGER); in isglobal()
289 vp->val.i = exstat & 0xFF; in isglobal()
292 vp->val.i = l->argc; in isglobal()
295 vp->flag &= ~INTEGER; in isglobal()
296 vp->val.s = getoptions(); in isglobal()
299 vp->flag &= ~(ISSET|INTEGER); in isglobal()
303 l = varsearch(e->loc, &vp, vn, h); in isglobal()
304 if (vp == NULL && docreate) in isglobal()
305 vp = ktenter(&l->vars, vn, h); in isglobal()
308 if (vp != NULL) { in isglobal()
310 vp = arraysearch(vp, val); in isglobal()
312 vp->flag |= DEFINED; in isglobal()
314 vp->flag |= SPECIAL; in isglobal()
321 return (vp); in isglobal()
330 struct tbl *vp; in local() local
343 vp = vtemp; in local()
344 vp->flag = DEFINED|RDONLY; in local()
345 vp->type = 0; in local()
346 vp->areap = ATEMP; in local()
349 vp = ktenter(&l->vars, vn, h); in local()
350 if (copy && !(vp->flag & DEFINED)) { in local()
355 vp->flag |= vq->flag & in local()
359 vp->type = vq->type; in local()
360 vp->u2.field = vq->u2.field; in local()
364 vp = arraysearch(vp, val); in local()
365 vp->flag |= DEFINED; in local()
367 vp->flag |= SPECIAL; in local()
372 return (vp); in local()
378 str_val(struct tbl *vp) in str_val() argument
382 if ((vp->flag&SPECIAL)) in str_val()
383 getspec(vp); in str_val()
384 if (!(vp->flag&ISSET)) in str_val()
387 else if (!(vp->flag&INTEGER)) in str_val()
389 s = vp->val.s + vp->type; in str_val()
400 const char *digits = (vp->flag & UCASEV_AL) ? in str_val()
404 if (vp->flag & INT_U) in str_val()
405 n = vp->val.u; in str_val()
407 n = (vp->val.i < 0) ? -vp->val.u : vp->val.u; in str_val()
408 base = (vp->type == 0) ? 10U : (unsigned int)vp->type; in str_val()
437 if (!(vp->flag & INT_U) && vp->val.i < 0) in str_val()
440 if (vp->flag & (RJUST|LJUST)) in str_val()
442 s = formatstr(vp, s); in str_val()
518 getint(struct tbl *vp, mksh_ari_u *nump, bool arith) in getint() argument
524 if (vp->flag & SPECIAL) in getint()
525 getspec(vp); in getint()
527 if (!(vp->flag & ISSET) || (!(vp->flag & INTEGER) && vp->val.s == NULL)) in getint()
529 if (vp->flag & INTEGER) { in getint()
530 nump->i = vp->val.i; in getint()
531 return (vp->type); in getint()
533 s = vp->val.s + vp->type; in getint()
555 !(vp->flag & ZEROFIL)) { in getint()
616 setint_v(struct tbl *vq, struct tbl *vp, bool arith) in setint_v() argument
621 if ((base = getint(vp, &num, arith)) == -1) in setint_v()
648 formatstr(struct tbl *vp, const char *s) in formatstr() argument
656 if (vp->flag & (RJUST|LJUST)) { in formatstr()
657 if (!vp->u2.field) in formatstr()
659 vp->u2.field = olen; in formatstr()
660 nlen = vp->u2.field; in formatstr()
665 if (vp->flag & (RJUST|LJUST)) { in formatstr()
668 if (vp->flag & RJUST) { in formatstr()
679 if (vp->flag & ZEROFIL && vp->flag & INTEGER) { in formatstr()
687 if (vp->u2.field <= n) in formatstr()
694 while (slen > vp->u2.field) in formatstr()
696 if (vp->u2.field - slen) in formatstr()
697 memset(p + n, (vp->flag & ZEROFIL) ? '0' : ' ', in formatstr()
698 vp->u2.field - slen); in formatstr()
700 shf_snprintf(p + vp->u2.field - slen, in formatstr()
701 psiz - (vp->u2.field - slen), in formatstr()
707 if (vp->flag & ZEROFIL) in formatstr()
711 vp->u2.field, vp->u2.field, s); in formatstr()
716 if (vp->flag & UCASEV_AL) { in formatstr()
719 } else if (vp->flag & LCASEV) { in formatstr()
731 exportprep(struct tbl *vp, const char *val) in exportprep() argument
734 char *op = (vp->flag&ALLOC) ? vp->val.s : NULL; in exportprep()
737 namelen = strlen(vp->name); in exportprep()
740 vp->flag |= ALLOC; in exportprep()
742 xp = alloc(namelen + 1 + vallen, vp->areap); in exportprep()
743 memcpy(vp->val.s = xp, vp->name, namelen); in exportprep()
747 vp->type = xp - vp->val.s; in exportprep()
749 afree(op, vp->areap); in exportprep()
760 struct tbl *vp; in typeset() local
839 varsearch(e->loc, &vp, tvar, hash(tvar)); in typeset()
840 if (vp == NULL) in typeset()
842 qval = str_val(vp); in typeset()
880 varsearch(e->loc, &vp, qval, hash(qval)); in typeset()
882 if (vp && ((vp->flag & (ARRAY | ASSOC)) == ASSOC)) in typeset()
883 qval = str_val(vp); in typeset()
893 vp = (set & LOCAL) ? local(tvar, tobool(set & LOCAL_COPY)) : in typeset()
895 if (new_refflag == SRF_DISABLE && (vp->flag & (ARRAY|ASSOC)) == ASSOC) in typeset()
896 vp->flag &= ~ASSOC; in typeset()
898 if (vp->flag & ARRAY) { in typeset()
902 for (a = vp->u.array; a; ) { in typeset()
909 vp->u.array = NULL; in typeset()
910 vp->flag &= ~ARRAY; in typeset()
912 vp->flag |= ASSOC; in typeset()
917 vpbase = (vp->flag & ARRAY) ? global(arrayname(tvar)) : vp; in typeset()
943 fake_assign = (t->flag & ISSET) && (!val || t != vp) && in typeset()
967 if ((set & INTEGER) && base > 0 && (!val || t != vp)) in typeset()
1000 tval = shf_smprintf(Tf_ss, str_val(vp), val); in typeset()
1005 if (vp->flag&INTEGER) { in typeset()
1007 setstr(vp, val, KSH_UNWIND_ERROR | 0x4); in typeset()
1010 vp->type = base; in typeset()
1013 setstr(vp, val, KSH_RETURN_ERROR | 0x4); in typeset()
1023 return (vp); in typeset()
1032 unset(struct tbl *vp, int flags) in unset() argument
1034 if (vp->flag & ALLOC) in unset()
1035 afree(vp->val.s, vp->areap); in unset()
1036 if ((vp->flag & ARRAY) && (flags & 1)) { in unset()
1040 for (a = vp->u.array; a; ) { in unset()
1047 vp->u.array = NULL; in unset()
1050 vp->flag &= ~(ALLOC|ISSET); in unset()
1054 vp->flag &= SPECIAL | ((flags & 1) ? 0 : ARRAY|DEFINED); in unset()
1055 if (vp->flag & SPECIAL) in unset()
1057 unsetspec(vp); in unset()
1141 struct tbl *vp, **vpp; in makenv() local
1148 if ((vp = *vpp++) != NULL && in makenv()
1149 (vp->flag&(ISSET|EXPORT)) == (ISSET|EXPORT)) { in makenv()
1152 uint32_t h = hash(vp->name); in makenv()
1156 vp2 = ktsearch(&l2->vars, vp->name, h); in makenv()
1160 if ((vp->flag&INTEGER)) { in makenv()
1163 val = str_val(vp); in makenv()
1164 vp->flag &= ~(INTEGER|RDONLY|SPECIAL); in makenv()
1166 setstr(vp, val, KSH_RETURN_ERROR); in makenv()
1170 if (!strcmp(vp->name, "BEGINLIBPATH") || in makenv()
1171 !strcmp(vp->name, "ENDLIBPATH") || in makenv()
1172 !strcmp(vp->name, "LIBPATHSTRICT")) in makenv()
1175 XPput(denv, vp->val.s); in makenv()
1217 getspec(struct tbl *vp) in getspec() argument
1223 switch ((st = special(vp->name))) { in getspec()
1257 vp->flag &= ~SPECIAL; in getspec()
1261 setstr(vp, buf, KSH_RETURN_ERROR | 0x4); in getspec()
1262 vp->flag |= SPECIAL; in getspec()
1277 if (vp->flag & ISSET) { in getspec()
1287 vp->flag &= ~SPECIAL; in getspec()
1288 setint_n(vp, num.i, 0); in getspec()
1289 vp->flag |= SPECIAL; in getspec()
1293 setspec(struct tbl *vp) in setspec() argument
1297 int st = special(vp->name); in setspec()
1308 if (!(vp->flag&INTEGER)) { in setspec()
1309 s = str_val(vp); in setspec()
1324 setextlibpath(vp->name, str_val(vp)); in setspec()
1329 sethistfile(str_val(vp)); in setspec()
1333 set_ifs(str_val(vp)); in setspec()
1337 s = str_val(vp); in setspec()
1344 x_initterm(str_val(vp)); in setspec()
1357 s = str_val(vp); in setspec()
1367 if (vp->flag & IMPORT) { in setspec()
1369 unspecial(vp->name); in setspec()
1370 vp->flag &= ~SPECIAL; in setspec()
1380 vp->flag &= ~SPECIAL; in setspec()
1381 if (getint(vp, &num, false) == -1) { in setspec()
1382 s = str_val(vp); in setspec()
1384 errorf(Tf_sD_sD_s, vp->name, Tbadnum, s); in setspec()
1387 vp->flag |= SPECIAL; in setspec()
1444 unsetspec(struct tbl *vp) in unsetspec() argument
1454 switch (special(vp->name)) { in unsetspec()
1459 setextlibpath(vp->name, ""); in unsetspec()
1493 unspecial(vp->name); in unsetspec()
1510 arraysearch(struct tbl *vp, uint32_t val) in arraysearch() argument
1515 vp->flag = (vp->flag | (ARRAY | DEFINED)) & ~ASSOC; in arraysearch()
1518 return (vp); in arraysearch()
1519 prev = vp; in arraysearch()
1520 curr = vp->u.array; in arraysearch()
1532 len = strlen(vp->name); in arraysearch()
1534 news = alloc(offsetof(struct tbl, name[0]) + ++len, vp->areap); in arraysearch()
1535 memcpy(news->name, vp->name, len); in arraysearch()
1537 news->flag = (vp->flag & ~(ALLOC|DEFINED|ISSET|SPECIAL)) | AINDEX; in arraysearch()
1538 news->type = vp->type; in arraysearch()
1539 news->areap = vp->areap; in arraysearch()
1540 news->u2.field = vp->u2.field; in arraysearch()
1595 struct tbl *vp, *vq; in set_array() local
1609 vp = global(ccp); in set_array()
1612 if ((vp->flag&RDONLY)) in set_array()
1617 unset(vp, 1); in set_array()
1619 arraysearch(vp, 0); in set_array()
1628 for (vq = vp; vq; vq = vq->u.array) { in set_array()
1661 vq = arraysearch(vp, j); in set_array()
1815 struct tbl *vp; in record_match() local
1817 vp = local("KSH_MATCH", false); in record_match()
1818 unset(vp, 1); in record_match()
1819 vp->flag = DEFINED | RDONLY; in record_match()
1820 setstr(vp, istr, 0x4); in record_match()
1827 struct tbl *vp, **p; in c_typeset() local
2057 for (p = ktsort(&l->funs); (vp = *p++); ) { in c_typeset()
2058 if (flag && (vp->flag & flag) == 0) in c_typeset()
2062 tobool(vp->flag & FKSH), in c_typeset()
2063 vp->name, vp->val.t); in c_typeset()
2065 shf_puts(vp->name, shl_stdout); in c_typeset()
2071 vp = isglobal(wp[i], false); in c_typeset()
2072 c_typeset_vardump(vp, flag, thing, in c_typeset()
2084 struct tbl **blockvars, *vp; in c_typeset_vardump_recursive() local
2089 while ((vp = *blockvars++)) in c_typeset_vardump_recursive()
2090 c_typeset_vardump(vp, flag, thing, 0, pflag, istset); in c_typeset_vardump_recursive()
2095 c_typeset_vardump(struct tbl *vp, uint32_t flag, int thing, int any_set, in c_typeset_vardump() argument
2101 if (!vp) in c_typeset_vardump()
2108 for (tvp = vp; tvp; tvp = tvp->u.array) in c_typeset_vardump()
2123 if (!any_set && !(vp->flag & USERATTRIB)) in c_typeset_vardump()
2125 if (flag && (vp->flag & flag) == 0) in c_typeset_vardump()
2127 if (!(vp->flag & ARRAY)) in c_typeset_vardump()
2136 if (any_set && !(vp->flag & ISSET)) in c_typeset_vardump()
2141 shprintf(Tf_s_s_sN, Tset, "-A", vp->name); in c_typeset_vardump()
2150 if (((vp->flag & (ARRAY | ASSOC)) == ASSOC)) in c_typeset_vardump()
2152 if ((vp->flag & INTEGER)) in c_typeset_vardump()
2154 if ((vp->flag & EXPORT)) in c_typeset_vardump()
2156 if ((vp->flag & RDONLY)) in c_typeset_vardump()
2158 if ((vp->flag & TRACE)) in c_typeset_vardump()
2160 if ((vp->flag & LJUST)) in c_typeset_vardump()
2161 shprintf("-L%d ", vp->u2.field); in c_typeset_vardump()
2162 if ((vp->flag & RJUST)) in c_typeset_vardump()
2163 shprintf("-R%d ", vp->u2.field); in c_typeset_vardump()
2164 if ((vp->flag & ZEROFIL)) in c_typeset_vardump()
2166 if ((vp->flag & LCASEV)) in c_typeset_vardump()
2168 if ((vp->flag & UCASEV_AL)) in c_typeset_vardump()
2170 if ((vp->flag & INT_U)) in c_typeset_vardump()
2177 shprintf("%s[%lu]", vp->name, arrayindex(vp)); in c_typeset_vardump()
2179 shf_puts(vp->name, shl_stdout); in c_typeset_vardump()
2181 (thing == '-' && (vp->flag & ISSET))) { in c_typeset_vardump()
2182 s = str_val(vp); in c_typeset_vardump()
2185 if ((vp->flag & (INTEGER | LJUST | RJUST)) == INTEGER) in c_typeset_vardump()
2198 } while (!(any_set & 4) && (vp = vp->u.array)); in c_typeset_vardump()