Questions tagged [gnu-indent]

For questions about GNU indent, a program designed to format (or beautify) C code.

GNU.org provides the following introduction for indent:

The indent program can be used to make code easier to read. It can also convert from one style of writing C to another. indent understands a substantial amount about the syntax of C, but it also attempts to cope with incomplete and misformed syntax.

Its documentation can be found here.

11 questions
4
votes
1 answer

Have GNU Indent Add New Braces After If Statement

I have a project where we're investigating adding a requirement for if conditionals to include braces (the reason is unimportant and off topic). For example: if (foo) return bar; else return baz; Becomes: if (foo) { return bar; } else { …
Wesley Bland
  • 8,816
  • 3
  • 44
  • 59
4
votes
1 answer

GNU Indent issue with GNU code style

I installed indent using brew thanks to the command brew install gnu-indent so now I have gnu-indent-2.2.10 installed on my MacOS X so far, so good. My problem is when I want to indent a file using GNU code style. I mean I would like to convert…
Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122
3
votes
1 answer

GNU indent: which option puts function return type same line

Using GNU indent, when I used gnu style, I will end up with a source like this: void compute_column_indices(u32 size, s32 * ind) { ... } But I don't want the return value (void) to sit on its own line. The linux style does it but it introduces…
Wirawan Purwanto
  • 3,613
  • 3
  • 28
  • 28
3
votes
1 answer

Use the GNU indent command to apply K&R style with only tabs

I've been trying to use GNU indent to indent some very simple C files, and I wish to use the K&R indentation style but without any use of spaces, purely tabs. I've tried indent -kr --use-tabs, and just indent -kr but they both just use the default…
2
votes
1 answer

How to set GNU Indent input

I use GNU indent and I want using bash script to give a command that takes as input all my C files(*.c, *.h) and gives output these files formatted with Indent. My command line is indent | find -regex '.*/.*\.\(c\|h\)$' | xargs Is not working,it…
2
votes
4 answers

with gnu indent how to make int * to int*

I want to change int *i; to int* i; using gnu indent. How can I go about doing that? If not possible how to at least make kernighan&ritchie style int * i; to int *i;
Necktwi
  • 2,483
  • 7
  • 39
  • 62
1
vote
0 answers

How to make GNU indent support CRLF terminators?

I tried to use GNU indent (v 2.2.12) on a source file that has CRLF terminators, with unexpected errors that I could not understand from the source code. The output file was like randomly indented. Then I converted the file to regular Unix file with…
Axel B
  • 111
  • 3
1
vote
2 answers

indent being odd -- fix or choose an alternative

I'm running indent with arguments -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1, all is good except two obstacles: 1) It tends to put an extra space after * in statements like mytype_t * my;, i.e. void my_function(my_type *ptr) turns into void…
Mark
  • 6,052
  • 8
  • 61
  • 129
1
vote
2 answers

Spacing between brace and comment

Given the file alfa.c: #include int main() { // this is a comment puts("hello world"); } I can format it with GNU Indent like so: $ indent -st alfa.c #include int main () { // this is a comment …
user6307369
0
votes
2 answers

how do I set space between function name and parenthesis with gnu indent?

With gnu-indent how to change int i = fact(n); to int i = fact (n); -gnu formats it so but I use -kr.
Necktwi
  • 2,483
  • 7
  • 39
  • 62
0
votes
1 answer

Pointer star location

With GNU indent is there a way to put the "star" right after the type? For example: void* foo(int* a) but keeping it near the var in a declaration like int *a, b;
Roberto Aureli
  • 1,428
  • 2
  • 12
  • 23