[Github-comments] [geany/geany] TM cleanups (#957)

Colomban Wendling notifications at xxxxx
Wed May 4 16:41:40 UTC 2016


> + */
> +
> +#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:
```c
#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:
```terminal
$ ./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:
https://github.com/geany/geany/pull/957/files/103d2c535862ae2682022dcfd714c2ffd983c42f..1c4aaa0eb72aa9e3c60cd604d4c20ca5f7dc5c8f#r62072600
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160504/15442339/attachment.html>


More information about the Github-comments mailing list