Lines Matching refs:xp
326 * expand one instance of v not in w into xp
331 uniq(Sfio_t* xp, char* v, char* w, int sep)
362 sfputc(xp, ' ');
365 sfputr(xp, s, -1);
382 sfputc(xp, ' ');
385 sfputr(xp, s, -1);
395 * if c!=0 then c marked prereqs listed in xp
396 * otherwise m marked prereqs listed in xp
397 * xp==0 removes marks
401 mark(Sfio_t* xp, Rule_t* r, int m, int c)
405 if (xp)
409 sfputr(xp, r->name, ' ');
416 if (mark(xp, p->rule, m, c))
418 sfputr(xp, r->name, ' ');
424 sfputr(xp, r->name, ' ');
431 mark(xp, p->rule, m, c);
437 * expand closure of v into xp
441 closure(Sfio_t* xp, char* v, char* w)
449 pos = sfstrtell(xp);
452 mark(xp, makerule(s), M_mark, cycle);
458 if (sfstrtell(xp) > pos)
459 sfstrseek(xp, -1, SEEK_CUR);
463 * expand the directory cross product of v and w into xp
489 cross(Sfio_t* xp, char* v, char* w)
510 if (sep) sfputc(xp, ' ');
512 pos = sfstrtell(xp);
513 sfputr(xp, t, 0);
514 x = sfstrseek(xp, pos, SEEK_SET);
516 sfstrseek(xp, pos, SEEK_SET);
524 if (sep) sfputc(xp, ' ');
526 pos = sfstrtell(xp);
531 sfprintf(xp, "%s", s);
533 sfprintf(xp, "%s/", s);
534 sfputr(xp, x, 0);
535 x = sfstrseek(xp, pos, SEEK_SET);
537 sfstrseek(xp, pos, SEEK_SET);
547 * expand the pathname intersection of v with w into xp
552 intersect(Sfio_t* xp, char* v, char* w, int sep)
628 if (n) sfputc(xp, ' ');
630 sfputr(xp, state.localview ? localview(p->rule) : p->rule->name, -1);
646 hasprereq(Sfio_t* xp, char* v, char* w)
670 if (sep) sfputc(xp, ' ');
672 sfputr(xp, r->name, -1);
686 linebreak(Sfio_t* xp, register char* s, char* pfx)
695 rew = sfstrtell(xp);
696 sfputr(xp, pfx, -1);
697 pre = pos = sfstrtell(xp);
705 pos += sfprintf(xp, "\n%s", pfx);
709 pos += sfprintf(xp, " %s", s);
712 if (pos == pre) sfstrseek(xp, rew, SEEK_SET);
720 listtab(Sfio_t* xp, Hash_table_t* tab, char* pat, int flags)
763 sfputr(xp, *v, -1);
765 sfprintf(xp, " %s", *v);
777 list(Sfio_t* xp, register char* s, char* pat, int flags)
900 sfprintf(xp, " %s/%s", s, *v);
902 sfputr(xp, *v, -1);
915 sfprintf(xp, " %s/%s", s, *v);
917 sfputr(xp, *v, -1);
926 sfputr(xp, *v, -1);
928 sfprintf(xp, " %s", *v);
942 * sort list s into xp
948 sort(Sfio_t* xp, register char* s, int flags)
969 sfputr(xp, *r, -1);
971 sfprintf(xp, " %s", *r);
977 sfputr(xp, *p, -1);
983 sfprintf(xp, " %s", s);
991 * construct relative path from dir s to t in xp
995 relative(Sfio_t* xp, register char* s, register char* t)
1019 pos = sfstrtell(xp);
1022 sfputr(xp, "../", -1);
1023 sfputr(xp, v, -1);
1024 if (sfstrtell(xp) > pos + 1) sfstrseek(xp, -1, SEEK_CUR);
1025 else sfputc(xp, '.');
1094 native(Sfio_t* xp, const char* s)
1101 sfputc(xp, '\'');
1106 n = pathnative(s, sfstrrsrv(xp, m), m);
1108 sfstrseek(xp, n, SEEK_CUR);
1109 sfputc(xp, '\'');
1138 order_descend(Sfio_t* xp, Hash_table_t* tab, Rule_t* r, unsigned long mark, unsigned int flags)
1146 here = sfstrtell(xp);
1163 sfprintf(xp, "%s :", r->name);
1165 sfprintf(xp, " %s", a->name);
1171 sfprintf(xp, "\n");
1179 mark = order_descend(xp, tab, a, mark, flags);
1196 if (sfstrtell(xp) != here || mark == need)
1198 if (sfstrtell(xp))
1199 sfputr(xp, "-", ' ');
1202 sfputr(xp, r->name, ' ');
1211 order_all(Sfio_t* xp, Sfio_t* tmp, Sfio_t* vec, Hash_table_t* tab, Rule_t* d, char* makefiles, char* skip, unsigned int flags)
1226 order_find(xp, tmp, vec, tab, d->name, t + n, makefiles, skip, flags);
1236 order_scan(Sfio_t* xp, Sfio_t* tmp, Sfio_t* vec, Hash_table_t* tab, Rule_t* d, Rule_t* r, char* makefiles, char* skip, unsigned int flags)
1255 if (sfstrtell(xp))
1256 sfputr(xp, "-", ' ');
1257 sfputr(xp, d->name, ' ');
1267 order_all(xp, tmp, vec, tab, d, makefiles, skip, flags);
1277 order_find(xp, tmp, vec, tab, NiL, s, makefiles, skip, flags|ORDER_force);
1279 order_all(xp, tmp, vec, tab, d, makefiles, skip, flags);
1292 order_find(Sfio_t* xp, Sfio_t* tmp, Sfio_t* vec, Hash_table_t* tab, char* dir, char* files, char* makefiles, char* skip, unsigned int flags)
1345 order_scan(xp, tmp, vec, tab, d, r, makefiles, skip, flags);
1360 order_scan(xp, tmp, vec, tab, d, r, makefiles, skip, flags);
1377 * generate an ordered list of directories in xp based on
1385 order_recurse(Sfio_t* xp, char* directories, char* makefiles, char* skip, char* targets, unsigned int flags)
1420 order_find(xp, tmp, vec, tab, NiL, directories, makefiles, skip, flags);
1617 mark = order_descend(xp, tab, r, mark, flags|ORDER_all);
1631 mark = order_descend(xp, tab, r, mark, flags);
1633 sfputr(xp, "-", ' ');
1641 mark = order_descend(xp, tab, r, mark, flags);
1646 sfprintf(xp, "all :");
1652 sfprintf(xp, " %s", r->name);
1661 sfprintf(xp, " %s", r->name);
1667 sfputr(xp, "+", ' ');
1669 sfputr(xp, r->name, ' ');
1680 * path name operations from (rule) s into xp using op
1687 pathop(Sfio_t* xp, register char* s, char* op, int sep)
1730 pos = sfstrtell(xp);
1732 sfputr(xp, s, 0);
1739 sfprintf(xp, "%s/%s%c", state.mam.statix ? internal.dot->name : internal.pwd, s, 0);
1740 s = sfstrseek(xp, pos, SEEK_SET);
1742 sfstrseek(xp, pos, SEEK_SET);
1754 sfputr(xp, s, -1);
1764 pos = sfstrtell(xp);
1765 sfputr(xp, s, 0);
1766 s = sfstrseek(xp, pos, SEEK_SET);
1768 sfstrseek(xp, pos, SEEK_SET);
1804 sfputr(xp, state.localview ? localview(x) : x->name, -1);
1819 sfputc(xp, ' ');
1820 sfputr(xp, state.localview ? localview(r) : r->name, -1);
1841 sfputc(xp, ' ');
1842 sfputc(xp, '.');
1852 pos = sfstrtell(xp);
1857 sfputc(xp, '.');
1858 sfputc(xp, '/');
1860 sfputr(xp, s, -1);
1869 sfputr(xp, r->name, -1);
1879 sfputc(xp, ' ');
1880 sfputr(xp, *p, -1);
1890 sfputc(xp, ' ');
1893 sfputr(xp, *p, -1);
1901 sfprintf(xp, "M%08lX", strhash(s));
1911 sfputc(xp, c);
1915 sfputc(xp, c);
1930 sfprintf(xp, "%lu", stat(s, &st) ? 0L : st.st_ino);
1932 sfputr(xp, s, -1);
1963 sfputc(xp, ' ');
1966 sfputr(xp, t + ((!n++ && !strncmp(t, internal.pwd, internal.pwdlen) && t[internal.pwdlen] == '/') ? (internal.pwdlen + 1) : 0), -1);
2028 sfputc(xp, ' ');
2031 sfputr(xp, t, -1);
2051 sfputr(xp, s, -1);
2055 native(xp, s);
2062 if (s = pathprobe(op, t ? t : idname, s, 0, sfstrrsrv(xp, MAXNAME), MAXNAME, NiL, 0))
2064 sfstrseek(xp, strlen(s), SEEK_CUR);
2073 relative(xp, s, op);
2109 sfputr(xp, r->name, -1);
2117 sfputr(xp, (r && !(r->property & P_state) && !(r->dynamic & D_alias)) ? unbound(r) : s, -1);
2151 sfputr(xp, s, -1);
2161 if ((n = astlicense(sfstrrsrv(xp, n), n, s, op, '/', '*', '/')) < 0)
2162 error(2, "license: %s", sfstrseek(xp, 0, SEEK_CUR));
2163 else if (n > 0 && *(sfstrseek(xp, n, SEEK_CUR) - 1) == '\n')
2164 sfstrseek(xp, -1, SEEK_CUR);
2173 sfputr(xp, s, -1);
2181 sfputr(xp, !(r->dynamic & D_alias) || !r->uname || strlen(r->name) >= strlen(r->uname) ? r->name : r->uname, -1);
2190 * edit a single (expanded) file name s into xp
2200 edit(Sfio_t* xp, register char* s, char* dir, char* bas, char* suf)
2208 pos = sfstrtell(xp);
2221 sfputc(xp, *s++);
2227 sfputr(xp, q, -1);
2228 if (*q && *(sfstrseek(xp, 0, SEEK_CUR) - 1) != '/')
2229 sfputc(xp, '/');
2244 sfputc(xp, *s++);
2248 sfputr(xp, q, -1);
2256 sfputr(xp, s, -1);
2258 sfputr(xp, q, -1);
2264 p = sfstrbase(xp) + pos + 1;
2265 q = sfstrseek(xp, 0, SEEK_CUR);
2268 pos = q - sfstrbase(xp);
2269 sfstrseek(xp, pos, SEEK_SET);
2273 * substitute a single (expanded) name s into xp
2277 substitute(Sfio_t* xp, regex_t* re, register char* s)
2288 sfputr(xp, s, -1);
2293 mimetype(Sfio_t* xp, char* file)
2318 sfputr(xp, mime, -1);
2322 * apply token op p on (possibly bound) s with result in xp
2331 token(Sfio_t* xp, char* s, register char* p, int sep)
2383 expand(xp, p);
2385 sfputc(xp, '1');
2442 sfputr(xp, s, -1);
2483 sfputr(xp, timefmt(ops, CURTIME), -1);
2508 expand(xp, s);
2523 localvar(xp, v, p, op == 'D' ? V_local_D : V_local_E);
2529 sfprintf(xp, "-D%s", v->name);
2535 sfputr(xp, p, -1);
2538 sfputc(xp, '=');
2539 shquote(xp, p);
2545 sfprintf(xp, "%s=", v->name);
2549 sfputr(xp, p, -1);
2551 shquote(xp, p);
2664 tmp = xp;
2677 if (tmp != xp)
2679 expand(xp, sfstruse(tmp));
2687 parentage(xp, r, ops);
2740 sfputr(xp, timefmt(ops, r->time), -1);
2786 sfputr(xp, x->name, -1);
2809 sfputr(xp, r->name, -1);
2815 sfputr(xp, r->name, -1);
2820 sfputr(xp, v->name, -1);
2823 sfputr(xp, r->name, -1);
2826 mimetype(xp, r->name);
2857 sfputr(xp, timefmt(ops, tm), -1);
2866 expand(xp, p);
2868 sfputr(xp, r->name, -1);
2891 * construct the parentage of r in xp, starting with r
2896 parentage(Sfio_t* xp, register Rule_t* r, char* sep)
2901 parentage(xp, r->active->parent->target, sep);
2903 sfputr(xp, sep, -1);
2905 sfputr(xp, (r->property & P_operator) && r->statedata ? r->statedata : r->name, -1);
2909 * copy s into xp if rule s has any attribute in att or
2910 * if att is 0 then copy the named attributes of rule s into xp
2915 attribute(Sfio_t* xp, char* s, register char* att, int sep)
2956 if (i) sfputc(xp, ' ');
2958 sfputr(xp, s, -1);
2969 if (i) sfputc(xp, ' ');
2971 sfputr(xp, y->name, -1);
2980 if (i) sfputc(xp, ' ');
2982 sfputr(xp, s, -1);
2993 if (i) sfputc(xp, ' ');
2995 sfputr(xp, s, -1);
3004 if (i) sfputc(xp, ' ');
3006 sfputr(xp, p->rule->name, -1);
3012 if (i) sfputc(xp, ' ');
3014 sfputr(xp, p->rule->name, -1);
3021 if (i) sfputc(xp, ' ');
3023 sfputr(xp, s, -1);
3035 generate(Sfio_t* xp, char* name, char* pat, int sep)
3048 sfputr(xp, name, -1);
3059 sfputr(xp, name, -1);
3067 sfputr(xp, name, -1);
3098 b = sfstrtell(xp);
3101 n = sfstrtell(xp);
3103 generate(xp, sfstruse(tp), pat, sep);
3104 if (sfstrtell(xp) != n)
3105 sfputc(xp, ' ');
3109 if (sfstrtell(xp) != b)
3110 sfstrseek(xp, -1, SEEK_CUR);
3120 b = sfstrtell(xp);
3123 n = sfstrtell(xp);
3125 generate(xp, sfstruse(tp), pat, sep);
3126 if (sfstrtell(xp) != n)
3127 sfputc(xp, ' ');
3129 if (sfstrtell(xp) != b)
3130 sfstrseek(xp, -1, SEEK_CUR);
3136 metaexpand(xp, stem, z && z->uname && (y = metarule(z->uname, p->rule->name, 0)) && y->action && !*y->action ? z->uname : p->rule->name);
3147 n = sfstrtell(xp);
3157 if (sfstrtell(xp) != n)
3158 sfputc(xp, ' ');
3159 generate(xp, sfstruse(tp), pat, sep);
3163 if (sfstrtell(xp) != n)
3179 metaexpand(xp, tmpname, p->rule->name);
3183 if (sep & NOT) sfputr(xp, name, -1);
3187 * quote s into xp according to sh syntax
3191 shquote(register Sfio_t* xp, char* s)
3200 sfprintf(xp, "\\\"%s\\\"", s);
3255 sfputr(xp, s, -1);
3259 sfprintf(xp, "%-.*s'%s'", b - s, s, b);
3261 sfprintf(xp, "'%s'", s);
3266 sfprintf(xp, "%-.*s\"%s\"", b - s, s, b);
3268 sfprintf(xp, "\"%s\"", s);
3277 sfputc(xp, '"');
3278 sfputc(xp, c);
3279 sfputc(xp, '"');
3300 sfputc(xp, '\\');
3303 sfputc(xp, c);
3309 * generate edit context in xp at cur from beg
3331 * expand rules selected by $(...) into xp
3335 expandall(register Sfio_t* xp, register unsigned long all)
3349 if (sep) sfputc(xp, ' ');
3351 sfputr(xp, r->name, -1);
3359 * apply edit operators ed on value v into xp
3371 expandops(Sfio_t* xp, char* v, char* ed, int del, int exp)
3417 buf[0] = xp;
3418 top[0] = beg = sfstrtell(xp);
3436 expand(xp, v);
3440 xp = buf[out];
3917 expandall(xp, exp < 0 ? 0 : all);
3923 if (xp)
3925 sfputc(xp, 0);
3926 x = sfstrseek(xp, beg, SEEK_SET);
3931 if (!(xp = buf[out]))
3932 xp = buf[out] = sfstropen();
3954 sfprintf(xp, "%ld", expr(xp, x));
3967 cross(xp, x, val);
3991 intersect(xp, x, val, sep);
3994 hasprereq(xp, x, val);
3997 linebreak(xp, x, val);
4018 listtab(xp, table.file, val, n);
4022 listtab(xp, table.rule, val, n);
4026 listtab(xp, table.var, val, n);
4033 list(xp, x, val, n);
4053 uniq(xp, x, val, sep);
4062 order_recurse(xp, x, NiL, NiL, val, ORDER_force|ORDER_paths);
4065 order_recurse(xp, x, getval(external.files, VAL_PRIMARY|VAL_AUXILIARY), getval(external.skip, VAL_PRIMARY|VAL_AUXILIARY), val, ORDER_force|ORDER_prereqs);
4068 order_recurse(xp, x, getval(external.files, VAL_PRIMARY|VAL_AUXILIARY), getval(external.skip, VAL_PRIMARY|VAL_AUXILIARY), val, ORDER_force);
4076 closure(xp, x, val);
4143 sort(xp, x, n);
4155 expand(xp, val);
4157 expand(xp, x);
4204 if (*s != '\n' && (cur = sfstrtell(xp)) > arg)
4206 if (!isspace(*(sfstrbase(xp) + cur - 1)))
4207 sfputc(xp, ' ');
4208 arg = sfstrtell(xp);
4215 sfputc(xp, MARK_CONTEXT);
4216 ctx_beg = sfstrtell(xp);
4221 attribute(xp, s, val, sep);
4229 cur = sfstrtell(xp);
4230 edit(xp, s, dir, bas, suf);
4231 if (dir == KEEP && cur == sfstrtell(xp))
4232 sfputc(xp, '.');
4236 substitute(xp, &re, s);
4256 strprintf(xp, val, s, 1, -1);
4266 generate(xp, s, v, sep);
4270 generate(xp, s, val, sep);
4277 sfputr(xp, s, -1);
4281 sfstrseek(xp, arg = beg, SEEK_SET);
4300 sfprintf(xp, "%d", strlen(s));
4325 sfputr(xp, s, -1);
4328 pathop(xp, s, val, sep);
4331 shquote(xp, s);
4334 token(xp, s, val, sep);
4337 expand(xp, (*s && (zer ? (*s != '0' || *(s + 1)) : 1)) ? (old ? s : oldp) : newp);
4348 n = sfstrtell(xp) - ctx_beg;
4350 sfstrseek(xp, -1, SEEK_CUR);
4351 else if (n > 1 && *(s = sfstrbase(xp) + ctx_beg) == MARK_CONTEXT)
4355 sfputc(xp, MARK_CONTEXT);
4356 s = sfstrbase(xp) + ctx_beg;
4364 sfprintf(xp, "%*s", m * 2, null);
4365 x = sfstrbase(xp) + ctx_beg + n + 1;
4381 if (all && sfstrtell(xp) > beg)
4383 sfputc(xp, 0);
4384 makerule(sfstrseek(xp, beg, SEEK_SET))->dynamic |= lla;
4391 if (sfstrtell(xp) == ctx_beg)
4392 sfstrseek(xp, -1, SEEK_CUR);
4424 if (sfstrtell(xp) == arg)
4427 sfprintf(xp, "%d", cnt - 1);
4429 sfstrseek(xp, -1, SEEK_CUR);
4459 sfputr(buf[0], xp ? sfstruse(xp) : v, -1);
4466 * expand first non-null of nvars variables in s with edit ops ed into xp
4470 expandvars(register Sfio_t* xp, register char* s, char* ed, int del, int nvars)
4498 beg = sfstrtell(xp);
4644 sfputr(xp, sfstruse(cvt), -1);
4669 expandops(xp, v ? v : sfstrbase(cvt), sfstrbase(cvt) + pos, del, exp);
4674 expand(xp, v);
4681 pos = sfstrtell(xp);
4682 sfputc(xp, 0);
4683 error(-10, "expand(%s,lev=%d): `%s'", sfstrbase(msg), level, sfstrseek(xp, beg, SEEK_SET));
4684 sfstrseek(xp, pos, SEEK_SET);
4696 * expand `$(...)' from a into xp
4700 expand(register Sfio_t* xp, register char* a)
4716 sfputr(xp, a, -1);
4724 sfwrite(xp, a, s - a);
4729 sfputc(xp, *a++);
4734 sfputc(xp, '$');
4735 sfputc(xp, '(');
4736 sfputc(xp, *a++);
4740 var = sfstrtell(xp);
4751 sfputc(xp, c);
4775 ed = sfstrtell(xp);
4780 ed = sfstrtell(xp);
4794 sfputc(xp, c);
4796 sfputc(xp, 0);
4797 s = sfstrseek(xp, var, SEEK_SET);
4803 expandvars(xp, s, ed ? sfstrbase(xp) + ed + 1 : (char*)0, del, nvars);
4810 sfputc(xp, '$');
4812 sfputc(xp, *a++);
4815 sfputc(xp, '$');