[comp.os.minix] sort.c bug fix

JM04%SWTEXAS.BITNET@ricevm1.rice.edu (04/15/91)

Below are the diffs for 'sort.c' packaged with version 1.5
If 'sort.c' is used to sort files larger than 20K, it may not
work properly.  Last_line does not reserve a space at the end of
the mem_top buffer for a '\0'.  It fails under the following condition:
the last character in mem_top is a '\n'.  In this case the string
doesn't get terminated correctly since '\0' is appended past the
end of the buffer.

489,490c489,490
<
<   for (i = MEMORY_SIZE - 1; i > 0; i--)
---
> /* Must be MEMORY_SIZE -2 to make room for insertion of '\0' */
>   for (i = MEMORY_SIZE - 2; i > 0; i--)


Jim Miles, Southwest Texas State University
Email: JM04@SWTEXAS