commit 485d36fbf2b426f1e6a909e8b7aedf6b8bed2568
parent a41bc0926d3d369009bf864cffafe83313b73c30
Author: zavok <an2qzavok@gmail.com>
Date: Sun, 23 Aug 2020 20:20:36 +0300
brlb
Diffstat:
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/svex.c b/svex.c
@@ -30,10 +30,11 @@ main (int argc, char *argv[])
ARGBEGIN{
default: usage();
} ARGEND
- if (argc == 0) usage();
if (argc > 1) usage();
- fname = argv[1];
- load();
+ if (argc == 1) {
+ fname = argv[0];
+ load();
+ }
return 0;
}
@@ -41,14 +42,12 @@ void
load(void)
{
int f;
- ulong n;
- char b[1024], *bp;
- bp = buff;
+ long n;
+ char b[1024];
f = open(fname, O_RDONLY);
while ((n = read(f, b, 1024)) > 0){
buff = realloc(buff, blen + n);
- memcpy(bp, b, n);
- bp += n;
+ memcpy(buff+blen, b, n);
blen += n;
}
close(f);