Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[Patch] Bug in strmetasort()
- X-seq: zsh-workers 23435
- From: "Nikolai Weibull" <now@xxxxxxxx>
- To: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Subject: [Patch] Bug in strmetasort()
- Date: Sun, 13 May 2007 21:58:26 +0200
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=WPGjeO/mCY0zlTkKRn7zIP3OxabqdnxgYZhBv5X/qi7epIzENEWeHRFyvTs8YwFkhDfcVk+xGOtnse+w6mDenffI1D4/PW+bh4pblGVG0aM8s3+xDGTjAoJHUBSsEYbRgJZHcVmyIcmITkmyUsBvwBjeKjVD4BhWAZZl7Jjywc0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=qfZRM14BRfMzYYXTqMy/thV6cvEmzL29398PyRNlklaT4PhfN5UB9uqkhipboxv2f+p2SDExPXoBOCVDxvHTW9wkWAAIGaVntuJOHfn0K1+tz8xw4InHd0T6ZsZzHRYynWEmnqSt77hJwMA9B6JWaZHjleEz57ltK6QHHl8cH6E=
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Sender: nikolai.weibull@xxxxxxxxx
The old test for determining when s has reached the end of src was
bugged. I don't quite see how this hasn't happened earlier, but I
managed to catch it when running history-beginning-search-menu on an
empty buffer.
The solution is simple, store the end before starting the loop and
then just verify that s stays below that end for the duration of the
loop. This will be faster too, so it's a win-win-win situation.
nikolai
Index: sort.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/sort.c,v
retrieving revision 1.5
diff -u -r1.5 sort.c
--- sort.c 16 Apr 2007 13:21:26 -0000 1.5
+++ sort.c 13 May 2007 19:56:22 -0000
@@ -338,8 +338,9 @@
src = dst;
}
if (sortwhat & SORTIT_IGNORING_BACKSLASHES) {
+ char *end = src + len + 1;
/* copy null byte, so increment length */
- for (s = src, t = dst; s - src != len+1; ) {
+ for (s = src, t = dst; s < end; ) {
if (*s == '\\') {
s++;
len--;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author