Mercurial > ~dholland > hg > tradcpp > index.cgi
diff place.c @ 178:0d5b9651b240
Merge Joerg's changes into upstream.
(now that they've been thrashed out a bit, include CHANGES entries, etc.)
author | David A. Holland |
---|---|
date | Fri, 12 Jun 2015 03:05:49 -0400 |
parents | a2f047301c15 |
children | 16b4451e34b8 |
line wrap: on
line diff
--- a/place.c Fri Jun 12 03:04:48 2015 -0400 +++ b/place.c Fri Jun 12 03:05:49 2015 -0400 @@ -53,7 +53,7 @@ static const char *myprogname; //////////////////////////////////////////////////////////// -// seenfiles +// placefiles static struct placefile * @@ -101,6 +101,58 @@ return place->file->dir; } +static +bool +place_eq(const struct place *a, const struct place *b) +{ + if (a->type != b->type) { + return false; + } + if (a->file != b->file) { + return false; + } + if (a->line != b->line || a->column != b->column) { + return false; + } + return true; +} + +static +struct placefile * +placefile_find(const struct place *incfrom, const char *name) +{ + unsigned i, num; + struct placefile *pf; + + num = placefilearray_num(&placefiles); + for (i=0; i<num; i++) { + pf = placefilearray_get(&placefiles, i); + if (place_eq(incfrom, &pf->includedfrom) && + !strcmp(name, pf->name)) { + return pf; + } + } + return NULL; +} + +void +place_changefile(struct place *p, const char *name) +{ + struct placefile *pf; + + assert(p->type == P_FILE); + if (!strcmp(name, p->file->name)) { + return; + } + pf = placefile_find(&p->file->includedfrom, name); + if (pf == NULL) { + pf = placefile_create(&p->file->includedfrom, name, + p->file->fromsystemdir); + placefilearray_add(&placefiles, pf, NULL); + } + p->file = pf; +} + const struct placefile * place_addfile(const struct place *place, const char *file, bool issystem) { @@ -154,7 +206,6 @@ p->column = 1; } -static const char * place_getname(const struct place *p) {