1

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 my_function(my_type * ptr)

2) It places extra space after & symbol in expressions like (uint16_t *) & q->drops i.e.

stats->drops = (uint16_t *) &q->drops

turns into

stats->drops = (uint16_t *) & q->drops

Running indent with -nss or without -ss does not solve the problem.

Is there a way to tell indent not to do this? If not, what are the alternatives to indent ?

Thanks.

SOLUTION

% indent -T my_type -T uint16_t
Mark
  • 6,052
  • 8
  • 61
  • 129

2 Answers2

2

After some searching, I couldn't find the option to remove the space between type and pointer. What was weird is it only happens when that type ends with a _t. So, this probably does not answer your question. However a good alternative to indent is astyle. For the style you're looking for, you can use these flags:

astyle --style=kr --indent=tab

I really hope this helps.

Ayan Shafqat
  • 98
  • 1
  • 8
1

From man indent:

You must use the '-T' option to tell indent the name of all the typenames in your program that are defined by typedef. '-T' can be specified more than once, and all names specified are used. For example, if your program contains

typedef unsigned long CODE_ADDR;
typedef enum {red, blue, green} COLOR;

you would use the options -T CODE_ADDR -T COLOR.

So it seems like indent doesn't know about the stdint.h types, so you have to let it know you are using them by passing -T uint16_t -T mytype_t

Eugene Sh.
  • 17,802
  • 8
  • 40
  • 61