/* sort - sort lines of text (with all kinds of options).
- Copyright (C) 1988, 1991, 1992, 1993, 1994 Free Software Foundation
+ Copyright (C) 1988, 1991, 1992, 1993, 1994, 1995 Free Software Foundation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Initial buffer size for in core sorting. Will not grow unless a
line longer than this is seen. */
-static int sortalloc = 4 * 1024 * 1024;
+static int sortalloc = 512 * 1024;
/* Initial buffer size for in core merge buffers. Bear in mind that
up to NMERGE * mergealloc bytes may be allocated for merge buffers. */
-static int mergealloc = 64 * 1024;
+static int mergealloc = 16 * 1024;
/* Guess of average line length. */
static int linelength = 30;
/* Maximum number of elements for the array(s) of struct line's, in bytes. */
-#define LINEALLOC (1024 * 1024)
+#define LINEALLOC (256 * 1024)
/* Prefix for temporary file names. */
static char *temp_file_prefix;
{
int cc;
- bcopy (buf->buf + buf->used - buf->left, buf->buf, buf->left);
+ memmove (buf->buf, buf->buf + buf->used - buf->left, buf->left);
buf->used = buf->left;
while (!feof (fp) && (buf->used == 0 || !memchr (buf->buf, '\n', buf->used)))
alloc *= 2;
temp.text = xrealloc (temp.text, alloc);
}
- bcopy (prev_line->text, temp.text, prev_line->length + 1);
+ memcpy (temp.text, prev_line->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);
/* Repeatedly output the smallest line until no input remains. */
while (nfps)
{
- /* If uniqified output is turned out, output only the first of
+ /* If uniqified output is turned on, output only the first of
an identical series of lines. */
if (unique)
{
saved.text = xrealloc (saved.text, savealloc);
}
saved.length = lines[ord[0]].lines[cur[ord[0]]].length;
- bcopy (lines[ord[0]].lines[cur[ord[0]]].text, saved.text,
+ memcpy (saved.text, lines[ord[0]].lines[cur[ord[0]]].text,
saved.length + 1);
if (lines[ord[0]].lines[cur[ord[0]]].keybeg != NULL)
{
if (strcmp (outfile, "-"))
{
struct stat outstat;
- if (SAFE_STAT (outfile, &outstat) == 0)
+ if (safe_stat (outfile, &outstat) == 0)
{
/* The following code prevents a race condition when
people use the brain dead shell programming idiom:
{
struct stat instat;
if ((strcmp (files[i], "-")
- ? SAFE_STAT (files[i], &instat)
+ ? safe_stat (files[i], &instat)
: fstat (fileno (stdin), &instat)) != 0)
{
error (0, errno, "%s", files[i]);