1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-10-04 10:36:20 +03:00

sch2fig/lib-parse.c (lib_parse): parse entire file, not just one line

This commit is contained in:
Werner Almesberger 2016-08-01 13:10:51 -03:00
parent 07eb87e25f
commit f0f2303fc3
3 changed files with 8 additions and 17 deletions

View File

@ -17,6 +17,7 @@
#include "util.h"
#include "text.h"
#include "file.h"
#include "lib.h"
@ -129,8 +130,9 @@ static bool parse_arc(struct lib_obj *obj, const char *line)
/* ----- Library parser ---------------------------------------------------- */
bool lib_parse(struct lib *lib, const char *line)
static bool lib_parse_line(void *user, const char *line)
{
struct lib *lib = user;
int n = 0;
unsigned points;
struct lib_obj *obj;
@ -251,17 +253,16 @@ bool lib_parse(struct lib *lib, const char *line)
}
void lib_reset(struct lib *lib)
void lib_parse(struct lib *lib, const char *file)
{
lib->state = lib_skip;
lib->lineno = 0;
file_read(file, lib_parse_line, lib);
}
void lib_init(struct lib *lib)
{
lib_reset(lib);
lib->comps = NULL;
lib->next_comp = &lib->comps;
}

View File

@ -118,8 +118,7 @@ const struct comp *lib_find(const struct lib *lib, const char *name);
bool lib_field_visible(const struct comp *comp, int n);
void lib_render(const struct comp *comp, unsigned unit, const int m[6]);
bool lib_parse(struct lib *lib, const char *line);
void lib_parse(struct lib *lib, const char *file);
void lib_init(struct lib *lib);
void lib_reset(struct lib *lib);
#endif /* !LIB_H */

View File

@ -21,7 +21,6 @@
#include "fig.h"
#include "cairo.h"
#include "gfx.h"
#include "file.h"
#include "lib.h"
#include "sch.h"
#include "main.h"
@ -34,12 +33,6 @@ static struct gfx_ops const *ops_list[] = {
};
static bool do_lib_parse(void *user, const char *line)
{
return lib_parse(user, line);
}
void usage(const char *name)
{
fprintf(stderr,
@ -83,10 +76,8 @@ int main(int argc, char *const *argv)
usage(*argv);
lib_init(&lib);
for (arg = optind; arg != dashdash - 1; arg++) {
lib_reset(&lib);
file_read(argv[arg], do_lib_parse, &lib);
}
for (arg = optind; arg != dashdash - 1; arg++)
lib_parse(&lib, argv[arg]);
if (dashdash == argc) {
gfx_argc = 1;