From e5f010797db1815100026bd836c9d1410cd59cb6 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 5 Aug 2016 20:41:35 -0300 Subject: [PATCH] eeshow/sch-parse.c (parse_line): no longer use return code 0 for EOF We'll soon use it to indicate a parsing problem. --- eeshow/sch-parse.c | 8 ++++++-- eeshow/sch.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/eeshow/sch-parse.c b/eeshow/sch-parse.c index 45e298e..eb3955f 100644 --- a/eeshow/sch-parse.c +++ b/eeshow/sch-parse.c @@ -438,8 +438,10 @@ static bool parse_line(const struct file *file, void *user, const char *line) /* EndSCHEMATC */ - if (sscanf(line, "$EndSCHEMATC%n", &n) == 0 && n) - return 0; + if (sscanf(line, "$EndSCHEMATC%n", &n) == 0 && n) { + ctx->state = sch_eof; + return 1; + } break; case sch_descr: if (sscanf(line, "Title \"%m[^\"]\"", &s) == 1) { @@ -530,6 +532,8 @@ static bool parse_line(const struct file *file, void *user, const char *line) submit_obj(ctx, sch_obj_wire); ctx->state = sch_basic; return 1; + case sch_eof: + return 1; default: abort(); } diff --git a/eeshow/sch.h b/eeshow/sch.h index ddfc323..61106e4 100644 --- a/eeshow/sch.h +++ b/eeshow/sch.h @@ -29,6 +29,7 @@ enum sch_state { sch_sheet, /* sub-sheet */ sch_text, /* text or label */ sch_wire, /* wire */ + sch_eof, /* skipping anything after $EndSCHEMATC */ }; struct sheet;