[PATCH] fix handling of enum typedef

View: New views
2 Messages — Rating Filter:   Alert me  

[PATCH] fix handling of enum typedef

by Hideki IWAMOTO :: Rate this Message:

| View Threaded | Show Only this Message

C/C++ parser cannot handle typedef of the form of
 typedef enum tag_name TYPEDEF_NAME;
correctly.
The attached patch corrects this bug.

diffstat:
 libparser/C.c   |    7 +++++--
 libparser/Cpp.c |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

=== example ===

$ cat -n b.c
     1  typedef enum { X } BAR, *BAZ;
     2  typedef enum foo { X } BAR, *BAZ;
     3  typedef enum foo BAR, *BAZ;

[ version 6.2 and current CVS version ]
$ global -f b.c
X                   1 b.c              typedef enum { X } BAR, *BAZ;
BAR                 1 b.c              typedef enum { X } BAR, *BAZ;
BAZ                 1 b.c              typedef enum { X } BAR, *BAZ;
foo                 2 b.c              typedef enum foo { X } BAR, *BAZ;
X                   2 b.c              typedef enum foo { X } BAR, *BAZ;
BAR                 2 b.c              typedef enum foo { X } BAR, *BAZ;
BAZ                 2 b.c              typedef enum foo { X } BAR, *BAZ;
$ global -frs b.c
foo                 3 b.c              typedef enum foo BAR, *BAZ;
BAR                 3 b.c              typedef enum foo BAR, *BAZ;
BAZ                 3 b.c              typedef enum foo BAR, *BAZ;

[ patched version ]
$ global -f b.c
X                   1 b.c              typedef enum { X } BAR, *BAZ;
BAR                 1 b.c              typedef enum { X } BAR, *BAZ;
BAZ                 1 b.c              typedef enum { X } BAR, *BAZ;
foo                 2 b.c              typedef enum foo { X } BAR, *BAZ;
X                   2 b.c              typedef enum foo { X } BAR, *BAZ;
BAR                 2 b.c              typedef enum foo { X } BAR, *BAZ;
BAZ                 2 b.c              typedef enum foo { X } BAR, *BAZ;
BAR                 3 b.c              typedef enum foo BAR, *BAZ;
BAZ                 3 b.c              typedef enum foo BAR, *BAZ;
$ global -frs b.c
foo                 3 b.c              typedef enum foo BAR, *BAZ;

--
Hideki IWAMOTO <h-iwamoto@...>


_______________________________________________
Bug-global mailing list
Bug-global@...
https://lists.gnu.org/mailman/listinfo/bug-global

20120217-enum_typedef.patch (1K) Download Attachment

Re: [PATCH] fix handling of enum typedef

by Shigio YAMAGUCHI-2 :: Rate this Message:

| View Threaded | Show Only this Message

Hi,
> C/C++ parser cannot handle typedef of the form of
>  typedef enum tag_name TYPEDEF_NAME;
> correctly.
> The attached patch corrects this bug.
...
> [ patched version ]
$ global -f b.c
...
> foo                 2 b.c              typedef enum foo { X } BAR, *BAZ;
> $ global -frs b.c
> foo                 3 b.c              typedef enum foo BAR, *BAZ;

Understanding it took time for a while.
Thank you for nice work.
--
Shigio YAMAGUCHI <shigio@...>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3

_______________________________________________
Bug-global mailing list
Bug-global@...
https://lists.gnu.org/mailman/listinfo/bug-global