From ce058cc432be29f143b544b3fe528262095ee131 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 25 Mar 2025 08:28:36 -0400 Subject: [PATCH] Fix `$fscanf` not returning -1 on EOF (#5881). --- Changes | 1 + include/verilated.cpp | 11 ++++-- ...ile_scan_input.dat => t_sys_file_scan.dat} | 0 test_regress/t/t_sys_file_scan.v | 2 +- test_regress/t/t_sys_file_scan2.dat | 1 + test_regress/t/t_sys_file_scan2.py | 18 +++++++++ test_regress/t/t_sys_file_scan2.v | 37 +++++++++++++++++++ 7 files changed, 66 insertions(+), 4 deletions(-) rename test_regress/t/{t_sys_file_scan_input.dat => t_sys_file_scan.dat} (100%) create mode 100644 test_regress/t/t_sys_file_scan2.dat create mode 100755 test_regress/t/t_sys_file_scan2.py create mode 100644 test_regress/t/t_sys_file_scan2.v diff --git a/Changes b/Changes index 88bbb38b1..fc5ef95f2 100644 --- a/Changes +++ b/Changes @@ -54,6 +54,7 @@ Verilator 5.035 devel * Fix streaming of unpacked arrays concatenations (#5856). [Ryszard Rozak, Antmicro Ltd.] * Fix Windows paths in Perl (#5858) (#5860). [Tobias Jensen] * Fix algorithm header portability in V3Os.cpp (for std::replace) (#5861). [William D. Jones] +* Fix `$fscanf` not returning -1 on EOF (#5881). Verilator 5.034 2025-02-24 diff --git a/include/verilated.cpp b/include/verilated.cpp index 489ec7ee7..20d0cacc8 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1249,9 +1249,9 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf bool inPct = false; bool inIgnore = false; std::string::const_iterator pos = format.cbegin(); - for (; pos != format.cend() && !_vl_vsss_eof(fp, floc); ++pos) { - // VL_DBG_MSGF("_vlscan fmt='"<