uncrustify / uncrustify

Code beautifier
http://uncrustify.sourceforge.net/
GNU General Public License v2.0
2.87k stars 566 forks source link

nl_func_var_def_blk has unwanted effect #3518

Closed RobertoBagnara closed 2 years ago

RobertoBagnara commented 2 years ago
$ uncrustify -v
Uncrustify_d-4dbe0768
$ cat p.cfg
nl_func_var_def_blk = 1
$ cat p.c
void g () {
  h();
  int x;
  return;
  {
    h();
    int x;
    return;
  }
}
$ uncrustify -c p.cfg p.c
Output suffix: .uncrustify
do_source_file(1505): Parsing: p.c as language C
$ cat p.c.uncrustify
void g () {
    h();
    int x;

    return;
    {
        h();
        int x;
        return;
    }
}

The first occurrence of int x; is a variable definitions not at the top of a function body, hence is should not be followed by a blank line.

guy-maurel commented 2 years ago

PR https://github.com/uncrustify/uncrustify/issues/3545 is a bugfix proposal. Please test it and report.