# HG changeset patch # User Space Falcon # Date 1437352723 0 # Node ID c91e7a30fab3dd0346271a21c77c583609473e78 # Parent e2130f1ef7207cb503e21865667ae4df32899e13 ueda/libueda Linuxified diff -r e2130f1ef720 -r c91e7a30fab3 ueda/libueda/Makefile --- a/ueda/libueda/Makefile Mon Jul 20 00:30:24 2015 +0000 +++ b/ueda/libueda/Makefile Mon Jul 20 00:38:43 2015 +0000 @@ -1,4 +1,5 @@ -CFLAGS= -O +CC= gcc +CFLAGS= -O2 LIBOBJS=filesearch.o hashmcl.o mclacc.o pinouts.o popopt.o readmcl.o util.o \ xga.o diff -r e2130f1ef720 -r c91e7a30fab3 ueda/libueda/filesearch.c --- a/ueda/libueda/filesearch.c Mon Jul 20 00:30:24 2015 +0000 +++ b/ueda/libueda/filesearch.c Mon Jul 20 00:38:43 2015 +0000 @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include extern char *copystr(); diff -r e2130f1ef720 -r c91e7a30fab3 ueda/libueda/hashmcl.c --- a/ueda/libueda/hashmcl.c Mon Jul 20 00:30:24 2015 +0000 +++ b/ueda/libueda/hashmcl.c Mon Jul 20 00:38:43 2015 +0000 @@ -8,6 +8,8 @@ #include #include +#include +#include #include #include "mcl.h" diff -r e2130f1ef720 -r c91e7a30fab3 ueda/libueda/mclacc.c --- a/ueda/libueda/mclacc.c Mon Jul 20 00:30:24 2015 +0000 +++ b/ueda/libueda/mclacc.c Mon Jul 20 00:38:43 2015 +0000 @@ -3,6 +3,8 @@ */ #include +#include +#include #include #include "mcl.h" diff -r e2130f1ef720 -r c91e7a30fab3 ueda/libueda/pinouts.c --- a/ueda/libueda/pinouts.c Mon Jul 20 00:30:24 2015 +0000 +++ b/ueda/libueda/pinouts.c Mon Jul 20 00:38:43 2015 +0000 @@ -4,11 +4,12 @@ #include #include +#include +#include #include #include "mcl.h" #include "pinouts.h" -extern char *malloc(); extern char *copystr(); extern struct component components[]; diff -r e2130f1ef720 -r c91e7a30fab3 ueda/libueda/popopt.c --- a/ueda/libueda/popopt.c Mon Jul 20 00:30:24 2015 +0000 +++ b/ueda/libueda/popopt.c Mon Jul 20 00:38:43 2015 +0000 @@ -4,6 +4,8 @@ #include #include +#include +#include #include #include "mcl.h" diff -r e2130f1ef720 -r c91e7a30fab3 ueda/libueda/readmcl.c --- a/ueda/libueda/readmcl.c Mon Jul 20 00:30:24 2015 +0000 +++ b/ueda/libueda/readmcl.c Mon Jul 20 00:38:43 2015 +0000 @@ -4,6 +4,8 @@ #include #include +#include +#include #include #include "mcl.h" @@ -31,6 +33,158 @@ static char *curcomp_refdes[MAX_REFDES_ON_LINE]; static int curcomp_nrefdes; +static +setup_partdef(np) + register char *np; +{ + register char *cp; + + while (isspace(*np)) + np++; + cp = index(np, ':'); + if (!cp || cp == np || cp[1]) { + fprintf(stderr, "%s: line %d: invalid part definition\n", + MCLfile, lineno); + exit(1); + } + *cp = '\0'; + if (npartdefs >= MAX_PARTDEFS) { + fprintf(stderr, "%s: line %d: too many part definitions\n", + MCLfile, lineno); + exit(1); + } + curcomp = partdefs + npartdefs; + curcomp->name = copystr(np); + curcomp->attrs = attrs + nattrs; + curcomp->nattrs = 0; + npartdefs++; + curcomp_nrefdes = 0; +} + +static +parse_refdes_list() +{ + int i; + register char *cp, *np; + register int c; + + for (cp = line, i = 0; ; ) { + if (!isupper(*cp)) { +inv: fprintf(stderr, "%s: line %d: invalid refdes line\n", + MCLfile, lineno); + exit(1); + } + for (np = cp; isalnum(*cp); cp++) + ; + c = *cp; + if (c != ':' && c != ',') + goto inv; + *cp++ = '\0'; + curcomp_refdes[i++] = copystr(np); + if (c == ':') + break; + } + curcomp_nrefdes = i; + if (*cp) + goto inv; +} + +static +clone_component() +{ + register int i; + register struct component *newcomp; + + for (i = 1; i < curcomp_nrefdes; i++) { + if (ncomponents >= MAX_COMPS) { + fprintf(stderr, "%s: %s: too many components\n", + MCLfile, curcomp_refdes[i]); + exit(1); + } + newcomp = components + ncomponents; + bcopy(curcomp, newcomp, sizeof(struct component)); + newcomp->name = curcomp_refdes[i]; + ncomponents++; + } +} + +static +finish_component() +{ + extern char *get_comp_attr(); + + if (curcomp_nrefdes == 0) + return; /* nothing to do for part defs */ + if (!curcomp->partdef && + (get_comp_attr(curcomp, "manufacturer") && + get_comp_attr(curcomp, "manufacturer_part_number") || + get_comp_attr(curcomp, "bom_part_title"))) + curcomp->partdef = curcomp; /* self-defines part */ + if (curcomp_nrefdes > 1) + clone_component(); +} + +static +handle_part_ref(partname) + char *partname; +{ + register struct component *part; + register int i; + + if (curcomp_nrefdes == 0) { + fprintf(stderr, + "%s: line %d: can't use a part reference in a part definition!\n", + MCLfile, lineno); + exit(1); + } + if (!strcmp(partname, "none")) { + curcomp->partdef = NULL; + return; + } + if (!strcmp(partname, "yes")) { + curcomp->partdef = curcomp; /* self-defines the part */ + return; + } + for (part = partdefs, i = 0; i < npartdefs; part++, i++) + if (!strcmp(part->name, partname)) { +gotit: curcomp->partdef = part; + return; + } + /* can also refer to a previous component that self-defines a part */ + for (part = components, i = 0; i < ncomponents-1; part++, i++) + if (!strcmp(part->name, partname)) { + if (part->partdef == part) + goto gotit; + else { + fprintf(stderr, +"%s: line %d: can't use %s as a part because it doesn't define a part\n", + MCLfile, lineno, partname); + exit(1); + } + } + fprintf(stderr, "%s: line %d: part %s not defined\n", MCLfile, lineno, + partname); + exit(1); +} + +static +get_line() +{ + register char *cp; + + if (fgets(line, sizeof line, mclf) == NULL) + return(0); + lineno++; + /* strip trailing comments and whitespace */ + cp = index(line, '#'); + if (!cp) + cp = index(line, '\0'); + while (cp > line && isspace(cp[-1])) + cp--; + *cp = '\0'; + return(1); +} + read_MCL() { register char *cp, *name, *value; @@ -41,7 +195,7 @@ exit(1); } - for (lineno = 0, curcomp = NULL; getline(); ) { + for (lineno = 0, curcomp = NULL; get_line(); ) { /* ignore blank lines and comments */ if (line[0] == '\0' || line[0] == '#') continue; @@ -106,155 +260,3 @@ fclose(mclf); finish_component(); } - -static -setup_partdef(np) - register char *np; -{ - register char *cp; - - while (isspace(*np)) - np++; - cp = index(np, ':'); - if (!cp || cp == np || cp[1]) { - fprintf(stderr, "%s: line %d: invalid part definition\n", - MCLfile, lineno); - exit(1); - } - *cp = '\0'; - if (npartdefs >= MAX_PARTDEFS) { - fprintf(stderr, "%s: line %d: too many part definitions\n", - MCLfile, lineno); - exit(1); - } - curcomp = partdefs + npartdefs; - curcomp->name = copystr(np); - curcomp->attrs = attrs + nattrs; - curcomp->nattrs = 0; - npartdefs++; - curcomp_nrefdes = 0; -} - -static -parse_refdes_list() -{ - int i; - register char *cp, *np; - register int c; - - for (cp = line, i = 0; ; ) { - if (!isupper(*cp)) { -inv: fprintf(stderr, "%s: line %d: invalid refdes line\n", - MCLfile, lineno); - exit(1); - } - for (np = cp; isalnum(*cp); cp++) - ; - c = *cp; - if (c != ':' && c != ',') - goto inv; - *cp++ = '\0'; - curcomp_refdes[i++] = copystr(np); - if (c == ':') - break; - } - curcomp_nrefdes = i; - if (*cp) - goto inv; -} - -static -finish_component() -{ - extern char *get_comp_attr(); - - if (curcomp_nrefdes == 0) - return; /* nothing to do for part defs */ - if (!curcomp->partdef && - (get_comp_attr(curcomp, "manufacturer") && - get_comp_attr(curcomp, "manufacturer_part_number") || - get_comp_attr(curcomp, "bom_part_title"))) - curcomp->partdef = curcomp; /* self-defines part */ - if (curcomp_nrefdes > 1) - clone_component(); -} - -static -clone_component() -{ - register int i; - register struct component *newcomp; - - for (i = 1; i < curcomp_nrefdes; i++) { - if (ncomponents >= MAX_COMPS) { - fprintf(stderr, "%s: %s: too many components\n", - MCLfile, curcomp_refdes[i]); - exit(1); - } - newcomp = components + ncomponents; - bcopy(curcomp, newcomp, sizeof(struct component)); - newcomp->name = curcomp_refdes[i]; - ncomponents++; - } -} - -static -handle_part_ref(partname) - char *partname; -{ - register struct component *part; - register int i; - - if (curcomp_nrefdes == 0) { - fprintf(stderr, - "%s: line %d: can't use a part reference in a part definition!\n", - MCLfile, lineno); - exit(1); - } - if (!strcmp(partname, "none")) { - curcomp->partdef = NULL; - return; - } - if (!strcmp(partname, "yes")) { - curcomp->partdef = curcomp; /* self-defines the part */ - return; - } - for (part = partdefs, i = 0; i < npartdefs; part++, i++) - if (!strcmp(part->name, partname)) { -gotit: curcomp->partdef = part; - return; - } - /* can also refer to a previous component that self-defines a part */ - for (part = components, i = 0; i < ncomponents-1; part++, i++) - if (!strcmp(part->name, partname)) { - if (part->partdef == part) - goto gotit; - else { - fprintf(stderr, -"%s: line %d: can't use %s as a part because it doesn't define a part\n", - MCLfile, lineno, partname); - exit(1); - } - } - fprintf(stderr, "%s: line %d: part %s not defined\n", MCLfile, lineno, - partname); - exit(1); -} - -static -getline() -{ - register char *cp; - - if (fgets(line, sizeof line, mclf) == NULL) - return(0); - lineno++; - /* strip trailing comments and whitespace */ - cp = index(line, '#'); - if (!cp) - cp = index(line, '\0'); - while (cp > line && isspace(cp[-1])) - cp--; - *cp = '\0'; - return(1); -} diff -r e2130f1ef720 -r c91e7a30fab3 ueda/libueda/util.c --- a/ueda/libueda/util.c Mon Jul 20 00:30:24 2015 +0000 +++ b/ueda/libueda/util.c Mon Jul 20 00:38:43 2015 +0000 @@ -3,10 +3,10 @@ */ #include +#include +#include #include -extern char *malloc(); - char * copystr(src) register char *src; diff -r e2130f1ef720 -r c91e7a30fab3 ueda/libueda/xga.c --- a/ueda/libueda/xga.c Mon Jul 20 00:30:24 2015 +0000 +++ b/ueda/libueda/xga.c Mon Jul 20 00:38:43 2015 +0000 @@ -5,10 +5,11 @@ #include #include +#include +#include #include #include "xga.h" -extern char *malloc(); extern char *copystr(); extern FILE *find_symlib_file();