zsh-workers
 help / color / mirror / code / Atom feed
* [Patch] Bug in strmetasort()
@ 2007-05-13 19:58 Nikolai Weibull
  0 siblings, 0 replies; only message in thread
From: Nikolai Weibull @ 2007-05-13 19:58 UTC (permalink / raw)
  To: Zsh hackers list

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--;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-05-13 19:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-13 19:58 [Patch] Bug in strmetasort() Nikolai Weibull

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).