FILE *istream;
int c;
size_t column = 0; /* Screen column where next char will go. */
- size_t offset_out = 0; /* Index in 'line_out' for next char. */
+ idx_t offset_out = 0; /* Index in 'line_out' for next char. */
static char *line_out = nullptr;
- static size_t allocated_out = 0;
+ static idx_t allocated_out = 0;
int saved_errno;
if (STREQ (filename, "-"))
while ((c = getc (istream)) != EOF)
{
- if (offset_out + 1 >= allocated_out)
- line_out = X2REALLOC (line_out, &allocated_out);
+ if (allocated_out - offset_out <= 1)
+ line_out = xpalloc (line_out, &allocated_out, 1, -1, sizeof *line_out);
if (c == '\n')
{
if (break_spaces)
{
bool found_blank = false;
- size_t logical_end = offset_out;
+ idx_t logical_end = offset_out;
/* Look for the last blank. */
while (logical_end)
if (found_blank)
{
- size_t i;
-
/* Found a blank. Don't output the part after it. */
logical_end++;
- fwrite (line_out, sizeof (char), (size_t) logical_end,
- stdout);
+ fwrite (line_out, sizeof (char), logical_end, stdout);
putchar ('\n');
/* Move the remainder to the beginning of the next line.
The areas being copied here might overlap. */
memmove (line_out, line_out + logical_end,
offset_out - logical_end);
offset_out -= logical_end;
- for (column = i = 0; i < offset_out; i++)
+ column = 0;
+ for (idx_t i = 0; i < offset_out; i++)
column = adjust_column (column, line_out[i]);
goto rescan;
}
}
line_out[offset_out++] = '\n';
- fwrite (line_out, sizeof (char), (size_t) offset_out, stdout);
+ fwrite (line_out, sizeof (char), offset_out, stdout);
column = offset_out = 0;
goto rescan;
}
saved_errno = 0;
if (offset_out)
- fwrite (line_out, sizeof (char), (size_t) offset_out, stdout);
+ fwrite (line_out, sizeof (char), offset_out, stdout);
if (STREQ (filename, "-"))
clearerr (istream);