Bug: C/C++ Function Pointer Return Types Misalign Argument Block
Description
In gitgalaxy/core/detector.py, the _count_top_level_args parses the argument string by assuming the parameter list starts after the first open parenthesis it encounters:
if not treat_as_body:
open_idx = args_str.find("(")
if open_idx != -1:
body = args_str[open_idx + 1 : self._matching_paren_end(args_str, open_idx)]
For standard function signatures (e.g. int foo(int a, int b)), this reliably isolates the parameter block. However, if a C or C++ function returns a function pointer, the function name is wrapped in a parenthesis (e.g., void (*foo(int a, int b))(int c)).
Impact
The .find("(") logic incorrectly locks onto the opening parenthesis of the return type block ((*foo...).
The resulting body string ends up being truncated incorrectly (e.g., *foo(int a, int b), creating an unbalanced open parenthesis. All commas inside this misaligned block are treated as having depth = 1 and are therefore hidden from the argument counter.
Steps to Reproduce
- Test with the signature:
void (*foo(int a, int b))(int c)
- Observe that the returned argument count is
0 instead of 2.
Suggested Fix
Improve the bounding logic for C-family languages to detect function pointer syntax and skip to the correct parameter parenthesis, or use treat_as_body=True for these specific signatures so the regex handles the precise capture.
Bug: C/C++ Function Pointer Return Types Misalign Argument Block
Description
In
gitgalaxy/core/detector.py, the_count_top_level_argsparses the argument string by assuming the parameter list starts after the first open parenthesis it encounters:For standard function signatures (e.g.
int foo(int a, int b)), this reliably isolates the parameter block. However, if a C or C++ function returns a function pointer, the function name is wrapped in a parenthesis (e.g.,void (*foo(int a, int b))(int c)).Impact
The
.find("(")logic incorrectly locks onto the opening parenthesis of the return type block ((*foo...).The resulting
bodystring ends up being truncated incorrectly (e.g.,*foo(int a, int b), creating an unbalanced open parenthesis. All commas inside this misaligned block are treated as havingdepth = 1and are therefore hidden from the argument counter.Steps to Reproduce
void (*foo(int a, int b))(int c)0instead of2.Suggested Fix
Improve the bounding logic for C-family languages to detect function pointer syntax and skip to the correct parameter parenthesis, or use
treat_as_body=Truefor these specific signatures so the regex handles the precise capture.