Lines Matching refs:jcl

23  * jcl file search
44 regular(Jcl_t* jcl, char* path, struct stat* st)
79 for (ip = jcl->include; ip; ip = ip->prev)
82 } while (jcl = jcl->scope);
88 * return expanded value returned in jcl->vp
89 * jcl->tp may be clobbered
93 expand(Jcl_t* jcl, const char* name, int flags)
104 if (jcl)
108 p = sfstrtell(jcl->tp);
110 sfwrite(jcl->tp, name, n);
115 n = sfstrtell(jcl->tp);
120 sfputr(jcl->tp, JCL_AUTO, -1);
123 sfputc(jcl->tp, c);
124 sfputc(jcl->tp, 0);
125 v = sfstrseek(jcl->tp, n, SEEK_SET);
128 if (t = matched(*v - '0', &n, jcl->disc))
129 sfwrite(jcl->tp, t, n);
131 else if (t = lookup(jcl, v, NiL, flags, DEFAULT))
133 if ((flags & JCL_SYM_SET) && jcl->vp != jcl->xp)
135 vp = jcl->vp;
136 jcl->vp = jcl->xp;
137 t = expand(jcl, t, flags);
138 sfputr(jcl->tp, t, -1);
139 jcl->vp = vp;
142 sfputr(jcl->tp, t, -1);
145 sfputr(jcl->tp, t, -1);
148 sfputc(jcl->tp, '$');
153 sfputc(jcl->tp, c);
154 sfputc(jcl->tp, 0);
155 s = sfstrseek(jcl->tp, p, SEEK_SET);
157 sfputr(jcl->vp, s, -1);
158 if (!(s = sfstruse(jcl->vp)))
159 nospace(jcl, NiL);
170 jclinclude(Jcl_t* jcl, const char* dir, unsigned long flags, Jcldisc_t* disc)
176 if (dir && *(dir = (const char*)expand(jcl, dir, 0)) && !streq(dir, ".") && directory(dir, &st))
178 lp = jcl ? &jcl->dirs : &state.dirs;
184 nospace(jcl, disc);
203 search(Jcl_t* jcl, const char* dir, const char* name, unsigned long flags, struct stat* st)
212 sfprintf(jcl->tp, "%s/", dir);
213 sfprintf(jcl->vp, "%s", name);
214 if (!(s = sfstruse(jcl->vp)))
215 nospace(jcl, NiL);
216 if (regular(jcl, s, st))
221 top = jcl;
222 dp = jcl->dirs.head;
232 nospace(jcl, NiL);
236 if (!jcl)
238 dp = (jcl = jcl->scope) ? jcl->dirs.head : state.dirs.head;
246 * path allocated in jcl->vs
249 * { jcl->tp jcl->vp jcl->xp } may be clobbered
253 jclfind(Jcl_t* jcl, const char* name, unsigned long flags, int level, Sfio_t** spp)
260 sfprintf(jcl->vp, "(PROC)%s", name);
261 if (!(s = sfstruse(jcl->vp)))
262 nospace(jcl, NiL);
263 if (s = lookup(jcl, s, NiL, 0, 0))
269 nospace(jcl, NiL);
276 name = (const char*)expand(jcl, jclpath(jcl, name), 0);
283 if (s = search(jcl, NiL, name, flags, &st))
294 sfprintf(jcl->tp, "%-.*s%s", s - error_info.file + 1, error_info.file, name);
295 if (!(s = sfstruse(jcl->tp)))
296 nospace(jcl, NiL);
297 if (regular(jcl, s, &st))
308 if (level && jcl->disc->errorf)
309 (*jcl->disc->errorf)(NiL, jcl->disc, ERROR_SYSTEM|level, "%s: not found", name);
312 if (spp && !(*spp = sfopen(NiL, s, "r")) && level > 0 && jcl->disc->errorf)
313 (*jcl->disc->errorf)(NiL, jcl->disc, ERROR_SYSTEM|level, "%s: cannot read", s);
316 return stash(jcl, jcl->vs, s, 0);