diff options
author | Werner Almesberger <werner@almesberger.net> | 2016-09-08 02:37:16 -0300 |
---|---|---|
committer | Werner Almesberger <werner@almesberger.net> | 2016-09-08 02:37:16 -0300 |
commit | 2023cbaea772add8c0f9f81feff49efb1d30ed99 (patch) | |
tree | 8e7d9454ff49c37b165d9c81f5c7ef12cce566ca /kicad | |
parent | 343fb24ecb118e1c027dcfc20cc2317657f60664 (diff) | |
download | eeshow-2023cbaea772add8c0f9f81feff49efb1d30ed99.tar.gz eeshow-2023cbaea772add8c0f9f81feff49efb1d30ed99.tar.bz2 eeshow-2023cbaea772add8c0f9f81feff49efb1d30ed99.zip |
kicad/pl-parse.c (pl_parse_search): use KiCad's default page layout as default
Diffstat (limited to 'kicad')
-rw-r--r-- | kicad/pl-parse.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/kicad/pl-parse.c b/kicad/pl-parse.c index 4cd8b1c..c22e171 100644 --- a/kicad/pl-parse.c +++ b/kicad/pl-parse.c @@ -476,16 +476,23 @@ static bool pl_parse_line(const struct file *file, } -struct pl_ctx *pl_parse(struct file *file) +static struct pl_ctx *new_pl_ctx(void) { struct pl_ctx *pl; - struct expr *e = NULL; pl = alloc_type(struct pl_ctx); pl->sexpr_ctx = sexpr_new(); pl->l = pl->r = pl->t = pl->b = 0; pl->tx = pl->ty = 0; pl->objs = NULL; + return pl; +} + + +struct pl_ctx *pl_parse(struct file *file) +{ + struct pl_ctx *pl = new_pl_ctx(); + struct expr *e = NULL; if (!file_read(file, pl_parse_line, pl)) { sexpr_abort(pl->sexpr_ctx); @@ -517,6 +524,21 @@ static bool pl_find_file(struct file *file, const char *name, } +static struct pl_ctx *default_pl(void) +{ +#include "../pl-default.inc" + struct pl_ctx *pl = new_pl_ctx(); + struct expr *e = NULL; + + if (!sexpr_parse(pl->sexpr_ctx, defaultPageLayout) || + !sexpr_finish(pl->sexpr_ctx, &e) || + !process(pl, e)) + BUG("cannot parse default layout"); + free_expr(e); + return pl; +} + + struct pl_ctx *pl_parse_search(const char *name, const struct file *related) { struct file file; @@ -530,10 +552,7 @@ struct pl_ctx *pl_parse_search(const char *name, const struct file *related) return pl; } - /* @@@ provide proper default */ - pl = alloc_type(struct pl_ctx); - pl->objs = NULL; - return pl; + return default_pl(); } |