1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-29 14:17:30 +02:00

b2/: add BOM dumping; dump processed BOM entries

This commit is contained in:
Werner Almesberger 2012-05-23 18:26:27 -03:00
parent ec04163f44
commit 66aea07f23
3 changed files with 31 additions and 0 deletions

View File

@ -11,6 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <assert.h> #include <assert.h>
@ -24,6 +25,9 @@
#include "bom.h" #include "bom.h"
#define INDENT 4
struct bom *bom = NULL; struct bom *bom = NULL;
int n_bom = 0; int n_bom = 0;
@ -149,3 +153,26 @@ int bom_subst(struct bom *b, const struct subst *sub)
n_bom--; n_bom--;
return res; return res;
} }
void bom_dump(FILE *file, const struct bom *b)
{
const char **f;
const struct param *var;
fprintf(file, "%s (%s)\n", b->ref, b->sym ? b->sym : "?");
fprintf(file, "%*s", INDENT, "");
for (f = b->fields; f != b->fields+b->n_fields; f++)
fprintf(file, "%s%s", f == b->fields ? "" : " ",
**f ? *f : "-");
fprintf(file, "\n");
if (!b->vars)
return;
fprintf(file, "%*s", INDENT, "");
for (var = b->vars; var; var = var->next) {
fprintf(file, "%s%s", var == b->vars ? "" : " ", var->u.name);
dump_relop(file, var->op);
fprintf(file, "%s", var->value.u.s);
}
fprintf(file, "\n");
}

View File

@ -13,6 +13,8 @@
#ifndef BOM_H #ifndef BOM_H
#define BOM_H #define BOM_H
#include <stdio.h>
#include "param.h" #include "param.h"
#include "subst.h" #include "subst.h"
@ -32,5 +34,6 @@ extern int n_bom;
struct bom *bom_parse_line(const char *s); struct bom *bom_parse_line(const char *s);
void bom_set_sym(const char *ref, const char *sym); void bom_set_sym(const char *ref, const char *sym);
int bom_subst(struct bom *b, const struct subst *sub); int bom_subst(struct bom *b, const struct subst *sub);
void bom_dump(FILE *file, const struct bom *b);
#endif /* !BOM_H */ #endif /* !BOM_H */

View File

@ -110,6 +110,7 @@ static void process_bom_line(const char *s)
b = bom_parse_line(s); b = bom_parse_line(s);
bom_subst(b, substitutions); bom_subst(b, substitutions);
bom_dump(stderr, b);
} }
%} %}