summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-22 04:02:14 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-22 04:02:14 -0300
commita0f738add03ad97bf5d0bbb16ef6af614412b344 (patch)
tree80b3ee8565f3612db902e4c05bdb897a9d636499 /kicad
parent7efc1b155cebbcc3adc6316e9140abb960d30f63 (diff)
downloadeeshow-a0f738add03ad97bf5d0bbb16ef6af614412b344.tar.gz
eeshow-a0f738add03ad97bf5d0bbb16ef6af614412b344.tar.bz2
eeshow-a0f738add03ad97bf5d0bbb16ef6af614412b344.zip
eeshow/kicad/sexpr.c (sexpr_abort): silently shut down parser
Diffstat (limited to 'kicad')
-rw-r--r--kicad/sexpr.c26
-rw-r--r--kicad/sexpr.h1
2 files changed, 17 insertions, 10 deletions
diff --git a/kicad/sexpr.c b/kicad/sexpr.c
index 373b757..d24aa2a 100644
--- a/kicad/sexpr.c
+++ b/kicad/sexpr.c
@@ -312,24 +312,30 @@ struct sexpr_ctx *sexpr_new(void)
/* ----- Termination ------------------------------------------------------- */
+void sexpr_abort(struct sexpr_ctx *ctx)
+{
+ free_stack(ctx);
+ free_expr(ctx->e);
+ free(ctx);
+}
+
+
bool sexpr_finish(struct sexpr_ctx *ctx, struct expr **res)
{
if (ctx->sp != &ctx->stack) {
error("not enough )\n");
ctx->state = failed;
- free_stack(ctx);
}
if (ctx->state != idle && ctx->state != failed)
error("invalid end state %d\n", ctx->state);
- if (ctx->state == idle) {
- if (res)
- *res = ctx->e;
- else
- free_expr(ctx->e);
- free(ctx);
- return 1;
+ if (ctx->state != idle) {
+ sexpr_abort(ctx);
+ return 0;
}
- free_expr(ctx->e);
+ if (res)
+ *res = ctx->e;
+ else
+ free_expr(ctx->e);
free(ctx);
- return 0;
+ return 1;
}
diff --git a/kicad/sexpr.h b/kicad/sexpr.h
index 8c47f28..1e9e8a2 100644
--- a/kicad/sexpr.h
+++ b/kicad/sexpr.h
@@ -42,6 +42,7 @@ void free_expr(struct expr *e);
struct sexpr_ctx *sexpr_new(void);
bool sexpr_parse(struct sexpr_ctx *ctx, const char *s);
+void sexpr_abort(struct sexpr_ctx *ctx);
bool sexpr_finish(struct sexpr_ctx *ctx, struct expr **res);
#endif /* !KICAD_SEXPR_H */