Author: pfg
Date: Sun May 29 16:18:55 2016
New Revision: 300961
URL: https://svnweb.freebsd.org/changeset/base/300961

Log:
  one-true-awk: replace 0 with NULL for pointers
  
  Also remove a redundant semicolon.
  Submitted upstream already.

Modified:
  vendor/one-true-awk/dist/b.c
  vendor/one-true-awk/dist/lex.c
  vendor/one-true-awk/dist/maketab.c
  vendor/one-true-awk/dist/parse.c
  vendor/one-true-awk/dist/run.c
  vendor/one-true-awk/dist/tran.c

Modified: vendor/one-true-awk/dist/b.c
==============================================================================
--- vendor/one-true-awk/dist/b.c        Sun May 29 16:10:01 2016        
(r300960)
+++ vendor/one-true-awk/dist/b.c        Sun May 29 16:18:55 2016        
(r300961)
@@ -82,11 +82,11 @@ fa *makedfa(const char *s, int anchor)      /
        fa *pfa;
        static int now = 1;
 
-       if (setvec == 0) {      /* first time through any RE */
+       if (setvec == NULL) {   /* first time through any RE */
                maxsetvec = MAXLIN;
                setvec = (int *) malloc(maxsetvec * sizeof(int));
                tmpset = (int *) malloc(maxsetvec * sizeof(int));
-               if (setvec == 0 || tmpset == 0)
+               if (setvec == NULL || tmpset == NULL)
                        overflo("out of space initializing makedfa");
        }
 
@@ -290,11 +290,11 @@ char *cclenter(const char *argp)  /* add 
        int i, c, c2;
        uschar *p = (uschar *) argp;
        uschar *op, *bp;
-       static uschar *buf = 0;
+       static uschar *buf = NULL;
        static int bufsz = 100;
 
        op = p;
-       if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
+       if (buf == NULL && (buf = (uschar *) malloc(bufsz)) == NULL)
                FATAL("out of space for character class [%.10s...] 1", p);
        bp = buf;
        for (i = 0; (c = *p++) != 0; ) {
@@ -350,7 +350,7 @@ void cfoll(fa *f, Node *v)  /* enter foll
                        maxsetvec *= 4;
                        setvec = (int *) realloc(setvec, maxsetvec * 
sizeof(int));
                        tmpset = (int *) realloc(tmpset, maxsetvec * 
sizeof(int));
-                       if (setvec == 0 || tmpset == 0)
+                       if (setvec == NULL || tmpset == NULL)
                                overflo("out of space in cfoll()");
                }
                for (i = 0; i <= f->accept; i++)
@@ -391,7 +391,7 @@ int first(Node *p)  /* collects initially
                        maxsetvec *= 4;
                        setvec = (int *) realloc(setvec, maxsetvec * 
sizeof(int));
                        tmpset = (int *) realloc(tmpset, maxsetvec * 
sizeof(int));
-                       if (setvec == 0 || tmpset == 0)
+                       if (setvec == NULL || tmpset == NULL)
                                overflo("out of space in first()");
                }
                if (type(p) == EMPTYRE) {
@@ -770,7 +770,7 @@ int relex(void)             /* lexical analyzer for
 {
        int c, n;
        int cflag;
-       static uschar *buf = 0;
+       static uschar *buf = NULL;
        static int bufsz = 100;
        uschar *bp;
        struct charclass *cc;
@@ -795,7 +795,7 @@ int relex(void)             /* lexical analyzer for
                rlxval = c;
                return CHAR;
        case '[': 
-               if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
+               if (buf == NULL && (buf = (uschar *) malloc(bufsz)) == NULL)
                        FATAL("out of space in reg expr %.10s..", lastre);
                bp = buf;
                if (*prestr == '^') {
@@ -860,7 +860,7 @@ int cgoto(fa *f, int s, int c)
                maxsetvec *= 4;
                setvec = (int *) realloc(setvec, maxsetvec * sizeof(int));
                tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int));
-               if (setvec == 0 || tmpset == 0)
+               if (setvec == NULL || tmpset == NULL)
                        overflo("out of space in cgoto()");
        }
        for (i = 0; i <= f->accept; i++)
@@ -882,7 +882,7 @@ int cgoto(fa *f, int s, int c)
                                                maxsetvec *= 4;
                                                setvec = (int *) 
realloc(setvec, maxsetvec * sizeof(int));
                                                tmpset = (int *) 
realloc(tmpset, maxsetvec * sizeof(int));
-                                               if (setvec == 0 || tmpset == 0)
+                                               if (setvec == NULL || tmpset == 
NULL)
                                                        overflo("cgoto 
overflow");
                                        }
                                        if (setvec[q[j]] == 0) {

Modified: vendor/one-true-awk/dist/lex.c
==============================================================================
--- vendor/one-true-awk/dist/lex.c      Sun May 29 16:10:01 2016        
(r300960)
+++ vendor/one-true-awk/dist/lex.c      Sun May 29 16:18:55 2016        
(r300961)
@@ -170,10 +170,10 @@ int       reg     = 0;    /* 1 => return a REGEXPR no
 int yylex(void)
 {
        int c;
-       static char *buf = 0;
+       static char *buf = NULL;
        static int bufsize = 5; /* BUG: setting this small causes core dump! */
 
-       if (buf == 0 && (buf = (char *) malloc(bufsize)) == NULL)
+       if (buf == NULL && (buf = (char *) malloc(bufsize)) == NULL)
                FATAL( "out of space in yylex" );
        if (sc) {
                sc = 0;
@@ -358,10 +358,10 @@ int string(void)
 {
        int c, n;
        char *s, *bp;
-       static char *buf = 0;
+       static char *buf = NULL;
        static int bufsz = 500;
 
-       if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL)
+       if (buf == NULL && (buf = (char *) malloc(bufsz)) == NULL)
                FATAL("out of space for strings");
        for (bp = buf; (c = input()) != '"'; ) {
                if (!adjbuf(&buf, &bufsz, bp-buf+2, 500, &bp, "string"))
@@ -504,11 +504,11 @@ void startreg(void)       /* next call to yyle
 int regexpr(void)
 {
        int c;
-       static char *buf = 0;
+       static char *buf = NULL;
        static int bufsz = 500;
        char *bp;
 
-       if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL)
+       if (buf == NULL && (buf = (char *) malloc(bufsz)) == NULL)
                FATAL("out of space for rex expr");
        bp = buf;
        for ( ; (c = input()) != '/' && c != 0; ) {
@@ -539,7 +539,7 @@ char        ebuf[300];
 char   *ep = ebuf;
 char   yysbuf[100];    /* pushback buffer */
 char   *yysptr = yysbuf;
-FILE   *yyin = 0;
+FILE   *yyin = NULL;
 
 int input(void)        /* get next lexical input character */
 {

Modified: vendor/one-true-awk/dist/maketab.c
==============================================================================
--- vendor/one-true-awk/dist/maketab.c  Sun May 29 16:10:01 2016        
(r300960)
+++ vendor/one-true-awk/dist/maketab.c  Sun May 29 16:18:55 2016        
(r300961)
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
                table[p->token-FIRSTTOKEN] = p->name;
        printf("\nCell *(*proctab[%d])(Node **, int) = {\n", SIZE);
        for (i=0; i<SIZE; i++)
-               if (table[i]==0)
+               if (table[i]==NULL)
                        printf("\tnullproc,\t/* %s */\n", names[i]);
                else
                        printf("\t%s,\t/* %s */\n", table[i], names[i]);

Modified: vendor/one-true-awk/dist/parse.c
==============================================================================
--- vendor/one-true-awk/dist/parse.c    Sun May 29 16:10:01 2016        
(r300960)
+++ vendor/one-true-awk/dist/parse.c    Sun May 29 16:18:55 2016        
(r300961)
@@ -259,7 +259,7 @@ int isarg(const char *s)            /* is s in arg
        Node *p = arglist;
        int n;
 
-       for (n = 0; p != 0; p = p->nnext, n++)
+       for (n = 0; p != NULL; p = p->nnext, n++)
                if (strcmp(((Cell *)(p->narg[0]))->nval, s) == 0)
                        return n;
        return -1;

Modified: vendor/one-true-awk/dist/run.c
==============================================================================
--- vendor/one-true-awk/dist/run.c      Sun May 29 16:10:01 2016        
(r300960)
+++ vendor/one-true-awk/dist/run.c      Sun May 29 16:18:55 2016        
(r300961)
@@ -499,7 +499,7 @@ Cell *awkdelete(Node **a, int n)    /* a[0]
        x = execute(a[0]);      /* Cell* for symbol table */
        if (!isarr(x))
                return True;
-       if (a[1] == 0) {        /* delete the elements, not the table */
+       if (a[1] == NULL) {     /* delete the elements, not the table */
                freesymtab(x);
                x->tval &= ~STR;
                x->tval |= ARR;
@@ -583,7 +583,7 @@ Cell *matchop(Node **a, int n)      /* ~ and 
        }
        x = execute(a[1]);      /* a[1] = target text */
        s = getsval(x);
-       if (a[0] == 0)          /* a[1] == 0: already-compiled reg expr */
+       if (a[0] == NULL)       /* a[1] == 0: already-compiled reg expr */
                i = (*mf)((fa *) a[2], s);
        else {
                y = execute(a[2]);      /* a[2] = regular expr */
@@ -699,7 +699,7 @@ Cell *gettemp(void) /* get a tempcell */
                        FATAL("out of space for temporaries");
                for(i = 1; i < 100; i++)
                        tmps[i-1].cnext = &tmps[i];
-               tmps[i-1].cnext = 0;
+               tmps[i-1].cnext = NULL;
        }
        x = tmps;
        tmps = x->cnext;
@@ -734,18 +734,18 @@ Cell *substr(Node **a, int nnn)           /* subs
        int k, m, n;
        char *s;
        int temp;
-       Cell *x, *y, *z = 0;
+       Cell *x, *y, *z = NULL;
 
        x = execute(a[0]);
        y = execute(a[1]);
-       if (a[2] != 0)
+       if (a[2] != NULL)
                z = execute(a[2]);
        s = getsval(x);
        k = strlen(s) + 1;
        if (k <= 1) {
                tempfree(x);
                tempfree(y);
-               if (a[2] != 0) {
+               if (a[2] != NULL) {
                        tempfree(z);
                }
                x = gettemp();
@@ -758,7 +758,7 @@ Cell *substr(Node **a, int nnn)             /* subs
        else if (m > k)
                m = k;
        tempfree(y);
-       if (a[2] != 0) {
+       if (a[2] != NULL) {
                n = (int) getfval(z);
                tempfree(z);
        } else
@@ -1172,7 +1172,7 @@ Cell *pastat(Node **a, int n)     /* a[0] { 
 {
        Cell *x;
 
-       if (a[0] == 0)
+       if (a[0] == NULL)
                x = execute(a[1]);
        else {
                x = execute(a[0]);
@@ -1209,16 +1209,16 @@ Cell *dopa2(Node **a, int n)    /* a[0], a[
 
 Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */
 {
-       Cell *x = 0, *y, *ap;
+       Cell *x = NULL, *y, *ap;
        char *s, *origs;
        int sep;
-       char *t, temp, num[50], *fs = 0;
+       char *t, temp, num[50], *fs = NULL;
        int n, tempstat, arg3type;
 
        y = execute(a[0]);      /* source string */
        origs = s = strdup(getsval(y));
        arg3type = ptoi(a[3]);
-       if (a[2] == 0)          /* fs string */
+       if (a[2] == NULL)               /* fs string */
                fs = *FS;
        else if (arg3type == STRING) {  /* split(str,arr,"string") */
                x = execute(a[2]);
@@ -1337,7 +1337,7 @@ Cell *split(Node **a, int nnn)    /* split(
        tempfree(ap);
        tempfree(y);
        free(origs);
-       if (a[2] != 0 && arg3type == STRING) {
+       if (a[2] != NULL && arg3type == STRING) {
                tempfree(x);
        }
        x = gettemp();
@@ -1369,7 +1369,7 @@ Cell *ifstat(Node **a, int n)     /* if (a[0
        if (istrue(x)) {
                tempfree(x);
                x = execute(a[1]);
-       } else if (a[2] != 0) {
+       } else if (a[2] != NULL) {
                tempfree(x);
                x = execute(a[2]);
        }
@@ -1421,7 +1421,7 @@ Cell *forstat(Node **a, int n)    /* for (a
        x = execute(a[0]);
        tempfree(x);
        for (;;) {
-               if (a[1]!=0) {
+               if (a[1]!=NULL) {
                        x = execute(a[1]);
                        if (!istrue(x)) return(x);
                        else tempfree(x);
@@ -1503,7 +1503,7 @@ Cell *bltin(Node **a, int n)      /* builtin 
        case FCOS:
                u = cos(getfval(x)); break;
        case FATAN:
-               if (nextarg == 0) {
+               if (nextarg == NULL) {
                        WARNING("atan2 requires two arguments; returning 1.0");
                        u = 1.0;
                } else {
@@ -1564,7 +1564,7 @@ Cell *bltin(Node **a, int n)      /* builtin 
        tempfree(x);
        x = gettemp();
        setfval(x, u);
-       if (nextarg != 0) {
+       if (nextarg != NULL) {
                WARNING("warning: function has too many arguments");
                for ( ; nextarg; nextarg = nextarg->nnext)
                        execute(nextarg);
@@ -1578,7 +1578,7 @@ Cell *printstat(Node **a, int n)  /* prin
        Cell *y;
        FILE *fp;
 
-       if (a[1] == 0)  /* a[1] is redirection operator, a[2] is file */
+       if (a[1] == NULL)       /* a[1] is redirection operator, a[2] is file */
                fp = stdout;
        else
                fp = redirect(ptoi(a[1]), a[2]);
@@ -1591,7 +1591,7 @@ Cell *printstat(Node **a, int n)  /* prin
                else
                        fputs(*OFS, fp);
        }
-       if (a[1] != 0)
+       if (a[1] != NULL)
                fflush(fp);
        if (ferror(fp))
                FATAL("write error on %s", filename(fp));
@@ -1650,7 +1650,7 @@ FILE *openfile(int a, const char *us)
 {
        const char *s = us;
        int i, m;
-       FILE *fp = 0;
+       FILE *fp = NULL;
 
        if (*s == '\0')
                FATAL("null file name in print or getline");
@@ -1665,7 +1665,7 @@ FILE *openfile(int a, const char *us)
                return NULL;
 
        for (i=0; i < nfiles; i++)
-               if (files[i].fp == 0)
+               if (files[i].fp == NULL)
                        break;
        if (i >= nfiles) {
                struct files *nf;
@@ -1782,7 +1782,7 @@ Cell *sub(Node **a, int nnn)      /* substitu
                FATAL("out of memory in sub");
        x = execute(a[3]);      /* target string */
        t = getsval(x);
-       if (a[0] == 0)          /* 0 => a[1] is already-compiled regexpr */
+       if (a[0] == NULL)       /* 0 => a[1] is already-compiled regexpr */
                pfa = (fa *) a[1];      /* regular expression */
        else {
                y = execute(a[1]);
@@ -1822,7 +1822,7 @@ Cell *sub(Node **a, int nnn)      /* substitu
                if (pb > buf + bufsz)
                        FATAL("sub result2 %.30s too big; can't happen", buf);
                setsval(x, buf);        /* BUG: should be able to avoid copy */
-               result = True;;
+               result = True;
        }
        tempfree(x);
        tempfree(y);
@@ -1845,7 +1845,7 @@ Cell *gsub(Node **a, int nnn)     /* global 
        num = 0;
        x = execute(a[3]);      /* target string */
        t = getsval(x);
-       if (a[0] == 0)          /* 0 => a[1] is already-compiled regexpr */
+       if (a[0] == NULL)       /* 0 => a[1] is already-compiled regexpr */
                pfa = (fa *) a[1];      /* regular expression */
        else {
                y = execute(a[1]);

Modified: vendor/one-true-awk/dist/tran.c
==============================================================================
--- vendor/one-true-awk/dist/tran.c     Sun May 29 16:10:01 2016        
(r300960)
+++ vendor/one-true-awk/dist/tran.c     Sun May 29 16:18:55 2016        
(r300961)
@@ -174,7 +174,7 @@ void freesymtab(Cell *ap)   /* free a symb
                        free(cp); 
                        tp->nelem--;
                }
-               tp->tab[i] = 0;
+               tp->tab[i] = NULL;
        }
        if (tp->nelem != 0)
                WARNING("can't happen: inconsistent element count freeing %s", 
ap->nval);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to