fix(IOB): EOF in stdin works

This commit is contained in:
Matteo Flebus 2026-01-22 14:05:49 +01:00
parent 609c1667af
commit fbc36f35b2
2 changed files with 11 additions and 6 deletions

View file

@ -85,7 +85,11 @@ ssize_t stream_read(char **stream)
if (nread == -1) if (nread == -1)
{ {
state = IOB_STATE_FINISHED; state = IOB_STATE_FINISHED;
return 0; // MAGNIFICO
// malloc(1);
*stream_buf = EOF;
*stream = stream_buf;
return 1;
} }
else if (nread < 0) else if (nread < 0)
state = IOB_STATE_ERROR; state = IOB_STATE_ERROR;

View file

@ -14,7 +14,6 @@
// === Static functions // === Static functions
/* Returns true if c is a command terminator, false otherwise /* Returns true if c is a command terminator, false otherwise
*/
static bool isterminator(struct token *token) static bool isterminator(struct token *token)
{ {
if (token == NULL) if (token == NULL)
@ -31,6 +30,8 @@ static bool isterminator(struct token *token)
} }
} }
*/
/* @brief: returns true if token is an end of list indicator. /* @brief: returns true if token is an end of list indicator.
* @warning: not used * @warning: not used
*/ */
@ -77,8 +78,8 @@ struct ast *parse_list(struct lexer_context *ctx)
while (token->type == TOKEN_SEMICOLON) while (token->type == TOKEN_SEMICOLON)
{ {
token = POP_TOKEN(); token = POP_TOKEN();
if (!isterminator(token)) // Follow(list) // if (!isterminator(token)) // Follow(list)
{ // {
current_node = parse_and_or(ctx); current_node = parse_and_or(ctx);
if (current_node == NULL) if (current_node == NULL)
{ {
@ -87,8 +88,8 @@ struct ast *parse_list(struct lexer_context *ctx)
return NULL; return NULL;
} }
result_list = list_append(result_list, current_node); result_list = list_append(result_list, current_node);
token = PEEK_TOKEN(); // }
} token = PEEK_TOKEN();
} }
// result_list = list_append(result_list, current_node); // result_list = list_append(result_list, current_node);