mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 07:54:06 +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:
parent
450769e031
commit
24a32525e2
@ -83,4 +83,4 @@ spotless: clean
|
||||
# ----- Experiments -----------------------------------------------------------
|
||||
|
||||
try:
|
||||
$(VALGRIND) ./boom HIERARCHY -c CHAR
|
||||
$(VALGRIND) ./boom HIERARCHY -c CHAR -i INV
|
||||
|
15
b2/db.c
15
b2/db.c
@ -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)
|
||||
{
|
||||
const struct param *p;
|
||||
@ -181,5 +193,6 @@ void part_dump(FILE *file, const struct part *part)
|
||||
}
|
||||
fprintf(file, "\n");
|
||||
}
|
||||
if (part->stock);
|
||||
if (part->stock)
|
||||
dump_stock(file, part->stock);
|
||||
}
|
||||
|
11
b2/lang.y
11
b2/lang.y
@ -378,9 +378,7 @@ characteristics:
|
||||
part:
|
||||
WORD WORD params TOK_NL
|
||||
{
|
||||
$$ = part_lookup($1, $2);
|
||||
if (!$$)
|
||||
$$ = part_add($1, $2);
|
||||
$$ = part_add($1, $2);
|
||||
if ($$->param)
|
||||
yyerror("parameters already defined");
|
||||
$$->param = $3;
|
||||
@ -414,14 +412,15 @@ param:
|
||||
inventory:
|
||||
| TOK_NL
|
||||
| inventory_item inventory
|
||||
{
|
||||
part_dump(stderr, $1);
|
||||
}
|
||||
;
|
||||
|
||||
inventory_item:
|
||||
WORD WORD stock TOK_NL
|
||||
{
|
||||
$$ = part_lookup($1, $2);
|
||||
if (!$$)
|
||||
$$ = part_add($1, $2);
|
||||
$$ = part_add($1, $2);
|
||||
part_add_stock($$, $3);
|
||||
}
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user