From 99b54b33b4a01fe8a49502779a2ea90d902704cc Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 27 Feb 2009 07:44:59 +0100 Subject: [PATCH] re PR fortran/39309 (.mod file versioning causes error instead of overwritting the file) 2009-02-27 Tobias Burnus PR fortran/39309 * module.c (read_md5_from_module_file): Include mod version in had-changed test. From-SVN: r144461 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/module.c | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4bf462504725..5d972c2eddaa 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2009-02-27 Tobias Burnus + + PR fortran/39309 + * module.c (read_md5_from_module_file): Include mod version + in had-changed test. + 2009-02-26 Paul Thomas PR fortran/39295 diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index bfc4ef9f0d2b..c234879a2a1c 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -4739,8 +4739,18 @@ read_md5_from_module_file (const char * filename, unsigned char md5[16]) return -1; /* Read two lines. */ - if (fgets (buf, sizeof (buf) - 1, file) == NULL - || fgets (buf, sizeof (buf) - 1, file) == NULL) + if (fgets (buf, sizeof (buf) - 1, file) == NULL) + { + fclose (file); + return -1; + } + + /* The file also needs to be overwritten if the version number changed. */ + n = strlen ("GFORTRAN module version " MOD_VERSION " created"); + if (strncmp (buf, "GFORTRAN module version " MOD_VERSION " created", n) != 0) + return -1; + + if (fgets (buf, sizeof (buf) - 1, file) == NULL) { fclose (file); return -1; -- 2.47.2