From: Jim Meyering Date: Fri, 2 Dec 1994 16:54:56 +0000 (+0000) Subject: (checkfp): Initialize keybeg and keylim fields. X-Git-Tag: textutils-1_12_1~424 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f55a29ab93d1b3c494790226583b07f558c6af60;p=thirdparty%2Fcoreutils.git (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 . --- diff --git a/src/sort.c b/src/sort.c index d86ae4bf80..87d6533479 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)