From deff077b4c42ca6ed73136c0c7d294cd7ef1cf66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Tue, 8 Apr 2008 21:49:14 +0000 Subject: [PATCH] close BSDL file upon deinit if it's still open git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1160 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 4 ++++ jtag/src/bsdl/bsdl_flex.l | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 2b62577d..b9c690a0 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,7 @@ +2008-04-08 Arnim Laeuger + + * src/bsdl/bsdl_flex.l (bsdl_flex_deinit): close file if still open + 2008-04-08 Kolja Waschk * src/cmd/idcode.c: [ 1936543 ] Check for set-up cable in idcode (U.Bonnes) diff --git a/jtag/src/bsdl/bsdl_flex.l b/jtag/src/bsdl/bsdl_flex.l index 0fe357d6..48b34a9f 100644 --- a/jtag/src/bsdl/bsdl_flex.l +++ b/jtag/src/bsdl/bsdl_flex.l @@ -447,6 +447,12 @@ void *bsdl_flex_init(FILE *f, int mode, int debug) void bsdl_flex_deinit(void *scanner) { + if (yyget_in(scanner)) { + /* file might still be open so close it in any case + e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */ + fclose(yyget_in(scanner)); + yyset_in(NULL, scanner); + } free(yyget_extra(scanner)); yylex_destroy(scanner); } @@ -495,7 +501,7 @@ void bsdl_flex_switch_file(yyscan_t scanner, char *filename) /* file in current directory has precedence */ f = fopen(filename, "r"); if (!f) { - char *db_path = jtag_get_data_dir(); + const char *db_path = jtag_get_data_dir(); char *db_file; if ((db_file = (char *)malloc(strlen(db_path) +