Ansified bin/sed
authorNick Downing <downing.nick@gmail.com>
Sun, 29 Jan 2017 15:53:30 +0000 (02:53 +1100)
committerNick Downing <downing.nick@gmail.com>
Sun, 29 Jan 2017 15:53:30 +0000 (02:53 +1100)
bin/sed/sed.h
bin/sed/sed0.c
bin/sed/sed1.c

index 0d3bb8f..c845218 100644 (file)
@@ -1,3 +1,8 @@
+#ifndef _SED_H_
+#define _SED_H_
+
+#include <stdio.h>
+
 /*     sed.h   4.1     85/04/05        */
 
 /*
@@ -118,7 +123,6 @@ extern struct       re {
        char    negfl;
 } ptrspace[PTRSIZE], *rep;
 
-
 extern char    respace[RESIZE];
 
 extern struct label {
@@ -143,12 +147,47 @@ extern int        depth;
 extern struct re       *pending;
 extern char    *badp;
 extern char    bad;
-char   *compile();
-char   *ycomp();
-char   *address();
-char   *text();
-char   *compsub();
-struct label   *search();
-char   *gline();
-char   *place();
+/*char *compile();*/
+/*char *ycomp();*/
+/*char *address();*/
+/*char *text();*/
+/*char *compsub();*/
+/*struct label *search();*/
+/*char *gline();*/
+/*char *place();*/
 extern char    compfl;
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* sed0.c */
+int main __P((int argc, char *argv[]));
+int fcomp __P((void));
+char *compsub __P((char *rhsbuf));
+char *compile __P((char *expbuf));
+int rline __P((char *lbuf));
+char *address __P((char *expbuf));
+int cmp __P((char *a, char *b));
+char *text __P((char *textbuf));
+struct label *search __P((struct label *ptr));
+int dechain __P((void));
+char *ycomp __P((char *expbuf));
+
+/* sed1.c */
+int execute __P((char *file));
+int match __P((char *expbuf, int gf));
+int advance __P((char *alp, char *aep));
+int substitute __P((struct re *ipc));
+int dosub __P((char *rhsbuf));
+char *place __P((char *asp, char *al1, char *al2));
+int command __P((struct re *ipc));
+char *gline __P((char *addr));
+int ecmp __P((char *a, char *b, int count));
+int arout __P((void));
+
+#endif
index 925784c..96df990 100644 (file)
@@ -1,7 +1,10 @@
+/*#include <stdio.h> sed.h*/
+#include "sed.h"
+
 /*     sed0.c  4.2     85/06/19        */
 
-#include <stdio.h>
-#include "sed.h"
+/*#include <stdio.h>*/
+/*#include "sed.h"*/
 
 /* moved here from sed.h, which now just declares them extern */
 FILE   *fin;
@@ -85,9 +88,7 @@ char  bittab[]  = {
                128
        };
 
-main(argc, argv)
-char   *argv[];
-{
+int main(argc, argv) int argc; char *argv[]; {
 
        eargc = argc;
        eargv = argv;
@@ -114,7 +115,6 @@ char        *argv[];
        if(eargc == 1)
                exit(0);
 
-
        while (--eargc > 0 && (++eargv)[0][0] == '-')
                switch (eargv[0][1]) {
 
@@ -149,7 +149,6 @@ char        *argv[];
                        continue;
                }
 
-
        if(compfl == 0) {
                eargv--;
                eargc++;
@@ -179,8 +178,7 @@ char        *argv[];
        fclose(stdout);
        exit(0);
 }
-fcomp()
-{
+int fcomp() {
 
        register char   *p, *op, *tp;
        char    *address();
@@ -316,7 +314,6 @@ swit:
                                while(*cp++ == ' ');
                                cp--;
 
-
                                tp = lab->asc;
                                while((*tp++ = *cp++))
                                        if(tp >= &(lab->asc[8])) {
@@ -631,9 +628,7 @@ done:
        rep->command = 0;
        lastre = op;
 }
-char   *compsub(rhsbuf)
-char   *rhsbuf;
-{
+char *compsub(rhsbuf) char *rhsbuf; {
        register char   *p, *q;
 
        p = rhsbuf;
@@ -658,9 +653,7 @@ char        *rhsbuf;
        }
 }
 
-char *compile(expbuf)
-char   *expbuf;
-{
+char *compile(expbuf) char *expbuf; {
        register c;
        register char *ep, *sp;
        char    neg;
@@ -819,9 +812,7 @@ char        *expbuf;
                }
        }
 }
-rline(lbuf)
-char   *lbuf;
-{
+int rline(lbuf) char *lbuf; {
        register char   *p, *q;
        register        t;
        static char     *saveq;
@@ -886,9 +877,7 @@ char        *lbuf;
        return(-1);
 }
 
-char   *address(expbuf)
-char   *expbuf;
-{
+char *address(expbuf) char *expbuf; {
        register char   *rcp;
        long    lno;
 
@@ -925,9 +914,7 @@ char        *expbuf;
        }
        return(0);
 }
-cmp(a, b)
-char   *a,*b;
-{
+int cmp(a, b) char *a; char *b; {
        register char   *ra, *rb;
 
        ra = a - 1;
@@ -938,9 +925,7 @@ char        *a,*b;
        return(1);
 }
 
-char   *text(textbuf)
-char   *textbuf;
-{
+char *text(textbuf) char *textbuf; {
        register char   *p, *q;
 
        p = textbuf;
@@ -961,10 +946,7 @@ char       *textbuf;
        }
 }
 
-
-struct label   *search(ptr)
-struct label   *ptr;
-{
+struct label *search(ptr) struct label *ptr; {
        struct label    *rp;
 
        rp = labtab;
@@ -977,9 +959,7 @@ struct label        *ptr;
        return(0);
 }
 
-
-dechain()
-{
+int dechain() {
        struct label    *lptr;
        struct re       *rptr, *trptr;
 
@@ -1001,9 +981,7 @@ dechain()
        }
 }
 
-char *ycomp(expbuf)
-char   *expbuf;
-{
+char *ycomp(expbuf) char *expbuf; {
        register char   c, *ep, *tsp;
        char    *sp;
 
index c84b63f..26bbe14 100644 (file)
@@ -1,7 +1,11 @@
+/*#include <stdio.h> sed.h*/
+#include <sys/file.h>
+#include "sed.h"
+
 /*     sed1.c  4.2     85/04/05        */
 
-#include       <stdio.h>
-#include "sed.h"
+/*#include     <stdio.h>*/
+/*#include "sed.h"*/
 
 char   *trans[040]  = {
        "\\01",
@@ -38,9 +42,7 @@ char  *trans[040]  = {
 };
 char   rub[] = {"\177"};
 
-execute(file)
-char *file;
-{
+int execute(file) char *file; {
        register char *p1, *p2;
        register struct re      *ipc;
        int     c;
@@ -157,9 +159,7 @@ char *file;
 
        }
 }
-match(expbuf, gf)
-char   *expbuf;
-{
+int match(expbuf, gf) char *expbuf; int gf; {
        register char   *p1, *p2, c;
 
        if(gf) {
@@ -204,9 +204,7 @@ char        *expbuf;
        } while(*p1++);
        return(0);
 }
-advance(alp, aep)
-char   *alp, *aep;
-{
+int advance(alp, aep) char *alp; char *aep; {
        register char *lp, *ep, *curlp;
        char    c;
        char *bbeg;
@@ -277,7 +275,6 @@ char        *alp, *aep;
                }
                return(0);
 
-
        case CDOT|STAR:
                curlp = lp;
                while (*lp++);
@@ -335,9 +332,7 @@ char        *alp, *aep;
                fprintf(stderr, "RE botch, %o\n", *--ep);
        }
 }
-substitute(ipc)
-struct re      *ipc;
-{
+int substitute(ipc) struct re *ipc; {
        if(match(ipc->re1, 0) == 0)     return(0);
 
        sflag = 1;
@@ -352,9 +347,7 @@ struct re   *ipc;
        return(1);
 }
 
-dosub(rhsbuf)
-char   *rhsbuf;
-{
+int dosub(rhsbuf) char *rhsbuf; {
        register char *lp, *sp, *rp;
        int c;
 
@@ -386,9 +379,7 @@ char        *rhsbuf;
        while (*lp++ = *sp++);
        spend = lp-1;
 }
-char   *place(asp, al1, al2)
-char   *asp, *al1, *al2;
-{
+char *place(asp, al1, al2) char *asp; char *al1; char *al2; {
        register char *sp, *l1, *l2;
 
        sp = asp;
@@ -402,14 +393,11 @@ char      *asp, *al1, *al2;
        return(sp);
 }
 
-command(ipc)
-struct re      *ipc;
-{
+int command(ipc) struct re *ipc; {
        register int    i;
        register char   *p1, *p2, *p3;
        char    *execp;
 
-
        switch(ipc->command) {
 
                case ACOM:
@@ -644,10 +632,7 @@ struct re  *ipc;
 
 }
 
-char   *
-gline(addr)
-char   *addr;
-{
+char *gline(addr) char *addr; {
        register char   *p1, *p2;
        register        c;
        p1 = addr;
@@ -683,16 +668,13 @@ char      *addr;
 
        return(p1);
 }
-ecmp(a, b, count)
-char   *a, *b;
-{
+int ecmp(a, b, count) char *a; char *b; int count; {
        while(count--)
                if(*a++ != *b++)        return(0);
        return(1);
 }
 
-arout()
-{
+int arout() {
        register char   *p1;
        FILE    *fi;
        char    c;
@@ -717,4 +699,3 @@ arout()
        aptr = abuf;
        *aptr = 0;
 }
-