aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/grep
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-03-25 23:25:45 +0000
committerrsc <devnull@localhost>2004-03-25 23:25:45 +0000
commit1a84af59e08c39200775a68b6af7175a6bcd044e (patch)
tree1c727cf1d3892372d0fd39756e803abf74e904cf /src/cmd/grep
parent285b4f85c0dff0aa5019ee93c17d1f8c734eb030 (diff)
downloadplan9port-1a84af59e08c39200775a68b6af7175a6bcd044e.tar.gz
plan9port-1a84af59e08c39200775a68b6af7175a6bcd044e.tar.bz2
plan9port-1a84af59e08c39200775a68b6af7175a6bcd044e.zip
Guess what? More anonymous unions!
Diffstat (limited to 'src/cmd/grep')
-rw-r--r--src/cmd/grep/grep.h4
-rw-r--r--src/cmd/grep/main.c18
2 files changed, 11 insertions, 11 deletions
diff --git a/src/cmd/grep/grep.h b/src/cmd/grep/grep.h
index c90be405..777bd1e8 100644
--- a/src/cmd/grep/grep.h
+++ b/src/cmd/grep/grep.h
@@ -76,12 +76,12 @@ EXTERN union
* if a line requires multiple reads, we keep shifting
* buf down into pre and then do another read into
* buf. so you'll get the last 16-32k of the matching line.
- * if pre were smaller than buf you'd get a suffix of the
+ * if h were smaller than buf you'd get a suffix of the
* line with a hole cut out.
*/
uchar pre[16*1024]; /* to save to previous '\n' */
uchar buf[16*1024]; /* input buffer */
- };
+ } u;
} u;
EXTERN char *filename;
diff --git a/src/cmd/grep/main.c b/src/cmd/grep/main.c
index f2a6e040..004d1b72 100644
--- a/src/cmd/grep/main.c
+++ b/src/cmd/grep/main.c
@@ -115,27 +115,27 @@ search(char *file, int flag)
eof = 0;
empty = 1;
nl = 0;
- lp = u.buf;
+ lp = u.u.buf;
bol = lp;
loop0:
n = lp-bol;
- if(n > sizeof(u.pre))
- n = sizeof(u.pre);
- memmove(u.buf-n, bol, n);
- bol = u.buf-n;
- n = read(fid, u.buf, sizeof(u.buf));
+ if(n > sizeof(u.u.pre))
+ n = sizeof(u.u.pre);
+ memmove(u.u.buf-n, bol, n);
+ bol = u.u.buf-n;
+ n = read(fid, u.u.buf, sizeof(u.u.buf));
/* if file has no final newline, simulate one to emit matches to last line */
if(n > 0) {
empty = 0;
- nl = u.buf[n-1]=='\n';
+ nl = u.u.buf[n-1]=='\n';
} else {
if(n < 0){
fprint(2, "grep: read error on %s: %r\n", file);
return count != 0;
}
if(!eof && !nl && !empty) {
- u.buf[0] = '\n';
+ u.u.buf[0] = '\n';
n = 1;
eof = 1;
}
@@ -152,7 +152,7 @@ loop0:
Bflush(&bout);
return count != 0;
}
- lp = u.buf;
+ lp = u.u.buf;
elp = lp+n;
if(flag & Iflag)
goto loopi;