Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Qmail-Scanner-Diagnostics: from mx1.redhat.com by f.primenet.com.au (envelope-from <kdudka@redhat.com>, uid 7791) with qmail-scanner-2.11 
 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1.  
 Clear:RC:0(209.132.183.28):SA:0(-0.5/5.0):. 
 Processed in 0.1767 secs); 12 Aug 2016 10:33:35 -0000
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-0.5 required=5.0 tests=RP_MATCHES_RCVD,SPF_PASS
	autolearn=unavailable autolearn_force=no version=3.4.1
X-Envelope-From: kdudka@redhat.com
X-Qmail-Scanner-Mime-Attachments: |
X-Qmail-Scanner-Zip-Files: |
Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender)
From: Kamil Dudka <kdudka@redhat.com>
To: zsh-workers@zsh.org
Cc: Peter Stephenson <p.stephenson@samsung.com>
Subject: Re: [PATCH] enable number argument for transpose-words
Date: Fri, 12 Aug 2016 12:25:55 +0200
Message-ID: <1516997.6itNjt3W91@kdudka-nb>
User-Agent: KMail/4.14.10 (Linux/4.7.0-gentoo; KDE/4.14.20; x86_64; ; )
In-Reply-To: <20160812102918.5ad0f649@pwslap01u.europe.root.pri>
References: <20160801103212.GA24067@localhost.localdomain> <20160812025402.GA5319@localhost.localdomain> <20160812102918.5ad0f649@pwslap01u.europe.root.pri>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 12 Aug 2016 10:25:54 +0000 (UTC)
X-Seq: zsh-workers 39030

On Friday, August 12, 2016 10:29:18 Peter Stephenson wrote:
> On Fri, 12 Aug 2016 10:54:02 +0800
>=20
> Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
> > Any suggestions to this one, please? Thanks in advance.
>=20
> Thanks, I've committed that.  This describes what it does.
>=20
> pws
>=20
> diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
> index eaca1b3..aa219dc 100644
> --- a/Doc/Zsh/zle.yo
> +++ b/Doc/Zsh/zle.yo
> @@ -1948,6 +1948,12 @@ to the left.
>  tindex(transpose-words)
>  item(tt(transpose-words) (tt(ESC-T ESC-t)) (unbound) (unbound))(
>  Exchange the current word with the one before it.
> +
> +With a positive numeric argument em(N), the word before the cursor i=
s
> +transposed with the following em(N) words.
> +
> +With a negative numeric argument em(-N), the word after the cursor
> +is transposed with the preceding em(N) words.
>  )
>  tindex(vi-unindent)
>  item(tt(vi-unindent) (unbound) (tt(<)) (unbound))(

Is the body of 'while (n--)' loop guaranteed to be executed at least on=
ce?

Otherwise p1 and p2 may be used uninitialized by code following after t=
he
loop.  I would suggest to initialize explicitly or add assert for the v=
alue
of 'n'.  The following warnings started to be reported after this commi=
t:

Error: CLANG_WARNING:
Src/Zle/zle_word.c:747:43: warning: The right operand of '-' is a garba=
ge value
#    pp =3D temp =3D (ZLE_STRING_T)zhalloc((p4 - p1)*ZLE_CHAR_SIZE);
#                                          ^ ~~
#  745|       }
#  746|  =20
#  747|->     pp =3D temp =3D (ZLE_STRING_T)zhalloc((p4 - p1)*ZLE_CHAR_=
SIZE);
#  748|       len =3D p4 - p3;
#  749|       ZS_memcpy(pp, zleline + p3, len);

Error: COMPILER_WARNING:
Src/Zle/zle_word.c:747:43: warning: =E2=80=98p1=E2=80=99 may be used un=
initialized in this function [-Wuninitialized]
#  745|       }
#  746|  =20
#  747|->     pp =3D temp =3D (ZLE_STRING_T)zhalloc((p4 - p1)*ZLE_CHAR_=
SIZE);
#  748|       len =3D p4 - p3;
#  749|       ZS_memcpy(pp, zleline + p3, len);

Error: COMPILER_WARNING:
Src/Zle/zle_word.c: scope_hint: In function =E2=80=98transposewords=E2=80=
=99
Src/Zle/zle_word.c:751:9: warning: =E2=80=98p2=E2=80=99 may be used uni=
nitialized in this function [-Wuninitialized]
#  749|       ZS_memcpy(pp, zleline + p3, len);
#  750|       pp +=3D len;
#  751|->     len =3D p3 - p2;
#  752|       ZS_memcpy(pp, zleline + p2, len);
#  753|       pp +=3D len;

Full build log at: https://travis-ci.org/kdudka/csbuild-zsh/builds/1517=
47546

Kamil

