Mercurial > hg > index.cgi
comparison lwcc/token.c @ 305:54f213c8fb81 ccdev
Various bugfixes and output tuning
Tuned output of preprocessor to include line markers similar to the ones
added by the gcc preprocessor.
Also, many fixes for various bits of dumbosity leading to misbehaviour and
crashing.
author | William Astle <lost@l-w.ca> |
---|---|
date | Wed, 18 Sep 2013 19:17:52 -0600 |
parents | d85d173ba120 |
children |
comparison
equal
deleted
inserted
replaced
304:d85d173ba120 | 305:54f213c8fb81 |
---|---|
39 t -> lineno = row; | 39 t -> lineno = row; |
40 t -> column = col; | 40 t -> column = col; |
41 t -> fn = fn; | 41 t -> fn = fn; |
42 t -> next = NULL; | 42 t -> next = NULL; |
43 t -> prev = NULL; | 43 t -> prev = NULL; |
44 t -> list = NULL; | |
44 return t; | 45 return t; |
45 } | 46 } |
46 | 47 |
47 void token_free(struct token *t) | 48 void token_free(struct token *t) |
48 { | 49 { |
53 struct token *token_dup(struct token *t) | 54 struct token *token_dup(struct token *t) |
54 { | 55 { |
55 struct token *t2; | 56 struct token *t2; |
56 | 57 |
57 t2 = lw_alloc(sizeof(struct token)); | 58 t2 = lw_alloc(sizeof(struct token)); |
58 (*t2) = (*t); | 59 t2 -> ttype = t -> ttype; |
60 t2 -> lineno = t -> lineno; | |
61 t2 -> column = t -> column; | |
62 t2 -> list = NULL; | |
59 t2 -> next = NULL; | 63 t2 -> next = NULL; |
60 t2 -> prev = NULL; | 64 t2 -> prev = NULL; |
61 if (t -> strval) | 65 if (t -> strval) |
62 t2 -> strval = lw_strdup(t -> strval); | 66 t2 -> strval = lw_strdup(t -> strval); |
67 else | |
68 t2 -> strval = NULL; | |
63 return t2; | 69 return t2; |
64 } | 70 } |
65 | 71 |
66 static struct { int ttype; char *tstr; } tok_strs[] = | 72 static struct { int ttype; char *tstr; } tok_strs[] = |
67 { | 73 { |
150 while (tl -> head) | 156 while (tl -> head) |
151 { | 157 { |
152 tl -> tail = tl -> head; | 158 tl -> tail = tl -> head; |
153 tl -> head = tl -> head -> next; | 159 tl -> head = tl -> head -> next; |
154 token_free(tl -> tail); | 160 token_free(tl -> tail); |
155 lw_free(tl -> tail); | |
156 } | 161 } |
157 lw_free(tl); | 162 lw_free(tl); |
158 } | 163 } |
159 | 164 |
160 void token_list_append(struct token_list *tl, struct token *tok) | 165 void token_list_append(struct token_list *tl, struct token *tok) |