From owner-svn-src-head@freebsd.org Sun Jun 2 16:28:23 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0405C15B99E4; Sun, 2 Jun 2019 16:28:23 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9743B6E5BF; Sun, 2 Jun 2019 16:28:22 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 556942969E; Sun, 2 Jun 2019 16:28:22 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x52GSMeb041017; Sun, 2 Jun 2019 16:28:22 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x52GSLT6041011; Sun, 2 Jun 2019 16:28:21 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201906021628.x52GSLT6041011@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sun, 2 Jun 2019 16:28:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348512 - head/contrib/one-true-awk X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/contrib/one-true-awk X-SVN-Commit-Revision: 348512 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9743B6E5BF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.945,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jun 2019 16:28:23 -0000 Author: imp Date: Sun Jun 2 16:28:20 2019 New Revision: 348512 URL: https://svnweb.freebsd.org/changeset/base/348512 Log: Reapply r301289 by pfg: | MFV r300961: one-true-awk: replace 0 with NULL for pointers | Also remove a redundant semicolon. | Also had to rebase on upstream pull. Modified: head/contrib/one-true-awk/b.c head/contrib/one-true-awk/lex.c head/contrib/one-true-awk/maketab.c head/contrib/one-true-awk/parse.c head/contrib/one-true-awk/run.c head/contrib/one-true-awk/tran.c Modified: head/contrib/one-true-awk/b.c ============================================================================== --- head/contrib/one-true-awk/b.c Sun Jun 2 16:25:07 2019 (r348511) +++ head/contrib/one-true-awk/b.c Sun Jun 2 16:28:20 2019 (r348512) @@ -91,11 +91,11 @@ fa *makedfa(const char *s, int anchor) /* returns dfa 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"); } @@ -317,11 +317,11 @@ char *cclenter(const char *argp) /* add a character cl int j; 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; ) { @@ -380,7 +380,7 @@ void cfoll(fa *f, Node *v) /* enter follow set of each 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++) @@ -421,7 +421,7 @@ int first(Node *p) /* collects initially active leaves 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) { @@ -923,7 +923,7 @@ int relex(void) /* lexical analyzer for reparse */ { int c, n; int cflag; - static uschar *buf = 0; + static uschar *buf = NULL; static int bufsz = 100; uschar *bp; struct charclass *cc; @@ -953,7 +953,7 @@ rescan: 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 == '^') { @@ -1129,7 +1129,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++) @@ -1151,7 +1151,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: head/contrib/one-true-awk/lex.c ============================================================================== --- head/contrib/one-true-awk/lex.c Sun Jun 2 16:25:07 2019 (r348511) +++ head/contrib/one-true-awk/lex.c Sun Jun 2 16:28:20 2019 (r348512) @@ -176,10 +176,10 @@ int reg = 0; /* 1 => return a REGEXPR now */ 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; @@ -366,10 +366,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")) @@ -513,11 +513,11 @@ void startreg(void) /* next call to yylex will return 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; ) { @@ -549,7 +549,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: head/contrib/one-true-awk/maketab.c ============================================================================== --- head/contrib/one-true-awk/maketab.c Sun Jun 2 16:25:07 2019 (r348511) +++ head/contrib/one-true-awk/maketab.c Sun Jun 2 16:28:20 2019 (r348512) @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) table[p->token-FIRSTTOKEN] = p->name; printf("\nCell *(*proctab[%d])(Node **, int) = {\n", SIZE); for (i=0; innext, n++) + for (n = 0; p != NULL; p = p->nnext, n++) if (strcmp(((Cell *)(p->narg[0]))->nval, s) == 0) return n; return -1; Modified: head/contrib/one-true-awk/run.c ============================================================================== --- head/contrib/one-true-awk/run.c Sun Jun 2 16:25:07 2019 (r348511) +++ head/contrib/one-true-awk/run.c Sun Jun 2 16:28:20 2019 (r348512) @@ -517,7 +517,7 @@ Cell *awkdelete(Node **a, int n) /* a[0] is symtab, a[ 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; @@ -603,7 +603,7 @@ Cell *matchop(Node **a, int n) /* ~ and match() */ } 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 */ @@ -719,7 +719,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; @@ -754,18 +754,18 @@ Cell *substr(Node **a, int nnn) /* substr(a[0], a[1], 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(); @@ -778,7 +778,7 @@ Cell *substr(Node **a, int nnn) /* substr(a[0], a[1], else if (m > k) m = k; tempfree(y); - if (a[2] != 0) { + if (a[2] != NULL) { n = (int) getfval(z); tempfree(z); } else @@ -1219,7 +1219,7 @@ Cell *pastat(Node **a, int n) /* a[0] { a[1] } */ { Cell *x; - if (a[0] == 0) + if (a[0] == NULL) x = execute(a[1]); else { x = execute(a[0]); @@ -1256,9 +1256,9 @@ Cell *dopa2(Node **a, int n) /* a[0], a[1] { a[2] } */ 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; - char *fs, *origfs = NULL; + char *fs = NULL, *origfs = NULL; int sep; char *t, temp, num[50]; int n, tempstat, arg3type; @@ -1266,8 +1266,8 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[ y = execute(a[0]); /* source string */ origs = s = strdup(getsval(y)); arg3type = ptoi(a[3]); - if (a[2] == 0) /* fs string */ - fs = getsval(fsloc); + if (a[2] == NULL) /* fs string */ + fs = *FS; else if (arg3type == STRING) { /* split(str,arr,"string") */ x = execute(a[2]); origfs = fs = strdup(getsval(x)); @@ -1387,6 +1387,9 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[ tempfree(y); free(origs); free(origfs); + if (a[2] != NULL && arg3type == STRING) { + tempfree(x); + } x = gettemp(); x->tval = NUM; x->fval = n; @@ -1416,7 +1419,7 @@ Cell *ifstat(Node **a, int n) /* if (a[0]) a[1]; else 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]); } @@ -1468,7 +1471,7 @@ Cell *forstat(Node **a, int n) /* for (a[0]; a[1]; a[2 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); @@ -1551,7 +1554,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0 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 { @@ -1697,7 +1700,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0 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); @@ -1711,7 +1714,7 @@ Cell *printstat(Node **a, int n) /* print a[0] */ 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]); @@ -1724,7 +1727,7 @@ Cell *printstat(Node **a, int n) /* print a[0] */ else fputs(getsval(ofsloc), fp); } - if (a[1] != 0) + if (a[1] != NULL) fflush(fp); if (ferror(fp)) FATAL("write error on %s", filename(fp)); @@ -1781,7 +1784,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"); @@ -1796,7 +1799,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; @@ -1912,7 +1915,7 @@ Cell *sub(Node **a, int nnn) /* substitute command */ 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]); @@ -1952,7 +1955,7 @@ Cell *sub(Node **a, int nnn) /* substitute command */ 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); @@ -1975,7 +1978,7 @@ Cell *gsub(Node **a, int nnn) /* global substitute */ 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: head/contrib/one-true-awk/tran.c ============================================================================== --- head/contrib/one-true-awk/tran.c Sun Jun 2 16:25:07 2019 (r348511) +++ head/contrib/one-true-awk/tran.c Sun Jun 2 16:28:20 2019 (r348512) @@ -194,7 +194,7 @@ void freesymtab(Cell *ap) /* free a symbol table */ 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);