In tagmanager/src/tm_ctags_wrappers.h:

> + */
> +
> +#ifndef TM_CTAGS_WRAPPERS
> +#define TM_CTAGS_WRAPPERS
> +
> +#include <glib.h>
> +
> +#include "tm_parser.h"
> +
> +#include "entry.h" /* for sTagEntryInfo */
> +
> +
> +G_BEGIN_DECLS
> +
> +typedef gboolean (*tm_ctags_callback) (const tagEntryInfo *const tag,
> +	gboolean invalidate, void *user_data);

AFAIK it's meant to recover from weird proeproc cases, i.e. imagine this C code:

#define FOO 0

int main(void)
{
#if FOO
  if (1) {
#endif
    // ...
#if ! FOO
  // ...
#else
  }
#endif

  return 0;
}

int foo() {

}

It has unmatched braces if you always take the first preproc branch.

However, AFAICT the current code can never hit: the passCount starts at 0 (I blamed it back to the initial revision), but the only code path setting retry to TRUE is guarded with if (exception == ExceptionBraceFormattingError && passCount == 1), so it could only happen on the second pass, which can't itself won't happen as it won't ever retry.
I imagine this is an oversight at some point and passCount shouldstart at 1, but indeed currently it seems like plain dead code.

U-Ctags doesn not have this bug, because it indeed starts passCount at one, by incrementing it before calling the rescanning parser: createTagsForFile (fileName, language, ++passCount), so it does start at 1, not 0.
With current version of the OldC parser (somewhat the one we have) you'll see it does output the foo tag we don't:

$ ./ctags --verbose --languages=OldC -o - file.c
...
OPENING file.c as OldC language file
/tmp/a.c: failed to find match for '{' at line 5
/tmp/a.c: retrying file with fallback brace matching algorithm
OPENING file.c as OldC language file
sorting tag file
system ("sort -u")
FOO file.c  /^#define FOO /;"   d   file:
foo file.c  /^int foo() {$/;"   f
main    file.c  /^int main(void)$/;"    f


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub