Indent reads a function pointer with more than one level of indirection
such as char **(*x) as 'char *' [decl] '*' [unary_op] '(' [lparen] which
was preventing it from being detected as a function pointer since the code
for that was expecting only 'decl' before the lparen.
This patch fixes the detection code to account for this fact, since it
seems that there's other functionality relying on it.
---
ChangeLog | 2 ++
regression/input/fp.c | 1 +
regression/standard/fp.c | 1 +
regression/standard/no-space-after-fp-name.c | 1 +
src/handletoken.c | 6 ++++--
5 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 96bc261..101bcbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,8 @@
* Added an option (-ntac/--dont-tab-align-comments) which if specified
prevents indent from automagically pushing comments out to the
nearest tabstoo.
+ * Fixed recognition of function pointers with multiple levels of
+ indirection by the -npcs stuff.
2015-06-16 Tim Hentenaar <[email protected]>
* Use want_blank instead of copying a space to e_code to avoid
diff --git a/regression/input/fp.c b/regression/input/fp.c
index 92f6354..dc869f3 100644
--- a/regression/input/fp.c
+++ b/regression/input/fp.c
@@ -1,6 +1,7 @@
int (*fp ())();
register void (*GCForward) () asm ("r16"); /* GC Forwarding code */
+char **(*get_string_array) (const char *s1, const char *s2);
main ()
{
diff --git a/regression/standard/fp.c b/regression/standard/fp.c
index af15ae8..dc775af 100644
--- a/regression/standard/fp.c
+++ b/regression/standard/fp.c
@@ -1,6 +1,7 @@
int (*fp ()) ();
register void (*GCForward) () asm ("r16"); /* GC Forwarding code */
+char **(*get_string_array) (const char *s1, const char *s2);
main ()
{
diff --git a/regression/standard/no-space-after-fp-name.c
b/regression/standard/no-space-after-fp-name.c
index 6bc5885..3b52ef7 100644
--- a/regression/standard/no-space-after-fp-name.c
+++ b/regression/standard/no-space-after-fp-name.c
@@ -1,6 +1,7 @@
int (*fp())();
register void (*GCForward)() asm("r16"); /* GC Forwarding code */
+char **(*get_string_array)(const char *s1, const char *s2);
main()
{
diff --git a/src/handletoken.c b/src/handletoken.c
index b3a807d..60828d5 100644
--- a/src/handletoken.c
+++ b/src/handletoken.c
@@ -353,8 +353,10 @@ static void handle_token_lparen(
}
/* Remember if this looks like a function pointer decl. */
- if (parser_state_tos->want_blank &&
- parser_state_tos->last_token == decl && *(token + 1) == '*')
+ if (*(token + 1) == '*' &&
+ parser_state_tos->last_rw == rw_decl &&
+ (parser_state_tos->last_token == decl ||
+ parser_state_tos->last_token == unary_op))
parser_state_tos->is_func_ptr_decl = true;
if (parser_state_tos->in_decl && !parser_state_tos->block_init)
--
2.3.6
_______________________________________________
bug-indent mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-indent