summaryrefslogtreecommitdiff
path: root/sys/src/cmd/awk
diff options
context:
space:
mode:
authorben <ben@rana>2016-04-27 08:09:16 -0500
committerben <ben@rana>2016-04-27 08:09:16 -0500
commitb8986a889d7e3a445c0265c5cfb3b1db385db756 (patch)
tree229b8b184610b14e6c5c8f4faba8c1f04fdcc692 /sys/src/cmd/awk
parent85824350b5f65053053245d141aaf7d668089d28 (diff)
use Beof for awk port
Diffstat (limited to 'sys/src/cmd/awk')
-rw-r--r--sys/src/cmd/awk/awk.h2
-rw-r--r--sys/src/cmd/awk/lex.c2
-rw-r--r--sys/src/cmd/awk/lib.c20
-rw-r--r--sys/src/cmd/awk/main.c4
-rw-r--r--sys/src/cmd/awk/run.c4
5 files changed, 15 insertions, 17 deletions
diff --git a/sys/src/cmd/awk/awk.h b/sys/src/cmd/awk/awk.h
index 933b59ea4..2ede5e1cf 100644
--- a/sys/src/cmd/awk/awk.h
+++ b/sys/src/cmd/awk/awk.h
@@ -18,8 +18,6 @@ typedef double Awkfloat;
#define FOPEN_MAX 40 /* max number of open files */
-#define EOF -1
-
extern char errbuf[];
extern int compile_time; /* 1 if compiling, 0 if running */
diff --git a/sys/src/cmd/awk/lex.c b/sys/src/cmd/awk/lex.c
index d01505507..90ecf4245 100644
--- a/sys/src/cmd/awk/lex.c
+++ b/sys/src/cmd/awk/lex.c
@@ -541,7 +541,7 @@ int input(void) /* get next lexical input character */
c = pgetc();
if (c == '\n')
lineno++;
- else if (c == EOF)
+ else if (c == Beof)
c = 0;
if (ep >= ebuf + sizeof ebuf)
ep = ebuf;
diff --git a/sys/src/cmd/awk/lib.c b/sys/src/cmd/awk/lib.c
index fcc8a9529..2d60e3abb 100644
--- a/sys/src/cmd/awk/lib.c
+++ b/sys/src/cmd/awk/lib.c
@@ -154,7 +154,7 @@ int getrec(char **pbuf, int *pbufsize, int isrecord) /* get next input record */
*pbufsize = bufsize;
return 1;
}
- /* EOF arrived on this file; set up next */
+ /* Beof arrived on this file; set up next */
if (infile != &stdin)
Bterm(infile);
infile = nil;
@@ -184,21 +184,21 @@ int readrec(char **pbuf, int *pbufsize, Biobuf *inf) /* read one record into buf
strcpy(inputFS, *FS); /* for subsequent field splitting */
if ((sep = **RS) == 0) {
sep = '\n';
- while ((c=Bgetc(inf)) == '\n' && c != EOF) /* skip leading \n's */
+ while ((c=Bgetc(inf)) == '\n' && c != Beof) /* skip leading \n's */
;
- if (c != EOF)
+ if (c != Beof)
Bungetc(inf);
}
for (rr = buf; ; ) {
- for (; (c=Bgetc(inf)) != sep && c != EOF; ) {
+ for (; (c=Bgetc(inf)) != sep && c != Beof; ) {
if (rr-buf+1 > bufsize)
if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 1"))
FATAL("input record `%.30s...' too long", buf);
*rr++ = c;
}
- if (**RS == sep || c == EOF)
+ if (**RS == sep || c == Beof)
break;
- if ((c = Bgetc(inf)) == '\n' || c == EOF) /* 2 in a row */
+ if ((c = Bgetc(inf)) == '\n' || c == Beof) /* 2 in a row */
break;
if (!adjbuf(&buf, &bufsize, 2+rr-buf, recsize, &rr, "readrec 2"))
FATAL("input record `%.30s...' too long", buf);
@@ -208,10 +208,10 @@ int readrec(char **pbuf, int *pbufsize, Biobuf *inf) /* read one record into buf
if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3"))
FATAL("input record `%.30s...' too long", buf);
*rr = 0;
- dprint( ("readrec saw <%s>, returns %d\n", buf, c == EOF && rr == buf ? 0 : 1) );
+ dprint( ("readrec saw <%s>, returns %d\n", buf, c == Beof && rr == buf ? 0 : 1) );
*pbuf = buf;
*pbufsize = bufsize;
- return c == EOF && rr == buf ? 0 : 1;
+ return c == Beof && rr == buf ? 0 : 1;
}
char *getargv(int n) /* get ARGV[n] */
@@ -512,7 +512,7 @@ void bracecheck(void)
if (beenhere++)
return;
- while ((c = input()) != EOF && c != '\0')
+ while ((c = input()) != Beof && c != '\0')
bclass(c);
bcheck2(bracecnt, '{', '}');
bcheck2(brackcnt, '[', ']');
@@ -618,7 +618,7 @@ void eprint(void) /* try to print context around error */
Bputc(&stderr, *p);
Bprint(&stderr, " <<< ");
if (*ep)
- while ((c = input()) != '\n' && c != '\0' && c != EOF) {
+ while ((c = input()) != '\n' && c != '\0' && c != Beof) {
Bputc(&stderr, c);
bclass(c);
}
diff --git a/sys/src/cmd/awk/main.c b/sys/src/cmd/awk/main.c
index 9f7899ea0..3d1ae4e0d 100644
--- a/sys/src/cmd/awk/main.c
+++ b/sys/src/cmd/awk/main.c
@@ -177,14 +177,14 @@ int pgetc(void) /* get 1 character from awk program */
for (;;) {
if (yyin == nil) {
if (curpfile >= npfile)
- return EOF;
+ return Beof;
if (strcmp(pfile[curpfile], "-") == 0)
yyin = &stdin;
else if ((yyin = Bopen(pfile[curpfile], OREAD)) == nil)
FATAL("can't open file %s", pfile[curpfile]);
lineno = 1;
}
- if ((c = Bgetc(yyin)) != EOF)
+ if ((c = Bgetc(yyin)) != Beof)
return c;
if (yyin != &stdin)
Bterm(yyin);
diff --git a/sys/src/cmd/awk/run.c b/sys/src/cmd/awk/run.c
index 1bf47a31f..6cf84394e 100644
--- a/sys/src/cmd/awk/run.c
+++ b/sys/src/cmd/awk/run.c
@@ -1618,7 +1618,7 @@ Cell *bltin(Node **a, int) /* builtin functions. a[0] is type, a[1] is arg list
flush_all(); /* fflush() or fflush("") -> all */
u = 0;
} else if ((fp = openfile(FFLUSH, getsval(x))) == nil)
- u = EOF;
+ u = Beof;
else
u = Bflush(fp);
break;
@@ -1783,7 +1783,7 @@ Cell *closefile(Node **a, int)
stat = pclose(files[i].fp);
else
stat = Bterm(files[i].fp);
- if (stat == EOF)
+ if (stat == Beof)
WARNING( "i/o error occurred closing %s", files[i].fname );
if (i > 2) /* don't do /dev/std... */
xfree(files[i].fname);