Mercurial > ~dholland > hg > tradcpp > index.cgi
diff place.c @ 28:8a955e3dda2c posted-20101220
two more tests, more fixes
author | David A. Holland |
---|---|
date | Mon, 20 Dec 2010 05:42:15 -0500 |
parents | 5045b9678bb0 |
children | 76c114899f63 |
line wrap: on
line diff
--- a/place.c Mon Dec 20 05:01:18 2010 -0500 +++ b/place.c Mon Dec 20 05:42:15 2010 -0500 @@ -10,6 +10,7 @@ struct placefile { struct place includedfrom; char *name; + int depth; bool fromsystemdir; }; DECLARRAY(placefile); @@ -32,6 +33,11 @@ pf->includedfrom = *from; pf->name = dostrdup(name); pf->fromsystemdir = fromsystemdir; + if (from->file != NULL) { + pf->depth = from->file->depth + 1; + } else { + pf->depth = 1; + } return pf; } @@ -52,6 +58,10 @@ pf = placefile_create(place, file, issystem); placefilearray_add(&placefiles, pf, NULL); + if (pf->depth > 128) { + complain(place, "Maximum include nesting depth exceeded"); + die(); + } return pf; } @@ -88,7 +98,7 @@ void place_setfilestart(struct place *p, const struct placefile *pf) { - p->type = P_COMMANDLINE; + p->type = P_FILE; p->file = pf; p->line = 1; p->column = 1;