Date:2012-05-23 23:26:27 (11 years 10 months ago)
Author:Werner Almesberger
Commit:66aea07f235fb28f38133d59cf0ab4e465220326
Message:b2/: add BOM dumping; dump processed BOM entries

Files: b2/bom.c (3 diffs)
b2/bom.h (2 diffs)
b2/lang.l (1 diff)

Change Details

b2/bom.c
1111
1212
1313#include <stdlib.h>
14#include <stdio.h>
1415#include <string.h>
1516#include <ctype.h>
1617#include <assert.h>
...... 
2425#include "bom.h"
2526
2627
28#define INDENT 4
29
30
2731struct bom *bom = NULL;
2832int n_bom = 0;
2933
...... 
149153        n_bom--;
150154    return res;
151155}
156
157
158void 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
1313#ifndef BOM_H
1414#define BOM_H
1515
16#include <stdio.h>
17
1618#include "param.h"
1719#include "subst.h"
1820
...... 
3234struct bom *bom_parse_line(const char *s);
3335void bom_set_sym(const char *ref, const char *sym);
3436int bom_subst(struct bom *b, const struct subst *sub);
37void bom_dump(FILE *file, const struct bom *b);
3538
3639#endif /* !BOM_H */
b2/lang.l
110110
111111    b = bom_parse_line(s);
112112    bom_subst(b, substitutions);
113    bom_dump(stderr, b);
113114}
114115
115116%}

Archive Download the corresponding diff file

Branches:
master



interactive