This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch,fortran] Fix INCLUDE with full path (PR30276)
- From: Tobias Burnus <burnus at net-b dot de>
- To: "'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 16:35:38 +0100
- Subject: [patch,fortran] Fix INCLUDE with full path (PR30276)
:ADDPATCH fortran:
Hi all,
first, I'd like to wish a belate happy new year.
Secondly, gfortran currently fails to INCLUDE files specified by the
full path, e.g.
include '/home/allan/slot2usl/physcons.inc'
The logic in gcc/fortran/scanner.c's open_included_file is:
for include_path in include_paths
try-to-open( include_path + filename )
The fix is simple: Try first to open the file without prefixing an
include path.
The following patch was tested on x86_64-unknown-linux-gnu; I also did
bootstrap and regression test it; furthermore, the patch was
pre-approved by Steven Bosscher (see PR30276). I don't see how one could
create a regression test for this ;-)
Ok for the trunk and after a week for 4.2?
Tobias
2007-01-02 Tobias Burnus <burnus@net-b.de>
PR fortran/30276
* scanner.c (open_included_file): Support full-path filenames.
Index: gcc/fortran/scanner.c
===================================================================
--- gcc/fortran/scanner.c (Revision 120340)
+++ gcc/fortran/scanner.c (Arbeitskopie)
@@ -192,20 +192,25 @@
}
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;
+
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);
f = gfc_open_file (fullname);