ref: 306bee92e181a9c8b1cf0e746abdfcee7f246328
parent: 4c639475ce8cf0aec59632b6f7537169f1537f13
author: ftrvxmtrx <devnull@localhost>
date: Sat May 3 06:48:13 EDT 2014
uniq: use Bsize for buffers
--- a/sys/src/cmd/uniq.c
+++ b/sys/src/cmd/uniq.c
@@ -6,8 +6,6 @@
#include <bio.h>
#include <ctype.h>
-#define SIZE 8000
-
int fields = 0;
int letters = 0;
int linec = 0;
@@ -14,7 +12,6 @@
char mode;
int uniq;
char *b1, *b2;
-long bsize;
Biobuf fin;
Biobuf fout;
@@ -29,9 +26,8 @@
int f;
argv0 = argv[0];
- bsize = SIZE;
- b1 = malloc(bsize);
- b2 = malloc(bsize);
+ b1 = malloc(Bsize);
+ b2 = malloc(Bsize);
f = 0;
while(argc > 1) {
if(*argv[1] == '-') {
@@ -93,7 +89,7 @@
if(p == 0)
return 1;
len = Blinelen(&fin);
- if(len >= bsize-1)
+ if(len > Bsize)
sysfatal("line too long");
memmove(buf, p, len);
buf[len-1] = 0;