From 1ed4603a18571f99501798b1ddb428e89abc084c Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 17 Feb 2016 13:55:19 +0100 Subject: [PATCH] vhdlpp: Set EOF flag right after reaching the end of file. --- vpi/vhdl_textio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vpi/vhdl_textio.c b/vpi/vhdl_textio.c index c0879cc64..cff0845b5 100644 --- a/vpi/vhdl_textio.c +++ b/vpi/vhdl_textio.c @@ -522,6 +522,11 @@ static PLI_INT32 ivlh_readline_calltf(ICARUS_VPI_CONST PLI_BYTE8*name) vpi_put_value(stringh, &val, 0, vpiNoDelay); free(text); + /* Set end-of-file flag if we have just reached the end of the file. + * Otherwise the flag would be set only after the next read operation. */ + int c = fgetc(fp); + ungetc(c, fp); + return 0; }