changeset 2:c91e7a30fab3

ueda/libueda Linuxified
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 20 Jul 2015 00:38:43 +0000
parents e2130f1ef720
children d098f8548b44
files ueda/libueda/Makefile ueda/libueda/filesearch.c ueda/libueda/hashmcl.c ueda/libueda/mclacc.c ueda/libueda/pinouts.c ueda/libueda/popopt.c ueda/libueda/readmcl.c ueda/libueda/util.c ueda/libueda/xga.c
diffstat 9 files changed, 171 insertions(+), 158 deletions(-) [+]
line wrap: on
line diff
--- 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
 
--- 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 <sys/param.h>
 #include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <strings.h>
 
 extern char *copystr();
--- 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 <sys/types.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <strings.h>
 #include "mcl.h"
 
--- 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <strings.h>
 #include "mcl.h"
 
--- 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 <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <strings.h>
 #include "mcl.h"
 #include "pinouts.h"
 
-extern char *malloc();
 extern char *copystr();
 
 extern struct component components[];
--- 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 <stdio.h>
 #include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
 #include <strings.h>
 #include "mcl.h"
 
--- 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 <stdio.h>
 #include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
 #include <strings.h>
 #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);
-}
--- 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 <ctype.h>
+#include <stdlib.h>
+#include <string.h>
 #include <strings.h>
 
-extern char *malloc();
-
 char *
 copystr(src)
 	register char *src;
--- 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 <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <strings.h>
 #include "xga.h"
 
-extern char *malloc();
 extern char *copystr();
 
 extern FILE *find_symlib_file();