Pre-ansification changes for lib/pcc
[43bsd.git] / lib / pcc / stab.c
index 44bd82f..312cb22 100644 (file)
@@ -14,21 +14,13 @@ static char *sccsid ="@(#)stab.c    1.12 (Berkeley) 3/27/86";
 #include <a.out.h>
 #include <stab.h>
 
-#define private static
-#define and &&
-#define or ||
-#define not !
-#define div /
-#define mod %
-#define nil 0
-
 #define bytes(bits) ((bits) / SZCHAR)
 #define bsize(p) bytes(dimtab[p->sizoff])      /* size in bytes of a symbol */
 
 #define NILINDEX -1
 #define FORWARD -2
 
-typedef int Boolean;
+typedef int bool;
 
 #define false 0
 #define true 1
@@ -40,10 +32,36 @@ extern char *malloc();
 int stabLCSYM;
 
 /*
- * Flag for producing either sdb or dbx symbol information.
+ * Flag for producing either sdb || dbx symbol information.
  */
 int oldway = false;
 
+/*
+ * Since type names are lost in the travels && because C has
+ * structural type equivalence we keep a table of type words that
+ * we've already seen.  The first time we see a type, it is assigned
+ * (inline) a number && future references just list that number.
+ * Structures, unions, enums, && arrays must be handled carefully
+ * since ! all the necessary information is in the type word.
+ */
+
+typedef struct Typeid *Typeid;
+
+struct Typeid {
+    TWORD tword;
+    int tarray;
+    int tstruct;
+    int tstrtag;
+    int tnum;
+    Typeid chain;
+};
+
+#define TABLESIZE 2003
+
+static int tcount = 1;
+static int t_int, t_char;
+static Typeid typetable[TABLESIZE];
+
 /*
  * Generate debugging info for a parameter.
  * The offset isn't known when it is first entered into the symbol table
@@ -65,28 +83,24 @@ struct symtab *p;
 /*
  * Determine if the given symbol is a global array with dimension 0,
  * which only makes sense if it's dimension is to be given later.
- * We therefore currently do not generate symbol information for
+ * We therefore currently do ! generate symbol information for
  * such entries.
  */
 
-#define isglobal(class) ( \
-    class == EXTDEF or class == EXTERN or class == STATIC \
-)
-
-private Boolean zero_length_array(p)
+static bool zero_length_array(p)
 register struct symtab *p;
 {
-    Boolean b;
+    bool b;
     int t;
 
-    if (not isglobal(p->sclass)) {
+    if (p->sclass != EXTDEF && p->sclass != EXTERN && p->sclass != STATIC) {
        b = false;
     } else {
        t = p->stype;
        if (ISFTN(t)) {
            t = DECREF(t);
        }
-       b = (Boolean) (ISARY(t) and dimtab[p->dimoff] == 0);
+       b = (bool) (ISARY(t) && dimtab[p->dimoff] == 0);
     }
     return b;
 }
@@ -101,12 +115,12 @@ struct symtab *sym;
     register struct symtab *p;
     char *classname;
     int offset;
-    Boolean ignore;
-    static Boolean firsttime = true;
+    bool ignore;
+    static bool firsttime = true;
 
     if (oldway) {
        old_outstab(sym);
-    } else if (gdebug and not zero_length_array(sym)) {
+    } else if (gdebug && ! zero_length_array(sym)) {
        if (firsttime) {
            firsttime = false;
            inittypes();
@@ -171,7 +185,7 @@ struct symtab *sym;
            ignore = true;
            break;
        }
-       if (not ignore) {
+       if (! ignore) {
            printf("\t.stabs\t\"%s:%s", p->sname, classname);
            gentype(p);
            geninfo(p);
@@ -179,37 +193,11 @@ struct symtab *sym;
     }
 }
 
-/*
- * Since type names are lost in the travels and because C has
- * structural type equivalence we keep a table of type words that
- * we've already seen.  The first time we see a type, it is assigned
- * (inline) a number and future references just list that number.
- * Structures, unions, enums, and arrays must be handled carefully
- * since not all the necessary information is in the type word.
- */
-
-typedef struct Typeid *Typeid;
-
-struct Typeid {
-    TWORD tword;
-    int tarray;
-    int tstruct;
-    int tstrtag;
-    int tnum;
-    Typeid chain;
-};
-
-#define TABLESIZE 2003
-
-private int tcount = 1;
-private int t_int, t_char;
-private Typeid typetable[TABLESIZE];
-
 /*
  * Look for the given type word in the type table.
  */
 
-private Typeid typelookup(type, arrindex, strindex, strtag)
+static Typeid typelookup(type, arrindex, strindex, strtag)
 TWORD type;
 int arrindex;
 int strindex;
@@ -219,17 +207,17 @@ int strtag;
     register int i1, i2;
     Typeid t;
 
-    t = typetable[type mod TABLESIZE];
-    while (t != nil) {
-       if (t->tword == type and
-         strindex == t->tstruct and strtag == t->tstrtag) {
+    t = typetable[type % TABLESIZE];
+    while (t != 0) {
+       if (t->tword == type &&
+         strindex == t->tstruct && strtag == t->tstrtag) {
            if (arrindex == NILINDEX) {
                break;
            } else {
                tword = type;
                i1 = arrindex;
                i2 = t->tarray;
-               while (ISARY(tword) and dimtab[i1] == dimtab[i2]) {
+               while (ISARY(tword) && dimtab[i1] == dimtab[i2]) {
                    ++i1;
                    ++i2;
                    tword >>= TSHIFT;
@@ -245,10 +233,10 @@ int strtag;
 }
 
 /*
- * Enter a type word and associated symtab indices into the type table.
+ * Enter a type word && associated symtab indices into the type table.
  */
 
-private int entertype(type, arrindex, strindex, strtag)
+static int entertype(type, arrindex, strindex, strtag)
 TWORD type;
 int arrindex;
 int strindex;
@@ -264,7 +252,7 @@ int strtag;
     t->tstrtag = strtag;
     t->tnum = tcount;
     ++tcount;
-    i = type mod TABLESIZE;
+    i = type % TABLESIZE;
     t->chain = typetable[i];
     typetable[i] = t;
     return t->tnum;
@@ -276,7 +264,7 @@ int strtag;
  * as the old one.
  */
 
-private reentertype(typeid, type, arrindex, strindex, strtag)
+static reentertype(typeid, type, arrindex, strindex, strtag)
 Typeid typeid;
 TWORD type;
 int arrindex;
@@ -292,7 +280,7 @@ int strtag;
     t->tstruct = strindex;
     t->tstrtag = strtag;
     t->tnum = typeid->tnum;
-    i = type mod TABLESIZE;
+    i = type % TABLESIZE;
     t->chain = typetable[i];
     typetable[i] = t;
 }
@@ -303,7 +291,7 @@ int strtag;
 
 #define builtintype(type) entertype(type, NILINDEX, NILINDEX, NILINDEX)
 
-private inittypes()
+static inittypes()
 {
     int t;
 
@@ -321,30 +309,30 @@ private inittypes()
     maketype("double", builtintype(DOUBLE), t_int, 8L, 0L);
     t = builtintype(UNDEF);
     printf("\t.stabs\t\"void:t%d=%d", t, t);
-    geninfo(nil);
+    geninfo(0);
     t = builtintype(FARG);
     printf("\t.stabs\t\"???:t%d=%d", t, t_int);
-    geninfo(nil);
+    geninfo(0);
 }
 
 /*
  * Generate info for a new range type.
  */
 
-private maketype(name, tnum, eqtnum, lower, upper)
+static maketype(name, tnum, eqtnum, lower, upper)
 char *name;
 int tnum, eqtnum;
 long lower, upper;
 {
     printf("\t.stabs\t\"%s:t%d=r%d;%d;%d;", name, tnum, eqtnum, lower, upper);
-    geninfo(nil);
+    geninfo(0);
 }
 
 /*
  * Generate debugging information for the given type of the given symbol.
  */
 
-private gentype(sym)
+static gentype(sym)
 struct symtab *sym;
 {
     register struct symtab *p;
@@ -364,7 +352,7 @@ struct symtab *sym;
     } else {
        arrindex = NILINDEX;
     }
-    if (basictype == STRTY or basictype == UNIONTY or basictype == ENUMTY) {
+    if (basictype == STRTY || basictype == UNIONTY || basictype == ENUMTY) {
        strindex = dimtab[p->sizoff + 1];
        if (strindex == -1) {
            strindex = FORWARD;
@@ -378,7 +366,7 @@ struct symtab *sym;
     }
     i = arrindex;
     typeid = typelookup(t, arrindex, strindex, strtag);
-    while (t != basictype and typeid == nil) {
+    while (t != basictype && typeid == 0) {
        printf("%d=", entertype(t, i, strindex, strtag));
        switch (t&TMASK) {
        case PTR:
@@ -403,10 +391,10 @@ struct symtab *sym;
            typeid = typelookup(t, i, strindex, strtag);
        }
     }
-    if (typeid == nil) {
+    if (typeid == 0) {
        if (strindex == FORWARD) {
            typeid = typelookup(t, NILINDEX, FORWARD, dimtab[p->sizoff + 3]);
-           if (typeid == nil) {
+           if (typeid == 0) {
                cerror("unbelievable forward reference");
            }
            printf("%d", typeid->tnum);
@@ -419,10 +407,10 @@ struct symtab *sym;
 }
 
 /*
- * Generate type information for structures, unions, and enumerations.
+ * Generate type information for structures, unions, && enumerations.
  */
 
-private genstruct(t, structid, index, name, size)
+static genstruct(t, structid, index, name, size)
 TWORD t;
 int structid;
 int index;
@@ -476,15 +464,15 @@ int size;
 }
 
 /*
- * Generate offset and size info.
+ * Generate offset && size info.
  */
 
-private geninfo(p)
+static geninfo(p)
 register struct symtab *p;
 {
     int stabtype;
 
-    if (p == nil) {
+    if (p == 0) {
        printf("\",0x%x,0,0,0\n", N_LSYM);
     } else {
        switch (p->sclass) {
@@ -539,10 +527,10 @@ int szindex, paramindex;
     } else if (gdebug) {
        i = dimtab[szindex + 3];
        p = &stab[i];
-       if (p->sname != nil) {
+       if (p->sname != 0) {
            strindex = dimtab[p->sizoff + 1];
            typeid = typelookup(p->stype, NILINDEX, FORWARD, i);
-           if (typeid == nil) {
+           if (typeid == 0) {
                t = 0;
            } else {
                t = typeid->tnum;
@@ -719,7 +707,7 @@ char *sname;
  * Old way of doing things.
  */
 
-private old_fixarg(p)
+static old_fixarg(p)
 struct symtab *p; {
        if (gdebug) {
                old_pstab(p->sname, N_PSYM);
@@ -728,7 +716,7 @@ struct symtab *p; {
        }
 }
 
-private old_outstab(p)
+static old_outstab(p)
 struct symtab *p; {
        register TWORD ptype;
        register char *pname;
@@ -803,7 +791,7 @@ struct symtab *p; {
        }
 }
 
-private old_pstab(name, type)
+static old_pstab(name, type)
 char *name;
 int type; {
        register int i;
@@ -829,7 +817,7 @@ int type; {
 }
 
 #ifdef STABDOT
-private old_pstabdot(type, value)
+static old_pstabdot(type, value)
        int     type;
        int     value;
 {
@@ -840,7 +828,7 @@ private old_pstabdot(type, value)
 }
 #endif
 
-private old_poffs(p)
+static old_poffs(p)
 register struct symtab *p; {
        int s;
        if (!gdebug) return;
@@ -850,7 +838,7 @@ register struct symtab *p; {
        }
 }
 
-private old_psline() {
+static old_psline() {
        static int lastlineno;
        register char *cp, *cq;
        register int i;
@@ -897,7 +885,7 @@ eq: if (lineno == lastlineno) return;
                }
        }
        
-private old_plcstab(level) {
+static old_plcstab(level) {
        if (!gdebug) return;
 #ifdef STABDOT
        old_pstabdot(N_LBRAC, level);
@@ -908,7 +896,7 @@ private old_plcstab(level) {
 #endif
        }
        
-private old_prcstab(level) {
+static old_prcstab(level) {
        if (!gdebug) return;
 #ifdef STABDOT
        pstabdot(N_RBRAC, level);
@@ -919,7 +907,7 @@ private old_prcstab(level) {
 #endif
        }
        
-private old_pfstab(sname) 
+static old_pfstab(sname) 
 char *sname; {
        if (!gdebug) return;
        pstab(sname, N_FUN);