Mercurial > ~dholland > hg > tradcpp > index.cgi
changeset 104:91f600e6647b
Allow absolute paths in include files.
author | David A. Holland |
---|---|
date | Tue, 11 Jun 2013 11:13:58 -0400 |
parents | 343af355df1b |
children | 600f36cd7353 |
files | CHANGES files.c |
diffstat | 2 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES Tue Jun 11 11:00:01 2013 -0400 +++ b/CHANGES Tue Jun 11 11:13:58 2013 -0400 @@ -1,6 +1,7 @@ pending - auto-recognize more builtin PowerPC and mips macros - pass -Wunused (partly from Baptiste Daroussin) + - allow absolute paths in include files (partly from Baptiste Daroussin) release 0.1 (20130610) - first release, works with at least some imake templates
--- a/files.c Tue Jun 11 11:00:01 2013 -0400 +++ b/files.c Tue Jun 11 11:13:58 2013 -0400 @@ -340,19 +340,29 @@ assert(place != NULL); - num = incdirarray_num(path); - for (i=0; i<num; i++) { - id = incdirarray_get(path, i); - file = mkfilename(id->name, name); - fd = file_tryopen(file); + if (name[0] == '/') { + fd = file_tryopen(name); if (fd >= 0) { - pf = place_addfile(place, file, id->issystem); - file_read(pf, fd, file, false); - dostrfree(file); + pf = place_addfile(place, name, true); + file_read(pf, fd, name, false); close(fd); return; } - dostrfree(file); + } else { + num = incdirarray_num(path); + for (i=0; i<num; i++) { + id = incdirarray_get(path, i); + file = mkfilename(id->name, name); + fd = file_tryopen(file); + if (fd >= 0) { + pf = place_addfile(place, file, id->issystem); + file_read(pf, fd, file, false); + dostrfree(file); + close(fd); + return; + } + dostrfree(file); + } } complain(place, "Include file %s not found", name); complain_fail();