This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch,fortran] Fix INCLUDE with full path (PR30276)


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);
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]