Lines Matching refs:pl
672 static char *pl2str(struct sh_pipeline *pl) in pl2str() argument
679 for (j = 0; ; j++) for (end = pl; end; end = end->next) { in pl2str()
683 for (i = 0; i<pl->arg->c; i++) in pl2str()
684 if (j) ss += sprintf(ss, "%s ", pl->arg->v[i]); in pl2str()
685 else len += strlen(pl->arg->v[i])+1; in pl2str()
687 sss = pl->arg->v[pl->arg->c]; in pl2str()
1085 struct sh_pipeline *pl = pipeline; in free_pipeline() local
1088 if (pl) for (j=0; j<=pl->count; j++) { in free_pipeline()
1089 for (i = 0; i<=pl->arg->c; i++) free(pl->arg[j].v[i]); in free_pipeline()
1090 free(pl->arg[j].v); in free_pipeline()
1092 free(pl); in free_pipeline()
1096 struct sh_pipeline *block_end(struct sh_pipeline *pl) in block_end() argument
1103 while (pl) { in block_end()
1104 if (pl->type == 1 || pl->type == 'f') i++; in block_end()
1105 else if (pl->type == 3) if (--i<1) break; in block_end()
1106 pl = pl->next; in block_end()
1109 return pl; in block_end()
1120 struct sh_pipeline *add_function(char *name, struct sh_pipeline *pl) in add_function() argument
1124 return block_end(pl->next); in add_function()
1132 struct sh_pipeline *pl = sp->pipeline ? sp->pipeline->prev : 0; in parse_line() local
1137 if (pl) { in parse_line()
1138 arg = pl->arg; in parse_line()
1147 } else if (pl->count != pl->here) { in parse_line()
1148 arg += 1+pl->here; in parse_line()
1163 pl->here++; in parse_line()
1168 } else pl = 0; in parse_line()
1176 if (pl && pl->count == -1) { in parse_line()
1177 pl->count = 0; in parse_line()
1178 arg = pl->arg; in parse_line()
1191 pl = xrealloc(pl, sizeof(*pl) + ++pl->count*sizeof(struct sh_arg)); in parse_line()
1192 dlist_add_nomalloc((void *)&sp->pipeline, (void *)pl); in parse_line()
1195 arg[pl->count].v = xzalloc(2*sizeof(void *)); in parse_line()
1196 arg[pl->count].v[0] = arg->v[++i]; in parse_line()
1197 arg[pl->count].v[1] = 0; in parse_line()
1198 arg[pl->count].c = 0; in parse_line()
1199 if (s[2] == '<') pl->here++; // <<< doesn't load more data in parse_line()
1201 pl = 0; in parse_line()
1215 if (!pl) { in parse_line()
1216 pl = xzalloc(sizeof(struct sh_pipeline)); in parse_line()
1217 arg = pl->arg; in parse_line()
1218 dlist_add_nomalloc((void *)&sp->pipeline, (void *)pl); in parse_line()
1235 if (end == start || (arg->c && *start == ')' && pl->type!='f')) { in parse_line()
1238 if (pl->type == 'f' && arg->c<3) { in parse_line()
1254 pl->count = -1; in parse_line()
1276 pl->count = -1; in parse_line()
1282 if (arg->c>1 && !strcmp(s, "(")) pl->type = 'f'; in parse_line()
1283 if (pl->type=='f') { in parse_line()
1289 pl->count = -1; in parse_line()
1303 pl->count = -1; in parse_line()
1326 if (!pl->prev->type) goto flush; in parse_line()
1327 if (!strncmp(pl->prev->arg->v[1], "((", 2)) goto flush; in parse_line()
1339 if (!pl->type) pl->type = 1; in parse_line()
1361 pl->type = 1; in parse_line()
1375 pl->type = anystr(s, (char *[]){"fi", "done", "esac", "}", "]]", ")", 0}) in parse_line()
1400 if (!pl->type) pl->type = 2; in parse_line()
1403 pl->count = -1; in parse_line()
1408 if (!pl->type && anystr(s, (char *[]){"then", "do", "esac", "}", "]]", ")", in parse_line()
1418 pl = sp->pipeline->prev; in parse_line()
1419 while (pl->count<pl->here && pl->arg[pl->count].c<0) in parse_line()
1420 pl->arg[pl->count++].c = 0; in parse_line()
1424 if (sp->pipeline && pl->count != pl->here) return 1; in parse_line()
1425 if (pl->arg->v[pl->arg->c]) return 1; in parse_line()
1441 struct sh_pipeline *pl; in dump_state() local
1455 for (pl = sp->pipeline; pl ; pl = (pl->next == sp->pipeline) ? 0 : pl->next) { in dump_state()
1456 for (i = 0; i<pl->arg->c; i++) in dump_state()
1457 dprintf(255, "arg[%d][%ld]=%s\n", q, i, pl->arg->v[i]); in dump_state()
1458 if (pl->arg->c<0) dprintf(255, "argc=%d\n", pl->arg->c); in dump_state()
1459 else dprintf(255, "type=%d term[%d]=%s\n", pl->type, q++, pl->arg->v[pl->arg->c]); in dump_state()
1538 static struct sh_pipeline *skip_andor(int rc, struct sh_pipeline *pl) in skip_andor() argument
1540 char *ctl = pl->arg->v[pl->arg->c]; in skip_andor()
1544 if (!pl->next || pl->next->type == 2 || pl->next->type == 3) break; in skip_andor()
1545 pl = pl->type ? block_end(pl) : pl->next; in skip_andor()
1546 ctl = pl ? pl->arg->v[pl->arg->c] : 0; in skip_andor()
1549 return pl; in skip_andor()
1555 static void run_function(struct sh_pipeline *pl) in run_function() argument
1574 while (pl) { in run_function()
1575 struct sh_arg *arg = pl->arg; in run_function()
1577 if (BUGBUG) dprintf(255, "%d runtype=%d %s %s\n", getpid(), pl->type, s, ctl); in run_function()
1579 if (!pl->type) { in run_function()
1583 while (pl->next && !pl->next->type) pl = pl->next; in run_function()
1611 pl = blk->start; in run_function()
1614 pl = blk->end; in run_function()
1628 pl = pl->next; in run_function()
1646 pl = skip_andor(toys.exitval, pl); in run_function()
1650 } else if (pl->type == 1) { in run_function()
1654 if (!blk || blk->start != pl) { in run_function()
1657 end = block_end(pl->next); in run_function()
1659 pl = end; in run_function()
1660 if (pl) pl = pl->next; in run_function()
1671 blk->start = pl; in run_function()
1706 if (!pl->next->type) { in run_function()
1707 for (i = 1; i<pl->next->arg->c; i++) in run_function()
1708 expand_arg(&blk->farg, pl->next->arg->v[i], 0, &blk->fdelete); in run_function()
1725 ss = pl2str(pl->next); in run_function()
1730 run_function(pl->next); in run_function()
1736 pl = blk->end->prev; in run_function()
1740 } else if (pl->type == 2) { in run_function()
1751 pl = block_end(pl); in run_function()
1760 } else if (pl->type == 3) { in run_function()
1767 pl = blk->start; in run_function()
1778 } else if (pl->type == 'f') pl = add_function(s, pl); in run_function()
1780 pl = pl->next; in run_function()