Pre-ansification changes for lib/c2
authorNick Downing <downing.nick@gmail.com>
Fri, 3 Feb 2017 13:55:44 +0000 (00:55 +1100)
committerNick Downing <downing.nick@gmail.com>
Fri, 3 Feb 2017 14:39:20 +0000 (01:39 +1100)
lib/c2/Makefile
lib/c2/c2.h
lib/c2/c20.c
lib/c2/c21.c
lib/c2/c22.c
lib/c2/conflicts.txt [new file with mode: 0644]
lib/c2/groups.txt [new file with mode: 0644]

index 4a8b05f..e68a65f 100644 (file)
@@ -2,12 +2,12 @@
 #
 CFLAGS=-DCOPYCODE -DC2 -O
 LDFLAGS=
-ASDIR = /usr/src/bin/as
+ASDIR = ../../bin/as
 
 SRCS = makefile c2.h c20.c c21.c c22.c
 
 c2:    c20.o c21.o c22.o
-       $(CC) $(LDFLAGS) -o c2 c2?.o
+       $(CC) $(LDFLAGS) -o c2 c20.o c21.o c22.o
 
 c20.o: c20.c c2.h
 c21.o: c21.c c2.h
index b30d8ef..2857121 100644 (file)
 
 #define C2_ASIZE 128
 
-struct optab {
+extern struct optab {
        char    opstring[7];
        short   opcode;
 } optab[];
@@ -147,36 +147,36 @@ struct node {
 #define subop op_un.un_op.op_subop
 #define combop op_un.un_combop
 
-char   line[512];
-struct node    first;
-char   *curlp;
-int    nbrbr;
-int    nsaddr;
-int    redunm;
-int    iaftbr;
-int    njp1;
-int    nrlab;
-int    nxjump;
-int    ncmot;
-int    nrevbr;
-int    loopiv;
-int    nredunj;
-int    nskip;
-int    ncomj;
-int    nsob;
-int    nrtst;
-int nbj;
-int nfield;
-
-int    nchange;
-long   isn;
-int    debug;
-char   revbr[];
+extern char    line[512];
+extern struct  node    first;
+extern char    *curlp;
+extern int     nbrbr;
+extern int     nsaddr;
+extern int     redunm;
+extern int     iaftbr;
+extern int     njp1;
+extern int     nrlab;
+extern int     nxjump;
+extern int     ncmot;
+extern int     nrevbr;
+extern int     loopiv;
+extern int     nredunj;
+extern int     nskip;
+extern int     ncomj;
+extern int     nsob;
+extern int     nrtst;
+extern int nbj;
+extern int nfield;
+
+extern int     nchange;
+extern long    isn;
+extern int     debug;
+extern char    revbr[];
 #define        NREG    12
-char   *regs[NREG+5]; /* 0-11, 4 for operands, 1 for running off end */
-char   conloc[C2_ASIZE];
-char   conval[C2_ASIZE];
-char   ccloc[C2_ASIZE];
+extern char    *regs[NREG+5]; /* 0-11, 4 for operands, 1 for running off end */
+extern char    conloc[C2_ASIZE];
+extern char    conval[C2_ASIZE];
+extern char    ccloc[C2_ASIZE];
 
 #define        RT1     12
 #define        RT2     13
index cd6cf44..e13af5a 100644 (file)
@@ -11,6 +11,35 @@ static       char sccsid[] = "@(#)c20.c      4.10 (Berkeley) 8/22/85";
 #include <ctype.h>
 #include <sys/types.h>
 
+/* moved here from c2.h which now just declares them extern */
+char   line[512];
+struct node    first;
+char   *curlp;
+int    nbrbr;
+int    nsaddr;
+int    redunm;
+int    iaftbr;
+int    njp1;
+int    nrlab;
+int    nxjump;
+int    ncmot;
+int    nrevbr;
+int    loopiv;
+int    nredunj;
+int    nskip;
+int    ncomj;
+int    nsob;
+int    nrtst;
+int nbj;
+int nfield;
+
+int    nchange;
+int    debug;
+char   *regs[NREG+5]; /* 0-11, 4 for operands, 1 for running off end */
+char   conloc[C2_ASIZE];
+char   conval[C2_ASIZE];
+char   ccloc[C2_ASIZE];
+
 char *malloc();
 char firstr[sizeof (char *)];
 char *currentb;
@@ -388,6 +417,13 @@ char *
 copy(ap)
 char *ap;
 {
+#if 1 /* in this application there is never more than one argument */
+       int len;
+       char *strcpy();
+
+       len = strlen(ap);
+       return(len ? strcpy((char *) alloc(len + 1), ap) : 0);
+#else
        register char *p, *np;
        char *onp;
        register n;
@@ -415,6 +451,7 @@ char *ap;
                while (*np++ = *p++);
        }
        return(onp);
+#endif
 }
 
 #define        OPHS    560
@@ -519,11 +556,11 @@ iterate()
                        }
                }
 #ifndef COPYCODE
-               if (p->op==CBR && (p1 = p->forw)->combop==JBR) {/* combop: RET problems */
+               if (p->op==CBR && (p1 = p->forw)->combop==JBR)
 #else
-               if (p->op==CBR && (p1 = p->forw)->combop==JBR &&
-                   p->ref) {/* combop: RET problems */
+               if (p->op==CBR && (p1 = p->forw)->combop==JBR && p->ref)
 #endif
+               { /* combop: RET problems */
                        rp = p->ref;
                        do
                                rp = rp->back;
index 5bbcd34..99cac69 100644 (file)
@@ -1010,14 +1010,14 @@ struct node *p2;
 }
 
 #ifndef delnode
-delnode(p) register struct node *p; {
+XXXdelnode(p) register struct node *p; {
        p->back->forw = p->forw;
        p->forw->back = p->back;
 }
 #endif
 
 #ifndef decref
-decref(p)
+XXXdecref(p)
 register struct node *p;
 {
        if (p && --p->refc <= 0) {
index eedd29f..ac41797 100644 (file)
@@ -3,9 +3,8 @@ static  char sccsid[] = "@(#)c22.c 4.3 3/19/85";
 #endif
 
 #include "c2.h"
-#define readonly
 
-readonly char revbr[] = {
+char revbr[] = {
        JNE, JEQ, JGT, JLT, JGE, JLE,
        JNE, JEQ, JHI, JLO, JHIS, JLOS,
        JBS, JBC, JLBS, JLBC, JBSC, JBCC, JBSS, JBCS };
@@ -20,7 +19,7 @@ readonly char revbr[] = {
 #define        TYPG    GFLOAT
 #define        TYPH    HFLOAT
 
-readonly struct optab optab[] = {
+struct optab optab[] = {
 
 #include "./instrs.c2"
 
diff --git a/lib/c2/conflicts.txt b/lib/c2/conflicts.txt
new file mode 100644 (file)
index 0000000..521044d
--- /dev/null
@@ -0,0 +1,6 @@
+c2.h arpa/tftp.h
+c2.h resolv.h
+c20.c arpa/tftp.h
+c20.c resolv.h
+c21.c arpa/tftp.h
+c21.c resolv.h
diff --git a/lib/c2/groups.txt b/lib/c2/groups.txt
new file mode 100644 (file)
index 0000000..1a38758
--- /dev/null
@@ -0,0 +1,3 @@
+c20.c c2.h
+c21.c c2.h
+c22.c c2.h