1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-22 15:49:22 +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 <stdio.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
@ -24,6 +25,9 @@
#include "bom.h"
#define INDENT 4
struct bom *bom = NULL;
int n_bom = 0;
@ -149,3 +153,26 @@ int bom_subst(struct bom *b, const struct subst *sub)
n_bom--;
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
#define BOM_H
#include <stdio.h>
#include "param.h"
#include "subst.h"
@ -32,5 +34,6 @@ extern int n_bom;
struct bom *bom_parse_line(const char *s);
void bom_set_sym(const char *ref, const char *sym);
int bom_subst(struct bom *b, const struct subst *sub);
void bom_dump(FILE *file, const struct bom *b);
#endif /* !BOM_H */

View File

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