[Top][All Lists]

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

[Bug-indent] No space before `*' in declarations

From: Pavel Roskin
Subject: [Bug-indent] No space before `*' in declarations
Date: Fri, 6 Dec 2002 21:18:13 -0500 (EST)


My previous patch was ignored:

Let me try one more time.  This patch is different because it fixes the
space not only in function definitions, but also in function declarations.
Also it only applies to "*".  Other binary operators are still followed by
space, although I don't think you can find them in declarations and

--- src/indent.c
+++ src/indent.c
@@ -1039,7 +1039,11 @@ static exit_values_ty indent (

-                parser_state_tos->want_blank = true;
+                /* no space after * in declarations and definitions */
+                parser_state_tos->want_blank = !(token[0] == '*'
+                                                 && parser_state_tos->
+                                                    procname[0] != '\0');

             case postop:                /* got a trailing ++ or -- */

Test file:
int f (foo_t *a, char *b);
f (foo_t *a, char *b)
    char *c;
    foo_t *d;
    return 1 * 2;

I also tested patched indent on large C files, and the difference from
indent 2.2.8 is only what I expect it to be.

There is an alternative solution that can be considered by those who know
the code better.  I believe that lexi() should return decl for "foo_t *a",
just like it would do for "struct foo_t *a"

If you look for "The following hack" in lexi.c, it doesn't check if the
parser is working with function arguments.  I don't feel save about
changing that huge condition without having the testsuite.

Pavel Roskin

reply via email to

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