mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-17 21:03:43 +02:00
eeshow/kicad/sexpr.c (sexpr_abort): silently shut down parser
This commit is contained in:
parent
2515c3b964
commit
83c452c522
@ -312,16 +312,26 @@ struct sexpr_ctx *sexpr_new(void)
|
|||||||
/* ----- Termination ------------------------------------------------------- */
|
/* ----- 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)
|
bool sexpr_finish(struct sexpr_ctx *ctx, struct expr **res)
|
||||||
{
|
{
|
||||||
if (ctx->sp != &ctx->stack) {
|
if (ctx->sp != &ctx->stack) {
|
||||||
error("not enough )\n");
|
error("not enough )\n");
|
||||||
ctx->state = failed;
|
ctx->state = failed;
|
||||||
free_stack(ctx);
|
|
||||||
}
|
}
|
||||||
if (ctx->state != idle && ctx->state != failed)
|
if (ctx->state != idle && ctx->state != failed)
|
||||||
error("invalid end state %d\n", ctx->state);
|
error("invalid end state %d\n", ctx->state);
|
||||||
if (ctx->state == idle) {
|
if (ctx->state != idle) {
|
||||||
|
sexpr_abort(ctx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (res)
|
if (res)
|
||||||
*res = ctx->e;
|
*res = ctx->e;
|
||||||
else
|
else
|
||||||
@ -329,7 +339,3 @@ bool sexpr_finish(struct sexpr_ctx *ctx, struct expr **res)
|
|||||||
free(ctx);
|
free(ctx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
free_expr(ctx->e);
|
|
||||||
free(ctx);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
@ -42,6 +42,7 @@ void free_expr(struct expr *e);
|
|||||||
|
|
||||||
struct sexpr_ctx *sexpr_new(void);
|
struct sexpr_ctx *sexpr_new(void);
|
||||||
bool sexpr_parse(struct sexpr_ctx *ctx, const char *s);
|
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);
|
bool sexpr_finish(struct sexpr_ctx *ctx, struct expr **res);
|
||||||
|
|
||||||
#endif /* !KICAD_SEXPR_H */
|
#endif /* !KICAD_SEXPR_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user