Menu

#257 nonunique anonymous struct id when append to tags file

open
nobody
None
5
2009-07-10
2009-07-10
Kevin Lei
No

Suppose we create a tags file foobar from some files include foo.c and bar.c.
Later we modified bar.c, and execute "ctags -a bar.c foo", now the anonymous struct in bar.c will named as anon1, anon2, etc in the tags file foobar, but the anonymous struct in file foo.c also named anon1, anon2, ...

I suggest use random number as the initial value of AnonymousID, to avoid this problem.

I wrote a patch, see attachment please.

Discussion

  • Kevin Lei

    Kevin Lei - 2009-07-10

    random_anon_struct_id.diff

     
  • Dan Price

    Dan Price - 2010-11-09

    I've also been affected by this behavior. I use a plugin in my editor to automatically update my tags file, appending to it, which results in this error.

     
  • Dmitry Frank

    Dmitry Frank - 2010-11-11

    I've also been affected by this behavior, but I don't like solution suggested by Kevin Lei in two reasons:
    1) when user appends tags for file that are already indexed, then all anonymous structures will be doubled (because of random number will be different every time).
    2) ctags with this patch doesn't compile successfully under Windows. It works at unix-like only systems.

    I suggest smarter solution: anonymous structs naming method is: "__anon_<filename>_<linenumber>".

    I've made patch: http://tinyurl.com/ctags-bug2

     

Log in to post a comment.