Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell /usr/bin/indent on Mac OS X 10.5 to format my C code K&R style?

On Linux I am used to running indent -kr ... to indent C files. /usr/bin/indent on Mac OS X 10.5 does not support the -kr option. Does anyone have a ~/.indent.pro file that would produce results closest to K&R style? Thanks!

like image 545
sigjuice Avatar asked Aug 29 '09 18:08

sigjuice


People also ask

How do you indent a code on a Mac?

Press Tab or ⌘] . From the main menu, select Outline > Indent.

What is indent Linux?

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.


2 Answers

You can always just get the original gnu indent program and use -kr option. This is probably best as you will have exact results on both machines. But still, if you want to use OS X, this are the flags that make up the -kr option:

-nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs -nprs -npsl -saf -sai -saw -nsc -nsob -nss

like image 197
daniel Avatar answered Sep 28 '22 04:09

daniel


MacPorts and Fink both have GNU indent packages.

like image 24
Ned Deily Avatar answered Sep 28 '22 03:09

Ned Deily