Fix a bug with embedded commands and make the parser more anal about what

can be embedded.
This commit is contained in:
Brian Koropoff 2003-02-28 05:07:15 +00:00
parent d2edce37a4
commit 7f72596ab5
2 changed files with 14 additions and 8 deletions

View file

@ -204,12 +204,6 @@ GIB_Execute (cbuf_t * cbuf)
return; return;
g->ip = g->ip ? g->ip->next : g->program; g->ip = g->ip ? g->ip->next : g->program;
while (g->ip) { while (g->ip) {
if (g->ip->flags & TREE_L_EMBED) {
// Get ready for return values
g->waitret = true;
GIB_Buffer_Push_Sstack (cbuf);
} else
g->waitret = false;
switch (g->ip->type) { switch (g->ip->type) {
case TREE_T_JUMP: case TREE_T_JUMP:
g->ip = g->ip->jump; g->ip = g->ip->jump;
@ -241,7 +235,13 @@ GIB_Execute (cbuf_t * cbuf)
case TREE_T_CMD: case TREE_T_CMD:
if (GIB_Execute_Prepare_Line (cbuf, g->ip)) if (GIB_Execute_Prepare_Line (cbuf, g->ip))
return; return;
else if (cbuf->args->argc) { if (g->ip->flags & TREE_L_EMBED) {
// Get ready for return values
g->waitret = true;
GIB_Buffer_Push_Sstack (cbuf);
} else
g->waitret = false;
if (cbuf->args->argc) {
if ((b = GIB_Builtin_Find (cbuf->args->argv[0]->str))) if ((b = GIB_Builtin_Find (cbuf->args->argv[0]->str)))
b->func (); b->func ();
else if ((f = GIB_Function_Find (cbuf->args->argv[0]->str))) { else if ((f = GIB_Function_Find (cbuf->args->argv[0]->str))) {

View file

@ -509,6 +509,9 @@ GIB_Parse_Semantic_Preprocess (gib_tree_t * line)
|| !line->children->next->next->next->next) { || !line->children->next->next->next->next) {
GIB_Parse_Error ("Malformed 'for' statement.", line->start); GIB_Parse_Error ("Malformed 'for' statement.", line->start);
return line; return line;
} else if (line->flags & TREE_L_EMBED) {
GIB_Parse_Error ("'for' statements may not be used in embedded commands.", line->start);
return line;
} }
// Find last token in line (contains program block) // Find last token in line (contains program block)
for (tmp = line->children->next->next->next->next; tmp->next; for (tmp = line->children->next->next->next->next; tmp->next;
@ -552,8 +555,11 @@ GIB_Parse_Semantic_Preprocess (gib_tree_t * line)
!(line->children->next->flags & TREE_A_CONCAT) && !(line->children->next->flags & TREE_A_CONCAT) &&
line->children->next->delim == ' ' && line->children->next->delim == ' ' &&
!strcmp (line->children->next->str, "=") !strcmp (line->children->next->str, "=")
) ) {
if (line->flags & TREE_L_EMBED)
GIB_Parse_Error ("Assignment may not be used as an embedded command.", line->start);
line->type = TREE_T_ASSIGN; line->type = TREE_T_ASSIGN;
}
return line; return line;
} }