bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: htags generates incorrect anchor when -s option is specified.


From: Hideki IWAMOTO
Subject: Re: htags generates incorrect anchor when -s option is specified.
Date: Mon, 29 May 2017 20:28:57 +0900

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 <address@hidden> 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 <address@hidden>:
> > 
> >> 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
> >> address@hidden
> >> https://lists.gnu.org/mailman/listinfo/bug-global
> >>
> > 
> > 
> > 
> > -- 
> > Shigio YAMAGUCHI <address@hidden>
> > PGP fingerprint:
> > 26F6 31B4 3D62 4A92 7E6F  1C33 969C 3BE3 89DD A6EB
> 
> _______________________________________________
> Bug-global mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-global

-- 
岩本 秀樹 <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]