uncrustify - проблема с отступом тела блока if-else, когда indent_braces true - PullRequest
0 голосов
/ 20 марта 2020

Я пытаюсь использовать uncrustify для преодоления проблем с отступами. Но я не знаю, как добавить отступ в теле if-else, когда indent_braces = true.

Вот пример: мой исходный код:

#include <stdio.h>

int main(int argc, char **argv)
{
    int a = 5;
    int b = 10;
    if (a != b)
    {
        printf("not equal\n");
    }
    else
    {
        printf("equal\n");
    }
}

uncrustify.cfg:

indent_with_tabs              = 0        # 0=spaces only; 1=indent to level only; 2=indent with tabs
input_tab_size                = 4        # original tab size
output_tab_size               = 4        # new tab size
indent_columns                = 2        # Two columns per indent level
indent_label                  = 1        # pos: absolute col, neg: relative column
code_width                    = 90       # Try to limit code width to N number of columns
indent_brace                  = 0
indent_braces                 = true
indent_braces_no_func         = true
indent_braces_no_struct       = true

Когда я выполняю uncrustify - c uncrustify.cfg sample. c, вывод:

#include <stdio.h>

int main(int argc, char **argv)
{
  int a = 5;
  int b = 10;
  if (a != b)
    {
    printf("not equal\n");
    }
  else
    {
    printf("equal\n");
    }
}

Но что я, что такое:

#include <stdio.h>

int main(int argc, char **argv)
{
  int a = 5;
  int b = 10;
  if (a != b)
    {
      printf("not equal\n"); // indentation inside the body !
    }
  else
    {
      printf("equal\n");
    }
}

Так есть ли способ достичь этой цели? Спасибо,

...