Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "read" broken in 2.6-beta21?
- X-seq: zsh-workers 1458
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: cbuckley@xxxxxxxxx (Colm Buckley)
- Subject: Re: "read" broken in 2.6-beta21?
- Date: Thu, 27 Jun 1996 23:42:50 +0200 (MET DST)
- Cc: zsh-workers@xxxxxxxxxxxxxxx (Zsh hacking and development)
- In-reply-to: <199606270011.BAA07863@xxxxxxxxxxxxxxxxx> from Colm Buckley at "Jun 27, 96 01:11:06 am"
>
> This has been affecting me recently; I just tracked it down to the
> following:
>
> The "read" command in zsh2.6-beta21 behaves strangely when the input
> exceeds 63 characters; the remaining characters in the line are
> truncated. For example :
>
> $ read x
> 1234567890123456789012345678901234567890123456789012345678901234567890
> $ echo $x
> 123456789012345678901234567890123456789012345678901234567890123
> $
>
> I don't *think* this affected previous versions of zsh. If a static
> buffer is being used for "read", might I suggest that it be increased in
> size to something greater than 64 bytes?
Yes, this bug appeared in beta21 but not because of static buffers. The
patch below should fix that.
Zoltan
*** Src/builtin.c 1996/06/26 22:32:07 2.47
--- Src/builtin.c 1996/06/27 21:25:38
***************
*** 4976,4983 ****
*bptr++ = c;
/* increase the buffer size, if necessary */
if (bptr >= buf + bsiz - 1) {
buf = realloc(buf, bsiz *= 2);
! bptr = buf + (bsiz / 2);
}
}
/* handle EOF */
--- 4976,4985 ----
*bptr++ = c;
/* increase the buffer size, if necessary */
if (bptr >= buf + bsiz - 1) {
+ int blen = bptr - buf;
+
buf = realloc(buf, bsiz *= 2);
! bptr = buf + blen;
}
}
/* handle EOF */
***************
*** 5055,5062 ****
*bptr++ = c;
/* increase the buffer size, if necessary */
if (bptr >= buf + bsiz - 1) {
buf = realloc(buf, bsiz *= 2);
! bptr = buf + (bsiz / 2);
}
}
while (bptr > buf && iwsep(bptr[-1]))
--- 5057,5066 ----
*bptr++ = c;
/* increase the buffer size, if necessary */
if (bptr >= buf + bsiz - 1) {
+ int blen = bptr - buf;
+
buf = realloc(buf, bsiz *= 2);
! bptr = buf + blen;
}
}
while (bptr > buf && iwsep(bptr[-1]))
Messages sorted by:
Reverse Date,
Date,
Thread,
Author