Re: gtags behaves strange when parsing code with the right curly brace in #else clause.

Shigio YAMAGUCHI <[email protected]>
Newsgroups gmane.comp.gnu.global.bugs
Message-ID <CADJmJYrLbkxDP-QZxSU=7AF1JSXykCfVGSD64zvhmJwddoetrg@mail.gmail.com>
Hi,
> The function foo2 was ignored:

This problem will solved by the attached patch.
Could you please do like this using the patched version?

$ export GTAGSFORCEENDBLOCK=
$ gtags
$ global -x '.*'
FOO                 1 test.c           #define FOO
foo1                3 test.c           int foo1()
foo2               14 test.c           int foo2()

If there is no problem, I will apply the patch to
the next release of GLOBAL.

> I'm sorry that my English is poor.
Me too. :)

Regards,
Shigio


2015-08-05 23:07 GMT+09:00 刘洋 <[email protected]>:

> Hi,
>
> My gtags behaves strange when parsing this code:
>
>   1 #define FOO
>   2
>   3 int foo1()
>   4 {
>   5     if (1)
>   6     {
>   7 #ifndef FOO
>   8 #else
>   9     }
>  10 #endif
>  11     return 1;
>  12 }
>  13
>  14 int foo2()
>  15 {
>  16     return 1;
>  17 }
>
>
> The function foo2 was ignored:
>
> $ gtags --verbose
> [Wed Aug 05 21:32:12 CST 2015] Gtags started.
> [Wed Aug 05 21:32:12 CST 2015] Creating 'GTAGS' and 'GRTAGS'.
>  [1] extracting tags of test.c
> [Wed Aug 05 21:32:12 CST 2015] Done.
>
> $ gtags -d GTAGS
>  __.COMPNAME __.COMPNAME
>  __.COMPRESS __.COMPRESS ddefine ttypedef
>  __.VERSION __.VERSION 6
> FOO 1 @n 1 #@d @n
> foo1 1 @n 3 int @n()
>
>
> My gtags version is 6.5:
>
> $ gtags --version
> gtags (GNU GLOBAL) 6.5
> Copyright (c) 2015 Tama Communications Corporation
> License GPLv3+: GNU GPL version 3 or later <
> http://www.gnu.org/licenses/gpl.html>
> This is free software; you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
>
> $ cat /etc/issue
> Ubuntu 15.04 \n \l
>
> $ uname -a
> Linux 7 3.19.0-22-generic #22-Ubuntu SMP Tue Jun 16 17:15:15 UTC 2015
> x86_64 x86_64 x86_64 GNU/Linux
>
>
> I think it's the same error when gtags parsing MySQL sql_parse.cc
> <https://github.com/mysql/mysql-server/blob/5.6/sql/sql_parse.cc> at line
> 1983 to line 2002.
> All functions after line 2001 was ignored.
>
>
> I'm sorry that my English is poor. If you need more information, please
> let me know.
>
> Thanks for your hard on GNU global!
>
> _______________________________________________
> Bug-global mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/bug-global
>
>


-- 
Shigio YAMAGUCHI <[email protected]>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3

_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global
block.patch (application/octet-stream, 2 KB)
Index: global/global.c
===================================================================
RCS file: /sources/global/global/global/global.c,v
retrieving revision 1.299
diff -c -r1.299 global.c
*** global/global.c	22 Jun 2015 06:42:35 -0000	1.299
--- global/global.c	6 Aug 2015 01:11:15 -0000
***************
*** 1617,1622 ****
--- 1617,1624 ----
  	if (wflag)
  		flags |= PARSER_WARNING;
  	*/
+ 	if (getenv("GTAGSFORCEENDBLOCK"))
+ 		flags |= PARSER_END_BLOCK;
  	if (db == GRTAGS + GSYMS)
  		data.target = TARGET_REF|TARGET_SYM;
  	else
Index: gtags/gtags.c
===================================================================
RCS file: /sources/global/global/gtags/gtags.c,v
retrieving revision 1.275
diff -c -r1.275 gtags.c
*** gtags/gtags.c	24 Jun 2015 01:59:25 -0000	1.275
--- gtags/gtags.c	6 Aug 2015 01:11:15 -0000
***************
*** 882,887 ****
--- 882,889 ----
  		flags |= PARSER_WARNING;
  	if (explain)
  		flags |= PARSER_EXPLAIN;
+ 	if (getenv("GTAGSFORCEENDBLOCK"))
+ 		flags |= PARSER_END_BLOCK;
  	/*
  	 * Add tags to GTAGS and GRTAGS.
  	 */
***************
*** 943,948 ****
--- 945,952 ----
  		flags |= PARSER_WARNING;
  	if (explain)
  		flags |= PARSER_EXPLAIN;
+ 	if (getenv("GTAGSFORCEENDBLOCK"))
+ 		flags |= PARSER_END_BLOCK;
  	/*
  	 * Add tags to GTAGS and GRTAGS.
  	 */
Index: gtags/manual.in
===================================================================
RCS file: /sources/global/global/gtags/manual.in,v
retrieving revision 1.101
diff -c -r1.101 manual.in
*** gtags/manual.in	28 Jun 2015 22:06:52 -0000	1.101
--- gtags/manual.in	6 Aug 2015 01:11:15 -0000
***************
*** 143,148 ****
--- 143,151 ----
  	@item{@var{GTAGSFORCECPP}}
  		If this variable is set, each file whose suffix is @file{.h} is treated
  		as a C++ source file.
+ 	@item{@var{GTAGSFORCEENDBLOCK}}
+ 		If this variable is set, each @} at the first column brings end of block
+ 		of 0 level.
  	@item{@var{GTAGSLABEL}}
  		Configuration label. The default is @val{default}.
  	@item{@var{GTAGSLOGGING}}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.