comparison files.c @ 112:2b0b61fd1a36

Fix handling of relative includes.
author David A. Holland
date Tue, 11 Jun 2013 13:50:07 -0400
parents 33954a07d013
children 1e7144176a42
comparison
equal deleted inserted replaced
111:36dd4701e0ba 112:2b0b61fd1a36
288 //////////////////////////////////////////////////////////// 288 ////////////////////////////////////////////////////////////
289 // path search 289 // path search
290 290
291 static 291 static
292 char * 292 char *
293 mkfilename(const char *dir, const char *file) 293 mkfilename(struct place *place, const char *dir, const char *file)
294 { 294 {
295 size_t dlen, flen, rlen; 295 size_t dlen, flen, rlen;
296 char *ret; 296 char *ret;
297 bool needslash = false; 297 bool needslash = false;
298
299 if (dir == NULL) {
300 dir = place_getparsedir(place);
301 }
298 302
299 dlen = strlen(dir); 303 dlen = strlen(dir);
300 flen = strlen(file); 304 flen = strlen(file);
301 if (dlen > 0 && dir[dlen-1] != '/') { 305 if (dlen > 0 && dir[dlen-1] != '/') {
302 needslash = true; 306 needslash = true;
350 } 354 }
351 } else { 355 } else {
352 num = incdirarray_num(path); 356 num = incdirarray_num(path);
353 for (i=0; i<num; i++) { 357 for (i=0; i<num; i++) {
354 id = incdirarray_get(path, i); 358 id = incdirarray_get(path, i);
355 file = mkfilename(id->name, name); 359 file = mkfilename(place, id->name, name);
356 fd = file_tryopen(file); 360 fd = file_tryopen(file);
357 if (fd >= 0) { 361 if (fd >= 0) {
358 pf = place_addfile(place, file, id->issystem); 362 pf = place_addfile(place, file, id->issystem);
359 file_read(pf, fd, file, false); 363 file_read(pf, fd, file, false);
360 dostrfree(file); 364 dostrfree(file);