From MAILER-DAEMON Sun May 28 10:46:38 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dEzSo-0001HP-3B
	for mharc-bug-global@gnu.org; Sun, 28 May 2017 10:46:38 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55519)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <ki@hh.iij4u.or.jp>) id 1dEyOY-0006VJ-To
	for bug-global@gnu.org; Sun, 28 May 2017 09:38:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <ki@hh.iij4u.or.jp>) id 1dEyOV-0005O3-Qq
	for bug-global@gnu.org; Sun, 28 May 2017 09:38:10 -0400
Received: from mo-sw1501.iij4u.or.jp ([210.130.239.241]:41721
	helo=mo-sw.iij4u.or.jp)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <ki@hh.iij4u.or.jp>) id 1dEyOU-0005IB-T3
	for bug-global@gnu.org; Sun, 28 May 2017 09:38:07 -0400
DKIM-Signature: v=1;a=rsa-sha256;c=relaxed/simple;d=hh.iij4u.or.jp;h=Date:
	Message-Id:To:Subject:From:Mime-Version:Content-Type:
	Content-Transfer-Encoding; i=ki@hh.iij4u.or.jp; s=20160530.iij4u;
	t=1495978682; 
	x=1497188282; bh=t5rcNgfcJ6m0xKN9STUKNGnalbXIl3cojymraqmtqc8=;
	b=aL5L4rMpYRhyiN
	1Gx7SEBz5DlyfqbBTCU78jgXrQZLjs2FeaRc8NJc6ejxsuCiJGrDPl5uXPwsQocwqxuxESm/4JDcH
	KGvqGsgs/3m843lb6MJKwLabHL56u2vBypeNZhELuqLpsYGHWLKT54RuoXCxkWcwMWOs3o5fnDLAb
	aE15H8S+I6FJtKu2tba6OkHZ5nKjbml5QzMEbVrjN9M5bd4XXYuPiL2V9kwKsOwIWCTao1uJIvTIE
	ctEgFCjzxcANDHrMaT26yuPUtC3nxmVhlSWe88nuZDlomclBcMiDg1jsO2LIm/+intDFXc/lsj5YG
	Dy/YB/eiM+EaWH2FmRKA==;
Received: by mo-sw.iij4u.or.jp (4u-mo-sw1501) id v4SDc1wj030299;
	Sun, 28 May 2017 22:38:02 +0900
Received: from localhost (158.239.69.115.shared.user.transix.jp
	[115.69.239.158])
	by mbox.iij4u.or.jp (4u-mbox1500) id v4SDbvPZ008121;
	Sun, 28 May 2017 22:38:01 +0900
Date: Sun, 28 May 2017 22:37:57 +0900 (JST)
Message-Id: <20170528.223757.132094201.ki@mbox.iij4u.or.jp>
To: bug-global@gnu.org
Subject: htags generates incorrect anchor when -s option is specified.
From: Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>
X-Mailer: Mew version 6.7 on Emacs 22.3 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 210.130.239.241
X-Mailman-Approved-At: Sun, 28 May 2017 10:46:37 -0400
X-BeenThere: bug-global@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Bug reports for GNU GLOBAL <bug-global.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-global/>
List-Post: <mailto:bug-global@gnu.org>
List-Help: <mailto:bug-global-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 28 May 2017 13:38:11 -0000

Hi,

I've found that htags command generates incorrect anchor link when -s
option is specified on FreeBSD and Cygwin. Linux is ok.  Upon
investigation, this seems to be caused by behaviour of qsort().

When anchor->lineno is same and cmp()@htags/anchor.c returns 0, some
qsort() impelmentation might swap objects. This causes that type 'R'
is upper than type 'T', and anchor_get() cannot find correct anchor.

If appling below patch to htags/anchor.c, htags seems generate correct
link.

 static int
 cmp(const void *s1, const void *s2)
 {
+#if 1
+	int diff = ((struct anchor *)s1)->lineno - ((struct anchor *)s2)->lineno;
+	/* when lineno is same, preserve current order. */
+	return diff == 0 ? -1 : diff;
+#else
 	return ((struct anchor *)s1)->lineno - ((struct anchor *)s2)->lineno;
+#endif
 }
 /*
  * Pointers (as lineno).

Is this right fix?

Thanks,


From MAILER-DAEMON Mon May 29 00:58:24 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dFCl6-0006rY-OL
	for mharc-bug-global@gnu.org; Mon, 29 May 2017 00:58:24 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47955)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <i.tamacom@gmail.com>) id 1dFCl4-0006rP-EK
	for bug-global@gnu.org; Mon, 29 May 2017 00:58:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <i.tamacom@gmail.com>) id 1dFCl2-0003M7-Tn
	for bug-global@gnu.org; Mon, 29 May 2017 00:58:22 -0400
Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]:34665)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <i.tamacom@gmail.com>) id 1dFCl2-0003Ke-M4
	for bug-global@gnu.org; Mon, 29 May 2017 00:58:20 -0400
Received: by mail-lf0-x22b.google.com with SMTP id 99so28600387lfu.1
	for <bug-global@gnu.org>; Sun, 28 May 2017 21:58:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:sender:in-reply-to:references:from:date:message-id
	:subject:to:cc;
	bh=Ueps+Y/pqRdxBHGGD7nKF7EUNsif1smSeRE198oxTjg=;
	b=m0IJEpU17JZTn55ss7wjq2Q0sq+DdpR2gUvCXyAc1Y41XmqMUSi+K8XGxa3TgaMEtl
	CGgzAHfZHYMoxJhjtmPrDyMTs/Egswj+UK9e+0ptNJDyR/k+DWnirW+4XOexpxUj1R1s
	Pyb1s3WCRE/v1dcNjAAy/fwLPd50C9WkzACV6s43sbSZDPXQ16+CcZEIKZNele3dQftE
	L4jAxr8GFPnM/+FKb5nkp5ubm5lN1ncR1O39S5vidhqnXqL4BSXCdXZdB+qYguHtmJhz
	kM1pTLprxzIjLnpwPXnr3PnYytvyPXM9+cy3pZut8N12gtlJXpQCb3V5/t0tqalHUsGp
	vI1w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
	:date:message-id:subject:to:cc;
	bh=Ueps+Y/pqRdxBHGGD7nKF7EUNsif1smSeRE198oxTjg=;
	b=UpTLT7wSKz0XCjFo8D1wbpHhQh7eL97mrkYoce2xtgQPkAfWVVyJqJJMSkpL7vgz/e
	RakF1plxoEQo0jVc40Tc/CAs2reGFGqt5+7F7Lj5lO3uZfiPoUGMJQ9oZ0/T432baksQ
	5zcyt4p5OhsFhd0IDva7mb82Nv/vkDtiGOP9edLfHs2zNm0Q3aFW3DrlYAXDv1JOWvhW
	9NV4/AYia0CgEfF7VTBbu93KfUuCRVAW+2a1AzGkP7XV9bVre29b1tmWyxetraHxOFrC
	CKNab1Pk3GnLjI++mI7buKG+wvpaRGqRFqeqBxkCywSYJZ9qSnWIZGQGI1d+cZZ7QxHK
	3XuQ==
X-Gm-Message-State: AODbwcAi/SZteW2fotMbj2tN8YmZ/+j/8RxUjtAaIJXDiWR4FdOYVUNU
	UZPTOr9fEseyKvfFQO8nf5hOwSZA/Q==
X-Received: by 10.25.18.84 with SMTP id h81mr3073687lfi.63.1496033898890; Sun,
	28 May 2017 21:58:18 -0700 (PDT)
MIME-Version: 1.0
Sender: i.tamacom@gmail.com
Received: by 10.46.32.37 with HTTP; Sun, 28 May 2017 21:58:18 -0700 (PDT)
In-Reply-To: <20170528.223757.132094201.ki@mbox.iij4u.or.jp>
References: <20170528.223757.132094201.ki@mbox.iij4u.or.jp>
From: Shigio YAMAGUCHI <shigio@gnu.org>
Date: Mon, 29 May 2017 13:58:18 +0900
X-Google-Sender-Auth: nBSchb7uTExowogUJbk6Jsq5i40
Message-ID: <CADJmJYqfa2gTUoX-eR=5Pv-HLhXFhgG0Sown4E_xYkrDhtjU8g@mail.gmail.com>
Subject: Re: htags generates incorrect anchor when -s option is specified.
To: Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>
Cc: "bug-global@gnu.org" <bug-global@gnu.org>
Content-Type: multipart/alternative; boundary="001a113fc2501d8beb0550a28997"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2a00:1450:4010:c07::22b
X-BeenThere: bug-global@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Bug reports for GNU GLOBAL <bug-global.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-global/>
List-Post: <mailto:bug-global@gnu.org>
List-Help: <mailto:bug-global-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 29 May 2017 04:58:23 -0000

--001a113fc2501d8beb0550a28997
Content-Type: text/plain; charset="UTF-8"

Hi,
Could you please send information to do a reproduction test?
o Which version of FreeBSD?
o What is the htags's command line?
o Where is the incorrect anchor link?

Thank you in advance.

Regards,
Shigio


2017-05-28 22:37 GMT+09:00 Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>:

> Hi,
>
> I've found that htags command generates incorrect anchor link when -s
> option is specified on FreeBSD and Cygwin. Linux is ok.  Upon
> investigation, this seems to be caused by behaviour of qsort().
>
> When anchor->lineno is same and cmp()@htags/anchor.c returns 0, some
> qsort() impelmentation might swap objects. This causes that type 'R'
> is upper than type 'T', and anchor_get() cannot find correct anchor.
>
> If appling below patch to htags/anchor.c, htags seems generate correct
> link.
>
>  static int
>  cmp(const void *s1, const void *s2)
>  {
> +#if 1
> +       int diff = ((struct anchor *)s1)->lineno - ((struct anchor
> *)s2)->lineno;
> +       /* when lineno is same, preserve current order. */
> +       return diff == 0 ? -1 : diff;
> +#else
>         return ((struct anchor *)s1)->lineno - ((struct anchor
> *)s2)->lineno;
> +#endif
>  }
>  /*
>   * Pointers (as lineno).
>
> Is this right fix?
>
> Thanks,
>
> _______________________________________________
> Bug-global mailing list
> Bug-global@gnu.org
> https://lists.gnu.org/mailman/listinfo/bug-global
>



-- 
Shigio YAMAGUCHI <shigio@gnu.org>
PGP fingerprint:
26F6 31B4 3D62 4A92 7E6F  1C33 969C 3BE3 89DD A6EB

--001a113fc2501d8beb0550a28997
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi,</div><div>Could you please send information to do=
 a reproduction test?</div><div>o Which version of FreeBSD?</div><div>o Wha=
t is the htags&#39;s command line?=C2=A0</div><div>o Where is the incorrect=
 anchor link?</div><div><br></div><div>Thank you in advance.</div><div><br>=
</div><div>Regards,</div><div>Shigio</div><div><br></div><div class=3D"gmai=
l_extra"><br><div class=3D"gmail_quote">2017-05-28 22:37 GMT+09:00 Shuichi =
KITAGUCHI <span dir=3D"ltr">&lt;<a href=3D"mailto:ki@hh.iij4u.or.jp" target=
=3D"_blank">ki@hh.iij4u.or.jp</a>&gt;</span>:<br><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex">Hi,<br>
<br>
I&#39;ve found that htags command generates incorrect anchor link when -s<b=
r>
option is specified on FreeBSD and Cygwin. Linux is ok.=C2=A0 Upon<br>
investigation, this seems to be caused by behaviour of qsort().<br>
<br>
When anchor-&gt;lineno is same and cmp()@htags/anchor.c returns 0, some<br>
qsort() impelmentation might swap objects. This causes that type &#39;R&#39=
;<br>
is upper than type &#39;T&#39;, and anchor_get() cannot find correct anchor=
.<br>
<br>
If appling below patch to htags/anchor.c, htags seems generate correct<br>
link.<br>
<br>
=C2=A0static int<br>
=C2=A0cmp(const void *s1, const void *s2)<br>
=C2=A0{<br>
+#if 1<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int diff =3D ((struct anchor *)s1)-&gt;lineno -=
 ((struct anchor *)s2)-&gt;lineno;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0/* when lineno is same, preserve current order.=
 */<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return diff =3D=3D 0 ? -1 : diff;<br>
+#else<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return ((struct anchor *)s1)-&gt;lineno - ((str=
uct anchor *)s2)-&gt;lineno;<br>
+#endif<br>
=C2=A0}<br>
=C2=A0/*<br>
=C2=A0 * Pointers (as lineno).<br>
<br>
Is this right fix?<br>
<br>
Thanks,<br>
<br>
______________________________<wbr>_________________<br>
Bug-global mailing list<br>
<a href=3D"mailto:Bug-global@gnu.org">Bug-global@gnu.org</a><br>
<a href=3D"https://lists.gnu.org/mailman/listinfo/bug-global" rel=3D"norefe=
rrer" target=3D"_blank">https://lists.gnu.org/mailman/<wbr>listinfo/bug-glo=
bal</a><br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><div class=
=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><d=
iv><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div=
 dir=3D"ltr">Shigio YAMAGUCHI &lt;<a href=3D"mailto:shigio@gnu.org" target=
=3D"_blank">shigio@gnu.org</a>&gt;</div><div dir=3D"ltr"><div dir=3D"ltr">P=
GP fingerprint:=C2=A0</div><div dir=3D"ltr">26F6 31B4 3D62 4A92 7E6F =C2=A0=
1C33 969C 3BE3 89DD A6EB</div></div></div></div></div></div></div></div></d=
iv>
</div></div>

--001a113fc2501d8beb0550a28997--


From MAILER-DAEMON Mon May 29 06:18:23 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dFHkl-0001X1-M5
	for mharc-bug-global@gnu.org; Mon, 29 May 2017 06:18:23 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52264)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <ki@hh.iij4u.or.jp>) id 1dFHki-0001Wu-CK
	for bug-global@gnu.org; Mon, 29 May 2017 06:18:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <ki@hh.iij4u.or.jp>) id 1dFHkf-0003IN-2p
	for bug-global@gnu.org; Mon, 29 May 2017 06:18:20 -0400
Received: from mo-sw1500.iij4u.or.jp ([210.130.239.240]:56730
	helo=mo-sw.iij4u.or.jp)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <ki@hh.iij4u.or.jp>) id 1dFHke-0003Hs-2w
	for bug-global@gnu.org; Mon, 29 May 2017 06:18:17 -0400
DKIM-Signature: v=1;a=rsa-sha256;c=relaxed/simple;d=hh.iij4u.or.jp;h=Date:
	Message-Id:To:Subject:From:In-Reply-To:References:Mime-Version:Content-Type:
	Content-Transfer-Encoding; i=ki@hh.iij4u.or.jp; s=20160530.iij4u;
	t=1496053091; 
	x=1497262691; bh=fkR7nBhhmXTp6UO0n+v+EQ1dACj7IyWYwkdoCZJgSZM=;
	b=DPjyVY5W3i8BX9
	1W/xlkWnHPmvF/DV13QFpwRntELLs1xLUq0ZJhSiVajjlmpeQCtNETUtI7Zr7ELK7nFNV7rgwOydV
	EXHKEKDWwvscHduyMRQgDSM3H2rdlMXXvittD68NW7rqFbfx5v1EWHJFF1HNPK07rHgfpnx8mgL6B
	ilMo6Oj61Zy+vQ2vxfz8P4x+Tvu6zyzkkUjQRmcTjIvARIAIx8JXotSf4ko1ctYImm7Xv/zl/iORB
	S6vawSQsdLqZkrRDI+vOs69qPMs+zjPSHQ+NxssCCGMDDhwYVKZE2cKvF0a2ae+oQzqcoztGzAsPp
	h0Fp5pkSlNedSDNZqDVw==;
Received: by mo-sw.iij4u.or.jp (4u-mo-sw1500) id v4TAIBMb016909;
	Mon, 29 May 2017 19:18:11 +0900
Received: from localhost (121.236.69.115.shared.user.transix.jp
	[115.69.236.121])
	by mbox.iij4u.or.jp (4u-mbox1500) id v4TAIArE017623;
	Mon, 29 May 2017 19:18:11 +0900
Date: Mon, 29 May 2017 19:18:11 +0900 (JST)
Message-Id: <20170529.191811.02618136.ki@mbox.iij4u.or.jp>
To: bug-global@gnu.org
Subject: Re: htags generates incorrect anchor when -s option is specified.
From: Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>
In-Reply-To: <CADJmJYqfa2gTUoX-eR=5Pv-HLhXFhgG0Sown4E_xYkrDhtjU8g@mail.gmail.com>
References: <20170528.223757.132094201.ki@mbox.iij4u.or.jp>
	<CADJmJYqfa2gTUoX-eR=5Pv-HLhXFhgG0Sown4E_xYkrDhtjU8g@mail.gmail.com>
X-Mailer: Mew version 6.7 on Emacs 22.3 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 210.130.239.240
X-BeenThere: bug-global@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Bug reports for GNU GLOBAL <bug-global.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-global/>
List-Post: <mailto:bug-global@gnu.org>
List-Help: <mailto:bug-global-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 29 May 2017 10:18:21 -0000

Hi,

> Hi,
> Could you please send information to do a reproduction test?
> o Which version of FreeBSD?

11.0-RELEASE (from binary package) and 12-CURRENT.

> o What is the htags's command line?

-s -a -n -g

> o Where is the incorrect anchor link?

When prepare following two header files and execute htags
with above options,

[a.h]
struct st1 {
        ST1 *st1_ptr;
};

struct st2 {
        ST1 st2_st1;
};

struct st3 {
        ST2 st3_st2;
};

[b.h]
typedef struct st1      ST1;
typedef struct st2      ST2;
typedef struct st3      ST3;

HTML/S/2.html contains below lines.

<a id='L1' name='L1'></a>   1 <strong class='reserved'>typedef</strong> <strong class='reserved'>struct</strong> <a href='../S/1.html#L1' title='Defined at 1 in a.h.'>st1</a>      <a href='../R/1.html' title='Multiple referred from 3 places.'>ST1</a>;
<a id='L2' name='L2'></a>   2 <strong class='reserved'>typedef</strong> <strong class='reserved'>struct</strong> <a href='../S/1.html#L5' title='Defined at 5 in a.h.'>st2</a>      <a href='../S/2.html#L2' title='Defined at 2 in b.h.'>ST2</a>;

'ST1' is linked to '../R/1.html', but 'ST2' is linked to
'../S/2.html'. I think 'ST2' should be linked to '../R/2.html'.

> Thank you in advance.
> 
> Regards,
> Shigio

Thanks,

> 2017-05-28 22:37 GMT+09:00 Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>:
> 
>> Hi,
>>
>> I've found that htags command generates incorrect anchor link when -s
>> option is specified on FreeBSD and Cygwin. Linux is ok.  Upon
>> investigation, this seems to be caused by behaviour of qsort().
>>
>> When anchor->lineno is same and cmp()@htags/anchor.c returns 0, some
>> qsort() impelmentation might swap objects. This causes that type 'R'
>> is upper than type 'T', and anchor_get() cannot find correct anchor.
>>
>> If appling below patch to htags/anchor.c, htags seems generate correct
>> link.
>>
>>  static int
>>  cmp(const void *s1, const void *s2)
>>  {
>> +#if 1
>> +       int diff = ((struct anchor *)s1)->lineno - ((struct anchor
>> *)s2)->lineno;
>> +       /* when lineno is same, preserve current order. */
>> +       return diff == 0 ? -1 : diff;
>> +#else
>>         return ((struct anchor *)s1)->lineno - ((struct anchor
>> *)s2)->lineno;
>> +#endif
>>  }
>>  /*
>>   * Pointers (as lineno).
>>
>> Is this right fix?
>>
>> Thanks,
>>
>> _______________________________________________
>> Bug-global mailing list
>> Bug-global@gnu.org
>> https://lists.gnu.org/mailman/listinfo/bug-global
>>
> 
> 
> 
> -- 
> Shigio YAMAGUCHI <shigio@gnu.org>
> PGP fingerprint:
> 26F6 31B4 3D62 4A92 7E6F  1C33 969C 3BE3 89DD A6EB


From MAILER-DAEMON Mon May 29 07:29:12 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dFIrI-0005qf-Jn
	for mharc-bug-global@gnu.org; Mon, 29 May 2017 07:29:12 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35667)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <h-iwamoto@kit.hi-ho.ne.jp>) id 1dFIrG-0005qY-Qh
	for bug-global@gnu.org; Mon, 29 May 2017 07:29:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <h-iwamoto@kit.hi-ho.ne.jp>) id 1dFIrD-00061b-L2
	for bug-global@gnu.org; Mon, 29 May 2017 07:29:10 -0400
Received: from mo-sw1505-0.mose-mail.jp ([210.130.202.8]:40327
	helo=mo-sw.mose-mail.jp)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <h-iwamoto@kit.hi-ho.ne.jp>)
	id 1dFIrD-00061N-1r
	for bug-global@gnu.org; Mon, 29 May 2017 07:29:07 -0400
Received: by mo-sw.mose-mail.jp (mose-mo-sw1505) id v4TBSvrG028368;
	Mon, 29 May 2017 20:28:57 +0900
Received: from [192.168.1.4] (localhost [127.0.0.1])
	by mbox.mose-mail.jp (mose-mbox1503) id v4TBSu8F019765;
	Mon, 29 May 2017 20:28:56 +0900
Date: Mon, 29 May 2017 20:28:57 +0900
From: Hideki IWAMOTO <h-iwamoto@kit.hi-ho.ne.jp>
To: Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>
Subject: Re: htags generates incorrect anchor when -s option is specified.
Cc: bug-global@gnu.org
In-Reply-To: <20170529.191811.02618136.ki@mbox.iij4u.or.jp>
References: <CADJmJYqfa2gTUoX-eR=5Pv-HLhXFhgG0Sown4E_xYkrDhtjU8g@mail.gmail.com>
	<20170529.191811.02618136.ki@mbox.iij4u.or.jp>
Message-Id: <20170529202855.D0AB.1976CC75@kit.hi-ho.ne.jp>
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-2022-JP"
Content-Transfer-Encoding: 7bit
X-Mailer: Becky! ver. 2.65.05 [ja]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 210.130.202.8
X-BeenThere: bug-global@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Bug reports for GNU GLOBAL <bug-global.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-global/>
List-Post: <mailto:bug-global@gnu.org>
List-Help: <mailto:bug-global-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 29 May 2017 11:29:11 -0000

Hi.

> 'ST1' is linked to '../R/1.html', but 'ST2' is linked to
> '../S/2.html'. I think 'ST2' should be linked to '../R/2.html'.

This was caused by a bug in the built-in parser of gtags.

I have fixed the bug in the repository.
 http://cvs.savannah.gnu.org/viewcvs/global/libparser/C.c?cvsroot=global&r1=1.14&r2=1.15
 http://cvs.savannah.gnu.org/viewcvs/global/libparser/Cpp.c?cvsroot=global&r1=1.23&r2=1.24

Thank you for the report.


On Mon, 29 May 2017 19:18:11 +0900 (JST)
Shuichi KITAGUCHI <ki@hh.iij4u.or.jp> wrote:

> Hi,
> 
> > Hi,
> > Could you please send information to do a reproduction test?
> > o Which version of FreeBSD?
> 
> 11.0-RELEASE (from binary package) and 12-CURRENT.
> 
> > o What is the htags's command line?
> 
> -s -a -n -g
> 
> > o Where is the incorrect anchor link?
> 
> When prepare following two header files and execute htags
> with above options,
> 
> [a.h]
> struct st1 {
>         ST1 *st1_ptr;
> };
> 
> struct st2 {
>         ST1 st2_st1;
> };
> 
> struct st3 {
>         ST2 st3_st2;
> };
> 
> [b.h]
> typedef struct st1      ST1;
> typedef struct st2      ST2;
> typedef struct st3      ST3;
> 
> HTML/S/2.html contains below lines.
> 
> <a id='L1' name='L1'></a>   1 <strong class='reserved'>typedef</strong> <strong class='reserved'>struct</strong> <a href='../S/1.html#L1' title='Defined at 1 in a.h.'>st1</a>      <a href='../R/1.html' title='Multiple referred from 3 places.'>ST1</a>;
> <a id='L2' name='L2'></a>   2 <strong class='reserved'>typedef</strong> <strong class='reserved'>struct</strong> <a href='../S/1.html#L5' title='Defined at 5 in a.h.'>st2</a>      <a href='../S/2.html#L2' title='Defined at 2 in b.h.'>ST2</a>;
> 
> 'ST1' is linked to '../R/1.html', but 'ST2' is linked to
> '../S/2.html'. I think 'ST2' should be linked to '../R/2.html'.
> 
> > Thank you in advance.
> > 
> > Regards,
> > Shigio
> 
> Thanks,
> 
> > 2017-05-28 22:37 GMT+09:00 Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>:
> > 
> >> Hi,
> >>
> >> I've found that htags command generates incorrect anchor link when -s
> >> option is specified on FreeBSD and Cygwin. Linux is ok.  Upon
> >> investigation, this seems to be caused by behaviour of qsort().
> >>
> >> When anchor->lineno is same and cmp()@htags/anchor.c returns 0, some
> >> qsort() impelmentation might swap objects. This causes that type 'R'
> >> is upper than type 'T', and anchor_get() cannot find correct anchor.
> >>
> >> If appling below patch to htags/anchor.c, htags seems generate correct
> >> link.
> >>
> >>  static int
> >>  cmp(const void *s1, const void *s2)
> >>  {
> >> +#if 1
> >> +       int diff = ((struct anchor *)s1)->lineno - ((struct anchor
> >> *)s2)->lineno;
> >> +       /* when lineno is same, preserve current order. */
> >> +       return diff == 0 ? -1 : diff;
> >> +#else
> >>         return ((struct anchor *)s1)->lineno - ((struct anchor
> >> *)s2)->lineno;
> >> +#endif
> >>  }
> >>  /*
> >>   * Pointers (as lineno).
> >>
> >> Is this right fix?
> >>
> >> Thanks,
> >>
> >> _______________________________________________
> >> Bug-global mailing list
> >> Bug-global@gnu.org
> >> https://lists.gnu.org/mailman/listinfo/bug-global
> >>
> > 
> > 
> > 
> > -- 
> > Shigio YAMAGUCHI <shigio@gnu.org>
> > PGP fingerprint:
> > 26F6 31B4 3D62 4A92 7E6F  1C33 969C 3BE3 89DD A6EB
> 
> _______________________________________________
> Bug-global mailing list
> Bug-global@gnu.org
> https://lists.gnu.org/mailman/listinfo/bug-global

-- 
$B4dK\(B $B=(<y(B <h-iwamoto@kit.hi-ho.ne.jp>



From MAILER-DAEMON Mon May 29 09:26:28 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dFKgm-0008NF-IX
	for mharc-bug-global@gnu.org; Mon, 29 May 2017 09:26:28 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57320)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <ki@hh.iij4u.or.jp>) id 1dFKgj-0008N3-S4
	for bug-global@gnu.org; Mon, 29 May 2017 09:26:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <ki@hh.iij4u.or.jp>) id 1dFKgg-00067p-Nv
	for bug-global@gnu.org; Mon, 29 May 2017 09:26:25 -0400
Received: from mo-sw1500.iij4u.or.jp ([210.130.239.240]:59483
	helo=mo-sw.iij4u.or.jp)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <ki@hh.iij4u.or.jp>) id 1dFKgf-00066n-UJ
	for bug-global@gnu.org; Mon, 29 May 2017 09:26:22 -0400
DKIM-Signature: v=1;a=rsa-sha256;c=relaxed/simple;d=hh.iij4u.or.jp;h=Date:
	Message-Id:To:Subject:From:In-Reply-To:References:Mime-Version:Content-Type:
	Content-Transfer-Encoding; i=ki@hh.iij4u.or.jp; s=20160530.iij4u;
	t=1496064378; 
	x=1497273978; bh=/7ibMJR3oHiFZnttzWpD8PI3MSZhUIpPSJt5ZFh2S54=;
	b=y8JvM5Basckguz
	Hph0kISLLBe60jw272h4taKfGlLO/dh6hm2MljPKrYw5+agT3KX/D+C0moVhfsaYT2vAfpKuBYt1n
	fHUwr3yHcnkPEeawJIBCHx5RMnb3xElQi48yhdZE1It5yajqSNC0elTQSxF+yB+p3KwWde9jjRSsB
	Sz6YcwG93/GPr4IB30LlbJgJ0L/nN3iB4HwrFVr/w4FSug1LDpw5jVWQLT9yJveJLlKHGeMy006a6
	xbeXh2CCXSfRKAiynIPabEZL+NTeuyaeZx8b9HP84HBwdxycEapsXe4/atmjA2VuRNEmanyJtkEd8
	q3CBLesGlEhpZB881YZw==;
Received: by mo-sw.iij4u.or.jp (4u-mo-sw1500) id v4TDQILp027176;
	Mon, 29 May 2017 22:26:18 +0900
Received: from localhost (121.236.69.115.shared.user.transix.jp
	[115.69.236.121])
	by mbox.iij4u.or.jp (4u-mbox1500) id v4TDQH12013201;
	Mon, 29 May 2017 22:26:17 +0900
Date: Mon, 29 May 2017 22:26:18 +0900 (JST)
Message-Id: <20170529.222618.127121719.ki@mbox.iij4u.or.jp>
To: bug-global@gnu.org
Subject: Re: htags generates incorrect anchor when -s option is specified.
From: Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>
In-Reply-To: <20170529202855.D0AB.1976CC75@kit.hi-ho.ne.jp>
References: <CADJmJYqfa2gTUoX-eR=5Pv-HLhXFhgG0Sown4E_xYkrDhtjU8g@mail.gmail.com>
	<20170529.191811.02618136.ki@mbox.iij4u.or.jp>
	<20170529202855.D0AB.1976CC75@kit.hi-ho.ne.jp>
X-Mailer: Mew version 6.7 on Emacs 22.3 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 210.130.239.240
X-BeenThere: bug-global@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Bug reports for GNU GLOBAL <bug-global.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-global/>
List-Post: <mailto:bug-global@gnu.org>
List-Help: <mailto:bug-global-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 29 May 2017 13:26:27 -0000

Hi,

>  http://cvs.savannah.gnu.org/viewcvs/global/libparser/C.c?cvsroot=global&r1=1.14&r2=1.15
>  http://cvs.savannah.gnu.org/viewcvs/global/libparser/Cpp.c?cvsroot=global&r1=1.23&r2=1.24

I applied this patch and get correct result.
Thanks!

> Hi.
> 
>> 'ST1' is linked to '../R/1.html', but 'ST2' is linked to
>> '../S/2.html'. I think 'ST2' should be linked to '../R/2.html'.
> 
> This was caused by a bug in the built-in parser of gtags.
> 
> I have fixed the bug in the repository.
>  http://cvs.savannah.gnu.org/viewcvs/global/libparser/C.c?cvsroot=global&r1=1.14&r2=1.15
>  http://cvs.savannah.gnu.org/viewcvs/global/libparser/Cpp.c?cvsroot=global&r1=1.23&r2=1.24
> 
> Thank you for the report.
> 
> 
> On Mon, 29 May 2017 19:18:11 +0900 (JST)
> Shuichi KITAGUCHI <ki@hh.iij4u.or.jp> wrote:
> 
>> Hi,
>> 
>> > Hi,
>> > Could you please send information to do a reproduction test?
>> > o Which version of FreeBSD?
>> 
>> 11.0-RELEASE (from binary package) and 12-CURRENT.
>> 
>> > o What is the htags's command line?
>> 
>> -s -a -n -g
>> 
>> > o Where is the incorrect anchor link?
>> 
>> When prepare following two header files and execute htags
>> with above options,
>> 
>> [a.h]
>> struct st1 {
>>         ST1 *st1_ptr;
>> };
>> 
>> struct st2 {
>>         ST1 st2_st1;
>> };
>> 
>> struct st3 {
>>         ST2 st3_st2;
>> };
>> 
>> [b.h]
>> typedef struct st1      ST1;
>> typedef struct st2      ST2;
>> typedef struct st3      ST3;
>> 
>> HTML/S/2.html contains below lines.
>> 
>> <a id='L1' name='L1'></a>   1 <strong class='reserved'>typedef</strong> <strong class='reserved'>struct</strong> <a href='../S/1.html#L1' title='Defined at 1 in a.h.'>st1</a>      <a href='../R/1.html' title='Multiple referred from 3 places.'>ST1</a>;
>> <a id='L2' name='L2'></a>   2 <strong class='reserved'>typedef</strong> <strong class='reserved'>struct</strong> <a href='../S/1.html#L5' title='Defined at 5 in a.h.'>st2</a>      <a href='../S/2.html#L2' title='Defined at 2 in b.h.'>ST2</a>;
>> 
>> 'ST1' is linked to '../R/1.html', but 'ST2' is linked to
>> '../S/2.html'. I think 'ST2' should be linked to '../R/2.html'.
>> 
>> > Thank you in advance.
>> > 
>> > Regards,
>> > Shigio
>> 
>> Thanks,
>> 
>> > 2017-05-28 22:37 GMT+09:00 Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>:
>> > 
>> >> Hi,
>> >>
>> >> I've found that htags command generates incorrect anchor link when -s
>> >> option is specified on FreeBSD and Cygwin. Linux is ok.  Upon
>> >> investigation, this seems to be caused by behaviour of qsort().
>> >>
>> >> When anchor->lineno is same and cmp()@htags/anchor.c returns 0, some
>> >> qsort() impelmentation might swap objects. This causes that type 'R'
>> >> is upper than type 'T', and anchor_get() cannot find correct anchor.
>> >>
>> >> If appling below patch to htags/anchor.c, htags seems generate correct
>> >> link.
>> >>
>> >>  static int
>> >>  cmp(const void *s1, const void *s2)
>> >>  {
>> >> +#if 1
>> >> +       int diff = ((struct anchor *)s1)->lineno - ((struct anchor
>> >> *)s2)->lineno;
>> >> +       /* when lineno is same, preserve current order. */
>> >> +       return diff == 0 ? -1 : diff;
>> >> +#else
>> >>         return ((struct anchor *)s1)->lineno - ((struct anchor
>> >> *)s2)->lineno;
>> >> +#endif
>> >>  }
>> >>  /*
>> >>   * Pointers (as lineno).
>> >>
>> >> Is this right fix?
>> >>
>> >> Thanks,
>> >>
>> >> _______________________________________________
>> >> Bug-global mailing list
>> >> Bug-global@gnu.org
>> >> https://lists.gnu.org/mailman/listinfo/bug-global
>> >>
>> > 
>> > 
>> > 
>> > -- 
>> > Shigio YAMAGUCHI <shigio@gnu.org>
>> > PGP fingerprint:
>> > 26F6 31B4 3D62 4A92 7E6F  1C33 969C 3BE3 89DD A6EB
>> 
>> _______________________________________________
>> Bug-global mailing list
>> Bug-global@gnu.org
>> https://lists.gnu.org/mailman/listinfo/bug-global
> 
> -- 
> $B4dK\(B $B=(<y(B <h-iwamoto@kit.hi-ho.ne.jp>
> 


From MAILER-DAEMON Mon May 29 20:05:16 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1dFUey-0006Nm-Pl
	for mharc-bug-global@gnu.org; Mon, 29 May 2017 20:05:16 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55856)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <i.tamacom@gmail.com>) id 1dFUev-0006Ng-Pa
	for bug-global@gnu.org; Mon, 29 May 2017 20:05:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <i.tamacom@gmail.com>) id 1dFUet-0001ga-JB
	for bug-global@gnu.org; Mon, 29 May 2017 20:05:13 -0400
Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]:35740)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <i.tamacom@gmail.com>) id 1dFUet-0001fw-4o
	for bug-global@gnu.org; Mon, 29 May 2017 20:05:11 -0400
Received: by mail-lf0-x231.google.com with SMTP id a5so40806137lfh.2
	for <bug-global@gnu.org>; Mon, 29 May 2017 17:05:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:sender:in-reply-to:references:from:date:message-id
	:subject:to:cc;
	bh=JZtMgT+1SI8le28QB1YJI4H2XVyQGUPCoaA0JURfi0o=;
	b=HUJfZKi3KST4TNhagnkcnXZaTBo+K9uS+D3O+mcglfQu2Kzj6sSHViiClyO4UTanQi
	lv3K5vbfBDzWDte8z8I0BhnBKM61kKaCu4PwCfxVK4jVKf488hCtnIoQSJdG+NIdAPjo
	95NLw/mN8vsfZc9YxEoRqzodLsPK6t70EUtUQGt8pfQR3Iwfwq5Mpf8rDR8G6xZ9qolb
	mLrszfkVgvsILyPfXkYBj8b9zrjuBkXZVhuMz2fwwPGpaiYGmWM/SkQPtQJ/8S3dFuJl
	arDQhBRhTB29T5/u0PJee/aay6V+Wekz+5uCtPjvqOi2XXFzbKv3W5kz/yx6UD1ySF3X
	qUkg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
	:date:message-id:subject:to:cc;
	bh=JZtMgT+1SI8le28QB1YJI4H2XVyQGUPCoaA0JURfi0o=;
	b=b2nluM53LI8h1YCLxel5Gq3uqcyjBevjV0d6Oh/YAC0zI3rUFIDvIsnZxIvkXBGlHc
	H+me40KSYDxWOpbjEg3Mp86enpFMKuOXhz6IiCNQOIsDDKbeQXQNPREZ/6JzNiweuqxU
	bdgbtzRkn9btHoyahFM/WP7zjUdAZnUcEdnBhKGpe0cHCuSJoz6yLJr7Wvp8FxdO4kE+
	XAxDY4yMlNCzem1qqppk458lp9hN2kw1kYLTa3jqucEPr2cShK1u/lToUY/PwC/WNQ6F
	J5dd2HUCvo4tFAxgXaRpAAzvQmTJSTclaevPsoEEsTOk8b630IW/s3yuuXOnkxB6pnWQ
	utOw==
X-Gm-Message-State: AODbwcDwMB2VvMS0nFEFfN/z3xAgdhemcdv5gGc7YJeO6JJpd2X77ESx
	GKqaeAQxmohPxlMJ472g556LfWLJpwVt
X-Received: by 10.46.0.65 with SMTP id 62mr5872174lja.83.1496102709582; Mon,
	29 May 2017 17:05:09 -0700 (PDT)
MIME-Version: 1.0
Sender: i.tamacom@gmail.com
Received: by 10.46.32.37 with HTTP; Mon, 29 May 2017 17:05:08 -0700 (PDT)
In-Reply-To: <20170529.222618.127121719.ki@mbox.iij4u.or.jp>
References: <CADJmJYqfa2gTUoX-eR=5Pv-HLhXFhgG0Sown4E_xYkrDhtjU8g@mail.gmail.com>
	<20170529.191811.02618136.ki@mbox.iij4u.or.jp>
	<20170529202855.D0AB.1976CC75@kit.hi-ho.ne.jp>
	<20170529.222618.127121719.ki@mbox.iij4u.or.jp>
From: Shigio YAMAGUCHI <shigio@gnu.org>
Date: Tue, 30 May 2017 09:05:08 +0900
X-Google-Sender-Auth: unsVtSbMftdtcRQ-viNJaeaQaQE
Message-ID: <CADJmJYp=YmO3VicF=bJu_s2ckM2gNC-eO6MRmm_ROEnyoVj01Q@mail.gmail.com>
Subject: Re: htags generates incorrect anchor when -s option is specified.
To: Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>
Cc: "bug-global@gnu.org" <bug-global@gnu.org>
Content-Type: multipart/alternative; boundary="001a1146ee608d60e90550b28e2b"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2a00:1450:4010:c07::231
X-BeenThere: bug-global@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Bug reports for GNU GLOBAL <bug-global.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-global/>
List-Post: <mailto:bug-global@gnu.org>
List-Help: <mailto:bug-global-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-global>,
	<mailto:bug-global-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 30 May 2017 00:05:15 -0000

--001a1146ee608d60e90550b28e2b
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,
I got the correct result too.
Thank you Iwamoto san, Kitaguch san.

Regards,
Shigio


2017-05-29 22:26 GMT+09:00 Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>:

> Hi,
>
> >  http://cvs.savannah.gnu.org/viewcvs/global/libparser/C.c?
> cvsroot=3Dglobal&r1=3D1.14&r2=3D1.15
> >  http://cvs.savannah.gnu.org/viewcvs/global/libparser/Cpp.
> c?cvsroot=3Dglobal&r1=3D1.23&r2=3D1.24
>
> I applied this patch and get correct result.
> Thanks!
>
> > Hi.
> >
> >> 'ST1' is linked to '../R/1.html', but 'ST2' is linked to
> >> '../S/2.html'. I think 'ST2' should be linked to '../R/2.html'.
> >
> > This was caused by a bug in the built-in parser of gtags.
> >
> > I have fixed the bug in the repository.
> >  http://cvs.savannah.gnu.org/viewcvs/global/libparser/C.c?
> cvsroot=3Dglobal&r1=3D1.14&r2=3D1.15
> >  http://cvs.savannah.gnu.org/viewcvs/global/libparser/Cpp.
> c?cvsroot=3Dglobal&r1=3D1.23&r2=3D1.24
> >
> > Thank you for the report.
> >
> >
> > On Mon, 29 May 2017 19:18:11 +0900 (JST)
> > Shuichi KITAGUCHI <ki@hh.iij4u.or.jp> wrote:
> >
> >> Hi,
> >>
> >> > Hi,
> >> > Could you please send information to do a reproduction test?
> >> > o Which version of FreeBSD?
> >>
> >> 11.0-RELEASE (from binary package) and 12-CURRENT.
> >>
> >> > o What is the htags's command line?
> >>
> >> -s -a -n -g
> >>
> >> > o Where is the incorrect anchor link?
> >>
> >> When prepare following two header files and execute htags
> >> with above options,
> >>
> >> [a.h]
> >> struct st1 {
> >>         ST1 *st1_ptr;
> >> };
> >>
> >> struct st2 {
> >>         ST1 st2_st1;
> >> };
> >>
> >> struct st3 {
> >>         ST2 st3_st2;
> >> };
> >>
> >> [b.h]
> >> typedef struct st1      ST1;
> >> typedef struct st2      ST2;
> >> typedef struct st3      ST3;
> >>
> >> HTML/S/2.html contains below lines.
> >>
> >> <a id=3D'L1' name=3D'L1'></a>   1 <strong class=3D'reserved'>typedef</=
strong>
> <strong class=3D'reserved'>struct</strong> <a href=3D'../S/1.html#L1'
> title=3D'Defined at 1 in a.h.'>st1</a>      <a href=3D'../R/1.html'
> title=3D'Multiple referred from 3 places.'>ST1</a>;
> >> <a id=3D'L2' name=3D'L2'></a>   2 <strong class=3D'reserved'>typedef</=
strong>
> <strong class=3D'reserved'>struct</strong> <a href=3D'../S/1.html#L5'
> title=3D'Defined at 5 in a.h.'>st2</a>      <a href=3D'../S/2.html#L2'
> title=3D'Defined at 2 in b.h.'>ST2</a>;
> >>
> >> 'ST1' is linked to '../R/1.html', but 'ST2' is linked to
> >> '../S/2.html'. I think 'ST2' should be linked to '../R/2.html'.
> >>
> >> > Thank you in advance.
> >> >
> >> > Regards,
> >> > Shigio
> >>
> >> Thanks,
> >>
> >> > 2017-05-28 22:37 GMT+09:00 Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>:
> >> >
> >> >> Hi,
> >> >>
> >> >> I've found that htags command generates incorrect anchor link when =
-s
> >> >> option is specified on FreeBSD and Cygwin. Linux is ok.  Upon
> >> >> investigation, this seems to be caused by behaviour of qsort().
> >> >>
> >> >> When anchor->lineno is same and cmp()@htags/anchor.c returns 0, som=
e
> >> >> qsort() impelmentation might swap objects. This causes that type 'R=
'
> >> >> is upper than type 'T', and anchor_get() cannot find correct anchor=
.
> >> >>
> >> >> If appling below patch to htags/anchor.c, htags seems generate
> correct
> >> >> link.
> >> >>
> >> >>  static int
> >> >>  cmp(const void *s1, const void *s2)
> >> >>  {
> >> >> +#if 1
> >> >> +       int diff =3D ((struct anchor *)s1)->lineno - ((struct ancho=
r
> >> >> *)s2)->lineno;
> >> >> +       /* when lineno is same, preserve current order. */
> >> >> +       return diff =3D=3D 0 ? -1 : diff;
> >> >> +#else
> >> >>         return ((struct anchor *)s1)->lineno - ((struct anchor
> >> >> *)s2)->lineno;
> >> >> +#endif
> >> >>  }
> >> >>  /*
> >> >>   * Pointers (as lineno).
> >> >>
> >> >> Is this right fix?
> >> >>
> >> >> Thanks,
> >> >>
> >> >> _______________________________________________
> >> >> Bug-global mailing list
> >> >> Bug-global@gnu.org
> >> >> https://lists.gnu.org/mailman/listinfo/bug-global
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Shigio YAMAGUCHI <shigio@gnu.org>
> >> > PGP fingerprint:
> >> > 26F6 31B4 3D62 4A92 7E6F  1C33 969C 3BE3 89DD A6EB
> >>
> >> _______________________________________________
> >> Bug-global mailing list
> >> Bug-global@gnu.org
> >> https://lists.gnu.org/mailman/listinfo/bug-global
> >
> > --
> > =E5=B2=A9=E6=9C=AC =E7=A7=80=E6=A8=B9 <h-iwamoto@kit.hi-ho.ne.jp>
> >
>
> _______________________________________________
> Bug-global mailing list
> Bug-global@gnu.org
> https://lists.gnu.org/mailman/listinfo/bug-global
>



--=20
Shigio YAMAGUCHI <shigio@gnu.org>
PGP fingerprint:
26F6 31B4 3D62 4A92 7E6F  1C33 969C 3BE3 89DD A6EB

--001a1146ee608d60e90550b28e2b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div>Hi,</div><div>I got the correct result too.</div=
><div>Thank you Iwamoto san, Kitaguch san.</div><div><br></div><div>Regards=
,</div><div>Shigio</div></div><div><br></div></div><div class=3D"gmail_extr=
a"><br><div class=3D"gmail_quote">2017-05-29 22:26 GMT+09:00 Shuichi KITAGU=
CHI <span dir=3D"ltr">&lt;<a href=3D"mailto:ki@hh.iij4u.or.jp" target=3D"_b=
lank">ki@hh.iij4u.or.jp</a>&gt;</span>:<br><blockquote class=3D"gmail_quote=
" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">H=
i,<br>
<br>
&gt;=C2=A0 <a href=3D"http://cvs.savannah.gnu.org/viewcvs/global/libparser/=
C.c?cvsroot=3Dglobal&amp;r1=3D1.14&amp;r2=3D1.15" rel=3D"noreferrer" target=
=3D"_blank">http://cvs.savannah.gnu.org/<wbr>viewcvs/global/libparser/C.c?<=
wbr>cvsroot=3Dglobal&amp;r1=3D1.14&amp;r2=3D1.15</a><br>
&gt;=C2=A0 <a href=3D"http://cvs.savannah.gnu.org/viewcvs/global/libparser/=
Cpp.c?cvsroot=3Dglobal&amp;r1=3D1.23&amp;r2=3D1.24" rel=3D"noreferrer" targ=
et=3D"_blank">http://cvs.savannah.gnu.org/<wbr>viewcvs/global/libparser/Cpp=
.<wbr>c?cvsroot=3Dglobal&amp;r1=3D1.23&amp;r2=3D1.<wbr>24</a><br>
<br>
I applied this patch and get correct result.<br>
Thanks!<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
&gt; Hi.<br>
&gt;<br>
&gt;&gt; &#39;ST1&#39; is linked to &#39;../R/1.html&#39;, but &#39;ST2&#39=
; is linked to<br>
&gt;&gt; &#39;../S/2.html&#39;. I think &#39;ST2&#39; should be linked to &=
#39;../R/2.html&#39;.<br>
&gt;<br>
&gt; This was caused by a bug in the built-in parser of gtags.<br>
&gt;<br>
&gt; I have fixed the bug in the repository.<br>
&gt;=C2=A0 <a href=3D"http://cvs.savannah.gnu.org/viewcvs/global/libparser/=
C.c?cvsroot=3Dglobal&amp;r1=3D1.14&amp;r2=3D1.15" rel=3D"noreferrer" target=
=3D"_blank">http://cvs.savannah.gnu.org/<wbr>viewcvs/global/libparser/C.c?<=
wbr>cvsroot=3Dglobal&amp;r1=3D1.14&amp;r2=3D1.15</a><br>
&gt;=C2=A0 <a href=3D"http://cvs.savannah.gnu.org/viewcvs/global/libparser/=
Cpp.c?cvsroot=3Dglobal&amp;r1=3D1.23&amp;r2=3D1.24" rel=3D"noreferrer" targ=
et=3D"_blank">http://cvs.savannah.gnu.org/<wbr>viewcvs/global/libparser/Cpp=
.<wbr>c?cvsroot=3Dglobal&amp;r1=3D1.23&amp;r2=3D1.<wbr>24</a><br>
&gt;<br>
&gt; Thank you for the report.<br>
&gt;<br>
&gt;<br>
&gt; On Mon, 29 May 2017 19:18:11 +0900 (JST)<br>
&gt; Shuichi KITAGUCHI &lt;<a href=3D"mailto:ki@hh.iij4u.or.jp">ki@hh.iij4u=
.or.jp</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt; Could you please send information to do a reproduction test?<=
br>
&gt;&gt; &gt; o Which version of FreeBSD?<br>
&gt;&gt;<br>
&gt;&gt; 11.0-RELEASE (from binary package) and 12-CURRENT.<br>
&gt;&gt;<br>
&gt;&gt; &gt; o What is the htags&#39;s command line?<br>
&gt;&gt;<br>
&gt;&gt; -s -a -n -g<br>
&gt;&gt;<br>
&gt;&gt; &gt; o Where is the incorrect anchor link?<br>
&gt;&gt;<br>
&gt;&gt; When prepare following two header files and execute htags<br>
&gt;&gt; with above options,<br>
&gt;&gt;<br>
&gt;&gt; [a.h]<br>
&gt;&gt; struct st1 {<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ST1 *st1_ptr;<br>
&gt;&gt; };<br>
&gt;&gt;<br>
&gt;&gt; struct st2 {<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ST1 st2_st1;<br>
&gt;&gt; };<br>
&gt;&gt;<br>
&gt;&gt; struct st3 {<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ST2 st3_st2;<br>
&gt;&gt; };<br>
&gt;&gt;<br>
&gt;&gt; [b.h]<br>
&gt;&gt; typedef struct st1=C2=A0 =C2=A0 =C2=A0 ST1;<br>
&gt;&gt; typedef struct st2=C2=A0 =C2=A0 =C2=A0 ST2;<br>
&gt;&gt; typedef struct st3=C2=A0 =C2=A0 =C2=A0 ST3;<br>
&gt;&gt;<br>
&gt;&gt; HTML/S/2.html contains below lines.<br>
&gt;&gt;<br>
&gt;&gt; &lt;a id=3D&#39;L1&#39; name=3D&#39;L1&#39;&gt;&lt;/a&gt;=C2=A0 =
=C2=A01 &lt;strong class=3D&#39;reserved&#39;&gt;typedef&lt;/<wbr>strong&gt=
; &lt;strong class=3D&#39;reserved&#39;&gt;struct&lt;/<wbr>strong&gt; &lt;a=
 href=3D&#39;../S/1.html#L1&#39; title=3D&#39;Defined at 1 in a.h.&#39;&gt;=
st1&lt;/a&gt;=C2=A0 =C2=A0 =C2=A0 &lt;a href=3D&#39;../R/1.html&#39; title=
=3D&#39;Multiple referred from 3 places.&#39;&gt;ST1&lt;/a&gt;;<br>
&gt;&gt; &lt;a id=3D&#39;L2&#39; name=3D&#39;L2&#39;&gt;&lt;/a&gt;=C2=A0 =
=C2=A02 &lt;strong class=3D&#39;reserved&#39;&gt;typedef&lt;/<wbr>strong&gt=
; &lt;strong class=3D&#39;reserved&#39;&gt;struct&lt;/<wbr>strong&gt; &lt;a=
 href=3D&#39;../S/1.html#L5&#39; title=3D&#39;Defined at 5 in a.h.&#39;&gt;=
st2&lt;/a&gt;=C2=A0 =C2=A0 =C2=A0 &lt;a href=3D&#39;../S/2.html#L2&#39; tit=
le=3D&#39;Defined at 2 in b.h.&#39;&gt;ST2&lt;/a&gt;;<br>
&gt;&gt;<br>
&gt;&gt; &#39;ST1&#39; is linked to &#39;../R/1.html&#39;, but &#39;ST2&#39=
; is linked to<br>
&gt;&gt; &#39;../S/2.html&#39;. I think &#39;ST2&#39; should be linked to &=
#39;../R/2.html&#39;.<br>
&gt;&gt;<br>
&gt;&gt; &gt; Thank you in advance.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Regards,<br>
&gt;&gt; &gt; Shigio<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt;<br>
&gt;&gt; &gt; 2017-05-28 22:37 GMT+09:00 Shuichi KITAGUCHI &lt;<a href=3D"m=
ailto:ki@hh.iij4u.or.jp">ki@hh.iij4u.or.jp</a>&gt;:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Hi,<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; I&#39;ve found that htags command generates incorrect anc=
hor link when -s<br>
&gt;&gt; &gt;&gt; option is specified on FreeBSD and Cygwin. Linux is ok.=
=C2=A0 Upon<br>
&gt;&gt; &gt;&gt; investigation, this seems to be caused by behaviour of qs=
ort().<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; When anchor-&gt;lineno is same and cmp()@htags/anchor.c r=
eturns 0, some<br>
&gt;&gt; &gt;&gt; qsort() impelmentation might swap objects. This causes th=
at type &#39;R&#39;<br>
&gt;&gt; &gt;&gt; is upper than type &#39;T&#39;, and anchor_get() cannot f=
ind correct anchor.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; If appling below patch to htags/anchor.c, htags seems gen=
erate correct<br>
&gt;&gt; &gt;&gt; link.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;=C2=A0 static int<br>
&gt;&gt; &gt;&gt;=C2=A0 cmp(const void *s1, const void *s2)<br>
&gt;&gt; &gt;&gt;=C2=A0 {<br>
&gt;&gt; &gt;&gt; +#if 1<br>
&gt;&gt; &gt;&gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0int diff =3D ((struct anchor =
*)s1)-&gt;lineno - ((struct anchor<br>
&gt;&gt; &gt;&gt; *)s2)-&gt;lineno;<br>
&gt;&gt; &gt;&gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0/* when lineno is same, prese=
rve current order. */<br>
&gt;&gt; &gt;&gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0return diff =3D=3D 0 ? -1 : d=
iff;<br>
&gt;&gt; &gt;&gt; +#else<br>
&gt;&gt; &gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return ((struct anchor *=
)s1)-&gt;lineno - ((struct anchor<br>
&gt;&gt; &gt;&gt; *)s2)-&gt;lineno;<br>
&gt;&gt; &gt;&gt; +#endif<br>
&gt;&gt; &gt;&gt;=C2=A0 }<br>
&gt;&gt; &gt;&gt;=C2=A0 /*<br>
&gt;&gt; &gt;&gt;=C2=A0 =C2=A0* Pointers (as lineno).<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Is this right fix?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Thanks,<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; &gt;&gt; Bug-global mailing list<br>
&gt;&gt; &gt;&gt; <a href=3D"mailto:Bug-global@gnu.org">Bug-global@gnu.org<=
/a><br>
&gt;&gt; &gt;&gt; <a href=3D"https://lists.gnu.org/mailman/listinfo/bug-glo=
bal" rel=3D"noreferrer" target=3D"_blank">https://lists.gnu.org/mailman/<wb=
r>listinfo/bug-global</a><br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt; Shigio YAMAGUCHI &lt;<a href=3D"mailto:shigio@gnu.org">shigio=
@gnu.org</a>&gt;<br>
&gt;&gt; &gt; PGP fingerprint:<br>
&gt;&gt; &gt; 26F6 31B4 3D62 4A92 7E6F=C2=A0 1C33 969C 3BE3 89DD A6EB<br>
&gt;&gt;<br>
&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; Bug-global mailing list<br>
&gt;&gt; <a href=3D"mailto:Bug-global@gnu.org">Bug-global@gnu.org</a><br>
&gt;&gt; <a href=3D"https://lists.gnu.org/mailman/listinfo/bug-global" rel=
=3D"noreferrer" target=3D"_blank">https://lists.gnu.org/mailman/<wbr>listin=
fo/bug-global</a><br>
&gt;<br>
&gt; --<br>
&gt; =E5=B2=A9=E6=9C=AC =E7=A7=80=E6=A8=B9 &lt;<a href=3D"mailto:h-iwamoto@=
kit.hi-ho.ne.jp">h-iwamoto@kit.hi-ho.ne.jp</a>&gt;<br>
&gt;<br>
<br>
______________________________<wbr>_________________<br>
Bug-global mailing list<br>
<a href=3D"mailto:Bug-global@gnu.org">Bug-global@gnu.org</a><br>
<a href=3D"https://lists.gnu.org/mailman/listinfo/bug-global" rel=3D"norefe=
rrer" target=3D"_blank">https://lists.gnu.org/mailman/<wbr>listinfo/bug-glo=
bal</a><br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>=
<div class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=
=3D"ltr"><div><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=
=3D"ltr"><div dir=3D"ltr">Shigio YAMAGUCHI &lt;<a href=3D"mailto:shigio@gnu=
.org" target=3D"_blank">shigio@gnu.org</a>&gt;</div><div dir=3D"ltr"><div d=
ir=3D"ltr">PGP fingerprint:=C2=A0</div><div dir=3D"ltr">26F6 31B4 3D62 4A92=
 7E6F =C2=A01C33 969C 3BE3 89DD A6EB</div></div></div></div></div></div></d=
iv></div></div>
</div>

--001a1146ee608d60e90550b28e2b--


