diff options
author | Jim Meyering <jim@meyering.net> | 1994-12-02 16:54:56 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-12-02 16:54:56 +0000 |
commit | f55a29ab93d1b3c494790226583b07f558c6af60 (patch) | |
tree | a62e90c4a616bf5e508a456f33e93a297a7039e1 /src/sort.c | |
parent | 97f9755aeb35b61ce0b431226077d4b504e98f10 (diff) | |
download | coreutils-f55a29ab93d1b3c494790226583b07f558c6af60.tar.xz |
(checkfp): Initialize keybeg and keylim fields.
Before, this command
perl -e 'print join ("\n", (1..513)), "\n";'|sort -cs -n
failed on SunOS 4 systems. From Robert H. de Vries <robert@and.nl>.
Diffstat (limited to 'src/sort.c')
-rw-r--r-- | src/sort.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/sort.c b/src/sort.c index d86ae4bf8..87d653347 100644 --- a/src/sort.c +++ b/src/sort.c @@ -948,6 +948,7 @@ checkfp (fp) { struct buffer buf; /* Input buffer. */ struct lines lines; /* Lines scanned from the buffer. */ + struct line *prev_line; /* Pointer to previous line. */ struct line temp; /* Copy of previous line. */ int cc; /* Character count. */ int cmp; /* Result of calling compare. */ @@ -977,15 +978,17 @@ checkfp (fp) } /* Save the last line of the buffer and refill the buffer. */ - if (lines.lines[lines.used - 1].length > alloc) + prev_line = lines.lines + lines.used - 1; + if (prev_line->length > alloc) { - while (lines.lines[lines.used - 1].length + 1 > alloc) + while (prev_line->length + 1 > alloc) alloc *= 2; temp.text = xrealloc (temp.text, alloc); } - bcopy (lines.lines[lines.used - 1].text, temp.text, - lines.lines[lines.used - 1].length + 1); - temp.length = lines.lines[lines.used - 1].length; + bcopy (prev_line->text, temp.text, prev_line->length + 1); + temp.length = prev_line->length; + temp.keybeg = temp.text + (prev_line->keybeg - prev_line->text); + temp.keylim = temp.text + (prev_line->keylim - prev_line->text); cc = fillbuf (&buf, fp); if (cc) |