fixed the standard console handlers to reset FNR when opening a new file upon EOF of the previous file

This commit is contained in:
hyung-hwan 2020-03-16 04:41:11 +00:00
parent e83fda484e
commit 1b46bba861
2 changed files with 8 additions and 0 deletions

View File

@ -1076,6 +1076,10 @@ StdAwk::ssize_t StdAwk::readConsole (Console& io, char_t* data, size_t size)
}
if (sio) qse_sio_close (sio);
/* reset FNR to 0 here since the caller doesn't know that the file has changed. */
((Run*)io)->setGlobal (QSE_AWK_GBL_FNR, (qse_awk_int_t)0);
}
return nn;

View File

@ -1838,6 +1838,10 @@ static qse_ssize_t awk_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_cmd_t cmd, q
}
if (sio) qse_sio_close (sio);
/* reset FNR to 0 here since the caller doesn't know that the file has changed. */
qse_awk_rtx_setgbl(rtx, QSE_AWK_GBL_FNR, qse_awk_rtx_makeintval(rtx, 0));
}
return nn;