comparison 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
comparison
equal deleted inserted replaced
27:01c3a2088ab4 28:8a955e3dda2c
8 #include "place.h" 8 #include "place.h"
9 9
10 struct placefile { 10 struct placefile {
11 struct place includedfrom; 11 struct place includedfrom;
12 char *name; 12 char *name;
13 int depth;
13 bool fromsystemdir; 14 bool fromsystemdir;
14 }; 15 };
15 DECLARRAY(placefile); 16 DECLARRAY(placefile);
16 DEFARRAY(placefile, ); 17 DEFARRAY(placefile, );
17 18
30 31
31 pf = domalloc(sizeof(*pf)); 32 pf = domalloc(sizeof(*pf));
32 pf->includedfrom = *from; 33 pf->includedfrom = *from;
33 pf->name = dostrdup(name); 34 pf->name = dostrdup(name);
34 pf->fromsystemdir = fromsystemdir; 35 pf->fromsystemdir = fromsystemdir;
36 if (from->file != NULL) {
37 pf->depth = from->file->depth + 1;
38 } else {
39 pf->depth = 1;
40 }
35 return pf; 41 return pf;
36 } 42 }
37 43
38 static 44 static
39 void 45 void
50 { 56 {
51 struct placefile *pf; 57 struct placefile *pf;
52 58
53 pf = placefile_create(place, file, issystem); 59 pf = placefile_create(place, file, issystem);
54 placefilearray_add(&placefiles, pf, NULL); 60 placefilearray_add(&placefiles, pf, NULL);
61 if (pf->depth > 128) {
62 complain(place, "Maximum include nesting depth exceeded");
63 die();
64 }
55 return pf; 65 return pf;
56 } 66 }
57 67
58 //////////////////////////////////////////////////////////// 68 ////////////////////////////////////////////////////////////
59 // places 69 // places
86 } 96 }
87 97
88 void 98 void
89 place_setfilestart(struct place *p, const struct placefile *pf) 99 place_setfilestart(struct place *p, const struct placefile *pf)
90 { 100 {
91 p->type = P_COMMANDLINE; 101 p->type = P_FILE;
92 p->file = pf; 102 p->file = pf;
93 p->line = 1; 103 p->line = 1;
94 p->column = 1; 104 p->column = 1;
95 } 105 }
96 106