From 1b46bba861510bb3b1747789d7e5d439199c235a Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 16 Mar 2020 04:41:11 +0000 Subject: [PATCH] fixed the standard console handlers to reset FNR when opening a new file upon EOF of the previous file --- qse/lib/awk/StdAwk.cpp | 4 ++++ qse/lib/awk/std.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/qse/lib/awk/StdAwk.cpp b/qse/lib/awk/StdAwk.cpp index 9e03c747..3b09a078 100644 --- a/qse/lib/awk/StdAwk.cpp +++ b/qse/lib/awk/StdAwk.cpp @@ -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; diff --git a/qse/lib/awk/std.c b/qse/lib/awk/std.c index 2fd2776b..bce7a4b7 100644 --- a/qse/lib/awk/std.c +++ b/qse/lib/awk/std.c @@ -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;