comparison files.c @ 28:8a955e3dda2c posted-20101220

two more tests, more fixes
author David A. Holland
date Mon, 20 Dec 2010 05:42:15 -0500
parents daa801fe719e
children 76c114899f63
comparison
equal deleted inserted replaced
27:01c3a2088ab4 28:8a955e3dda2c
100 return limit; 100 return limit;
101 } 101 }
102 102
103 static 103 static
104 void 104 void
105 file_read(const struct placefile *pf, int fd, const char *name) 105 file_read(const struct placefile *pf, int fd, const char *name, bool toplevel)
106 { 106 {
107 struct place linestartplace, nextlinestartplace, ptmp; 107 struct place linestartplace, nextlinestartplace, ptmp;
108 size_t bufend, bufmax, linestart, lineend, nextlinestart, tmp; 108 size_t bufend, bufmax, linestart, lineend, nextlinestart, tmp;
109 ssize_t result; 109 ssize_t result;
110 bool ateof = false; 110 bool ateof = false;
208 linestart = nextlinestart; 208 linestart = nextlinestart;
209 lineend = findnl(buf, linestart, bufend); 209 lineend = findnl(buf, linestart, bufend);
210 linestartplace = nextlinestartplace; 210 linestartplace = nextlinestartplace;
211 } 211 }
212 212
213 directive_goteof(&linestartplace); 213 if (toplevel) {
214 directive_goteof(&linestartplace);
215 }
214 free(buf); 216 free(buf);
215 } 217 }
216 218
217 //////////////////////////////////////////////////////////// 219 ////////////////////////////////////////////////////////////
218 // path search 220 // path search
274 id = incdirarray_get(path, i); 276 id = incdirarray_get(path, i);
275 file = mkfilename(id->name, name); 277 file = mkfilename(id->name, name);
276 fd = file_tryopen(file); 278 fd = file_tryopen(file);
277 if (fd >= 0) { 279 if (fd >= 0) {
278 pf = place_addfile(place, file, id->issystem); 280 pf = place_addfile(place, file, id->issystem);
279 file_read(pf, fd, file); 281 file_read(pf, fd, file, false);
280 free(file); 282 free(file);
281 close(fd); 283 close(fd);
282 return; 284 return;
283 } 285 }
284 free(file); 286 free(file);
317 die(); 319 die();
318 } 320 }
319 pf = place_addfile(place, name, false); 321 pf = place_addfile(place, name, false);
320 } 322 }
321 323
322 file_read(pf, fd, name); 324 file_read(pf, fd, name, true);
323 325
324 if (name != NULL) { 326 if (name != NULL) {
325 close(fd); 327 close(fd);
326 } 328 }
327 } 329 }