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

Re: [PATCH] enable number argument for transpose-words



On Fri, 12 Aug 2016 12:25:55 +0200
Kamil Dudka <kdudka@xxxxxxxxxx> wrote:
> Is the body of 'while (n--)' loop guaranteed to be executed at least once?
> 
> Otherwise p1 and p2 may be used uninitialized by code following after the
> loop.

It's probably reasonable to do the following...

pws

diff --git a/Src/Zle/zle_word.c b/Src/Zle/zle_word.c
index 2a15171..e4a878e 100644
--- a/Src/Zle/zle_word.c
+++ b/Src/Zle/zle_word.c
@@ -722,7 +722,7 @@ transposewords(UNUSED(char **args))
     if (!p3)
 	return 1;
 
-    pt = p3;
+    p1 = p2 = pt = p3;
 
     while (n--) {
 	for (p2 = pt; p2; ) {



Messages sorted by: Reverse Date, Date, Thread, Author