Change Details
b2/bom.c |
11 | 11 | |
12 | 12 | |
13 | 13 | #include <stdlib.h> |
| 14 | #include <stdio.h> |
14 | 15 | #include <string.h> |
15 | 16 | #include <ctype.h> |
16 | 17 | #include <assert.h> |
... | ... | |
24 | 25 | #include "bom.h" |
25 | 26 | |
26 | 27 | |
| 28 | #define INDENT 4 |
| 29 | |
| 30 | |
27 | 31 | struct bom *bom = NULL; |
28 | 32 | int n_bom = 0; |
29 | 33 | |
... | ... | |
149 | 153 | n_bom--; |
150 | 154 | return res; |
151 | 155 | } |
| 156 | |
| 157 | |
| 158 | void bom_dump(FILE *file, const struct bom *b) |
| 159 | { |
| 160 | const char **f; |
| 161 | const struct param *var; |
| 162 | |
| 163 | fprintf(file, "%s (%s)\n", b->ref, b->sym ? b->sym : "?"); |
| 164 | fprintf(file, "%*s", INDENT, ""); |
| 165 | for (f = b->fields; f != b->fields+b->n_fields; f++) |
| 166 | fprintf(file, "%s%s", f == b->fields ? "" : " ", |
| 167 | **f ? *f : "-"); |
| 168 | fprintf(file, "\n"); |
| 169 | if (!b->vars) |
| 170 | return; |
| 171 | fprintf(file, "%*s", INDENT, ""); |
| 172 | for (var = b->vars; var; var = var->next) { |
| 173 | fprintf(file, "%s%s", var == b->vars ? "" : " ", var->u.name); |
| 174 | dump_relop(file, var->op); |
| 175 | fprintf(file, "%s", var->value.u.s); |
| 176 | } |
| 177 | fprintf(file, "\n"); |
| 178 | } |
b2/bom.h |
13 | 13 | #ifndef BOM_H |
14 | 14 | #define BOM_H |
15 | 15 | |
| 16 | #include <stdio.h> |
| 17 | |
16 | 18 | #include "param.h" |
17 | 19 | #include "subst.h" |
18 | 20 | |
... | ... | |
32 | 34 | struct bom *bom_parse_line(const char *s); |
33 | 35 | void bom_set_sym(const char *ref, const char *sym); |
34 | 36 | int bom_subst(struct bom *b, const struct subst *sub); |
| 37 | void bom_dump(FILE *file, const struct bom *b); |
35 | 38 | |
36 | 39 | #endif /* !BOM_H */ |
b2/lang.l |
110 | 110 | |
111 | 111 | b = bom_parse_line(s); |
112 | 112 | bom_subst(b, substitutions); |
| 113 | bom_dump(stderr, b); |
113 | 114 | } |
114 | 115 | |
115 | 116 | %} |
Download the corresponding diff file