mirror of
https://github.com/troglobit/editline.git
synced 2025-09-18 10:28:07 +08:00
Minix editline v0.2.1
===================== Fix Debian batch mode reader, read_redirected(), which is activated when input comes from a file rather than a tty. The implementation of read_redirected() did not support lines longer than 64 chars. It tried to realloc(), but goofed up and instead truncated all the first 64 chars. The result was that each read line only contained the reminder of a a division with 64... :-)
This commit is contained in:
@@ -988,18 +988,24 @@ hist_add(p)
|
||||
}
|
||||
|
||||
STATIC char *
|
||||
read_redirected()
|
||||
read_redirected(void)
|
||||
{
|
||||
int size;
|
||||
int size = MEM_INC;
|
||||
char *p;
|
||||
char *line;
|
||||
char *end;
|
||||
|
||||
for (size = MEM_INC, p = line = NEW(char, size), end = p + size; ; p++) {
|
||||
p = line = NEW(char, size);
|
||||
end = p + size;
|
||||
while (1) {
|
||||
if (p == end) {
|
||||
int oldpos = end - line;
|
||||
|
||||
size += MEM_INC;
|
||||
p = line = realloc(line, size);
|
||||
p = RENEW(line, char, size);
|
||||
end = p + size;
|
||||
|
||||
p += oldpos; /* Continue where we left off... */
|
||||
}
|
||||
if (read(0, p, 1) <= 0) {
|
||||
/* Ignore "incomplete" lines at EOF, just like we do for a tty. */
|
||||
@@ -1008,6 +1014,7 @@ read_redirected()
|
||||
}
|
||||
if (*p == '\n')
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
*p = '\0';
|
||||
return line;
|
||||
|
Reference in New Issue
Block a user