bug-indent
[Top][All Lists]
Advanced

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

Option to put space in function definiton


From: Dmitry Bogatov
Subject: Option to put space in function definiton
Date: Sat, 3 Jul 2021 14:29:28 -0400

Hello. I am trying to force indent(1) to format source code according to
style when function definiton have space between function name and '('
symbol, but no space in function call.

So here is example of what I want:

```
1       int frob (void)
2       {
3               int z = foo(10, 20);
4               do_stuff(z, stdin);
5
6               return 42;
7       }
```

With all configuration options I tried, indent(1) does not put space
between "frob" and "(" in first line, except with "-pcs", which adds
space not only in line 1, but also in lines 3 and 4.

I think "-pcs" should not insert space in line 1, since it is function
definition, not function call, and space in function definition deserves
separate option.

>From my glance at code, there should be some change to following lines
in src/handletoken.c, probably at line 361, but I am not familiar with
parsing code to make this change myself right now.

```
358     if (parser_state_tos->want_blank &&
359         (*token != '[') &&
360         ( (parser_state_tos->last_token != ident) ||
361           settings.proc_calls_space ||
362           (parser_state_tos->its_a_keyword &&
363            (!parser_state_tos->sizeof_keyword || 
settings.blank_after_sizeof))))
364     {
365         set_buf_break (bb_proc_call, paren_target);
366         *(e_code++) = ' ';
367         *e_code = '\0';     /* null terminate code sect */
368     }
369     else
370     {
371         set_buf_break (bb_proc_call, paren_target);
372     }
```

Thoughts?



reply via email to

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