ANSIfication] Another batch.
authorManoel Trapier <godzil@godzil.net>
Mon, 11 Mar 2013 15:08:38 +0000 (16:08 +0100)
committerManoël Trapier <godzil@MacBook-Pro.home>
Wed, 24 Jun 2015 22:41:44 +0000 (23:41 +0100)
27 files changed:
lang/cem/cpp.ansi/LLlex.c
lang/cem/cpp.ansi/LLlex.h
lang/cem/cpp.ansi/LLmessage.c
lang/cem/cpp.ansi/Parameters
lang/cem/cpp.ansi/ch3bin.c
lang/cem/cpp.ansi/ch3mon.c
lang/cem/cpp.ansi/domacro.c
lang/cem/cpp.ansi/error.c
lang/cem/cpp.ansi/init.c
lang/cem/cpp.ansi/main.c
lang/cem/cpp.ansi/options.c
lang/cem/cpp.ansi/preprocess.c
lang/cem/cpp.ansi/replace.c
modules/src/idf/idf_pkg.body
modules/src/input/inp_pkg.body
util/cgg/bootgram.y
util/cgg/bootlex.l
util/cgg/main.c
util/cpp/init.c
util/cpp/input.c
util/cpp/interface.h
util/cpp/main.c
util/cpp/options.c
util/cpp/preprocess.c
util/cpp/replace.c
util/cpp/scan.c
util/cpp/skip.c

index e828ac7..dea9222 100644 (file)
@@ -37,16 +37,13 @@ extern arith        char_constant();
 #define                FLG_ESEEN       0x01    /* possibly a floating point number */
 #define                FLG_DOTSEEN     0x02    /* certainly a floating point number */
 
-int
-LLlex()
+int LLlex()
 {
        return (DOT != EOF) ? GetToken(&dot) : EOF;
 }
 
 
-int
-GetToken(ptok)
-       register struct token *ptok;
+int GetToken(struct token *ptok)
 {
        /*      GetToken() is the actual token recognizer. It calls the
                control line interpreter if it encounters a "\n{w}*#"
@@ -325,9 +322,10 @@ garbage:
                crash("bad class for char 0%o", ch);
        }
        /*NOTREACHED*/
+       return -1;
 }
 
-skipcomment()
+void skipcomment()
 {
        /*      The last character read has been the '*' of '/_*'.  The
                characters, except NL and EOI, between '/_*' and the first
@@ -358,9 +356,7 @@ skipcomment()
        NoUnstack--;
 }
 
-arith
-char_constant(nm)
-       char *nm;
+arith char_constant(char *nm)
 {
        register arith val = 0;
        register int ch;
@@ -391,9 +387,7 @@ char_constant(nm)
        return val;
 }
 
-char *
-string_token(nm, stop_char)
-       char *nm;
+char *string_token(char *nm, int stop_char)
 {
        register int ch;
        register int str_size;
@@ -423,9 +417,7 @@ string_token(nm, stop_char)
        return str;
 }
 
-int
-quoted(ch)
-       register int ch;
+int quoted(int ch)
 {      
        /*      quoted() replaces an escaped character sequence by the
                character meant.
@@ -483,9 +475,7 @@ quoted(ch)
 }
 
 
-int
-val_in_base(ch, base)
-       register int ch;
+int val_in_base(int ch, int base)
 {
        switch (base) {
        case 8:
@@ -500,11 +490,11 @@ val_in_base(ch, base)
                fatal("(val_in_base) illegal base value %d", base);
                /* NOTREACHED */
        }
+       return -1;
 }
 
 
-int
-GetChar()
+int GetChar()
 {
        /*      The routines GetChar and trigraph parses the trigraph
                sequences and removes occurences of \\\n.
@@ -532,8 +522,7 @@ again:
 }
 
 
-int
-trigraph()
+int trigraph()
 {
        register int ch;
 
index 6c7e7ee..3e82bb0 100644 (file)
@@ -41,6 +41,9 @@ extern int NoUnstack;         /* buffer.c     */
 
 extern int err_occurred;       /* "error.c"    */
 
+
+void skipcomment();
+
 #define        DOT     dot.tk_symb
 
 #define EOF    (-1)
index 92b5070..46eef7b 100644 (file)
@@ -9,9 +9,9 @@
 #include       "LLlex.h"
 #include       "Lpars.h"
 
-extern char *symbol2str();
 
-LLmessage(tk)  {
+void LLmessage(int tk)
+{
        if (tk < 0)
                error("garbage at end of line");
        else if (tk)    {
index 0917443..1ae090e 100644 (file)
 
 
 !File: botch_free.h
-/*#define BOTCH_FREE   1       /* botch freed memory, as a check       */
+/*#define BOTCH_FREE   1*/     /* botch freed memory, as a check       */
 
 
 !File: debug.h
-/*#define DEBUG                1       /* perform various self-tests           */
+/*#define DEBUG                1*/     /* perform various self-tests           */
 #define NDEBUG         1       /* disable assertions                   */
 
 
@@ -53,7 +53,7 @@
 
 
 !File: inputtype.h
-/*#define INP_READ_IN_ONE      1       /* read input file in one.  */
+/*#define INP_READ_IN_ONE      1*/     /* read input file in one.  */
                                /* If defined, we cannot read from a pipe */
 
 
index e85457e..45e1ef3 100644 (file)
@@ -10,9 +10,7 @@
 
 #define arith_sign (1L << (sizeof(arith)*8-1))
 
-ch3bin(pval, pis_uns, oper, val, is_uns)
-       register arith *pval, val;
-       int oper, is_uns, *pis_uns;
+void ch3bin(arith *pval, int *pis_uns, int oper, arith val, int is_uns)
 {
        if (is_uns) *pis_uns = 1;
        switch (oper)   {
index a5f6095..81caf27 100644 (file)
@@ -9,9 +9,7 @@
 #include       "arith.h"
 
 /*ARGSUSED2*/
-ch3mon(oper, pval, puns)
-       register arith *pval;
-       int *puns;
+void ch3mon(int oper, arith *pval, int *puns)
 {
        switch (oper)   {
        case '~':
index 47f09af..feddbcb 100644 (file)
@@ -5,6 +5,8 @@
 /* $Id$ */
 /* PREPROCESSOR: CONTROLLINE INTERPRETER */
 
+#include <string.h>
+
 #include       "arith.h"
 #include       "LLlex.h"
 #include       "Lpars.h"
 #include       "macbuf.h"
 #include       "replace.h"
 
+char *getwdir(char *fn); /* /util/cpp/input.c */
+
 extern char options[];
 extern char **inctable;        /* list of include directories          */
-extern char *getwdir();
 char ifstack[IFDEPTH]; /* if-stack: the content of an entry is */
                                /* 1 if a corresponding ELSE has been   */
                                /* encountered.                         */
 
+void do_include();
+void do_define();
+void do_elif();
+void push_if();
+void do_else();
+void do_endif();
+void do_if();
+void do_ifdef(int how);
+void do_undef(char *argstr);
+void do_error();
+void do_line(unsigned int l);
+
+void macro_def(struct idf *id, char *text, int nformals, int length, int flags);
+
 int    nestlevel = -1;
 int    svnestlevel[30] = {-1};
 int    nestcount;
 extern int do_preprocess;
 
-char *
-GetIdentifier(skiponerr)
-       int skiponerr;          /* skip the rest of the line on error */
+/* skiponerr => skip the rest of the line on error */
+char *GetIdentifier(int skiponerr)
 {
        /*      Returns a pointer to the identifier that is read from the
                input stream. When the input does not contain an
@@ -73,7 +89,7 @@ GetIdentifier(skiponerr)
        Pragma's are handled by do_pragma(). They are passed on to the
        compiler.
 */
-domacro()
+void domacro()
 {
        struct token tk;        /* the token itself                     */
        register struct idf *id;
@@ -154,8 +170,7 @@ domacro()
        }
 }
 
-skip_block(to_endif)
-int to_endif;
+void skip_block(int to_endif)
 {
        /*      skip_block() skips the input from
                1)      a false #if, #ifdef, #ifndef or #elif until the
@@ -275,7 +290,7 @@ int to_endif;
 }
 
 
-ifexpr()
+int ifexpr()
 {
        /*      ifexpr() returns whether the restricted constant
                expression following #if or #elif evaluates to true.  This
@@ -296,7 +311,7 @@ ifexpr()
        return (errors == err_occurred) && (ifval != (arith)0);
 }
 
-do_include()
+void do_include()
 {
        /*      do_include() performs the inclusion of a file.
        */
@@ -333,7 +348,7 @@ do_include()
        }
 }
 
-do_define()
+void do_define()
 {
        /*      do_define() interprets a #define control line.
        */
@@ -373,7 +388,7 @@ do_define()
        LineNumber++;
 }
 
-push_if()
+void push_if()
 {
        if (nestlevel >= IFDEPTH)
                fatal("too many nested #if/#ifdef/#ifndef");
@@ -381,7 +396,7 @@ push_if()
                ifstack[++nestlevel] = 0;
 }
 
-do_elif()
+void do_elif()
 {
        if (nestlevel <= svnestlevel[nestcount]) {
                error("#elif without corresponding #if");
@@ -398,7 +413,7 @@ do_elif()
        }
 }
 
-do_else()
+void do_else()
 {
        if (SkipToNewLine()) {
                if (!options['o'])
@@ -415,7 +430,7 @@ do_else()
        }
 }
 
-do_endif()
+void do_endif()
 {
        if (SkipToNewLine()) {
                if (!options['o'])
@@ -427,14 +442,14 @@ do_endif()
        else    nestlevel--;
 }
 
-do_if()
+void do_if()
 {
        push_if();
        if (!ifexpr())  /* a false #if/#elif expression */
                skip_block(0);
 }
 
-do_ifdef(how)
+void do_ifdef(int how)
 {
        register struct idf *id;
        register char *str;
@@ -463,8 +478,7 @@ do_ifdef(how)
 }
 
 /* argstr != NULL when the undef came from a -U option */
-do_undef(argstr)
-       char *argstr;
+void do_undef(char *argstr)
 {
        register struct idf *id;
        register char *str = argstr;
@@ -492,7 +506,7 @@ do_undef(argstr)
                error("illegal #undef construction");
 }
 
-do_error()
+void do_error()
 {
        int len;
        char *get_text();
@@ -503,10 +517,7 @@ do_error()
        LineNumber++;
 }
 
-int
-getparams(buf, parbuf)
-       char *buf[];
-       char parbuf[];
+int getparams(char *buf[], char parbuf[])
 {
        /*      getparams() reads the formal parameter list of a macro
                definition.
@@ -570,11 +581,10 @@ getparams(buf, parbuf)
                c = skipspaces(c,0);
        }
        /*NOTREACHED*/
+       return -1;
 }
 
-macro_def(id, text, nformals, length, flags)
-       register struct idf *id;
-       char *text;
+void macro_def(struct idf *id, char *text, int nformals, int length, int flags)
 {
        register struct macro *newdef = id->id_macro;
 
@@ -613,9 +623,7 @@ macro_def(id, text, nformals, length, flags)
        newdef->mc_flag = flags;        /* special flags        */
 }
 
-int
-find_name(nm, index)
-       char *nm, *index[];
+int find_name(char *nm, char *index[])
 {
        /*      find_name() returns the index of "nm" in the namelist
                "index" if it can be found there.  0 is returned if it is
@@ -632,10 +640,7 @@ find_name(nm, index)
 
 #define        BLANK(ch)       ((ch == ' ') || (ch == '\t'))
 
-char *
-get_text(formals, length)
-       char *formals[];
-       int *length;
+char *get_text(char *formals[], int *length)
 {
        /*      get_text() copies the replacement text of a macro
                definition with zero, one or more parameters, thereby
@@ -726,7 +731,7 @@ get_text(formals, length)
                                add2repl(repl, ' ');
                        }
                        /* construct the formal parameter mark or identifier */
-                       if (n = find_name(id_buf, formals))
+                       if ( (n = find_name(id_buf, formals)) )
                                add2repl(repl, FORMALP | (char) n);
                        else {
                                idp = id_buf;
@@ -775,8 +780,7 @@ get_text(formals, length)
        as strings, without taking care of the leading and trailing
        blanks (spaces and tabs).
 */
-macroeq(s, t)
-       register char *s, *t;
+int macroeq(char *s, char *t)
 {
        
        /* skip leading spaces  */
@@ -798,8 +802,7 @@ macroeq(s, t)
        }
 }
 
-do_line(l)
-       unsigned int l;
+void do_line(unsigned int l)
 {
        struct token tk;
        int t = GetToken(&tk);
index a567b3d..86c7964 100644 (file)
@@ -23,8 +23,7 @@
 
 int err_occurred;
 
-err_hdr(s)
-       char *s;
+void err_hdr(char *s)
 {
        if (FileName) {
                fprint(ERROUT, "\"%s\", line %d: %s", FileName, (int)LineNumber, s);
@@ -34,7 +33,7 @@ err_hdr(s)
 
 #if __STDC__
 /*VARARGS*/
-error(char *fmt, ...)
+void error(char *fmt, ...)
 {
        va_list ap;
 
@@ -47,7 +46,7 @@ error(char *fmt, ...)
 }
 
 /*VARARGS*/
-warning(char *fmt, ...)
+void warning(char *fmt, ...)
 {
        va_list ap;
 
@@ -59,7 +58,7 @@ warning(char *fmt, ...)
 }
 
 /*VARARGS*/
-strict(char *fmt, ...)
+void strict(char *fmt, ...)
 {
        va_list ap;
 
@@ -71,7 +70,7 @@ strict(char *fmt, ...)
 }
 
 /*VARARGS*/
-crash(char *fmt, ...)
+void crash(char *fmt, ...)
 {
        va_list ap;
 
@@ -84,7 +83,7 @@ crash(char *fmt, ...)
 }
 
 /*VARARGS*/
-fatal(char *fmt, ...)
+void fatal(char *fmt, ...)
 {
        va_list ap;
 
index 07d86e9..25ea041 100644 (file)
@@ -36,7 +36,7 @@ struct mkey   {
 //char *strcpy();
 //char *sprint();
 
-init_pp()
+void init_pp()
 {
        static char *months[12] = {
                "Jan", "Feb", "Mar", "Apr", "May", "Jun",
@@ -74,7 +74,7 @@ init_pp()
        /* __DATE__ */
        sprint(dbuf, "\"%s %2d %d\"", months[tp->tm_mon],
                        tp->tm_mday, tp->tm_year+1900);
-       /* if (tp->tm_mday < 10) dbuf[5] = ' ';         /* hack */
+       /* if (tp->tm_mday < 10) dbuf[5] = ' ';*/               /* hack */
        macro_def(str2idf("__DATE__", 0), dbuf, -1, strlen(dbuf), NOUNDEF);
 
        /* __TIME__ */
index 46f9fd2..3544257 100644 (file)
@@ -10,6 +10,7 @@
 #include       <alloc.h>
 #include       <assert.h>
 #include       <system.h>
+#include       <string.h>
 #include       "arith.h"
 #include       "file_info.h"
 #include       "idfsize.h"
@@ -32,8 +33,13 @@ char *prog_name;
 extern char **inctable;
 extern int inc_max, inc_total;
 
-main(argc, argv)
-       char *argv[];
+
+void compile(int argc, char *argv[]);
+void list_dependencies(char *source);
+void dependency(char *s, char *source);
+
+
+int main(int argc, char *argv[])
 {
        /* parse and interpret the command line options */
        prog_name = argv[0];
@@ -61,11 +67,12 @@ main(argc, argv)
        }
        compile(argc - 1, &argv[1]);
        sys_stop(err_occurred ? S_EXIT : S_END);
+
        /*NOTREACHED*/
+       return -1;
 }
 
-compile(argc, argv)
-       char *argv[];
+void compile(int argc, char *argv[])
 {
        register char *source = 0;
        char *dummy;
@@ -94,10 +101,8 @@ compile(argc, argv)
 }
 
 struct idf     *file_head;
-extern char *strrchr();
 
-list_dependencies(source)
-       char *source;
+void list_dependencies(char *source)
 {
        register struct idf *p = file_head;
 
@@ -112,7 +117,7 @@ list_dependencies(source)
                          * object generated, so don't include the pathname
                          * leading to it.
                          */
-                        if (s = strrchr(source, '/')) {
+                        if ( (s = strrchr(source, '/')) ) {
                                 source = s + 1;
                         }
                }
@@ -128,8 +133,7 @@ list_dependencies(source)
        }
 }
 
-add_dependency(s)
-       char *s;
+void add_dependency(char *s)
 {
        register struct idf *p = str2idf(s, 0);
 
@@ -140,8 +144,7 @@ add_dependency(s)
        }
 }
 
-dependency(s, source)
-       char *s, *source;
+void dependency(char *s, char *source)
 {
        if (options['i'] && !strncmp(s, "/usr/include/", 13)) {
                return;
@@ -152,8 +155,7 @@ dependency(s, source)
        else    fprint(dep_fd, "%s\n", s);
 }
 
-void
-No_Mem()                               /* called by alloc package */
+void No_Mem()                          /* called by alloc package */
 {
        fatal("out of memory");
 }
index fb16ef8..42eebbe 100644 (file)
@@ -23,10 +23,8 @@ char **inctable;
 char   *dep_file = 0;
 
 extern int idfsize;
-int    txt2int();
 
-do_option(text)
-       char *text;
+void do_option(char *text)
 {
        switch(*text++) {
        case '-':
@@ -127,9 +125,7 @@ do_option(text)
        }
 }
 
-int
-txt2int(tp)
-       char **tp;
+int txt2int(char **tp)
 {
        /*      the integer pointed to by *tp is read, while increasing
                *tp; the resulting value is yielded.
index 72fa647..f734bb2 100644 (file)
@@ -29,12 +29,11 @@ extern int InputLevel;
 
 extern char *sprint();
 
-Xflush()
+void Xflush()
 {
        sys_write(STDOUT, _obuf, OBUFSIZE);
 }
 
-static char *SkipComment();
 extern char options[];
 
 /* #pragma directives are saved here and passed to the compiler later on.
@@ -47,7 +46,10 @@ struct prag_info {
 static struct prag_info *pragma_tab;
 static int pragma_nr;
 
-do_pragma()
+static char *SkipComment(char *op, int *lineno);
+void preprocess(char *fn);
+
+void do_pragma()
 {
        register int size = ITEXTSIZE;
        char *cur_line = Malloc((unsigned)size);
@@ -105,8 +107,7 @@ do_pragma()
 
 char Xbuf[256];
 
-preprocess(fn)
-       char *fn;
+void preprocess(char *fn)
 {
        register int c;
        register char *op = _obuf;
@@ -409,10 +410,7 @@ preprocess(fn)
        /*NOTREACHED*/
 }
 
-static char *
-SkipComment(op, lineno)
-char *op;
-int *lineno;
+static char *SkipComment(char *op, int *lineno)
 {
        char *ob = &_obuf[OBUFSIZE];
        register int c, oldc = '\0';
index 485e10f..fb8e743 100644 (file)
 #include       "macbuf.h"
 #include       "replace.h"
 
-//extern char *GetIdentifier();
-//extern char *strcpy();
-//extern char *strcat();
 extern int InputLevel;
 struct repl *ReplaceList;      /* list of currently active macros */
 
-int
-replace(idf)
-       register struct idf *idf;
+void expand_defined(struct repl *repl);
+void getactuals(struct repl *repl, struct idf *idf);
+void macro_func(struct idf *idef);
+void macro2buffer(struct repl *repl, struct idf *idf, struct args *args);
+void add2repl(struct repl *repl, int ch);
+void stash(struct repl *repl, int ch, int stashraw);
+
+char *GetIdentifier(int skiponerr); /* domacro.c */
+
+int replace(struct idf *idf)
 {
        /*      replace is called by the lexical analyzer to perform
                macro replacement. The routine actualy functions as a
@@ -60,13 +64,12 @@ replace(idf)
        return 1;
 }
 
-unstackrepl()
+void unstackrepl()
 {
        Unstacked++;
 }
 
-freeargs(args)
-       struct args *args;
+void freeargs(struct args *args)
 {
        register int i;
 
@@ -84,7 +87,7 @@ freeargs(args)
        free_args(args);
 }
 
-EnableMacros()
+void EnableMacros()
 {
        register struct repl *r = ReplaceList, *prev = 0;
 
@@ -106,9 +109,7 @@ EnableMacros()
        Unstacked = 0;
 }
 
-expand_macro(repl, idf)
-       register struct repl *repl;
-       register struct idf *idf;
+int expand_macro(struct repl *repl, struct idf *idf)
 {
        /*      expand_macro() does the actual macro replacement.
                "idf" is a description of the identifier which
@@ -171,8 +172,7 @@ expand_macro(repl, idf)
        return 1;
 }
 
-expand_defined(repl)
-       register struct repl *repl;
+void expand_defined(struct repl *repl)
 {
        register int ch = GetChar();
        struct idf *id;
@@ -207,16 +207,13 @@ expand_defined(repl)
        add2repl(repl, ' ');
 }
 
-newarg(args)
-       struct args *args;
+void newarg(struct args *args)
 {
        args->a_expptr = args->a_expbuf = Malloc((unsigned)(args->a_expsize = ARGBUF));
        args->a_rawptr = args->a_rawbuf = Malloc((unsigned)(args->a_rawsize = ARGBUF));
 }
 
-getactuals(repl, idf)
-       struct repl *repl;
-       register struct idf *idf;
+void getactuals(struct repl *repl, struct idf *idf)
 {
        /*      Get the actual parameters from the input stream.
                The hard part is done by actual(), only comma's and
@@ -257,8 +254,7 @@ getactuals(repl, idf)
                error("too many macro arguments");
 }
 
-saveraw(repl)
-struct repl *repl;
+void saveraw(struct repl *repl)
 {
        register struct repl *nrepl = ReplaceList;
        register struct args *ap = nrepl->r_args;
@@ -295,9 +291,7 @@ struct repl *repl;
        }
 }
 
-int
-actual(repl)
-       struct repl *repl;
+int actual(struct repl *repl)
 {
        /*      This routine deals with the scanning of an actual parameter.
                It keeps in account the opening and closing brackets,
@@ -498,8 +492,7 @@ a_new_line:         ch = GetChar();
        }
 }
 
-macro_func(idef)
-       register struct idf *idef;
+void macro_func(struct idf *idef)
 {
        /*      macro_func() performs the special actions needed with some
                macros.  These macros are __FILE__ and __LINE__ which
@@ -528,10 +521,7 @@ macro_func(idef)
        }
 }
 
-macro2buffer(repl, idf, args)
-       register struct repl *repl;
-       register struct idf *idf;
-       register struct args *args;
+void macro2buffer(struct repl *repl, struct idf *idf, struct args *args)
 {
        /*      macro2buffer expands the replacement list and places the
                result onto the replacement buffer. It deals with the #
@@ -681,11 +671,7 @@ macro2buffer(repl, idf, args)
                error("illegal use of ## operator");
 }
 
-char *
-stringify(repl, ptr, args)
-       register struct repl *repl;
-       register char *ptr;
-       register struct args *args;
+char *stringify(struct repl *repl, char *ptr, struct args *args)
 {
        /*      If a parameter is immediately preceded by a # token
                both are replaced by a single string literal that
@@ -748,9 +734,7 @@ stringify(repl, ptr, args)
 
 /* The following routine is also called from domacro.c.
  */
-add2repl(repl, ch)
-       register struct repl *repl;
-       int ch;
+void add2repl(struct repl *repl, int ch)
 {
        register int index = repl->r_ptr - repl->r_text;
  
@@ -767,10 +751,7 @@ add2repl(repl, ch)
  * buffer. If the variable is zero, we must only stash into the expanded
  * buffer. Otherwise, we must use both buffers.
  */
-stash(repl, ch, stashraw)
-        struct repl *repl;
-        register int ch;
-        int stashraw;
+void stash(struct repl *repl, int ch, int stashraw)
 {
        /* Stash characters into the macro expansion buffer.
         */
index 4b71bfa..25ed527 100644 (file)
@@ -19,15 +19,11 @@ static struct idf *IDF_hashtable[IDF_HASHSIZE];
 
 _PROTOTYPE(static struct idf *IDF_new, (char *, int, int));
 
-void
-init_idf()
+void init_idf()
 {
 }
 
-static struct idf *
-IDF_new(tg, size, cpy)
-       register char *tg;
-       register int size;
+static struct idf *IDF_new(char *tg, int size, int cpy)
 {
        static int nidf;
        static struct idf *pidf;
@@ -67,8 +63,7 @@ IDF_new(tg, size, cpy)
 }
 
 #ifdef IDF_DEBUG
-void
-hash_stat()
+void hash_stat()
 {
        register int i;
        int total_count = 0;
@@ -91,10 +86,7 @@ hash_stat()
        print("End hash table tally\n");
 }
 
-void
-idfappfun(fun, opt)
-       int     (*fun)();
-       int     opt;
+void idfappfun(int     (*fun)(struct idf *, int), int opt)
 {
        register int    i;
 
@@ -109,9 +101,7 @@ idfappfun(fun, opt)
 }
 #endif /* IDF_DEBUG */
 
-struct idf *
-str2idf(tg, cpy)
-       char tg[];
+struct idf *str2idf(char tg[], int cpy)
 {
        /*      str2idf() returns an entry in the symbol table for the
                identifier tg.  If necessary, an entry is created.
@@ -124,7 +114,7 @@ str2idf(tg, cpy)
        int size;
 
        IDF_STARTHASH(hash);
-       while (c = *cp++) {
+       while ((c = *cp++)) {
                IDF_ENHASH(hash, c);
        }
        IDF_STOPHASH(hash);
index 3cca88a..cde13c3 100644 (file)
@@ -99,12 +99,16 @@ INP_PRIVATE struct INP_buffer_header *INP_head, *INP_free;
 
 _PROTOTYPE(INP_PRIVATE int INP_rdfile, (File *, char *, long *, char **));
 
+#if __STDC__
+INP_PRIVATE int INP_rdfile(File *fd, char *fn, long size, char **pbuf)
+#else
 INP_PRIVATE int
 INP_rdfile(fd, fn, size, pbuf)
        register File *fd;
        char *fn;               /* file name */
        register long *size;
        char **pbuf;            /* output parameter */
+#endif
 {
        extern long sys_filesize();
        int rsize;
@@ -137,8 +141,7 @@ INP_rdfile(fd, fn, size, pbuf)
 INP_PRIVATE struct INP_i_buf *i_ptr;
 
 _PROTOTYPE(INP_PRIVATE char * INP_pbuf, (void));
-INP_PRIVATE char *
-INP_pbuf()
+INP_PRIVATE char *INP_pbuf()
 {
        register struct INP_i_buf *ib = 
                (struct INP_i_buf *) malloc(sizeof(struct INP_i_buf));
@@ -159,12 +162,11 @@ INP_pbuf()
 _PROTOTYPE(INP_PRIVATE struct INP_buffer_header *INP_push_bh, (void));
 _PROTOTYPE(INP_PRIVATE int INP_pop_bh, (void));
 
-INP_PRIVATE struct INP_buffer_header *
-INP_push_bh()
+INP_PRIVATE struct INP_buffer_header *INP_push_bh()
 {
        register struct INP_buffer_header *bh;
 
-       if (bh = INP_head) {
+       if ((bh = INP_head)) {
                bh->bh_ipp = _ipp;
 #ifdef INP_TYPE
                bh->bh_i = INP_VAR;
@@ -183,8 +185,7 @@ INP_push_bh()
        of headers.  0 is returned if there are no more
        inputbuffers on the stack, 1 is returned in the other case.
 */
-INP_PRIVATE int
-INP_pop_bh()
+INP_PRIVATE int INP_pop_bh()
 {
        register struct INP_buffer_header *bh = INP_head;
 
@@ -213,11 +214,15 @@ INP_pop_bh()
 */
 _PROTOTYPE(INP_PRIVATE int INP_rdblock, (File *, char *, int *));
 
+#if __STDC__
+INP_PRIVATE int INP_rdblock(File *fd, char *buf, int *n)
+#else
 INP_PRIVATE int
 INP_rdblock(fd, buf, n)
        File *fd;
        char *buf;
        int *n;
+#endif
 {
 
        if (!sys_read(fd, buf, INP_BUFSIZE, n)) {
@@ -235,10 +240,14 @@ _PROTOTYPE(INP_PRIVATE int INP_mk_filename, (char *, char *, char **));
 
 /*     INP_mk_filename() concatenates a dir and filename.
 */
+#if __STDC__
+INP_PRIVATE int INP_mk_filename(char *dir, char *file, char **newname)
+#else
 INP_PRIVATE int
 INP_mk_filename(dir, file, newname)
        register char *dir, *file;
        char **newname;
+#endif
 {
 
        register char *dst;
@@ -247,21 +256,24 @@ INP_mk_filename(dir, file, newname)
        if (!dst) return 0;
        *newname = dst;
        if (*dir) {
-               while (*dst++ = *dir++) ;
+               while (((*dst++) = (*dir++))) ;
                *(dst-1) = '/';
        }
-       while (*dst++ = *file++);
+       while (((*dst++) = (*file++)));
        return 1;
 }
 
 /*     Interface routines : InsertFile, InsertText, and loadbuf
 */
-
+#if __STDC__
+int InsertFile(char *filnam, char *table[], char **result)
+#else
 int
 InsertFile(filnam, table, result)
        char *filnam;
        char *table[];
        char **result;
+#endif
 {
        char *newfn = 0;
 
@@ -327,9 +339,13 @@ InsertFile(filnam, table, result)
        return 0;
 }
 
+#if __STDC__
+int InsertText(char *text, int length)
+#else
 int
 InsertText(text, length)
        char *text;
+#endif
 {
        register struct INP_buffer_header *bh = INP_push_bh();
 
@@ -346,8 +362,7 @@ InsertText(text, length)
        Note: this routine is exported due to its occurence in the definition
        of LoadChar [input.h], that is defined as a macro.
 */
-int
-loadbuf()
+int loadbuf()
 {
        register struct INP_buffer_header *bh = INP_head;
        static char buf[INP_NPUSHBACK + 1];
index d1ff22c..48f68e5 100644 (file)
@@ -113,9 +113,9 @@ registerdefs
 
 registerdef
        : IDENT '=' '(' STRING ',' NUMBER list1 ')' optregvar list1 '.'
-               {       register ident_p ip;
-                       register list1 l;
-                       register reginfo r;
+               {       ident_p ip;
+                       list1 l;
+                       reginfo r;
                        int i;
 
                        r=(reginfo) myalloc(sizeof(struct reginfo));
@@ -190,8 +190,8 @@ tkdefs
        ;
 tkdef
        : IDENT '=' structdecl NUMBER optcost optformat
-               { register token_p tp;
-                 register ident_p ip;
+               { token_p tp;
+                 ident_p ip;
 
                  chktabsiz(nmachtokens,MAXTOKENS,"Token table");
                  tp = &machtokens[nmachtokens];
@@ -253,7 +253,7 @@ tokenexpressions
 tokenexpressionline
        : IDENT '=' tokenexpression
                {
-                 {     register ident_p ip;
+                 {     ident_p ip;
 
                        chktabsiz(nmachsets,MAXSETS,"Expression table");
                        machsets[nmachsets] = $3;
@@ -268,7 +268,7 @@ tokenexpression
        : PIDENT
                { $$ = machprops[$1->i_i.i_prpno].propset; }
        | TIDENT
-               { register i;
+               { int i;
 
                  for(i=0;i<SETSIZE;i++) $$.set_val[i]=0;
                  $$.set_val[($1->i_i.i_tokno+nmachregs+1)>>4] |=
@@ -278,7 +278,7 @@ tokenexpression
        | EIDENT
                { $$=machsets[$1->i_i.i_expno]; }
        | tokenexpression '*' tokenexpression
-               { register i;
+               { int i;
 
                  if (($$.set_size=$1.set_size)==0)
                        $$.set_size = $3.set_size;
@@ -286,7 +286,7 @@ tokenexpression
                        $$.set_val[i] = $1.set_val[i] & $3.set_val[i];
                }
        | tokenexpression '+' tokenexpression
-               { register i;
+               { int i;
 
                  if ($1.set_size == -1)
                        $$.set_size = $3.set_size;
@@ -300,7 +300,7 @@ tokenexpression
                        $$.set_val[i] = $1.set_val[i] | $3.set_val[i];
                }
        | tokenexpression '-' tokenexpression
-               { register i;
+               { int i;
 
                  if ($1.set_size == -1)
                        $$.set_size = $3.set_size;
@@ -403,7 +403,7 @@ empattern
        : /* empty */
                { empatlen=0; }
        | mnemlist optboolexpr
-               { register i;
+               { int i;
 
                  empatexpr = $2;
                  patbyte(0);
@@ -441,7 +441,7 @@ mnem    :       IDENT
 
 stackpattern
        : optnocoerc tokenexpressionlist optstack
-               { register i;
+               { int i;
 
                  if (tokpatlen != 0) {
                          outbyte(($1 ? ( $3 ? DO_XXMATCH: DO_XMATCH ) : DO_MATCH)+(tokpatlen<<5));
@@ -703,7 +703,7 @@ movedef
                  tokpatlen=2;
                }
          optboolexpr ',' code optcommacost ')'
-               { register move_p mp;
+               { move_p mp;
 
                  outbyte(DO_RETURN);
                  fprintf(cfile,"\n");
@@ -735,7 +735,7 @@ testdef : '(' tokenexpressionno
                  tokpatlen=2;
                }
          optboolexpr ',' code optcommacost ')'
-               { register move_p mp;
+               { move_p mp;
 
                  outbyte(DO_RETURN);
                  fprintf(cfile,"\n");
@@ -765,7 +765,7 @@ stackdef
                  tokpatlen=1;
                }
          optboolexpr ',' optprop ',' code optcommacost ')'
-               { register c1_p cp;
+               { c1_p cp;
 
                  outbyte(DO_TOKREPLACE);
                  outbyte(DO_RETURN);
@@ -1053,7 +1053,7 @@ tokeninstanceno
 
 tokeninstance
        : '%' '[' tokargno subreg ']'
-               { register i;
+               { int i;
 
                  if ($4!=0)
                          chkregexp(pattokexp[$3]);
@@ -1065,7 +1065,7 @@ tokeninstance
                }
        | '%' '[' tokargno '.' IDENT ']'
                { int typ;
-                 register i;
+                 int i;
                  $$.in_which = IN_COPY;
                  $$.in_info[0] = $3;
                  $$.in_info[1] = findstructel(pattokexp[$3],$5,&typ);
@@ -1075,14 +1075,14 @@ tokeninstance
                        $$.in_info[i] = 0;
                }
        | RIDENT
-               { register i;
+               { int i;
                  $$.in_which = IN_RIDENT;
                  $$.in_info[0] = $1->i_i.i_regno;
                  for (i=1;i<TOKENSIZE;i++)
                        $$.in_info[i] = 0;
                }
        | REGVAR '(' expr ')'
-               { register i;
+               { int i;
                  MUST1BEINT($3);
                  $$.in_which = IN_REGVAR;
                  $$.in_info[0] = exp1;
@@ -1090,7 +1090,7 @@ tokeninstance
                        $$.in_info[i] = 0;
                }
        | '%' '[' LCASELETTER subreg ']'
-               { register i;
+               { int i;
                  if ($3 >= 'a'+nallreg)
                        yyerror("Bad letter in %[x] construct");
                  $$.in_which = IN_ALLOC;
@@ -1100,7 +1100,7 @@ tokeninstance
                        $$.in_info[i] = 0;
                }
        | '{' TIDENT attlist '}'
-               { register i;
+               { int i;
                  $$.in_which = IN_DESCR;
                  $$.in_info[0] = $2->i_i.i_tokno;
                  for(i=0;i<narexp;i++) {
index 3fba33c..b7d3f64 100644 (file)
@@ -21,6 +21,8 @@ static char rcsid2[]="$Id$";
 #include "booth.h"
 #include "y.tab.h"
 
+void yyerror(string s);
+
 int lineno = 1;
 extern char *iname;
 extern char *scopy();
@@ -158,10 +160,9 @@ return                     return(RETURN);
 .                       return(yytext[0]);
 %%
 
-yyerror(s,a1,a2,a3,a4) string s; {
-
+void yyerror(string s)
+{
        fprintf(stderr,"\"%s\", line %d:",iname ? iname : "",lineno);
-       fprintf(stderr,s,a1,a2,a3,a4);
        fprintf(stderr,"\n");
         nerrors++;
 }
index fba8e31..15be1ca 100644 (file)
@@ -9,7 +9,23 @@
 
 #include "booth.h"
 
-char * myalloc(n) {
+void tabovf(string tablename);
+void compueq();
+void initio();
+void inittables();
+void finishio();
+void outregvar();
+void verbose();
+void chkregexp(int number);
+void inithash();
+void enter(char *name, int value);
+void debug();
+void outbyte(int n);
+void patbyte(int n);
+void hashpatterns();
+
+char * myalloc(int n)
+{
        register char *p;
 
        p= malloc((unsigned)n);
@@ -20,21 +36,22 @@ char * myalloc(n) {
        return(p);
 }
 
-tstint(e) expr_t e; {
-
+void tstint(expr_t e)
+{
        if(e.expr_typ != TYPINT)
                yyerror("Must be integer expression");
 }
 
-tstbool(e) expr_t e; {
-
+void tstbool(expr_t e)
+{
        if(e.expr_typ != TYPBOOL)
                yyerror("Must be boolean expression");
 }
 
-structsize(s) register list2 s; {
-       register list1 l;
-       register sum;
+int structsize(register list2 s)
+{
+       list1 l;
+       int sum;
 
        sum = 0;
        while ( s != 0 ) {
@@ -48,7 +65,8 @@ structsize(s) register list2 s; {
        return(sum);
 }
 
-list2 lookstruct(ll) list2 ll; {
+list2 lookstruct(list2 ll)
+{
        list3 l3;
        list2 l21,l22;
        list1 l11,l12;
@@ -74,8 +92,9 @@ list2 lookstruct(ll) list2 ll; {
        return(ll);
 }
 
-instno(inst) inst_t inst; {
-       register i,j;
+int instno(inst_t inst)
+{
+       int i,j;
 
        for(i=1;i<narinstance;i++) {
                if (arinstance[i].in_which != inst.in_which)
@@ -91,16 +110,18 @@ instno(inst) inst_t inst; {
        return(narinstance++);
 }
 
-string scopy(s) string s; {
-       register string t;
+string scopy(string s)
+{
+       string t;
 
        t = (char *) myalloc(strlen(s)+1);
        strcpy(t,s);
        return(t);
 }
 
-strlookup(s) string s; {
-       register i;
+int strlookup(string s)
+{
+       int i;
 
        for(i=0;i<ncodestrings;i++)
                if(strcmp(s,codestrings[i])==0)
@@ -110,9 +131,10 @@ strlookup(s) string s; {
        return(ncodestrings++);
 }
 
-stringno(s) register string s; {
+int stringno(string s)
+{
        char buf[256];
-       register char *p=buf;
+       char *p=buf;
 
        while(*s != 0) switch(*s) {
        default:
@@ -212,7 +234,8 @@ stringno(s) register string s; {
        return(strlookup(buf));
 }
 
-tabovf(tablename) string tablename; {
+void tabovf(string tablename)
+{
        char buf[256];
 
        sprintf(buf,"%s overflow",tablename);
@@ -220,8 +243,8 @@ tabovf(tablename) string tablename; {
        exit(-1);
 }
 
-main(argc,argv) char *argv[]; {
-
+int main(int argc, char *argv[])
+{
        while (--argc) {
                ++argv;
                if (argv[0][0]=='-') {
@@ -252,16 +275,18 @@ main(argc,argv) char *argv[]; {
        }
        debug();
        exit(nerrors);
+       return nerrors;
 }
 
-lookup(comm,operator,lnode,rnode) {
-       register node_p p;
+int lookup(int comm, int operator, int lnode, int rnode)
+{
+       node_p p;
 
        for (p=nodes+1;p<lastnode;p++) {
                if (p->ex_operator != operator)
                        continue;
-               if (!(p->ex_lnode == lnode && p->ex_rnode == rnode ||
-                   comm && p->ex_lnode == rnode && p->ex_rnode == lnode))
+               if (!( ((p->ex_lnode == lnode) && (p->ex_rnode == rnode)) ||
+                   ((comm && p->ex_lnode == rnode) && (p->ex_rnode == lnode)) ) )
                        continue;
                return(p-nodes);
        }
@@ -274,8 +299,9 @@ lookup(comm,operator,lnode,rnode) {
        return(p-nodes);
 }
 
-compueq() {
-       register i,j;
+void compueq()
+{
+       int i,j;
 
        for (i=1;i<nmachregs;i++) {
                for (j=1;j<i;j++)
@@ -288,9 +314,10 @@ compueq() {
        }
 }
 
-eqregclass(r1,r2) {
-       register reginfo rp1,rp2;
-       register i;
+int eqregclass(int r1, int r2)
+{
+       reginfo rp1,rp2;
+       int i;
        short regbits[(MAXREGS+15)>>4];
        int member;
 
@@ -301,7 +328,7 @@ eqregclass(r1,r2) {
        for (i=0;i<((MAXREGS+15)>>4);i++)
                regbits[i] = 0;
        for (i=0;i<maxmembers;i++) {
-               if (member = rp1->rmembers[i])
+               if ( (member = rp1->rmembers[i]) )
                        regbits[member>>4] |= (1<<(member&017));
        }
        for (i=0;i<maxmembers;i++) {
@@ -312,25 +339,34 @@ eqregclass(r1,r2) {
        return(1);
 }
 
-unsigned hash(name) register string name; {
-       register unsigned sum;
-       register i;
+unsigned hash(string name)
+{
+       unsigned int sum;
+       int i;
 
        for (sum=i=0;*name;i+=3)
                sum ^= (*name++)<<(i&07);
        return(sum);
 }
 
-ident_p ilookup(name,enterf) string name; int enterf; {
+ident_p ilookup(string name, int enterf)
+{
        register ident_p p,*pp;
 
        pp = &identtab[hash(name)%ITABSIZE];
-       while (*pp != 0) {
+       while (*pp != 0)
+       {
                if (strcmp((*pp)->i_name,name)==0)
+               {
                        if (enterf != ENTER)
+                       {
                                return(*pp);
+                       }
                        else
+                       {
                                yyerror("Multiply defined symbol");
+                       }
+               }
                pp = &(*pp)->i_next;
        }
        if (enterf == LOOKUP)
@@ -344,8 +380,8 @@ ident_p ilookup(name,enterf) string name; int enterf; {
        return(p);
 }
 
-initio() {
-
+void initio()
+{
        if (iname!=0 && freopen(iname,"r",stdin)==NULL) {
                fprintf(stderr,"Can't open %s\n",iname);
                exit(-1);
@@ -367,8 +403,9 @@ initio() {
        patbyte(0);
 }
 
-exprlookup(sett) set_t sett; {
-       register i,j,ok;
+int exprlookup(set_t sett)
+{
+       int i,j,ok;
 
        for(i=0;i<nmachsets;i++) {
                ok= (sett.set_size == machsets[i].set_size);
@@ -386,9 +423,10 @@ exprlookup(sett) set_t sett; {
        return(nmachsets++);
 }
 
-inittables() {
-       register reginfo r;
-       register i;
+void inittables()
+{
+       reginfo r;
+       int i;
        inst_t inst;
        set_t sett;
 
@@ -421,8 +459,9 @@ inittables() {
        cocosetno=exprlookup(sett);
 }
 
-outregs() {
-       register i,j,k;
+void outregs()
+{
+       int i,j,k;
        static short rset[(MAXREGS+15)>>4];
        int t,ready;
 
@@ -444,29 +483,53 @@ outregs() {
                         */
                        for (j=0;j<((MAXREGS+15)>>4);j++)
                                rset[j]=0;
+
                        rset[i>>4] |= (1<<(i&017));
-                       do {
-                           ready=1;
-                           for (j=1;j<nmachregs;j++)
-                               if (rset[j>>4]&(1<<(j&017)))
-                                   for (k=0;k<maxmembers;k++)
-                                       if ((t=machregs[j]->rmembers[k])!=0) {
-                                           if ((rset[t>>4]&(1<<(t&017)))==0)
-                                               ready=0;
-                                           rset[t>>4] |= (1<<(t&017));
+
+                       do
+                       {
+                               ready = 1;
+                               for ( j = 1 ; j < nmachregs ; j++ )
+                               {
+                                       if ( rset[j >> 4] & (1 << (j & 017)) )
+                                       {
+                                               for ( k = 0 ; k < maxmembers ; k++ )
+                                               {
+                                                       if ( (t = machregs[j]->rmembers[k]) != 0 )
+                                                       {
+                                                               if ( ( rset[t >> 4] & (1 << (t & 017)) ) == 0 )
+                                                               {
+                                                                       ready = 0;
+                                                               }
+                                                               rset[t >> 4] |= (1 << (t & 017));
+                                                       }
+                                               }
                                        }
+                               }
                        } while (!ready);
-                       do {
-                           ready=1;
-                           for (j=1;j<nmachregs;j++)
-                               for (k=0;k<maxmembers;k++)
-                                   if ((t=machregs[j]->rmembers[k])!=0)
-                                       if (rset[t>>4]&(1<<(t&017))) {
-                                               if (rset[j>>4]&(1<<(j&017))==0)
-                                                   ready=0;
-                                               rset[j>>4] |= (1<<(j&017));
+
+                       do
+                       {
+                               ready=1;
+                               for ( j = 1 ; j < nmachregs ; j++ )
+                               {
+                                       for ( k = 0 ; k < maxmembers ; k++ )
+                                       {
+                                               if ( ( t = machregs[j]->rmembers[k] ) !=0 )
+                                               {
+                                                       if ( rset[t >> 4] & (1 << (t & 017)) )
+                                                       {
+                                                               if ( ( rset[j >> 4] & (1 << (j & 017)) ) == 0)
+                                                               {
+                                                                       ready=0;
+                                                               }
+                                                               rset[j >> 4] |= (1 << (j & 017));
+                                                       }
+                                               }
                                        }
+                               }
                        } while (!ready);
+
                        fprintf(cfile,"},{");
                        for (j=0;j<((nmachregs+15)>>4);j++)
                                fprintf(cfile,"%d,",rset[j]);
@@ -479,12 +542,13 @@ outregs() {
        fprintf(cfile,"};\n\n");
 }
 
-finishio() {
-       register i;
-       register node_p np;
+void finishio()
+{
+       int i;
+       node_p np;
        int j;
        int setsize;
-       register move_p mp;
+       move_p mp;
 
        fprintf(cfile,"};\n\n");
        if (wsize>0)
@@ -637,8 +701,9 @@ finishio() {
                outregvar();
 }
 
-outregvar() {
-       register i,j;
+void outregvar()
+{
+       int i,j;
 
        fprintf(hfile,"#define REGVARS\n");
        fprintf(cfile,"#include \"regvar.h\"\n");
@@ -670,8 +735,8 @@ outregvar() {
        fprintf(cfile,"};\n");
 }
 
-verbose() {
-
+void verbose()
+{
        fprintf(stderr,"Codebytes %d\n",codebytes);
        fprintf(stderr,"Registers %d(%d)\n",nmachregs,MAXREGS);
        fprintf(stderr,"Properties %d(%d)\n",nprops,MAXPROPS);
@@ -683,10 +748,11 @@ verbose() {
        fprintf(stderr,"Patbytes %d(%d)\n",npatbytes,MAXPATTERN);
 }
 
-inbetween() {
-       register ident_p ip;
-       register i,j;
-       register move_p mp;
+void inbetween()
+{
+       ident_p ip;
+       int i,j;
+       move_p mp;
 
        lookident=1;    /* for lexical analysis */
 
@@ -728,11 +794,12 @@ inbetween() {
        }
 }
 
-formconversion(p,tp) register char *p; register token_p tp; {
+int formconversion(char *p, token_p tp)
+{
        char buf[256];
-       register char *q=buf;
+       char *q=buf;
        char field[256];
-       register char *f;
+       char *f;
        int i;
 
        if (p==0)
@@ -768,10 +835,11 @@ formconversion(p,tp) register char *p; register token_p tp; {
        return(strlookup(buf));
 }
 
-setfields(tp,format) register token_p tp; string format; {
-       register i;
+void setfields(token_p tp, string format)
+{
+       int i;
        list2 ll;
-       register list1 l;
+       list1 l;
        int type;
 
        for(i=0;i<TOKENSIZE-1;i++)
@@ -796,18 +864,20 @@ setfields(tp,format) register token_p tp; string format; {
                tp->t_format = -1;
 }
 
-chkregexp(number) {
-       register i;
+void chkregexp(int number)
+{
+       int i;
 
        for(i=nmachregs+1;i<nmachregs+1+nmachtokens;i++)
                if(machsets[number].set_val[i>>4]&(01<<(i&017)))
                        yyerror("No tokens allowed in this set");
 }
 
-findstructel(number,name,t) string name; int *t; {
-       register i;
-       register token_p tp;
-       register list2 structdecl;
+int findstructel(int number, string name, int *t)
+{
+       int i;
+       token_p tp;
+       list2 structdecl;
        int offset;
 
        for(i=1;i<=nmachregs;i++)
@@ -839,8 +909,8 @@ findstructel(number,name,t) string name; int *t; {
 
 extern char em_flag[];
 
-argtyp(mn) {
-
+int argtyp(int mn)
+{
        switch(em_flag[mn-sp_fmnem]&EM_PAR) {
        case PAR_W:
        case PAR_S:
@@ -857,8 +927,8 @@ argtyp(mn) {
        }
 }
 
-commontype(e1,e2) expr_t e1,e2; {
-
+int commontype(expr_t e1, expr_t e2)
+{
        if(e1.expr_typ != e2.expr_typ)
                yyerror("Type incompatibility");
        return(e1.expr_typ);
@@ -873,15 +943,17 @@ struct hashmnem {
        byte h_value;
 } hashmnem[HASHSIZE];
 
-inithash() {
-       register i;
+void inithash()
+{
+       int i;
 
        for(i=0;i<=sp_lmnem-sp_fmnem;i++)
                enter(em_mnem[i],i+sp_fmnem);
 }
 
-enter(name,value) char *name; {
-       register unsigned h;
+void enter(char *name, int value)
+{
+       unsigned int h;
 
        h=hash(name)%HASHSIZE;
        while (hashmnem[h].h_name[0] != 0)
@@ -890,8 +962,9 @@ enter(name,value) char *name; {
        hashmnem[h].h_value = value;
 }
 
-int mlookup(name) char *name; {
-       register unsigned h;
+int mlookup(char *name)
+{
+       unsigned int h;
 
        h = hash(name)%HASHSIZE;
        while (strncmp(hashmnem[h].h_name,name,3) != 0 &&
@@ -900,10 +973,11 @@ int mlookup(name) char *name; {
        return(hashmnem[h].h_value&BMASK);      /* 0 if not found */
 }
 
-hashpatterns() {
+void hashpatterns()
+{
        short index;
-       register byte *bp,*tp;
-       register short i;
+       byte *bp,*tp;
+       short i;
        unsigned short hashvalue;
        int patlen;
 
@@ -937,18 +1011,19 @@ hashpatterns() {
        }
 }
 
-debug() {
-       register i,j;
+void debug()
+{
+       int i,j;
 
        for(i=0;i<ITABSIZE;i++) {
-               register ident_p ip;
+               ident_p ip;
                for(ip=identtab[i];ip!=0;ip=ip->i_next)
                        printf("%-14s %1d %3d\n",ip->i_name,
                                ip->i_type,ip->i_i.i_regno);
        }
 
        for(i=2;i<nmachregs;i++) {
-               register reginfo rp;
+               reginfo rp;
 
                rp=machregs[i];
                printf("%s = (\"%s\", %d",rp->rname,rp->rrepr,rp->rsize);
@@ -963,8 +1038,8 @@ debug() {
        }
 }
 
-out(n) {
-
+void out(int n)
+{
        assert(n>=0);
        if (n<128)
                outbyte(n);
@@ -974,14 +1049,14 @@ out(n) {
        }
 }
 
-outbyte(n) {
-
+void outbyte(int n)
+{
        fprintf(cfile,"%d, ",n&BMASK);
        codebytes++;
 }
 
-pat(n) {
-
+void pat(int n)
+{
        assert(n>=0);
        if (n<128)
                patbyte(n);
@@ -991,20 +1066,20 @@ pat(n) {
        }
 }
 
-patshort(n) {
-
+void patshort(int n)
+{
        patbyte(n&BMASK);
        patbyte(n>>BSHIFT);
 }
 
-patbyte(n) {
-
+void patbyte(int n)
+{
        chktabsiz(npatbytes,MAXPATTERN,"Pattern table");
        pattern[npatbytes++] = n;
 }
 
-max(a,b) {
-
+int max(int a, int b)
+{
        if (a>b)
                return(a);
        return(b);
index 61e2ac8..5f829ab 100644 (file)
@@ -5,6 +5,7 @@
  */
 /* PREPROCESSOR: INITIALIZATION ROUTINES */
 
+#include       <string.h>
 #include       <system.h>
 #include       <alloc.h>
 #include       "class.h"
@@ -12,7 +13,7 @@
 #include       "idf.h"
 #include       "interface.h"
 
-PRIVATE struct mkey    {
+static struct mkey     {
        char *mk_reserved;
        int mk_key;
 } mkey[] =     {
@@ -30,10 +31,7 @@ PRIVATE struct mkey  {
        {0,             K_UNKNOWN}
 };
 
-char *strcpy();
-
-EXPORT
-init_pp()
+void init_pp()
 {
        long clock, sys_time();
        static char date[30];
index 4ab5f48..3a42ac5 100644 (file)
@@ -15,10 +15,9 @@ struct file_info     finfo;
 #include <inp_pkg.body>
 #include <alloc.h>
 
-char * getwdir(char *fn)
+char *getwdir(char *fn)
 {
-       register char *p;
-       char *strrchr();
+       char *p;
 
        p = strrchr(fn, '/');
        while (p && *(p + 1) == '\0') { /* remove trailing /'s */
@@ -42,7 +41,7 @@ int   NoUnstack;
 int    Unstacked;
 int    InputLevel;
 
-AtEoIT()
+int AtEoIT()
 {
        /* if (NoUnstack) warning("unexpected EOF"); ??? */
        /* This is wrong; in an #elif, NoUnstack can be set, but you
@@ -53,7 +52,7 @@ AtEoIT()
        return 0;
 }
 
-AtEoIF()
+int AtEoIF()
 {
        extern int nestlevel;
        extern int nestcount;
index 6cc8bbb..1e16b92 100644 (file)
@@ -3,6 +3,6 @@
  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  * See the copyright notice in the ACK home directory, in the file "Copyright".
  */
-#define PRIVATE        
+#define PRIVATE
 #define IMPORT extern
 #define EXPORT
index 3d9d347..0bf2aaf 100644 (file)
@@ -6,6 +6,7 @@
 /* MAIN PROGRAM */
 
 #include <stdlib.h>
+#include <string.h>
 #include <alloc.h>
 #include <em_arith.h>
 #include <assert.h>
@@ -26,13 +27,16 @@ static File *dep_fd = STDOUT;
 
 arith ifval;
 
+void compile(int argc, char *argv[]);
+void list_dependencies(char *source);
+void dependency(char *s, char *source);
+
 char *prog_name;
 
 extern char **inctable;
 extern int inc_max, inc_total;
 
-main(argc, argv)
-       char *argv[];
+int main(int argc, char *argv[])
 {
        /* parse and interpret the command line options */
        prog_name = argv[0];
@@ -61,10 +65,10 @@ main(argc, argv)
        }
        compile(argc - 1, &argv[1]);
        exit(err_occurred);
+       return 0;
 }
 
-compile(argc, argv)
-       char *argv[];
+void compile(int argc, char *argv[])
 {
        register char *source = 0;
        char *dummy;
@@ -93,10 +97,8 @@ compile(argc, argv)
 }
 
 struct idf     *file_head;
-extern char *strrchr();
 
-list_dependencies(source)
-       char *source;
+void list_dependencies(char *source)
 {
        register struct idf *p = file_head;
 
@@ -111,7 +113,7 @@ list_dependencies(source)
                          * object generated, so don't include the pathname
                          * leading to it.
                          */
-                        if (s = strrchr(source, '/')) {
+                        if ( (s = strrchr(source, '/')) ) {
                                 source = s + 1;
                         }
                }
@@ -127,8 +129,7 @@ list_dependencies(source)
        }
 }
 
-add_dependency(s)
-       char *s;
+void add_dependency(char *s)
 {
        register struct idf *p = str2idf(s, 0);
 
@@ -139,8 +140,7 @@ add_dependency(s)
        }
 }
 
-dependency(s, source)
-       char *s, *source;
+void dependency(char *s, char *source)
 {
        if (options['i'] && !strncmp(s, "/usr/include/", 13)) {
                return;
index 1d66d69..218eb49 100644 (file)
@@ -23,10 +23,9 @@ char **inctable;
 char *dep_file = 0;
 
 extern int idfsize;
-int txt2int();
+int txt2int(char **tp);
 
-do_option(text)
-       char *text;
+void do_option(char *text)
 {
        switch(*text++) {
        case '-':
@@ -130,9 +129,7 @@ do_option(text)
        }
 }
 
-int
-txt2int(tp)
-       char **tp;
+int txt2int(char **tp)
 {
        /*      the integer pointed to by *tp is read, while increasing
                *tp; the resulting value is yielded.
index 5c02de1..5ac8d9b 100644 (file)
@@ -22,12 +22,12 @@ char bits[128];
 char _obuf[OBUFSIZE];
 extern int do_preprocess;
 
-Xflush()
+void Xflush()
 {
        if (do_preprocess) sys_write(STDOUT, _obuf, OBUFSIZE);
 }
 
-preprocess(fn)
+void preprocess(fn)
        char *fn;
 {
        register int c;
index 923b2c9..777b387 100644 (file)
 #include       "class.h"
 #include       "interface.h"
 
-char *strcpy(), *strcat();
-char *long2str();
 extern int InputLevel;
 
-PRIVATE struct mlist *ReplList;        /* list of currently active macros */
+static struct mlist *ReplList; /* list of currently active macros */
+static char *macro2buffer(struct idf *idef, char **actpars, int *siztext);
+static void macro_func(struct idf *idef); 
 
-EXPORT int
-replace(idef)
-       register struct idf *idef;
+
+char *GetIdentifier(); /* domacro.c */
+char **getactuals(struct idf *idef); /* scan.c */
+char *long2str(long value, int base); /* External lib */
+
+int replace(struct idf *idef)
 {
        /*      replace() is called by the lexical analyzer to perform
                macro replacement.  "idef" is the description of the
@@ -41,8 +44,8 @@ replace(idef)
        */
        register struct macro *mac = idef->id_macro;
        register char c;
-       char **actpars, **getactuals();
-       char *reptext, *macro2buffer();
+       char **actpars;
+       char *reptext;
        register struct mlist *repl;
        int size;
 
@@ -79,7 +82,6 @@ replace(idef)
                if (mac->mc_flag & FUNC) {
                        struct idf *param;
                        char *nam;
-                       extern char *GetIdentifier();
 
                        UnknownIdIsZero = 0;
                        nam = GetIdentifier();
@@ -137,9 +139,7 @@ replace(idef)
 
 char FilNamBuf[PATHLENGTH];
 
-PRIVATE
-macro_func(idef)
-       register struct idf *idef;
+static void macro_func(struct idf *idef)
 {
        /*      macro_func() performs the special actions needed with some
                macros.  These macros are __FILE__ and __LINE__ which
@@ -167,11 +167,7 @@ macro_func(idef)
        }
 }
 
-PRIVATE char *
-macro2buffer(idef, actpars, siztext)
-       struct idf *idef;
-       char **actpars;
-       int *siztext;
+static char *macro2buffer(struct idf *idef, char **actpars, int *siztext)
 {
        /*      Macro2buffer() turns the macro replacement text, as it is
                stored, into an input buffer, while each occurrence of the
@@ -214,14 +210,12 @@ macro2buffer(idef, actpars, siztext)
        return Realloc(text, pos+1);
 }
 
-EXPORT
-DoUnstack()
+void DoUnstack()
 {
        Unstacked = 1;
 }
 
-EXPORT
-EnableMacros()
+void EnableMacros()
 {
        register struct mlist *p = ReplList, *prev = 0;
 
index 78c5b22..9b777f6 100644 (file)
 #define        EOS             '\0'
 #define        overflow()      (fatal("actual parameter buffer overflow"))
 
-PRIVATE char apbuf[LAPBUF]; /* temporary storage for actual parameters */
-PRIVATE char *actparams[NPARAMS]; /* pointers to the text of the actuals */
-PRIVATE char *aptr;    /* pointer to last inserted character in apbuf  */
+static char apbuf[LAPBUF]; /* temporary storage for actual parameters  */
+static char *actparams[NPARAMS]; /* pointers to the text of the actuals */
+static char *aptr;     /* pointer to last inserted character in apbuf  */
 
 #define        copy(ch)        ((aptr < &apbuf[LAPBUF]) ? (*aptr++ = ch) : overflow())
 
-PRIVATE int nr_of_params;      /* number of actuals read until now     */
+static int nr_of_params;       /* number of actuals read until now     */
 
-PRIVATE char **
-getactuals(idef)
-       struct idf *idef;
+static void copyact(char ch1, char ch2, int level);
+
+char **getactuals(struct idf *idef)
 {
        /*      getactuals() collects the actual parameters and turns them
                into a list of strings, a pointer to which is returned.
@@ -76,10 +76,7 @@ getactuals(idef)
        return actparams;
 }
 
-PRIVATE
-copyact(ch1, ch2, level)
-       char ch1, ch2;
-       int level;
+static void copyact(char ch1, char ch2, int level)
 {
        /*      copyact() is taken from Ceriel Jacobs' LLgen, with
                permission.  Its task is to build a list of actuals
index 86e9470..7e4dc7e 100644 (file)
@@ -9,9 +9,7 @@
 #include       "class.h"
 #include       "input.h"
 
-int
-skipspaces(ch, skipnl)
-       register int ch;
+int skipspaces(int ch, int skipnl)
 {
        /*      skipspaces() skips any white space and returns the first
                non-space character.
@@ -52,18 +50,18 @@ skipspaces(ch, skipnl)
        }
 }
 
-skipline()
+void skipline()
 {
        /*      skipline() skips all characters until a newline character
                is seen, not escaped by a '\\'.
                Any comment is skipped.
        */
-       register int c;
+       int c;
 
        LoadChar(c);
        while (class(c) != STNL && c != EOI) {
                if (class(c) == STSTR || class(c) == STCHAR) {
-                       register int stopc = c;
+                       int stopc = c;
                        int escaped;
                        do {
                                escaped = 0;