Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[Patch] Bug in strmetasort()



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