1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-23 03:02:47 +02:00

b2/: add dumping of stock information

Also use part_add without first calling part_lookup, since the latter is
implicit.
This commit is contained in:
Werner Almesberger 2012-04-30 20:40:11 -03:00
parent 450769e031
commit 24a32525e2
3 changed files with 20 additions and 8 deletions

View File

@ -83,4 +83,4 @@ spotless: clean
# ----- Experiments ----------------------------------------------------------- # ----- Experiments -----------------------------------------------------------
try: try:
$(VALGRIND) ./boom HIERARCHY -c CHAR $(VALGRIND) ./boom HIERARCHY -c CHAR -i INV

15
b2/db.c
View File

@ -168,6 +168,18 @@ void part_add_stock(struct part *part, struct stock *stock)
} }
static void dump_stock(FILE *file, const struct stock *s)
{
const struct price *p;
fprintf(file, " %s %d %d %s %g",
s->cat, s->avail, s->package, "???", s->add);
for (p = s->price; p; p = p->next)
fprintf(file, " %d %g", p->qty, p->value);
fprintf(file, "\n");
}
void part_dump(FILE *file, const struct part *part) void part_dump(FILE *file, const struct part *part)
{ {
const struct param *p; const struct param *p;
@ -181,5 +193,6 @@ void part_dump(FILE *file, const struct part *part)
} }
fprintf(file, "\n"); fprintf(file, "\n");
} }
if (part->stock); if (part->stock)
dump_stock(file, part->stock);
} }

View File

@ -378,9 +378,7 @@ characteristics:
part: part:
WORD WORD params TOK_NL WORD WORD params TOK_NL
{ {
$$ = part_lookup($1, $2); $$ = part_add($1, $2);
if (!$$)
$$ = part_add($1, $2);
if ($$->param) if ($$->param)
yyerror("parameters already defined"); yyerror("parameters already defined");
$$->param = $3; $$->param = $3;
@ -414,14 +412,15 @@ param:
inventory: inventory:
| TOK_NL | TOK_NL
| inventory_item inventory | inventory_item inventory
{
part_dump(stderr, $1);
}
; ;
inventory_item: inventory_item:
WORD WORD stock TOK_NL WORD WORD stock TOK_NL
{ {
$$ = part_lookup($1, $2); $$ = part_add($1, $2);
if (!$$)
$$ = part_add($1, $2);
part_add_stock($$, $3); part_add_stock($$, $3);
} }
; ;