summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-19 05:54:39 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-09-19 05:55:41 (GMT)
commitae0f907822865a3d55e9534e5da1828dd0a95bb9 (patch)
tree896742cc75b9025b9a0701836b7e5ad56d0497ed /kicad
parent269b377f0066130ef209d653dbf3787800e77f24 (diff)
downloadeeshow-ae0f907822865a3d55e9534e5da1828dd0a95bb9.zip
eeshow-ae0f907822865a3d55e9534e5da1828dd0a95bb9.tar.gz
eeshow-ae0f907822865a3d55e9534e5da1828dd0a95bb9.tar.bz2
kicad/: support remaining header fields (date, revision, company)
Diffstat (limited to 'kicad')
-rw-r--r--kicad/pl-render.c6
-rw-r--r--kicad/sch-parse.c22
-rw-r--r--kicad/sch.h4
3 files changed, 26 insertions, 6 deletions
diff --git a/kicad/pl-render.c b/kicad/pl-render.c
index da628b9..c5cdfe7 100644
--- a/kicad/pl-render.c
+++ b/kicad/pl-render.c
@@ -87,7 +87,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
}
break;
case 'D': // date
- cx = "%D";
+ cx = sheet->date;
break;
case 'F': // file name
cx = sheet->file;
@@ -105,7 +105,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
cx = sheet->path;
break;
case 'R': // revision
- cx = "%R";
+ cx = sheet->rev;
break;
case 'S': // sheet number
n = 1;
@@ -118,7 +118,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
cx = sheet->title;
break;
case 'Y': // company name
- cx = "%Y";
+ cx = sheet->comp;
break;
case 'Z': // paper format
cx = sheet->size;
diff --git a/kicad/sch-parse.c b/kicad/sch-parse.c
index 76f82b1..afb543e 100644
--- a/kicad/sch-parse.c
+++ b/kicad/sch-parse.c
@@ -604,10 +604,25 @@ static bool parse_line(const struct file *file, void *user, const char *line)
&ctx->curr_sheet->size,
&ctx->curr_sheet->w, &ctx->curr_sheet->h) == 2)
return 1;
- if (sscanf(line, "Title \"%m[^\"]\"", &s) == 1) {
- ctx->curr_sheet->title = s;
+
+ /*
+ * %[ only accepts non-empty strings, so we fail to parse any
+ * of the following items if the string is empty. However,
+ * since we silently ignore all unrecognized lines, this does
+ * not cause a parse error or warning.
+ */
+ if (sscanf(line, "Title \"%m[^\"]\"",
+ &ctx->curr_sheet->title) == 1)
+ return 1;
+ if (sscanf(line, "Date \"%m[^\"]\"",
+ &ctx->curr_sheet->date) == 1)
+ return 1;
+ if (sscanf(line, "Rev \"%m[^\"]\"",
+ &ctx->curr_sheet->rev) == 1)
+ return 1;
+ if (sscanf(line, "Comp \"%m[^\"]\"",
+ &ctx->curr_sheet->comp) == 1)
return 1;
- }
if (sscanf(line, "Comment%d \"%m[^\"]\"", &i, &s) == 2) {
if (i < 0)
fatal("%s:%u: invalid comment index %d",
@@ -615,6 +630,7 @@ static bool parse_line(const struct file *file, void *user, const char *line)
add_comment(ctx->curr_sheet, i, s);
return 1;
}
+
if (sscanf(line, "$EndDescr%n", &n) || !n)
return 1;
ctx->state = sch_basic;
diff --git a/kicad/sch.h b/kicad/sch.h
index 395b77a..9bf7ffd 100644
--- a/kicad/sch.h
+++ b/kicad/sch.h
@@ -109,8 +109,12 @@ struct sheet {
struct sch_obj **next_obj;
struct sheet *next;
+ /* header items */
const char *size; /* paper size, from $Descr */
int w, h;
+ const char *date;
+ const char *rev;
+ const char *comp;
const char **comments;
unsigned n_comments;