[Nagios-devel] Nagios indentation

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Nagios indentation

Post by Guest »

The nagios indentation has been discussed quite a few times, and once
upon a time we agreed that it would be nifty if we could use a style
that's supported by a program so contributors can auto-format their
code before submitting it upstream.

Having spent all of 30 minutes on the problem this morning, I think
I've come up with something.

astyle --indent=tab --unpad-paren --pad-oper --pad-header --brackets=linux

seems to create a very sensible indentation for all the files we have.
The GNU indent program simply can't be convinced to indent with tabs
and align with spaces. Or rather, it can, but not without unbreaking
long lines that are broken manually.

Using the options set above causes code to be indented with tabs and
aligned with spaces, and makes it look like this:

int some_function_name(int a_function_param, const char *lala_param)
{
if (something) {
do_something();
} else {
do_something_else();
}

switch (some_value) {
case SOME_VALUE_MACRO1:
lalala();
break;
default:
lalala_default(some_value);
break;
}

return something;
}


It touches only indentation and spaces surrounding operators and
parentheses, which is, imo, a good thing since it won't cause a lot
of unwanted changes each and every time it's run.

Unless someone complains before monday I'll add a Makefile target
to indent the sources, run it once and then commit the results, with
a note added so that future contributors know what to do to make
their code conform to the standard.

vim and emacs users should look into using their editors respective
'smart tabs' settings. Most decent editors support aligning with
spaces and indenting with tabs nowadays, but if you're not using one
of them, you can just run 'make pretty' or 'make indent' before you
submit your patches.

--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked