10 |
|
#include "copyright.h" |
11 |
|
|
12 |
|
#include <ctype.h> |
13 |
– |
#include <string.h> |
13 |
|
|
14 |
|
#include "platform.h" |
15 |
|
#include "rtio.h" |
37 |
|
return(-1); |
38 |
|
if ((fd = open(fname, 0)) < 0) |
39 |
|
return(-1); /* open error */ |
41 |
– |
SET_FD_BINARY(fd); /* Windows bug workaround */ |
40 |
|
words[0] = NULL; |
41 |
|
while (nargs > 1 && (n += read(fd, buf+n, MAXWLEN-n)) > 0) { |
42 |
+ |
int dlen = n; |
43 |
|
int crem = 0; |
44 |
|
if (n > MAXWLEN/2) /* check for mid-word end */ |
45 |
|
while (!isspace(buf[--n])) { |
56 |
|
words += n; nargs -= n; |
57 |
|
wrdcnt += n; |
58 |
|
if ((n = crem) > 0) /* move remainder */ |
59 |
< |
memmove(buf, buf+MAXWLEN-crem, crem); |
59 |
> |
memmove(buf, buf+dlen-crem, crem); |
60 |
|
} |
61 |
|
done: |
62 |
|
close(fd); |