enhanced ARGC/ARGV handling in the console input handler
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
10
lib/std.c
10
lib/std.c
@ -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)
|
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* ptr = dirs->ptr;
|
||||||
const hawk_ooch_t* dirend = dirs->ptr + dirs->len;
|
const hawk_ooch_t* dirend = dirs->ptr + dirs->len;
|
||||||
const hawk_ooch_t* colon, * endptr;
|
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 */
|
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 */
|
/* reached the last ARGV */
|
||||||
|
|
||||||
if (rxtn->c.in.count <= 0) /* but no file has been ever opened */
|
if (rxtn->c.in.count <= 0) /* but no file has been ever opened */
|
||||||
{
|
{
|
||||||
console_open_stdin:
|
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);
|
pair = hawk_map_search(map, ibuf, ibuflen);
|
||||||
if (!pair)
|
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 */
|
/* the key doesn't exist any more */
|
||||||
if (rxtn->c.in.count <= 0) goto console_open_stdin;
|
if (rxtn->c.in.count <= 0) goto console_open_stdin;
|
||||||
return 0; /* end of console */
|
return 0; /* end of console */
|
||||||
|
Reference in New Issue
Block a user