summaryrefslogtreecommitdiffstats
path: root/contrib/one-true-awk/run.c
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-06-03 21:23:11 +0000
committerpfg <pfg@FreeBSD.org>2016-06-03 21:23:11 +0000
commitf3c56b202ca8991518d5a34f9b5fbcb3e19e3de4 (patch)
tree023f875bc1740ed25d4ef1e5d4305950cb94027f /contrib/one-true-awk/run.c
parentf727892517784f5b9c91124b39142b939b54acc5 (diff)
downloadFreeBSD-src-f3c56b202ca8991518d5a34f9b5fbcb3e19e3de4.zip
FreeBSD-src-f3c56b202ca8991518d5a34f9b5fbcb3e19e3de4.tar.gz
MFV r300961:
one-true-awk: replace 0 with NULL for pointers Also remove a redundant semicolon.
Diffstat (limited to 'contrib/one-true-awk/run.c')
-rw-r--r--contrib/one-true-awk/run.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/contrib/one-true-awk/run.c b/contrib/one-true-awk/run.c
index 2bcd9df..1e5f1c2 100644
--- a/contrib/one-true-awk/run.c
+++ b/contrib/one-true-awk/run.c
@@ -502,7 +502,7 @@ Cell *awkdelete(Node **a, int n) /* a[0] is symtab, a[1] is list of subscripts *
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;
@@ -586,7 +586,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 */
@@ -702,7 +702,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;
@@ -737,18 +737,18 @@ Cell *substr(Node **a, int nnn) /* substr(a[0], a[1], a[2]) */
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();
@@ -761,7 +761,7 @@ Cell *substr(Node **a, int nnn) /* substr(a[0], a[1], a[2]) */
else if (m > k)
m = k;
tempfree(y);
- if (a[2] != 0) {
+ if (a[2] != NULL) {
n = (int) getfval(z);
tempfree(z);
} else
@@ -1175,7 +1175,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]);
@@ -1212,16 +1212,16 @@ 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;
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]);
@@ -1340,7 +1340,7 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */
tempfree(ap);
tempfree(y);
free(origs);
- if (a[2] != 0 && arg3type == STRING) {
+ if (a[2] != NULL && arg3type == STRING) {
tempfree(x);
}
x = gettemp();
@@ -1372,7 +1372,7 @@ Cell *ifstat(Node **a, int n) /* if (a[0]) a[1]; else a[2] */
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]);
}
@@ -1424,7 +1424,7 @@ Cell *forstat(Node **a, int n) /* for (a[0]; a[1]; a[2]) a[3] */
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);
@@ -1506,7 +1506,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis
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 {
@@ -1569,7 +1569,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis
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);
@@ -1583,7 +1583,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]);
@@ -1596,7 +1596,7 @@ Cell *printstat(Node **a, int n) /* print a[0] */
else
fputs(*OFS, fp);
}
- if (a[1] != 0)
+ if (a[1] != NULL)
fflush(fp);
if (ferror(fp))
FATAL("write error on %s", filename(fp));
@@ -1655,7 +1655,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");
@@ -1670,7 +1670,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;
@@ -1787,7 +1787,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]);
@@ -1827,7 +1827,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);
@@ -1850,7 +1850,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]);
OpenPOWER on IntegriCloud