Lines Matching refs:f

94 	ForLoop *f = bmake_malloc(sizeof *f);  in ForLoop_New()  local
96 Vector_Init(&f->vars, sizeof(char *)); in ForLoop_New()
97 SubstringWords_Init(&f->items); in ForLoop_New()
98 Buf_Init(&f->body); in ForLoop_New()
99 f->nextItem = 0; in ForLoop_New()
101 return f; in ForLoop_New()
105 ForLoop_Free(ForLoop *f) in ForLoop_Free() argument
107 while (f->vars.len > 0) in ForLoop_Free()
108 free(*(char **)Vector_Pop(&f->vars)); in ForLoop_Free()
109 Vector_Done(&f->vars); in ForLoop_Free()
111 SubstringWords_Free(f->items); in ForLoop_Free()
112 Buf_Done(&f->body); in ForLoop_Free()
114 free(f); in ForLoop_Free()
118 ForLoop_Details(const ForLoop *f) in ForLoop_Details() argument
125 n = f->vars.len; in ForLoop_Details()
126 vars = f->vars.items; in ForLoop_Details()
127 assert(f->nextItem >= n); in ForLoop_Details()
128 items = f->items.words + f->nextItem - n; in ForLoop_Details()
149 ForLoop_ParseVarnames(ForLoop *f, const char **pp) in ForLoop_ParseVarnames() argument
159 while (f->vars.len > 0) in ForLoop_ParseVarnames()
160 free(*(char **)Vector_Pop(&f->vars)); in ForLoop_ParseVarnames()
170 while (f->vars.len > 0) in ForLoop_ParseVarnames()
171 free(*(char **)Vector_Pop(&f->vars)); in ForLoop_ParseVarnames()
181 *(char **)Vector_Push(&f->vars) = bmake_strldup(p, len); in ForLoop_ParseVarnames()
185 if (f->vars.len == 0) { in ForLoop_ParseVarnames()
194 ForLoop_ParseItems(ForLoop *f, const char *p) in ForLoop_ParseItems() argument
203 f->items = Substring_Words(items, false); in ForLoop_ParseItems()
206 if (f->items.len == 1 && Substring_IsEmpty(f->items.words[0])) in ForLoop_ParseItems()
207 f->items.len = 0; /* .for var in ${:U} */ in ForLoop_ParseItems()
209 if (f->items.len % f->vars.len != 0) { in ForLoop_ParseItems()
213 (unsigned)f->items.len, (unsigned)f->vars.len); in ForLoop_ParseItems()
246 ForLoop *f; in For_Eval() local
254 f = ForLoop_New(); in For_Eval()
255 ForLoop_ParseVarnames(f, &p); in For_Eval()
256 if (f->vars.len > 0 && !ForLoop_ParseItems(f, p)) in For_Eval()
257 f->items.len = 0; /* don't iterate */ in For_Eval()
259 accumFor = f; in For_Eval()
375 ForLoop_SubstVarLong(ForLoop *f, unsigned int firstItem, Buffer *body, in ForLoop_SubstVarLong() argument
380 const char **varnames = Vector_Get(&f->vars, 0); in ForLoop_SubstVarLong()
382 for (i = 0; i < f->vars.len; i++) { in ForLoop_SubstVarLong()
397 AddEscaped(body, f->items.words[firstItem + i], endc); in ForLoop_SubstVarLong()
410 ForLoop_SubstVarShort(ForLoop *f, unsigned int firstItem, Buffer *body, in ForLoop_SubstVarShort() argument
421 vars = Vector_Get(&f->vars, 0); in ForLoop_SubstVarShort()
422 for (i = 0; i < f->vars.len; i++) { in ForLoop_SubstVarShort()
435 AddEscaped(body, f->items.words[firstItem + i], '}'); in ForLoop_SubstVarShort()
454 ForLoop_SubstBody(ForLoop *f, unsigned int firstItem, Buffer *body) in ForLoop_SubstBody() argument
461 mark = f->body.data; in ForLoop_SubstBody()
462 end = f->body.data + f->body.len; in ForLoop_SubstBody()
467 ForLoop_SubstVarLong(f, firstItem, body, in ForLoop_SubstBody()
470 ForLoop_SubstVarShort(f, firstItem, body, in ForLoop_SubstBody()
484 For_NextIteration(ForLoop *f, Buffer *body) in For_NextIteration() argument
486 if (f->nextItem == f->items.len) in For_NextIteration()
489 f->nextItem += (unsigned int)f->vars.len; in For_NextIteration()
490 ForLoop_SubstBody(f, f->nextItem - (unsigned int)f->vars.len, body); in For_NextIteration()
492 char *details = ForLoop_Details(f); in For_NextIteration()
502 For_Break(ForLoop *f) in For_Break() argument
504 f->nextItem = (unsigned int)f->items.len; in For_Break()
512 ForLoop *f = accumFor; in For_Run() local
515 if (f->items.len > 0) { in For_Run()
517 Parse_PushInput(NULL, headLineno, bodyReadLines, buf, f); in For_Run()
519 ForLoop_Free(f); in For_Run()