Pre-ansification changes for bin/as
authorNick Downing <downing.nick@gmail.com>
Wed, 25 Jan 2017 22:34:25 +0000 (09:34 +1100)
committerNick Downing <downing.nick@gmail.com>
Thu, 26 Jan 2017 14:15:55 +0000 (01:15 +1100)
31 files changed:
.gitignore
bin/adb/conflicts.txt
bin/as/as.h
bin/as/asexpr.h
bin/as/asio.c
bin/as/asmain.c
bin/as/asnumber.h
bin/as/asparse.c
bin/as/asscan.h
bin/as/asscan1.c
bin/as/asscan2.c
bin/as/asscan4.c
bin/as/asscanl.h
bin/as/assyms.c
bin/as/bignum2.c
bin/as/conflicts.txt [new file with mode: 0644]
bin/as/groups.txt [new file with mode: 0644]
bin/as/instrs.h
bin/as/uniqify.sed [new file with mode: 0644]
cproto-4.6/grammar.y
cproto-4.6/lex.l
include/stdio.h
lib/libc/ansify.sh
lib/libc/vax/Makefile
lib/libc/vax/compat-sys5/DEFS.h [new file with mode: 0644]
lib/libc/vax/compat-sys5/Makefile [new file with mode: 0644]
lib/libc/vax/compat-sys5/memcmp.s [new file with mode: 0644]
lib/libc/vax/compat-sys5/memcpy.s [new file with mode: 0644]
lib/libc/vax/compat-sys5/memset.s [new file with mode: 0644]
scripts/ansify.sh
xify/xify.sh

index 50cfefb..b5f7df3 100644 (file)
@@ -11,6 +11,8 @@
 bin/adb/adb
 bin/adb/instrs.adb
 bin/ar
+bin/as/as
+bin/as/instrs.as
 bin/cat
 bin/cc
 bin/chgrp
index 0b662e8..7050ba2 100644 (file)
@@ -1,4 +1,4 @@
-../as/asnumber.h assert.h
+../as/instrs.h vax/mtpr.h
 access.c sys/map.h
 command.c sys/map.h
 head.h sys/map.h
index f3b7b5d..8309bb6 100644 (file)
@@ -6,13 +6,10 @@
  *     @(#)as.h        5.3 (Berkeley) 7/6/85
  */
 
-#define        reg     register
-
 #include <sys/types.h>
 #include <a.out.h>
 #include <stab.h>
 
-#define readonly
 #define        NINST           300
 
 #define        NEXP            20      /* max number of expr. terms per instruction */
 #      undef   NCPName
 #      define  NCPName 4096
 #endif not NCPS
-/*
- *     Check sizes, and compiler error if sizes botch
- */
-#if STRPOOLDALLOP < NCPName
-       $$$botch with definition sizes
-#endif test botches
+
+/* note: STRPOOLDALLOP has to be at least as large as NCPName */
+
 /*
  * Symbol types
  */
@@ -353,6 +347,15 @@ struct     strdesc{
 #define        STR_BOTH        0x3
 
 struct strdesc *savestr();
+/*
+ *     Assertions
+ */
+/* only used by bignum stuff, moved to here to avoid a circular dependency */
+#if 1
+#define        assert(x, str) if (!(x)) panic("%s%s\n", "x", str)
+#else
+#define assert(x, str)
+#endif
 \f
 /*
  *     Global variables
@@ -500,5 +503,5 @@ struct      biobuf {
         *      we have a bunch of buffers allocated internally that
         *      contain the relocation information.
         */
-       struct  relbufdesc      *rusefile[NLOC + NLOC];
-       struct  relbufdesc      *relfil;
+       extern struct   relbufdesc      *rusefile[NLOC + NLOC];
+       extern struct   relbufdesc      *relfil;
index 3c46f3b..3215f3d 100644 (file)
 
 #define ERROR(string)          yyerror(string); goto errorfix
 
-#define peekahead (*tokptr)
-
-#define shift                  val = yylex()
-#define advance        shift
+#define peekahead (*(char *)tokptr)
 
 #define shiftover(token)       if (val != token) { \
                                        shiftoerror(token); \
                                        goto errorfix; \
                                } \
-                               shift
-
-#define advanceover    shiftover
+                               val = yylex()
 
 /*
  *     To speed up the expression processing, we class the input tokens
index 1e26c57..b46d2bc 100644 (file)
@@ -71,7 +71,11 @@ top:
 #ifdef lint
                *to = *to;
 #endif lint
+#ifdef __STDC__ /* this is a bit non-ideal, revisit later */
+               memcpy(to, p, put);
+#else
                asm("movc3 r8,(r11),(r7)");
+#endif
                bp->b_ptr += put;
                p += put;
                cnt -= put;
index 14ecb44..9b5a431 100644 (file)
@@ -17,6 +17,7 @@ static char sccsid[] = "@(#)asmain.c  5.2 (Berkeley) 10/21/85";
 #include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
+#include <varargs.h>
 
 #include "as.h"
 #include "assyms.h"
@@ -177,7 +178,7 @@ main(argc, argv)
        int     argc;
        char    **argv;
 {
-       char    *sbrk();
+       void    *sbrk();
 
        tokfilename[0] = 0;
        strfilename[0] = 0;
@@ -341,7 +342,7 @@ selfwhat(place)
        register        char    *ub;
        register        char *cp;
        register        char    *pat;
-       char    *sbrk();
+       void    *sbrk();
 
        for (cp = (char *)&environ, ub = sbrk(0); cp < ub; cp++){
                if (cp[0] != '@') continue;
@@ -693,19 +694,25 @@ delete()
 
 sawabort()
 {
+#if 0 /* I don't see why this is necessary... and fillinbuffer() is now void */
        char    *fillinbuffer();
        while (fillinbuffer() != (char *)0)
                continue;
+#endif
        delete();
        exit(1);        /*although the previous pass will also exit non zero*/
 }
 
-panic(fmt, a1, a2, a3, a4)
+panic(fmt, va_alist)
        char    *fmt;
-       /*VARARGS 1*/
+       va_dcl
 {
+       va_list argp;
+
        yyerror("Assembler panic: bad internal data structure.");
-       yyerror(fmt, a1, a2, a3, a4);
+       va_start(argp);
+       vyyerror(fmt, argp);
+       va_end(argp);
        delete();
        abort();
 }
index 775c4ca..c388e5a 100644 (file)
@@ -1,8 +1,3 @@
-#ifndef ____AS_ASNUMBER_H_
-#define ____AS_ASNUMBER_H_
-
-#include <sys/types.h>
-
 /*
  * Copyright (c) 1982 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
@@ -107,7 +102,7 @@ typedef     u_int           *chptr;         /* basic data type */
 #define        MAXINT_1        ((unsigned)(1<<(CH_BITS - 1)))
 #define        MAXINT_10       ((unsigned)((MAXINT_1/(unsigned)10)))
 #define        MAXINT_5        ((unsigned)((MAXINT_1/(unsigned)5)))
-#else
+#else not 0
 /*
  *     These values were computed using dc, so are exact.
  *     Only MAXINT_10 and MAXINT_5 are used in the programs.
@@ -115,16 +110,16 @@ typedef   u_int           *chptr;         /* basic data type */
 #define        MAXINT_1        2147483648
 #define        MAXINT_10       214748364
 #define        MAXINT_5        429496729
-#endif
-
-/*Bignum as_atoi();*/          /* converts string to integer */
-/*Bignum as_atof();*/          /* converts string to float */
-/*Bignum bigatof();*/          /* converts string to float */
-/*Bignum floatconvert();*/     /* converts amongst float #s */
-/*Bignum intconvert();*/               /* converts amongst float #s */
-/*Bignum bignumconvert();*/    /* converts amongst float #s */
-/*Bignum bignumpack();*/               /* converts UNPACKED bignum to bignum */
-/*Bignum bignumunpack();*/     /* converts bignum to UNPACKED bignum */
+#endif not 0
+
+Bignum as_atoi();              /* converts string to integer */
+Bignum as_atof();              /* converts string to float */
+Bignum bigatof();              /* converts string to float */
+Bignum floatconvert(); /* converts amongst float #s */
+Bignum intconvert();           /* converts amongst float #s */
+Bignum bignumconvert();        /* converts amongst float #s */
+Bignum bignumpack();           /* converts UNPACKED bignum to bignum */
+Bignum bignumunpack(); /* converts bignum to UNPACKED bignum */
 \f
 /*
  *     Definitions for overflows.
@@ -142,13 +137,13 @@ typedef   u_int   Ovf;
 #define        OVF_OVERFLOW    (1<<9)  /* overflow in conversion */
 #define        OVF_UNDERFLOW   (1<<10) /* underflow in conversion */
 
-/*Ovf  posovf();*/
-/*Ovf  numclear();*/
-/*Ovf  numshift();*/
-/*Ovf  numaddv();*/
-/*Ovf  numaddd();*/
-/*Ovf  num1comp();*/
-/*Ovf  numnegate();*/
+Ovf    posovf();
+Ovf    numclear();
+Ovf    numshift();
+Ovf    numaddv();
+Ovf    numaddd();
+Ovf    num1comp();
+Ovf    numnegate();
 \f
 /*
  *     Definitions to unpack big numbers numbers into
@@ -187,13 +182,3 @@ extern struct ty_bigdesc ty_bigdesc[];
  *     Bit manipulations
  */
 #define        ONES(n) ((1 << (n)) - 1)
-/*
- *     Assertions
- */
-#if 1
-#define        assert(x, str) if (!(x)) panic("%s%s\n", "x", str)
-#else
-#define assert(x, str)
-#endif
-
-#endif
index f97c112..5dd88c4 100644 (file)
@@ -9,6 +9,7 @@ static char sccsid[] = "@(#)asparse.c   5.2 (Berkeley) 6/19/85";
 #endif not lint
 
 #include <stdio.h>
+#include <varargs.h>
 #include "as.h"
 #include "asscan.h"
 #include "assyms.h"
@@ -187,10 +188,11 @@ restlab:
        break;
 
    case PARSEEOF:
-       tokptr -= sizeof(bytetoktype);
-       *tokptr++ = VOID;
-       tokptr[1] = VOID;
-       tokptr[2] = PARSEEOF;
+ /* better check this -- is tokptr[-1] supposed to be a word or byte? */
+ /* why is a gap left at tokptr[0]? why is this code necessary at all? */
+       ((bytetoktype *)tokptr)[-1] = VOID;
+       ((bytetoktype *)tokptr)[1] = VOID;
+       ((bytetoktype *)tokptr)[2] = PARSEEOF;
        break;
 
    case IFILE:
@@ -647,8 +649,8 @@ restlab:
        if (passno == 2) goto errorfix;
        stpt = (struct symtab *)yylval;
        stabstart = tokptr;
-       (bytetoktype *)stabstart -= sizeof(struct symtab *);
-       (bytetoktype *)stabstart -= sizeof(bytetoktype);
+       *(bytetoktype **)&stabstart -= sizeof(struct symtab *);
+       *(bytetoktype **)&stabstart -= sizeof(bytetoktype);
        shift;
        if (auxval == ISTABSTR){
                stringp = (struct strdesc *)yylval;
@@ -983,36 +985,45 @@ shiftoerror(token)
        yyerror("%s expected", tok_to_name(token));
 }
 
-/*VARARGS1*/
-yyerror(s, a1, a2,a3,a4,a5)
+vyyerror(s, argp)
        char    *s;
+       va_list argp;
 {
-
-#define        sink stdout
-
        if (anyerrs == 0 && anywarnings == 0 && ! silent) 
-               fprintf(sink, "Assembler:\n");
+               printf("Assembler:\n");
        anyerrs++;
        if (silent)
                return;
-       fprintf(sink, "\"%s\", line %d: ", dotsname, lineno);
-       fprintf(sink, s, a1, a2,a3,a4,a5);
-       fprintf(sink, "\n");
-#undef sink
+       printf("\"%s\", line %d: ", dotsname, lineno);
+       vprintf(s, argp);
+       printf("\n");
+}
+
+yyerror(s, va_alist)
+       char    *s;
+       va_dcl
+{
+       va_list argp;
+
+       va_start(argp);
+       vyyerror(s, argp);
+       va_end(argp);
 }
 
-/*VARARGS1*/
-yywarning(s, a1, a2,a3,a4,a5)
+yywarning(s, va_alist)
        char    *s;
+       va_dcl
 {
-#define        sink stdout
+       va_list argp;
+
        if (anyerrs == 0 && anywarnings == 0 && ! silent) 
-               fprintf(sink, "Assembler:\n");
+               printf("Assembler:\n");
        anywarnings++;
        if (silent)
                return;
-       fprintf(sink, "\"%s\", line %d: WARNING: ", dotsname, lineno);
-       fprintf(sink, s, a1, a2,a3,a4,a5);
-       fprintf(sink, "\n");
-#undef sink
+       printf("\"%s\", line %d: WARNING: ", dotsname, lineno);
+       va_start(argp);
+       vprintf(s, argp);
+       va_end(argp);
+       printf("\n");
 }
index 59ef215..65029ae 100644 (file)
@@ -43,8 +43,6 @@ struct tokbufdesc{
 
 typedef int inttoktype;
 typedef char bytetoktype;
-
-typedef char *ptrall;                  /*all uses will be type cast*/
 typedef u_short lgtype;                        /*for storing length of strings or skiping*/
 /*
  *     defintions for putting various typed values
@@ -52,39 +50,39 @@ typedef u_short lgtype;                     /*for storing length of strings or skiping*/
  *     ptr will ALWAYS be of type ptrall
  */
 
-#define        pchar(ptr,val)          *ptr++  = val
-#define        puchar(ptr,val)         *ptr++  = val
+#define pchar(ptr,val)         (*(*(char **)&(ptr))++ = (val))
+#define puchar(ptr,val)                (*(*(char **)&(ptr))++ = (val))
 
-#define        pshort(ptr,val)         *(short *)ptr=val,      ptr += sizeof(short)
-#define        plgtype(ptr,val)        *(lgtype *)ptr=val,     ptr += sizeof(lgtype)
-#define        pushort(ptr,val)        *(u_short *)ptr=val,    ptr += sizeof(short)
-#define        pint(ptr,val)           *(int *)ptr  = val,     ptr += sizeof(int)
-#define        puint(ptr,val)          *(u_int int *)ptr=val,  ptr += sizeof(int)
-#define        plong(ptr,val)          *(long *)ptr  = val,    ptr += sizeof(long)
-#define        pulong(ptr,val)         *(u_int long *)ptr=val, ptr += sizeof(long)
-#define        pnumber(ptr,val)        *(Bignum*)ptr=val,      ptr += sizeof(Bignum)
-#define        popcode(ptr,val)        *(struct Opcode*)ptr=val,       ptr += sizeof(struct Opcode)
+#define pshort(ptr,val)                (*(*(short **)&(ptr))++ = (val))
+#define plgtype(ptr,val)       (*(*(lgtype **)&(ptr))++ = (val))
+#define pushort(ptr,val)       (*(*(u_short **)&(ptr))++ = (val))
+#define pint(ptr,val)          (*(*(int **)&(ptr))++ = (val))
+#define puint(ptr,val)         (*(*(u_int **)&(ptr))++ = (val))
+#define plong(ptr,val)         (*(*(long **)&(ptr))++ = (val))
+#define pulong(ptr,val)                (*(*(u_long **)&(ptr))++ = (val))
+#define pnumber(ptr,val)       (*(*(Bignum **)&(ptr))++ = (val))
+#define popcode(ptr,val)       (*(*(struct Opcode **)&(ptr))++ = (val))
 
-#define        pptr(ptr,val)           *(int *)ptr  = (val),   ptr += sizeof(ptrall)
-#define        ptoken(ptr,val)         *ptr++  = val
-#define        pskiplg(ptr,val)        *(lgtype *)ptr  = val,  ptr += sizeof(short)
+#define pptr(ptr,val)          (*(*(int **)&(ptr))++ = (val))
+#define ptoken(ptr,val)                (*(*(char **)&(ptr))++ = (val))
+#define pskiplg(ptr,val)       (*(*(lgtype **)&(ptr))++ = (val))
 
-#define        gchar(val, ptr)         val = *ptr++
-#define        guchar(val, ptr)        val = *ptr++
+#define gchar(val, ptr)                ((val) = *(*(char **)&(ptr))++)
+#define guchar(val, ptr)       ((val) = *(*(u_char **)&(ptr))++)
 
-#define        gshort(val, ptr)        val = *(short *)ptr , ptr += sizeof (short)
-#define        glgtype(val, ptr)       val = *(lgtype *)ptr , ptr += sizeof (lgtype)
-#define        gushort(val, ptr)       val = *(u_short *)ptr , ptr += sizeof (short)
-#define        gint(val, ptr)          val = *(int *)ptr, ptr += sizeof (int)
-#define        guint(val, ptr)         val = *(u_int *)ptr, ptr += sizeof (int)
-#define        glong(val, ptr)         val = *(long *)ptr, ptr += sizeof (long)
-#define        gulong(val, ptr)        val = *(u_int *)ptr, ptr += sizeof (long)
-#define        gnumber(val, ptr)       val = *(Bignum *)ptr, ptr += sizeof(Bignum)
-#define        gopcode(val, ptr)       val = *(struct Opcode *)ptr, ptr += sizeof(struct Opcode)
+#define gshort(val, ptr)       ((val) = *(*(short **)&(ptr))++ )
+#define glgtype(val, ptr)      ((val) = *(*(lgtype **)&(ptr))++ )
+#define gushort(val, ptr)      ((val) = *(*(u_short **)&(ptr))++ )
+#define gint(val, ptr)         ((val) = *(*(int **)&(ptr))++)
+#define guint(val, ptr)                ((val) = *(*(u_int **)&(ptr))++)
+#define glong(val, ptr)                ((val) = *(*(long **)&(ptr))++)
+#define gulong(val, ptr)       ((val) = *(*(u_int **)&(ptr))++)
+#define gnumber(val, ptr)      ((val) = *(*(Bignum **)&(ptr))++)
+#define gopcode(val, ptr)      ((val) = *(*(struct Opcode **)&(ptr))++)
 
-#define        gptr(val, ptr)          val = *(int *)ptr, ptr += sizeof (ptrall)
-#define        gtoken(val, ptr)        val = *ptr++
-#define        gskiplg(val, ptr)       val = *(lgtype *)ptr, ptr += sizeof (short)
+#define gptr(val, ptr)         ((val) = *(*(int **)&(ptr))++)
+#define gtoken(val, ptr)       ((val) = *(*(char **)&(ptr))++)
+#define gskiplg(val, ptr)      ((val) = *(*(lgtype **)&(ptr))++)
 
 extern ptrall tokptr;  /*the next token to consume, call by copy*/
 extern ptrall tokub;   /*current upper bound in the current buffer*/
index 8a0e0bf..b1aa723 100644 (file)
@@ -10,6 +10,31 @@ static char sccsid[] = "@(#)asscan1.c        5.1 (Berkeley) 4/30/85";
 
 #include "asscanl.h"
 
+/* moved here from asscanl.h: */
+struct tokbufdesc *bufstart;   /*where the buffer list begins*/
+struct tokbufdesc *buftail;    /*last one on the list*/
+struct tokbufdesc *emptybuf;   /*the one being filled*/
+
+struct tokbufdesc *tok_free;   /* free pool */
+struct tokbufdesc *tok_temp;   /* temporary for doing list manipulation */
+
+int    bufno;                  /*which buffer number: 0,1 for tmp file*/
+struct         tokbufdesc tokbuf[2];   /*our initial increment of buffers*/
+ptrall tokptr;                 /*where the current token comes from*/
+ptrall tokub;                  /*the last token in the current token buffer*/
+
+#ifdef DEBUG
+ptrall firsttoken;
+#endif DEBUG
+
+int    yylval;                 /* normal semantic value */
+Bignum yybignum;               /* a big number */
+struct Opcode  yyopcode;       /* a structure opcode */
+
+int    newfflag;
+char   *newfname;
+int    scanlineno;             /*the scanner's linenumber*/
+
 inittokfile()
 {
        if (passno == 1){
@@ -205,13 +230,13 @@ inttoktype yylex()
                        }
                        buftail->tok_next = 0;
                }       /*end of need to get more buffers*/
-               (bytetoktype *)bufptr = &(emptybuf->toks[0]);
+               *(bytetoktype **)&bufptr = &(emptybuf->toks[0]);
                if (passno == 1)
                        scan_dot_s(emptybuf);
            } else {    /*don't use VM*/
                bufno ^= 1;
                emptybuf = &tokbuf[bufno];
-               ((bytetoktype *)bufptr) = &(emptybuf->toks[0]);
+               *(bytetoktype **)&bufptr = &(emptybuf->toks[0]);
                if (passno == 1){
                        /*
                         *      First check if there are things to write
@@ -232,7 +257,7 @@ inttoktype yylex()
                    }
                }
            }   /*end of using a real live file*/
-           (char *)tokub = (char *)bufptr + emptybuf->tok_count;
+           *(char **)&tokub = (char *)bufptr + emptybuf->tok_count;
 #ifdef DEBUG
            firsttoken = bufptr;
            if (debug)
@@ -283,7 +308,7 @@ buildskip(from, to)
                /*
                 *      Now, force from to be in the same buffer as to
                 */
-               (bytetoktype *)from = (bytetoktype *)&(emptybuf->toks[0]);
+               *(bytetoktype **)&from = (bytetoktype *)&(emptybuf->toks[0]);
        }
        /*
         *      Now, to and from are in the same buffer
@@ -302,18 +327,6 @@ buildskip(from, to)
        }
 }
 
-movestr(to, from, lg)
-       char    *to;    /* 4(ap) */ 
-       char    *from;  /* 8(ap) */
-       int     lg;     /* 12(ap) */
-{
-       if (lg <= 0)
-               return;
-       ;
-       asm("movc3      12(ap),*8(ap),*4(ap)");
-       ;
-}
-
 new_dot_s(namep)
        char    *namep;
 {
index a5ad892..6e544bf 100644 (file)
@@ -73,8 +73,8 @@ scan_dot_s(bufferbox)
                struct  Opcode          opstruct;
        reg     int     strlg;          /* the length of a string */
 
-       (bytetoktype *)bufptr = (bytetoktype *) & (bufferbox->toks[0]); 
-       (bytetoktype *)bufub = &(bufferbox->toks[AVAILTOKS]);
+       *(bytetoktype **)&bufptr = (bytetoktype *) & (bufferbox->toks[0]);      
+       *(bytetoktype **)&bufub = &(bufferbox->toks[AVAILTOKS]);
 
        MEMTOREGBUF;
        if (newfflag){
index 76e3cae..79b9578 100644 (file)
@@ -10,7 +10,6 @@ static char sccsid[] = "@(#)asscan4.c 5.1 (Berkeley) 4/30/85";
 
 #include "asscanl.h"
 
-#define        reg     register
 #define        NUMSIZE 128     /* how many characters long a number can be */
 #define        FLTCHAR(x)      (INCHARSET((x),(DIGIT|SIGN|FLOATEXP|POINT)))
 
index 435f7c9..f6d28b7 100644 (file)
@@ -66,22 +66,22 @@ extern      int     Ginbufcnt;
  *     for errors encountered in the scanner and in the parser.
  */
 #define TOKDALLOP      8
-struct tokbufdesc *bufstart;   /*where the buffer list begins*/
-struct tokbufdesc *buftail;    /*last one on the list*/
-struct tokbufdesc *emptybuf;   /*the one being filled*/
+extern struct  tokbufdesc *bufstart;   /*where the buffer list begins*/
+extern struct  tokbufdesc *buftail;    /*last one on the list*/
+extern struct  tokbufdesc *emptybuf;   /*the one being filled*/
 /*
  *     If we are using VM, during the second pass we reclaim the used
  *     token buffers for saving the relocation information
  */
-struct tokbufdesc *tok_free;   /* free pool */
-struct tokbufdesc *tok_temp;   /* temporary for doing list manipulation */
+extern struct  tokbufdesc *tok_free;   /* free pool */
+extern struct  tokbufdesc *tok_temp;   /* temporary for doing list manipulation */
 /*
  *     Other token buffer managers
  */
-int    bufno;                  /*which buffer number: 0,1 for tmp file*/
-struct         tokbufdesc tokbuf[2];   /*our initial increment of buffers*/
-ptrall tokptr;                 /*where the current token comes from*/
-ptrall tokub;                  /*the last token in the current token buffer*/
+extern int     bufno;                  /*which buffer number: 0,1 for tmp file*/
+extern struct  tokbufdesc tokbuf[2];   /*our initial increment of buffers*/
+extern ptrall  tokptr;                 /*where the current token comes from*/
+extern ptrall  tokub;                  /*the last token in the current token buffer*/
 /*
  *     as does not use fread and fwrite for the token buffering.
  *     The token buffers are integrals of BUFSIZ
@@ -97,17 +97,17 @@ ptrall      tokub;                  /*the last token in the current token buffer*/
 
 #define bskiplg(from, length) \
        *(lgtype *)from = length; \
-       (bytetoktype *)from += sizeof(lgtype) + length
+       *(bytetoktype **)&from += sizeof(lgtype) + length
 
 #define bskipfromto(from, to) \
        *(lgtype *)from = (bytetoktype *)to - (bytetoktype *)from - sizeof(lgtype); \
-       (bytetoktype *)from += sizeof (lgtype) + (bytetoktype *)to - (bytetoktype *)from
+       *(bytetoktype **)&from += sizeof (lgtype) + (bytetoktype *)to - (bytetoktype *)from
 
 #define eatskiplg(from) \
-       (bytetoktype *)from += sizeof(lgtype) + *(lgtype *)from
+       *(bytetoktype **)&from += sizeof(lgtype) + *(lgtype *)from
 
 #ifdef DEBUG
-       ptrall  firsttoken;
+extern ptrall  firsttoken;
 #endif DEBUG
 
 /*
@@ -116,16 +116,16 @@ ptrall    tokub;                  /*the last token in the current token buffer*/
  *     They are the semantic values associated with a particular token.
  *     The token itself is the return value from yylex()
  */
-int    yylval;                 /* normal semantic value */
-Bignum yybignum;               /* a big number */
-struct Opcode  yyopcode;       /* a structure opcode */
+extern int     yylval;                 /* normal semantic value */
+extern Bignum  yybignum;               /* a big number */
+extern struct  Opcode  yyopcode;       /* a structure opcode */
 
-int    newfflag;
-char   *newfname;
-int    scanlineno;             /*the scanner's linenumber*/
+extern int     newfflag;
+extern char    *newfname;
+extern int     scanlineno;             /*the scanner's linenumber*/
 
 /*
  *     Definitions for sets of characters
  */
-readonly short charsets[];
-readonly short type[];
+extern readonly short charsets[];
+extern readonly short type[];
index 94fb447..125d2f8 100644 (file)
@@ -177,9 +177,9 @@ char *Calloc(number, size)
        int     number, size;
 {
        register        char *newstuff;
-       char    *sbrk();
+       void    *sbrk();
        newstuff = sbrk(number*size);
-       if ((int)newstuff == -1){
+       if (newstuff == (char *)-1){
                yyerror("Ran out of Memory");
                delexit();
        }
@@ -195,7 +195,11 @@ char *ClearCalloc(number, size)
        length = length;
 #endif length
        newstuff = Calloc(number, size);
+#ifdef __STDC__ /* this is a bit non-ideal, revisit later */
+       bzero(newstuff, length);
+#else
        asm("movc5 $0, (r0), $0, r10, (r11)");
+#endif
        return(newstuff);
 }
 
index 51c0712..231b8c9 100644 (file)
@@ -51,11 +51,19 @@ Bignum floatconvert(number, convto)
 
        switch(CONV(number.num_tag, convto)){
 
+#ifdef __STDC__ /* this is not ideal, revisit later */
+       case CONV(TYPF, TYPD):  *(double *)bp = *(float *)bp; break;
+#else
        case CONV(TYPF, TYPD):  asm("cvtfd (r11), (r11)"); break;
+#endif
        case CONV(TYPF, TYPG):  mixs++; break;
        case CONV(TYPF, TYPH):  mixs++; break;
 
+#ifdef __STDC__ /* this is not ideal, revisit later */
+       case CONV(TYPD, TYPF):  *(float *)bp = *(double *)bp; break;
+#else
        case CONV(TYPD, TYPF):  asm("cvtdf (r11), (r11)"); break;
+#endif
        case CONV(TYPD, TYPG):  mixs++; break;
        case CONV(TYPD, TYPH):  mixs++; break;
 
diff --git a/bin/as/conflicts.txt b/bin/as/conflicts.txt
new file mode 100644 (file)
index 0000000..22e4d8b
--- /dev/null
@@ -0,0 +1,22 @@
+as.h assert.h
+as.h instrs.h
+ascode.c vax/mtpr.h
+asexpr.c sys/inode.h
+asexpr.c sys/ioctl.h
+asexpr.c vax/reg.h
+asexpr.h arpa/ftp.h
+asexpr.h arpa/tftp.h
+asparse.c arpa/ftp.h
+asparse.c arpa/tftp.h
+asparse.c sys/inode.h
+asscan.h instrs.h
+asscan2.c vax/reg.h
+asscan3.c sys/ioctl.h
+asscan3.c vax/reg.h
+astoks.h sys/inode.h
+astoks.h sys/ioctl.h
+astoks.h vax/reg.h
+bignum1.c assert.h
+bignum2.c assert.h
+instrs.h vax/mtpr.h
+natof.c assert.h
diff --git a/bin/as/groups.txt b/bin/as/groups.txt
new file mode 100644 (file)
index 0000000..7b8a02e
--- /dev/null
@@ -0,0 +1,17 @@
+ascode.c as.h
+asexpr.c asexpr.h
+asio.c as.h
+asjxxx.c as.h
+asmain.c as.h
+asparse.c asexpr.h
+aspseudo.c as.h
+asscan1.c asscan.h
+asscan2.c asscan.h
+asscan3.c asscan.h
+asscan4.c asscan.h
+assizetab.c as.h
+assyms.c as.h
+bignum1.c asnumber.h
+bignum2.c asnumber.h
+floattab.c as.h
+natof.c asnumber.h
index 5aad0fe..99768fb 100644 (file)
@@ -1,9 +1,3 @@
-#ifndef ____AS_INSTRS_H_
-#define ____AS_INSTRS_H_
-
-#include <sys/types.h>
-#include <vax/mtpr.h>
-
 /*
  * Copyright (c) 1982 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
@@ -149,5 +143,3 @@ extern struct insttab{
 #define        NEW     1
 #define        ESCD    0xfd
 #define        ESCF    0xff
-
-#endif
diff --git a/bin/as/uniqify.sed b/bin/as/uniqify.sed
new file mode 100644 (file)
index 0000000..215d999
--- /dev/null
@@ -0,0 +1,22 @@
+s/@/ATSIGN/g
+s/^/@/
+s/$/@/
+s/[^A-Za-z0-9_]\+/@&@/g
+
+s/@movestr@/@memcpy@/g
+s/@readonly@[  ]*/@/g
+s/@reg@/@register@/g
+s/@register@[   ]*@ptrall@/@ptrall@/g
+s/@ptrall@/@void *CHECKME@/g
+s/@shift@;/val = yylex()@;/g
+
+s/@//g
+s/ATSIGN/@/g
+
+s/\[\]CHECKME\([        ]*[A-Za-z_][0-9A-Za-z_]*\)\([   ]*;\)/\1[]\2/g
+s/\*CHECKME\([  ]*\)\([A-Za-z_][0-9A-Za-z_]*[   ]*;\)/\1*\2/g
+s/CHECKME[      ]*)/)/g
+s/CHECKME[      ]*$//g
+
+# specific to this file because I'm lazy and don't want a 2 step process:
+s/\*CHECKME    from, to;/      *from, *to;/
index acc3f67..55531ab 100644 (file)
@@ -904,6 +904,8 @@ char *name;
        put_string(stdout, cur_file_name());
        put_string(stdout, " */\n");
     }
+ /*extern int yydebug; yydebug = 1;*/
+ extern int yy_flex_debug; yy_flex_debug = 0;
     if (yyparse())
        fprintf(stderr, "warning: yyparse() aborted\n");
     free_symbol_table(define_names);
index eee99ab..61014ef 100644 (file)
@@ -467,7 +467,14 @@ save_text ()
 #if OPT_LINTLIBRARY
     if (!in_cpp)
        copy_typedef(yytext);
-#endif 
+#endif
+#ifdef NICK
+ for (int i = 0; yytext[i]; ++i) {
+  if (yytext[i] == '\n')
+   fprintf(stderr, "@%s:%d", cur_file->file_name, cur_file->line_num);
+  fputc(yytext[i], stderr);
+ }
+#endif
     if (cur_file->convert) {
        fputs(yytext, cur_file->tmp_file);
     }
@@ -482,6 +489,13 @@ save_text_offset ()
     (void)strcpy(yylval.text.text, yytext);
 #if OPT_LINTLIBRARY
     copy_typedef(yytext);
+#endif
+#ifdef NICK
+ for (int i = 0; yytext[i]; ++i) {
+  if (yytext[i] == '\n')
+   fprintf(stderr, "@%s:%d", cur_file->file_name, cur_file->line_num);
+  fputc(yytext[i], stderr);
+ }
 #endif
     if (cur_file->convert) {
        yylval.text.begin = ftell(cur_file->tmp_file);
@@ -559,7 +573,14 @@ int c;
 # if OPT_LINTLIBRARY
        if (!in_cpp)
            copy_typedef(temp);
-# endif        
+# endif
+#ifdef NICK
+ for (int i = 0; temp[i]; ++i) {
+  if (temp[i] == '\n')
+   fprintf(stderr, "@%s:%d", cur_file->file_name, cur_file->line_num);
+  fputc(temp[i], stderr);
+ }
+#endif
        if (cur_file->convert) {
            fputs(temp, cur_file->tmp_file);
        }
@@ -636,6 +657,11 @@ get_comment ()
 #endif
 
     while ((c = input()) != 0) {
+#ifdef NICK
+ if (c == '\n')
+  fprintf(stderr, "@%s:%d", cur_file->file_name, cur_file->line_num);
+ fputc(c, stderr);
+#endif
        if (cur_file->convert)
            fputc(c, cur_file->tmp_file);
 
@@ -716,6 +742,11 @@ unsigned n;                /* size of buffer to store directive text */
        *dest = '\0';
 
     while ((c = input()) != 0) {
+#ifdef NICK
+ if (c == '\n')
+  fprintf(stderr, "@%s:%d", cur_file->file_name, cur_file->line_num);
+ fputc(c, stderr);
+#endif
        if (cur_file->convert)
            fputc(c, cur_file->tmp_file);
 
index 0189eef..a61197e 100644 (file)
@@ -104,7 +104,7 @@ int exit __P((int code)) NORETURN;
 FILE *fdopen __P((int fd, register char *mode));
 
 /* stdio/fgetc.c */
-/*int fgetc __P((FILE *fp));*/
+int fgetc __P((FILE *fp));
 
 /* stdio/fgets.c */
 char *fgets __P((char *s, int n, register FILE *iop));
@@ -131,7 +131,7 @@ FILE *fopen __P((char *file, register char *mode));
 int fprintf __P((register FILE *iop, char *fmt, ...));
 
 /* stdio/fputc.c */
-/*int fputc __P((int c, register FILE *fp));*/
+int fputc __P((int c, register FILE *fp));
 
 /* stdio/fputs.c */
 int fputs __P((register char *s, register FILE *iop));
index cd4e602..c9ddd5c 100755 (executable)
@@ -4,6 +4,7 @@
 ROOT=../..
 ROOT=`cd $ROOT && pwd`
 INCLUDE=$ROOT/cross/usr/include
+SCRIPTS=$ROOT/scripts
 
 #all_c=`echo *.c`
 #if test "$all_c" = "*.c"
@@ -52,7 +53,7 @@ then
     git checkout $ROOT/include $ROOT/sys $all_c
     rm -rf $INCLUDE/g
     mkdir -p $INCLUDE/g
-    (cd $ROOT/include && ../scripts/make.sh SHARED=copies install)
+    (cd $ROOT/include && $SCRIPTS/make.sh SHARED=copies install)
   fi
 fi
 
@@ -220,11 +221,11 @@ then
   all_c_protos_nocomm=
   for i in $all_c
   do
-    $ROOT/scripts/nocomment <$i |$ROOT/scripts/nostring >$i.nocomm
+    $SCRIPTS/nocomment <$i |$SCRIPTS/nostring >$i.nocomm
     all_c_nocomm="$all_c_nocomm $i.nocomm"
     if test -f $i.protos
     then
-      $ROOT/scripts/nocomment <$i.protos |$ROOT/scripts/nostring >$i.protos.nocomm
+      $SCRIPTS/nocomment <$i.protos |$SCRIPTS/nostring >$i.protos.nocomm
       all_c_protos_nocomm="$all_c_protos_nocomm $i.protos.nocomm"
     fi
   done
@@ -233,18 +234,18 @@ then
   all_h_protos_nocomm=
   for i in $all_h
   do
-    $ROOT/scripts/nocomment <$i |$ROOT/scripts/nostring >$i.nocomm
+    $SCRIPTS/nocomment <$i |$SCRIPTS/nostring >$i.nocomm
     all_h_nocomm="$all_h_nocomm $i.nocomm"
     if test -f $i.protos
     then
-      $ROOT/scripts/nocomment <$i.protos |$ROOT/scripts/nostring >$i.protos.nocomm
+      $SCRIPTS/nocomment <$i.protos |$SCRIPTS/nostring >$i.protos.nocomm
       all_h_protos_nocomm="$all_h_protos_nocomm $i.protos.nocomm"
     fi
   done
 
   for i in $std_h
   do
-    $ROOT/scripts/nocomment <$i |$ROOT/scripts/nostring >$i.nocomm
+    $SCRIPTS/nocomment <$i |$SCRIPTS/nostring >$i.nocomm
   done
 
   if test -f conflicts.txt
@@ -432,7 +433,7 @@ then
     echo "i=$i"
     rm -f xx*
     csplit -b '%05d' -q $i '/^#/' '{*}'
-    if test -f xx00001 && ! $ROOT/scripts/nocomment <xx00000 |grep -q '[^       ]'
+    if test -f xx00001 && ! $SCRIPTS/nocomment <xx00000 |grep -q '[^    ]'
     then
       for j in xx*
       do
@@ -441,7 +442,7 @@ then
       echo "j=$j"
       define="`sed -ne 's/^#[   ]*ifndef[       ]\+\([A-Za-z_][0-9A-Za-z_]*\).*/\1/p' xx00001`"
       echo "define=$define"
-      if test -n "$define" && grep -q '^#[      ]*endif$' $j && ! grep -v "^#" $j |$ROOT/scripts/nocomment |grep -q '[^         ]'
+      if test -n "$define" && grep -q '^#[      ]*endif$' $j && ! grep -v "^#" $j |$SCRIPTS/nocomment |grep -q '[^      ]'
       then
         sed -e "s/^#[   ]*ifndef[       ]\\+$define/\\/\\*&\\*\\//" -i xx00001
         sed -e "s/^\\(#[        ]*define[       ]\\+$define\\)[         ]*$/\\/\\*\1\\*\\//" -i xx00002
@@ -473,7 +474,7 @@ then
     for j in xx*
     do
       sed -e 's/^#[     ]*include[      ]*\(<[^>]*>\|"[^"]*"\)/\/\*&\*\//' -i $j
-      if grep -v "^#[   ]*include[^0-9A-Za-z_]" $j |sed -e '/^#[        ]*if.*SCCS\|lint/,/^#[  ]*endif/s/.*//' |$ROOT/scripts/nocomment |grep -q '[^   ]'
+      if grep -v "^#[   ]*include[^0-9A-Za-z_]" $j |sed -e '/^#[        ]*if.*SCCS\|lint/,/^#[  ]*endif/s/.*//' |$SCRIPTS/nocomment |grep -q '[^        ]'
       then
         break
       fi
@@ -540,7 +541,7 @@ EOF
         echo
       fi
       sed -e 's/\([^0-9A-Za-z_]\)va_start(argp);/\1_va_start(argp, fmt);/' $i
-    ) |$ROOT/scripts/newline >b
+    ) |$SCRIPTS/newline >b
     mv b $i
   done
 
@@ -608,7 +609,7 @@ EOF
 
 #endif
 EOF
-    ) |$ROOT/scripts/newline >b
+    ) |$SCRIPTS/newline >b
     mv b $i
   done
 fi
@@ -620,8 +621,11 @@ then
   # checking header loops
   if test -n "$all_h"
   then
+    #grep -H '^#include \(<[^>]*>\|"[^"]*"\)' $all_h |\
+    #sed -e 's:^\(.*\)\:#include \(<\([^>]*\)>\|"\([^"]*\)"\):\1 \3\4:' |\
+    #tsort >a
     grep -H '^#include <[^>]*>' $all_h |\
-    sed -e "s:^\(.*\)\:#include <\(.*\)>:\1 \2:" |\
+    sed -e "s:^$INCLUDE/::; s:^\\(.*\\)\\:#include <\\([^>]*\\)>:\1 \2:" |\
     tsort >a
   fi
 
@@ -660,8 +664,12 @@ then
     echo "pattern=$pattern"
     if test -n "$pattern"
     then
-      #sed -e "s:^#include \\(<\\($pattern\\)>\\|\"\\($pattern\\)\"\\)$:/\\*& $h\\*/:" -i `grep -H "^#include \\(<$h>\\|\"$h\"\\)$" $all_c $all_h |sed -e 's/:.*//'`
-      sed -e "s:^#include <\\($pattern\\)>$:/\\*& $h\\*/:" -i `grep -H "^#include <$h>$" $all_c $all_h |sed -e 's/:.*//'`
+      grep -H "^#include \\(<$h>\\|\"$h\"\\)$" $all_c $all_h >b
+      if test -s b
+      then
+        #sed -e "s:^#include \\(<\\($pattern\\)>\\|\"\\($pattern\\)\"\\)$:/\\*& $h\\*/:" -i `sed -e 's/:.*//' b`
+        sed -e "s:^#include <\\($pattern\\)>$:/\\*& $h\\*/:" -i `sed -e 's/:.*//' b`
+      fi
     fi
   done
   rm -f $INCLUDE/g/stdarg.h temp.c
index 6c6a8c1..cb468fb 100644 (file)
@@ -7,7 +7,7 @@
 #
 # Machine dependent routines for the VAX are located here
 #
-COMPAT=        compat-4.1
+COMPAT=        compat-4.1 compat-sys5
 ALL=   gen net stdio sys ${COMPAT}
 TAGSFILE=tags
 
diff --git a/lib/libc/vax/compat-sys5/DEFS.h b/lib/libc/vax/compat-sys5/DEFS.h
new file mode 100644 (file)
index 0000000..8ba6d7e
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)DEFS.h      5.1 (Berkeley) 5/30/85
+ */
+
+#ifdef PROF
+#define        ENTRY(x)        .globl _/**/x; .align 2; _/**/x: .word 0; \
+                       .data; 1:; .long 0; .text; moval 1b,r0; jsb mcount
+#define        ASENTRY(x)      .globl x; .align 2; x: .word 0; \
+                       .data; 1:; .long 0; .text; moval 1b,r0; jsb mcount
+#else
+#define        ENTRY(x)        .globl _/**/x; .align 2; _/**/x: .word 0
+#define        ASENTRY(x)      .globl x; .align 2; x: .word 0
+#endif
diff --git a/lib/libc/vax/compat-sys5/Makefile b/lib/libc/vax/compat-sys5/Makefile
new file mode 100644 (file)
index 0000000..6f0920a
--- /dev/null
@@ -0,0 +1,52 @@
+LD=ld
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved.  The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+#      @(#)Makefile    5.5 (Berkeley) 9/6/85
+#
+SRCS=  memcmp.s memcpy.s memset.s
+OBJS=  memcmp.o memcpy.o memset.o
+CFLAGS= ${DEFS}
+TAGSFILE=tags
+
+.c.o:
+       /lib/cpp -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
+       -${LD} -X -r $*.o
+       mv a.out profiled/$*.o
+       /lib/cpp -E ${CFLAGS} $*.c | ${AS} -o $*.o
+       -${LD} -x -r $*.o
+       mv a.out $*.o
+
+compat-sys5lib compat-sys5lib_p: ${OBJS}
+       @echo "building profiled compat-sys5"
+       @cd profiled; ar cru ../compat-sys5lib_p ${OBJS}
+       @echo "building normal compat-sys5"
+       @ar cru compat-sys5lib ${OBJS}
+
+tags:
+
+clean:
+       rm -f *.o profiled/*.o errs a.out core \
+           compat-sys5lib compat-sys5lib_p tags
+
+depend:
+       for i in ${SRCS}; do \
+           ${CC} -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+               { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+               else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+               else rec = rec " " $$2 } } \
+               END { print rec } ' >> makedep; done
+       echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+       echo '$$r makedep' >>eddep
+       echo 'w' >>eddep
+       cp Makefile Makefile.bak
+       ed - Makefile < eddep
+       rm eddep makedep
+       echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+       echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+       echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
diff --git a/lib/libc/vax/compat-sys5/memcmp.s b/lib/libc/vax/compat-sys5/memcmp.s
new file mode 100644 (file)
index 0000000..a16e113
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+       .asciz  "@(#)memcmp.s   5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* memcmp(s1, s2, n) */
+
+#include "DEFS.h"
+
+ENTRY(memcmp, 0)
+       movl    4(ap),r1
+       movl    8(ap),r3
+       movl    12(ap),r4
+1:
+       movzwl  $65535,r0
+       cmpl    r4,r0
+       jleq    3f
+       subl2   r0,r4
+       cmpc3   r0,(r1),(r3)
+       jeql    1b
+2:
+       subb3   (r1),(r3),r0    # r0 = *s1 - *s2
+       cvtbl   r0,r0
+       ret
+3:
+       cmpc3   r4,(r1),(r3)
+       jneq    2b
+       ret
diff --git a/lib/libc/vax/compat-sys5/memcpy.s b/lib/libc/vax/compat-sys5/memcpy.s
new file mode 100644 (file)
index 0000000..9897909
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+       .asciz  "@(#)memcpy.s   5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* memcpy(to, from, size) */
+
+#include "DEFS.h"
+
+ENTRY(memcpy, R6)
+       movl    4(ap),r3
+       movl    8(ap),r1
+       movl    12(ap),r6
+       jbr     2f
+1:
+       subl2   r0,r6
+       movc3   r0,(r1),(r3)
+2:
+       movzwl  $65535,r0
+       cmpl    r6,r0
+       jgtr    1b
+       movc3   r6,(r1),(r3)
+       ret
diff --git a/lib/libc/vax/compat-sys5/memset.s b/lib/libc/vax/compat-sys5/memset.s
new file mode 100644 (file)
index 0000000..b67fc7d
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+       .asciz  "@(#)memset.s   5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* memset(base, fill, length) */
+
+#include "DEFS.h"
+
+ENTRY(memset, 0)
+       movl    4(ap),r3
+       jbr     2f
+1:
+       subl2   r0,12(ap)
+       movc5   $0,(r3),8(ap),r0,(r3)
+2:
+       movzwl  $65535,r0
+       cmpl    12(ap),r0
+       jgtr    1b
+       movc5   $0,(r3),8(ap),12(ap),(r3)
+       ret
index 7c10877..a51a3b8 100755 (executable)
@@ -4,6 +4,7 @@ ROOT=`dirname $0`/..
 #ROOT=../..
 ROOT=`cd $ROOT && pwd`
 INCLUDE=$ROOT/cross/usr/include
+SCRIPTS=$ROOT/scripts
 
 all_c=`echo *.c`
 if test "$all_c" = "*.c"
@@ -60,7 +61,7 @@ then
     #git checkout $ROOT/include $ROOT/sys $all_c
     #rm -rf $INCLUDE
     #mkdir -p $INCLUDE
-    #(cd $ROOT/include && ../scripts/make.sh SHARED=copies install)
+    #(cd $ROOT/include && $SCRIPTS/make.sh SHARED=copies install)
   fi
 fi
 
@@ -86,7 +87,12 @@ std_h=`find $INCLUDE -type f -name '*.h' -print |grep -v "^$INCLUDE/\(stand\|vax
 if test -z "$1" || test $1 -eq 1
 then
   echo "===stage 1==="
+
+  if test -f uniqify.sed
+  then
+    sed -f uniqify.sed -i $all_c $all_h
+  fi
+
   for i in $all_c $all_h
   do
     echo "i=$i"
@@ -199,7 +205,7 @@ EOF
       if test -s a
       then
         mv a $i.oldprotos
-        grep -v "^$group:" $i.oldprotos
+        grep -v "^$group:" $i.oldprotos >&2
       fi
     fi
   done
@@ -224,11 +230,11 @@ then
   all_c_protos_nocomm=
   for i in $all_c
   do
-    $ROOT/scripts/nocomment <$i |$ROOT/scripts/nostring >$i.nocomm
+    $SCRIPTS/nocomment <$i |$SCRIPTS/nostring >$i.nocomm
     all_c_nocomm="$all_c_nocomm $i.nocomm"
     if test -f $i.protos
     then
-      $ROOT/scripts/nocomment <$i.protos |$ROOT/scripts/nostring >$i.protos.nocomm
+      $SCRIPTS/nocomment <$i.protos |$SCRIPTS/nostring >$i.protos.nocomm
       all_c_protos_nocomm="$all_c_protos_nocomm $i.protos.nocomm"
     fi
   done
@@ -237,18 +243,18 @@ then
   all_h_protos_nocomm=
   for i in $all_h
   do
-    $ROOT/scripts/nocomment <$i |$ROOT/scripts/nostring >$i.nocomm
+    $SCRIPTS/nocomment <$i |$SCRIPTS/nostring >$i.nocomm
     all_h_nocomm="$all_h_nocomm $i.nocomm"
     if test -f $i.protos
     then
-      $ROOT/scripts/nocomment <$i.protos |$ROOT/scripts/nostring >$i.protos.nocomm
+      $SCRIPTS/nocomment <$i.protos |$SCRIPTS/nostring >$i.protos.nocomm
       all_h_protos_nocomm="$all_h_protos_nocomm $i.protos.nocomm"
     fi
   done
 
   for i in $std_h
   do
-    $ROOT/scripts/nocomment <$i |$ROOT/scripts/nostring >$i.nocomm
+    $SCRIPTS/nocomment <$i |$SCRIPTS/nostring >$i.nocomm
   done
 
   if test -f conflicts.txt
@@ -436,7 +442,7 @@ then
     echo "i=$i"
     rm -f xx*
     csplit -b '%05d' -q $i '/^#/' '{*}'
-    if test -f xx00001 && ! $ROOT/scripts/nocomment <xx00000 |grep -q '[^       ]'
+    if test -f xx00001 && ! $SCRIPTS/nocomment <xx00000 |grep -q '[^    ]'
     then
       for j in xx*
       do
@@ -445,7 +451,7 @@ then
       echo "j=$j"
       define="`sed -ne 's/^#[   ]*ifndef[       ]\+\([A-Za-z_][0-9A-Za-z_]*\).*/\1/p' xx00001`"
       echo "define=$define"
-      if test -n "$define" && grep -q '^#[      ]*endif$' $j && ! grep -v "^#" $j |$ROOT/scripts/nocomment |grep -q '[^         ]'
+      if test -n "$define" && grep -q '^#[      ]*endif$' $j && ! grep -v "^#" $j |$SCRIPTS/nocomment |grep -q '[^      ]'
       then
         sed -e "s/^#[   ]*ifndef[       ]\\+$define/\\/\\*&\\*\\//" -i xx00001
         sed -e "s/^\\(#[        ]*define[       ]\\+$define\\)[         ]*$/\\/\\*\1\\*\\//" -i xx00002
@@ -477,7 +483,7 @@ then
     for j in xx*
     do
       sed -e 's/^#[     ]*include[      ]*\(<[^>]*>\|"[^"]*"\)/\/\*&\*\//' -i $j
-      if grep -v "^#[   ]*include[^0-9A-Za-z_]" $j |sed -e '/^#[        ]*if.*SCCS\|lint/,/^#[  ]*endif/s/.*//' |$ROOT/scripts/nocomment |grep -q '[^   ]'
+      if grep -v "^#[   ]*include[^0-9A-Za-z_]" $j |sed -e '/^#[        ]*if.*SCCS\|lint/,/^#[  ]*endif/s/.*//' |$SCRIPTS/nocomment |grep -q '[^        ]'
       then
         break
       fi
@@ -544,7 +550,7 @@ EOF
         echo
       fi
       sed -e 's/\([^0-9A-Za-z_]\)va_start(argp);/\1_va_start(argp, fmt);/' $i
-    ) |$ROOT/scripts/newline >b
+    ) |$SCRIPTS/newline >b
     mv b $i
   done
 
@@ -612,7 +618,7 @@ EOF
 
 #endif
 EOF
-    ) |$ROOT/scripts/newline >b
+    ) |$SCRIPTS/newline >b
     mv b $i
   done
 fi
@@ -624,9 +630,12 @@ then
   # checking header loops
   if test -n "$all_h"
   then
-    grep -H '^#include <[^>]*>' $all_h |\
-    sed -e "s:^\(.*\)\:#include <\(.*\)>:\1 \2:" |\
+    grep -H '^#include \(<[^>]*>\|"[^"]*"\)' $all_h |\
+    sed -e 's:^\(.*\)\:#include \(<\([^>]*\)>\|"\([^"]*\)"\):\1 \3\4:' |\
     tsort >a
+    #grep -H '^#include <[^>]*>' $all_h |\
+    #sed -e "s:^$INCLUDE/::; s:^\\(.*\\)\\:#include <\\([^>]*\\)>:\1 \2:" |\
+    #tsort >a
   fi
 
   # removing useless extra header inclusions that are pulled in anyway
@@ -664,8 +673,12 @@ then
     echo "pattern=$pattern"
     if test -n "$pattern"
     then
-      sed -e "s:^#include \\(<\\($pattern\\)>\\|\"\\($pattern\\)\"\\)$:/\\*& $h\\*/:" -i `grep -H "^#include \\(<$h>\\|\"$h\"\\)$" $all_c $all_h |sed -e 's/:.*//'`
-      #sed -e "s:^#include <\\($pattern\\)>$:/\\*& $h\\*/:" -i `grep -H "^#include <$h>$" $all_c $all_h |sed -e 's/:.*//'`
+      grep -H "^#include \\(<$h>\\|\"$h\"\\)$" $all_c $all_h >b
+      if test -s b
+      then
+        sed -e "s:^#include \\(<\\($pattern\\)>\\|\"\\($pattern\\)\"\\)$:/\\*& $h\\*/:" -i `sed -e 's/:.*//' b`
+        #sed -e "s:^#include <\\($pattern\\)>$:/\\*& $h\\*/:" -i `sed -e 's/:.*//' b`
+      fi
     fi
   done
   rm -f $INCLUDE/stdarg.h temp.c
index 2833400..e96dd0c 100755 (executable)
@@ -22,5 +22,5 @@ typedef uint32_t x_unsigned_long;
 
 #endif
 EOF
-  "`dirname "$0"`/xifyfilt" <$1 2>$3 |sed -e 's/\(extern\|register\|static\) x_int\([   ]\+x_\)\(Bignum\|bool\|caddr_t\|datum\|off_t\|time_t\|u_char\|u_int\|u_short\|u_long\)/\1\2\3/g; s/va_arg(x_argp, x_\(unsigned_\)\?\(short\|int\|long\))/_va_arg_\1\2(x_argp)/g'
+  "`dirname "$0"`/xifyfilt" <$1 2>$3 |sed -e 's/\(extern\|register\|static\) x_int\([   ]\+x_\)\(Bignum\|Iptr\|bytetoktype\|bool\|caddr_t\|chptr\|datum\|inttoktype\|lgtype\|off_t\|time_t\|u_char\|u_int\|u_short\|u_long\)/\1\2\3/g; s/va_arg(x_argp, x_\(unsigned_\)\?\(short\|int\|long\))/_va_arg_\1\2(x_argp)/g'
 ) >$2