zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] enable number argument for transpose-words
Date: Fri, 12 Aug 2016 11:41:42 +0100	[thread overview]
Message-ID: <20160812114142.79587341@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <1516997.6itNjt3W91@kdudka-nb>

On Fri, 12 Aug 2016 12:25:55 +0200
Kamil Dudka <kdudka@redhat.com> 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; ) {


  reply	other threads:[~2016-08-12 10:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-01 10:32 Han Pingtian
2016-08-12  2:54 ` Han Pingtian
2016-08-12  9:29   ` Peter Stephenson
2016-08-12 10:25     ` Kamil Dudka
2016-08-12 10:41       ` Peter Stephenson [this message]
2016-08-12 13:10         ` Kamil Dudka
2016-08-15  2:22     ` Han Pingtian
2016-08-15  8:39       ` Peter Stephenson
2016-08-15  9:01         ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160812114142.79587341@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).