Mercurial > ~dholland > hg > tradcpp > index.cgi
diff files.c @ 104:91f600e6647b
Allow absolute paths in include files.
author | David A. Holland |
---|---|
date | Tue, 11 Jun 2013 11:13:58 -0400 |
parents | 60184aa42604 |
children | 33954a07d013 |
line wrap: on
line diff
--- 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();