bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: With a wacky macro before it, 'global' appears to miss a function


From: Ezolt, Phillip
Subject: Re: With a wacky macro before it, 'global' appears to miss a function
Date: Sat, 23 Apr 2011 22:12:05 -0400

Shigio,

On Apr 23, 2011, at 7:27 PM, "Shigio YAMAGUCHI" <address@hidden> wrote:

> Hello,
> Thank you for the bug report.
> 
> To solve the problem, I would like to add a new rule like follows:
> 

Thanks for looking at this.

> (In C parser)
> A function definition must not have blank lines between the first "(" and the 
> first "{".
> 
> o An example that is a definition.
> 
> int main(int argc, char *argv[])
> {                    <= blank lines don't exist.
> 
>    printf("Hello\n");
> 
> }
> 
> o An example that is not a definition.
> 
> int main(int argc, char *argv[])
>                    <= blank lines exist.
> {
> 
>    printf("Hello\n");
> 
> }
> 
> The difference of the two is whether there are blank lines between
> "main(" and the first "{".
> 
> What do you think?

That seems a little dangerous to me.  I could easily see someone adding an 
extra line after a function definition by accident,  and being completely 
confused when that function doesn't show up. (leading to another bug report..)
...

Alternatively, would it be possible to use the semicolon at the end of the 
STRUCT_DEF_MACRO to stop the parsing of that function? (so we move on to the 
next function..)

The rule should be something like: If we hit a semicolon,  and we don't have 
any open braces, then consider the function to be complete..

Cheers,
--Phil
> 
>> If there is a wacky macro before a function, it appears as if global  
>> misses the functions after it.
>> 
>> Sample:
>> test.c:
>> 
>> #define STRUCT_DEF_MACRO(name, type)    \
>> struct name {                      \
>>      struct type *first;        \
>> }
>> 
>> STRUCT_DEF_MACRO(my_struct, int) struct_instance_name;
>> 
>> void test_func(long dummy1, long dummy2)
>> {
>> 
>> }
>> 
>> .....
>> Current behavior:  (NOTICE: test_func is missing from the display)
>> address@hidden test]$ ../global-5.9.4/gtags/gtags ; ../global-5.9.4/ 
>> global/global -f test.c
>> STRUCT_DEF_MACRO    1 test.c           #define STRUCT_DEF_MACRO(name,  
>> type)    \
>> name                2 test.c           struct name {                      \
>> STRUCT_DEF_MACRO    6 test.c           STRUCT_DEF_MACRO(my_struct,  
>> int) struct_instance_name;
>> 
>> 
>> Expected Behavior:
>> address@hidden test]$ ../global-5.9.4/gtags/gtags ; ../global-5.9.4/ 
>> global/global -f test.c
>> STRUCT_DEF_MACRO    1 test.c           #define STRUCT_DEF_MACRO(name,  
>> type)    \
>> name                2 test.c           struct name {                      \
>> test_func           8 test.c           void test_func(long dummy1,  
>> long dummy2)
>> 
>> 
>> (NOTE: If you comment out the call to 'STRUCT_DEF_MACRO', things  
>> behave as expected..)
>> 
>> Cheers,
>> --Phil
> --
> Shigio YAMAGUCHI <address@hidden>
> PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3



reply via email to

[Prev in Thread] Current Thread [Next in Thread]