enhanced ARGC/ARGV handling in the console input handler
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-04 18:35:43 +09:00
parent 50e8499925
commit 4ca08e122a

View File

@ -1292,7 +1292,7 @@ int hawk_stdplainfileexists (hawk_t* hawk, const hawk_ooch_t* file)
const hawk_ooch_t* hawk_stdgetfileindirs (hawk_t* hawk, const hawk_oocs_t* dirs, const hawk_ooch_t* file)
{
xtn_t* xtn = GET_XTN(hawk);
/*xtn_t* xtn = GET_XTN(hawk);*/
const hawk_ooch_t* ptr = dirs->ptr;
const hawk_ooch_t* dirend = dirs->ptr + dirs->len;
const hawk_ooch_t* colon, * endptr;
@ -2356,7 +2356,6 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
if (rxtn->c.in.index >= (i_argc - 1)) /* ARGV is a kind of 0-based array unlike other normal arrays or substring indexing scheme */
{
/* reached the last ARGV */
if (rxtn->c.in.count <= 0) /* but no file has been ever opened */
{
console_open_stdin:
@ -2379,6 +2378,13 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
pair = hawk_map_search(map, ibuf, ibuflen);
if (!pair)
{
if (rxtn->c.in.index < i_argc)
{
/* not found but still didn't hit ARGC */
rxtn->c.in.index++;
goto nextfile;
}
/* the key doesn't exist any more */
if (rxtn->c.in.count <= 0) goto console_open_stdin;
return 0; /* end of console */