bug-global
[Top][All Lists]
Advanced

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

htags generates incorrect anchor when -s option is specified.


From: Shuichi KITAGUCHI
Subject: htags generates incorrect anchor when -s option is specified.
Date: Sun, 28 May 2017 22:37:57 +0900 (JST)

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,



reply via email to

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