This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch,fortran] Fix INCLUDE with full path (PR30276)
- From: Tobias Burnus <burnus at net-b dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 02 Jan 2007 17:58:53 +0100
- Subject: Re: [patch,fortran] Fix INCLUDE with full path (PR30276)
- References: <459A7BCA.7040403@net-b.de> <20070102155359.GL29911@devserv.devel.redhat.com>
Jakub Jelinek wrote:
> The right fix is IMHO to add
> if (IS_ABSOLUTE_PATH (name))
> return gfc_open_file (name);
> to the beginning of gfc_open_file_name and gfc_open_intrinsic_module.
> Then it will do the right thing and never open any file more than once
> within one gfc_open_* call.
>
This looks more sensible! Thanks for pointing out the problem of the
patch and thanks for making me aware of IS_ABSOLUTE_PATH; thanks also to
Richard.
This proves again that it is easy to get a (seemingly?) trivial patch
wrong, just because one thinks the problem is simple and thus there are
no side effects possible.* Mea culpa also to Steven Bosscher for
misreading his comment.
I use now Jakub's patch which makes more sense. (It also avoids the
pointless iteration over the include paths, which is pointless for
absolute pathnames.) Note, patching gfc_open_intrinsic_module is not
needed as it calls open_included_file.
Is the following patch ok for the trunk and then for 4.2?
(Compiled, regtested and tested on x86_64-unknown-linux-gnu.)
Tobias
* I know of a professor in mathematics who checks in theses carefully
the parts labelled as "one trivially sees that", whereas he only skims
over the difficult maths shown in every detail -- and he knows why.
2007-01-02 Tobias Burnus <burnus@net-b.de>
Jakub Jelinek <jakub@redhat.com>
PR fortran/30276
* scanner.c (open_included_file): Fix support of full-path filenames.
Index: gcc/fortran/scanner.c
===================================================================
--- gcc/fortran/scanner.c (Revision 120344)
+++ gcc/fortran/scanner.c (Arbeitskopie)
@@ -192,24 +192,22 @@
}
static FILE *
open_included_file (const char *name, gfc_directorylist *list, bool module)
{
char *fullname;
gfc_directorylist *p;
FILE *f;
- f = gfc_open_file (name);
-
- if (f != NULL)
- return f;
+ if (IS_ABSOLUTE_PATH (name))
+ return gfc_open_file (name);
for (p = list; p; p = p->next)
{
if (module && !p->use_for_modules)
continue;
fullname = (char *) alloca(strlen (p->path) + strlen (name) + 1);
strcpy (fullname, p->path);
strcat (fullname, name);