mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-22 16:31:54 +02:00
b2/bom.c (bom_parse_line): check that components reference are unique
This commit is contained in:
parent
ddd22ba16c
commit
9445f2c85b
31
b2/bom.c
31
b2/bom.c
@ -11,6 +11,7 @@
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "util.h"
|
||||
@ -22,17 +23,23 @@ struct bom *bom = NULL;
|
||||
int n_bom = 0;
|
||||
|
||||
|
||||
static struct bom *bom_find(const char *ref)
|
||||
{
|
||||
struct bom *b;
|
||||
|
||||
for (b = bom; b != bom+n_bom; b++)
|
||||
if (b->ref == ref)
|
||||
return b;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
struct bom *bom_parse_line(const char *s)
|
||||
{
|
||||
struct bom *b;
|
||||
const char *t;
|
||||
const char *ref, *t;
|
||||
char *f;
|
||||
|
||||
bom = realloc(bom, sizeof(struct bom)*(n_bom+1));
|
||||
if (!bom)
|
||||
abort();
|
||||
b = bom+n_bom++;
|
||||
|
||||
if (*s++ != '|')
|
||||
abort();
|
||||
while (*s == ' ' || *s == '\t')
|
||||
@ -40,7 +47,17 @@ struct bom *bom_parse_line(const char *s)
|
||||
for (t = s+1; *t && !isspace(*t); t++);
|
||||
if (!*t)
|
||||
yyerror("invalid BOM record (1)\n");
|
||||
b->ref = stralloc_n(s, t-s);
|
||||
|
||||
ref = unique_n(s, t-s);
|
||||
if (bom_find(ref))
|
||||
yyerrorf("duplicate component reference %s", ref);
|
||||
|
||||
bom = realloc(bom, sizeof(struct bom)*(n_bom+1));
|
||||
if (!bom)
|
||||
abort();
|
||||
b = bom+n_bom++;
|
||||
|
||||
b->ref = ref;
|
||||
b->sym = NULL;
|
||||
b->fields = NULL;
|
||||
b->n_fields = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user