• Home
  • Raw
  • Download

Lines Matching +full:r +full:- +full:xp

3 /*-
11 * is granted to deal in this work without restriction, including un-
68 #define IFS_WS 1 /* have seen IFS white-space */
69 #define IFS_NWS 2 /* have seen IFS non-white-space */
118 while ((*lp)--) in utfincptr()
120 *lp = cp - s; in utfincptr()
131 s->start = s->str = cp; in substitute()
141 * expand arg-list
181 * expand string - return only one component
211 struct SubType *next; /* poped type (to avoid re-allocating) */
213 unsigned short stype; /* [=+-?%#] action after expanded word */
216 uint8_t quotew; /* saved value of quote (for ${..[+-=]..}) */
313 quote = st->quotew; in expand()
380 /* ${{#}var{:}[=+-?#%]word} */ in expand()
381 /*- in expand()
383 * OSUBST [{x] plain-variable-part \0 in expand()
384 * compiled-word-part CSUBST [}x] in expand()
399 sp = varname - 2; in expand()
402 CSUBST) - sp) + beg; in expand()
417 if (!st->next) { in expand()
421 newst->next = NULL; in expand()
422 newst->prev = st; in expand()
423 st->next = newst; in expand()
425 st = st->next; in expand()
426 st->stype = stype; in expand()
427 st->base = Xsavepos(ds, dp); in expand()
428 st->f = f; in expand()
430 st->var = tempvar(vtemp->name); in expand()
431 st->var->flag &= ~INTEGER; in expand()
433 setstr(st->var, in expand()
437 st->var = x.var; in expand()
439 st->quotew = st->quotep = quote; in expand()
449 mksh_ari_t from = 0, num = -1, flen, finc = 0; in expand()
452 mid = beg + (wdscan(sp, ADELIM) - sp); in expand()
453 stg = beg + (wdscan(sp, CSUBST) - sp); in expand()
454 mid[-2] = EOS; in expand()
455 if (ord(mid[-1]) == ORD(/*{*/ '}')) { in expand()
456 sp += mid - beg - 1; in expand()
460 (wdscan(mid, ADELIM) - mid); in expand()
461 if (ord(end[-1]) != ORD(/*{*/ '}')) in expand()
464 end[-2] = EOS; in expand()
465 sp += end - beg - 1; in expand()
476 beg = str_val(st->var); in expand()
479 if (-from < flen) in expand()
503 p = s + (wdscan(sp, ADELIM) - sp); in expand()
504 d = s + (wdscan(sp, CSUBST) - sp); in expand()
505 p[-2] = EOS; in expand()
506 if (ord(p[-1]) == ORD(/*{*/ '}')) in expand()
509 d[-2] = EOS; in expand()
510 sp += (d ? d : p) - s - 1; in expand()
530 strdupx(s, str_val(st->var), ATEMP); in expand()
594 p--; in expand()
614 * |--------|---------|-------\0 in expand()
618 * |------------| in expand()
624 size_t n1 = sbeg - s; in expand()
625 size_t n2 = p - sbeg; in expand()
626 size_t n3 = d - p; in expand()
669 st->quotew = quote = 0; in expand()
685 * In non-POSIX mode historic in expand()
690 * non-POSIX thing - makes in expand()
694 if (!(x.var->flag & INTEGER)) in expand()
707 st->var->name); in expand()
712 /* '-' '+' '?' */ in expand()
723 sp += wdscan(sp, CSUBST) - sp; in expand()
731 /* in case of ${unset:-} */ in expand()
734 quote = st->quotep; in expand()
735 f = st->f; in expand()
737 doblank--; in expand()
738 switch (st->stype & STYPE_SINGLE) { in expand()
742 /* Append end-pattern */ in expand()
747 dp = Xrestpos(ds, dp, st->base); in expand()
749 * Must use st->var since calling in expand()
753 x.str = trimsub(str_val(st->var), in expand()
754 dp, st->stype); in expand()
768 st = st->prev; in expand()
773 * the value of st->var (may not be in expand()
775 * of integer/right-adj/etc attributes). in expand()
777 dp = Xrestpos(ds, dp, st->base); in expand()
779 * Must use st->var since calling in expand()
793 setstr(st->var, in expand()
796 x.str = str_val(st->var); in expand()
800 st = st->prev; in expand()
804 dp = Xrestpos(ds, dp, st->base); in expand()
806 errorf(Tf_sD_s, st->var->name, in expand()
811 (unsigned int)hash(str_val(st->var))); in expand()
817 print_value_quoted(&shf, str_val(st->var)); in expand()
825 dp = Xrestpos(ds, dp, st->base); in expand()
830 st = st->prev; in expand()
832 /* default: '-' '+' */ in expand()
834 st = st->prev; in expand()
861 * Special case for "$@" (and "${foo[@]}") - no in expand()
867 doblank--; in expand()
924 --level; in expand()
939 doblank--; in expand()
952 * set -- "" 2 ""; echo "$@" will do in expand()
960 doblank--; in expand()
965 /* pseudo-field-split reliably */ in expand()
971 /* do not field-split */ in expand()
986 /* now force-emit a word */ in expand()
1002 c = -1; in expand()
1006 --newlines; in expand()
1011 if (c == ORD('\r')) { in expand()
1019 case -1: in expand()
1020 c = ORD('\r'); in expand()
1029 if (newlines && c != -1) { in expand()
1032 --newlines; in expand()
1035 if (c == -1) { in expand()
1043 doblank--; in expand()
1052 /*- in expand()
1056 * ----------------------------------- in expand()
1058 * IFS_WS -/WS -/NWS - in expand()
1059 * IFS_NWS -/NWS w/NWS - in expand()
1060 * IFS_IWS -/WS w/NWS - in expand()
1074 cp + Xlength(ds, (dp - 1)), in expand()
1104 /* age tilde_ok info - ~ code tests second bit */ in expand()
1111 case ORD('-'): in expand()
1114 * For character classes - doesn't hurt in expand()
1115 * to have magic !,-,]s outside of in expand()
1216 varsub(Expand *xp, const char *sp, const char *word, in varsub() argument
1234 return (-1); in varsub()
1236 xp->var = NULL; in varsub()
1257 /*- in varsub()
1258 * ${%var}, string width (-U: screen columns, +U: octets) in varsub()
1259 * ${#var}, string length (-U: characters, +U: octets) or array size in varsub()
1261 * ${*…} -> set flag for argv in varsub()
1262 * ${@…} -> set flag for argv in varsub()
1279 return (-1); in varsub()
1285 return (-1); in varsub()
1305 if (vp->flag & ISSET) in varsub()
1308 } while ((vp = vp->u.array)); in varsub()
1311 xp->var = global(sp); in varsub()
1313 xp->str = p ? shf_smprintf("%s[%lu]", xp->var->name, in varsub()
1314 arrayindex(xp->var)) : xp->var->name; in varsub()
1324 return (-1); in varsub()
1331 (wv.len = utf_mbtowc(&c, p)) == (size_t)-1) in varsub()
1332 /* not UTFMODE or not UTF-8 */ in varsub()
1335 /* UTFMODE and UTF-8 */ in varsub()
1338 if ((slen = utf_wcwidth(c)) == -1) { in varsub()
1339 /* 646, 8859-1, 10646 C0/C1 */ in varsub()
1340 sc = -1; in varsub()
1351 if (vp->flag & (ISSET|ARRAY)) in varsub()
1355 if (vp->flag & ISSET) in varsub()
1357 } while ((vp = vp->u.array)); in varsub()
1360 sc = e->loc->argc; in varsub()
1371 xp->str = shf_smprintf(Tf_d, sc); in varsub()
1419 return (-1); in varsub()
1425 return (-1); in varsub()
1427 return (-1); in varsub()
1430 xp->var = global(sp); in varsub()
1431 xp->str = str_val(xp->var); in varsub()
1434 !*xp->str && ctype(*sp, C_VAR1 | C_DIGIT)) in varsub()
1435 return (-1); in varsub()
1440 case ORD('-'): in varsub()
1456 return (-1); in varsub()
1463 if (vp->flag & ISSET) in varsub()
1465 } while ((vp = vp->u.array)); in varsub()
1471 xp->u.strv = (const char **)XPptrv(wv); in varsub()
1474 if ((c = (e->loc->argc == 0))) in varsub()
1475 xp->var = global(sp); in varsub()
1477 xp->u.strv = (const char **)e->loc->argv + 1; in varsub()
1484 xp->str = null; in varsub()
1488 xp->str = *xp->u.strv++; in varsub()
1490 xp->split = tobool(sc & 4); in varsub()
1498 (((stype & STYPE_DBL) ? *xp->str == '\0' : xp->str == null) && in varsub()
1499 (state != XARG || (ifs0 || xp->split ? in varsub()
1500 (xp->u.strv[0] == NULL) : !hasnonempty(xp->u.strv))) ? in varsub()
1508 if (Flag(FNOUNSET) && xp->str == null && !zero_ok && in varsub()
1520 comsub(Expand *xp, const char *cp, int fn) in comsub() argument
1539 s->start = s->str = cp; in comsub()
1551 xp->split = false; in comsub()
1553 if (t->type == TCOM && in comsub()
1554 *t->args == NULL && *t->vars == NULL && t->ioact != NULL) { in comsub()
1556 struct ioword *io = *t->ioact; in comsub()
1559 switch (io->ioflag & IOTYPE) { in comsub()
1561 shf = shf_open(name = evalstr(io->ioname, DOTILDE), in comsub()
1570 xp->str = name; in comsub()
1573 while (name > xp->str && name[-1] == '\n') in comsub()
1574 --name; in comsub()
1593 if (!tf->shf) { in comsub()
1595 Tcreate, tf->tffn, cstrerror(errno)); in comsub()
1598 shf = tf->shf; in comsub()
1599 unlink(tf->tffn); in comsub()
1614 xp->str = valsub(t, ATEMP); in comsub()
1631 xp->split = true; in comsub()
1634 xp->u.shf = shf; in comsub()
1662 for (p = end; p >= str; p--) { in trimsub()
1680 while ((p-- > str) && ((rtt2asc(*p) & 0xC0) == 0x80)) in trimsub()
1683 p = op - 1; in trimsub()
1685 --p; in trimsub()
1694 strndupx(end, str, p - str, ATEMP); in trimsub()
1718 qsort(XPptrv(*wp) + oldsize, XPsize(*wp) - oldsize, in glob()
1736 char *xp; in glob_str() local
1738 Xinit(xs, xp, 256, ATEMP); in glob_str()
1739 globit(&xs, &xp, cp, wp, markdirs ? GF_MARKDIR : GF_NONE); in glob_str()
1740 Xfree(xs, xp); in glob_str()
1742 return (XPsize(*wp) - oldsize); in glob_str()
1753 char *xp = *xpp; in globit() local
1764 * is followed by a non-pattern (eg, foo*x/bar; no check in globit()
1772 stat(Xstring(*xs, xp), &statb) < 0 ? -1 : 1)) in globit()
1774 /* -1: failed, 1 ok, 0 not yet done */ in globit()
1777 if (mksh_lstat(Xstring(*xs, xp), &lstatb) < 0) in globit()
1784 if ((check & GF_EXCHECK) && xp > Xstring(*xs, xp) && in globit()
1785 mksh_cdirsep(xp[-1]) && !S_ISDIR(lstatb.st_mode) && in globit()
1795 xp > Xstring(*xs, xp) && !mksh_cdirsep(xp[-1]) && in globit()
1799 *xp++ = '/'; in globit()
1800 *xp = '\0'; in globit()
1803 strndupx(np, Xstring(*xs, xp), Xlength(*xs, xp), ATEMP); in globit()
1808 if (xp > Xstring(*xs, xp)) in globit()
1809 *xp++ = '/'; in globit()
1811 Xcheck(*xs, xp); in globit()
1812 *xp++ = *sp++; in globit()
1827 * Check if sp needs globbing - done to avoid pattern checks for strings in globit()
1830 * directory isn't readable - if no globbing is needed, only execute in globit()
1834 XcheckN(*xs, xp, se - sp + 1); in globit()
1835 debunk(xp, sp, Xnleft(*xs, xp)); in globit()
1836 xp = strnul(xp); in globit()
1837 *xpp = xp; in globit()
1845 /* xp = *xpp; copy_non_glob() may have re-alloc'd xs */ in globit()
1846 *xp = '\0'; in globit()
1847 prefix_len = Xlength(*xs, xp); in globit()
1848 dirp = opendir(prefix_len ? Xstring(*xs, xp) : Tdot); in globit()
1852 name = d->d_name; in globit()
1861 len = strlen(d->d_name) + 1; in globit()
1862 XcheckN(*xs, xp, len); in globit()
1863 memcpy(xp, name, len); in globit()
1864 *xpp = xp + len - 1; in globit()
1867 xp = Xstring(*xs, xp) + prefix_len; in globit()
1875 *--np = odirsep; in globit()
1886 if (s - sp >= (ssize_t)dlen) in debunk()
1888 memmove(dp, sp, s - sp); in debunk()
1889 for (d = dp + (s - sp); *s && (d - dp < (ssize_t)dlen); s++) in debunk()
1897 if (d - dp < (ssize_t)dlen) in debunk()
1917 const char *r; in maybe_expand_tilde() local
1928 r = (p[0] == EOS || p[0] == CHAR || p[0] == CSUBST) ? in maybe_expand_tilde()
1931 if (r) { in maybe_expand_tilde()
1932 while (*r) { in maybe_expand_tilde()
1934 if (ISMAGIC(*r)) in maybe_expand_tilde()
1936 *dp++ = *r++; in maybe_expand_tilde()
1939 r = p; in maybe_expand_tilde()
1941 return (r); in maybe_expand_tilde()
1998 if (!(ap->flag & ISSET)) { in homedir()
2004 strdupx(ap->val.s, pw->pw_dir, APERM); in homedir()
2005 ap->flag |= DEFINED|ISSET|ALLOC; in homedir()
2007 return (ap->val.s); in homedir()
2034 --count; in alt_expand()
2051 XPput(*wp, debunk(start, start, end - start)); in alt_expand()
2067 else if ((ord(*p) == ORD(/*{*/ '}') && --count == 0) || in alt_expand()
2076 l1 = brace_start - start; in alt_expand()
2077 l2 = (p - 1) - field_start; in alt_expand()
2078 l3 = end - brace_end; in alt_expand()
2104 if (!kshsetjmp(e->jbuf)) in valsub()