diff options
author | Werner Almesberger <werner@almesberger.net> | 2016-09-03 19:16:24 -0300 |
---|---|---|
committer | Werner Almesberger <werner@almesberger.net> | 2016-09-03 23:45:52 -0300 |
commit | d3156984f74dd3d8f3a66f0dd03f015888922919 (patch) | |
tree | 8eb466fb953394e4ba8e73f2f208589f8e0d4abb /kicad | |
parent | bc2e6ca7c656616f7241fc54a3bb915b2f831c0d (diff) | |
download | eeshow-d3156984f74dd3d8f3a66f0dd03f015888922919.tar.gz eeshow-d3156984f74dd3d8f3a66f0dd03f015888922919.tar.bz2 eeshow-d3156984f74dd3d8f3a66f0dd03f015888922919.zip |
kicad/ext.c (classify_files_ab): classification of two sheets, i.e., diff
Diffstat (limited to 'kicad')
-rw-r--r-- | kicad/ext.c | 50 | ||||
-rw-r--r-- | kicad/ext.h | 2 |
2 files changed, 47 insertions, 5 deletions
diff --git a/kicad/ext.c b/kicad/ext.c index 8f5b64c..1764c37 100644 --- a/kicad/ext.c +++ b/kicad/ext.c @@ -42,15 +42,25 @@ enum ext identify(const char *path) } -void classify_files(struct file_names *fn, char *const *args, - unsigned n_args) +static void do_classify_files_ab(struct file_names *a, struct file_names *b, + char *const *args, unsigned n_args) { + struct file_names *fn = a; + bool may_advance = 0; unsigned i; enum ext ext; - fn->pro = fn->sch = fn->pl = NULL; - fn->libs = NULL; - fn->n_libs = 0; + a->pro = a->sch = a->pl = NULL; + a->libs = NULL; + a->n_libs = 0; + + if (b) { + b->pro = b->sch = b->pl = NULL; + b->libs = NULL; + b->n_libs = 0; + } + + fn = a; for (i = 0; i != n_args; i++) { ext = identify(args[i]); @@ -58,24 +68,34 @@ void classify_files(struct file_names *fn, char *const *args, case ext_unknown: fatal("%s: unknown file type", args[i]); case ext_project: + if ((a->pro || a->sch) && b) + fn = b; if (fn->pro) fatal("%s: there can only be one project", args[i]); fn->pro = stralloc(args[i]); + may_advance = 1; break; case ext_sch: + if (a->sch && b) + fn = b; if (fn->sch) fatal("%s: there can only be one top sheet", args[i]); fn->sch = stralloc(args[i]); + may_advance = 1; break; case ext_lib: + if (may_advance && b) + fn = b; fn->n_libs++; fn->libs = realloc_type_n(fn->libs, const char *, fn->n_libs); fn->libs[fn->n_libs - 1] = stralloc(args[i]); break; case ext_pl: + if (may_advance && b) + fn = b; if (fn->pl) fatal("%s: there can only be one page layout", args[i]); @@ -88,6 +108,26 @@ void classify_files(struct file_names *fn, char *const *args, } +void classify_files(struct file_names *fn, char *const *args, + unsigned n_args) +{ + classify_files_ab(fn, NULL, args, n_args); +} + + +void classify_files_ab(struct file_names *a, struct file_names *b, + char *const *args, unsigned n_args) +{ + do_classify_files_ab(a, b, args, n_args); + + /* resolve a.pro b.sch */ + if (a->pro && a->sch && !b->pro && !b->sch) { + a->sch = NULL; + b->sch = a->sch; + } +} + + struct file_names *clone_file_names(const struct file_names *fn) { struct file_names *new; diff --git a/kicad/ext.h b/kicad/ext.h index 603b9e0..8c8ba67 100644 --- a/kicad/ext.h +++ b/kicad/ext.h @@ -35,6 +35,8 @@ struct file_names { enum ext identify(const char *path); void classify_files(struct file_names *fn, char *const *args, unsigned n_args); +void classify_files_ab(struct file_names *a, struct file_names *b, + char *const *args, unsigned n_args); struct file_names *clone_file_names(const struct file_names *fn); void free_file_names(struct file_names *fn); |