--- ray/src/common/wordfile.c 2016/05/12 16:30:39 2.21 +++ ray/src/common/wordfile.c 2016/05/13 09:12:19 2.22 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: wordfile.c,v 2.21 2016/05/12 16:30:39 greg Exp $"; +static const char RCSid[] = "$Id: wordfile.c,v 2.22 2016/05/13 09:12:19 schorsch Exp $"; #endif /* * Load whitespace separated words from a file into an array. @@ -29,6 +29,7 @@ wordfile( /* get words from fname, put in words */ { int wrdcnt = 0; int n = 0; + int dlen = 0; int fd; char buf[MAXWLEN]; /* load file into buffer */ @@ -38,9 +39,9 @@ wordfile( /* get words from fname, put in words */ return(-1); if ((fd = open(fname, 0)) < 0) return(-1); /* open error */ - SET_FD_BINARY(fd); /* Windows bug workaround */ words[0] = NULL; while (nargs > 1 && (n += read(fd, buf+n, MAXWLEN-n)) > 0) { + dlen = n; int crem = 0; if (n > MAXWLEN/2) /* check for mid-word end */ while (!isspace(buf[--n])) { @@ -57,7 +58,7 @@ wordfile( /* get words from fname, put in words */ words += n; nargs -= n; wrdcnt += n; if ((n = crem) > 0) /* move remainder */ - memmove(buf, buf+MAXWLEN-crem, crem); + memmove(buf, buf+dlen-crem, crem); } done: close(fd);