Mark Mark - 1 year ago 86
C Question

indent being odd -- fix or choose an alternative

I'm running

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

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

turns into

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

or without
does not solve the problem.

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



% indent -T my_type -T uint16_t

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download