H
Hallvard B Furuseth
I'd like to reformat an open source package (OpenLDAP) to a new C style.
8M code, 0.3M lines. With some currently hopeless formatting rules like
tab-width=4. I'm sure that made sense once to save disk space for the
source code, or something:-( The project's normal rule is "don't
reformat unnecessarily" since it makes source control merge/diff
difficult. That hasn't helped the style over time either.
Anyway, can someone recommend a "tool-friendly" style, which Indent,
Emacs, Vi or whatever all can be easily configured to produce? Doesn't
hurt if whatever is used on Windows can it too. Any clever ideas to
keep future code more or less conformant to the chosen style, without
getting too anal about it?
I thought I'd just pick something close to Emacs "stroustrup" style and
give Indent the options for that, but at least Gnu Indent isn't willing
to produce just the same. In particular, it aligns variable
declarations like this:
int foo;
int **bar;
with the declared identifier aligned. Which is cool, but it's not what
one naturally produces with an editor. Have I missed some Indent option
to prevent it? Or some other indent program, maybe? Or are there
"active" Emacs and Vi modes that help produce this?
I don't see much point in re-indenting to some indentation style only to
see newly written code immediately deviate from it. Though I guess one
could just say "follow The Style everyone" and be anal about it.
Or maybe we should just not indent variable and struct member names:-(
Looks far less readable to me though.
We'll likely keep some quirks of the current formatting anyway, like
foo_bar_baz(one, two,
three);
instead of
foo_bar_baz(one, two,
three);
due to long functions with long parameter lists passed long argument
names.
How much work am I looking at? Have anyone here done a similar job? I
don't normally put too much work into OpenLDAP over a short time. Even
with Indent it looks like it'll be a fair amount of work to re-indent
and then prettify what Indent produces. In particular comments and the
too many deeply nested functions. On the other hand, the job of
splitting up big functions and making sure the change really didn't
affect program logic looks tedious too. I can't test all the changes
either, and I have no idea how some of the code works.
And the headers will likely have to be done by hand anyway, due to macro
magic in public declarations.
8M code, 0.3M lines. With some currently hopeless formatting rules like
tab-width=4. I'm sure that made sense once to save disk space for the
source code, or something:-( The project's normal rule is "don't
reformat unnecessarily" since it makes source control merge/diff
difficult. That hasn't helped the style over time either.
Anyway, can someone recommend a "tool-friendly" style, which Indent,
Emacs, Vi or whatever all can be easily configured to produce? Doesn't
hurt if whatever is used on Windows can it too. Any clever ideas to
keep future code more or less conformant to the chosen style, without
getting too anal about it?
I thought I'd just pick something close to Emacs "stroustrup" style and
give Indent the options for that, but at least Gnu Indent isn't willing
to produce just the same. In particular, it aligns variable
declarations like this:
int foo;
int **bar;
with the declared identifier aligned. Which is cool, but it's not what
one naturally produces with an editor. Have I missed some Indent option
to prevent it? Or some other indent program, maybe? Or are there
"active" Emacs and Vi modes that help produce this?
I don't see much point in re-indenting to some indentation style only to
see newly written code immediately deviate from it. Though I guess one
could just say "follow The Style everyone" and be anal about it.
Or maybe we should just not indent variable and struct member names:-(
Looks far less readable to me though.
We'll likely keep some quirks of the current formatting anyway, like
foo_bar_baz(one, two,
three);
instead of
foo_bar_baz(one, two,
three);
due to long functions with long parameter lists passed long argument
names.
How much work am I looking at? Have anyone here done a similar job? I
don't normally put too much work into OpenLDAP over a short time. Even
with Indent it looks like it'll be a fair amount of work to re-indent
and then prettify what Indent produces. In particular comments and the
too many deeply nested functions. On the other hand, the job of
splitting up big functions and making sure the change really didn't
affect program logic looks tedious too. I can't test all the changes
either, and I have no idea how some of the code works.
And the headers will likely have to be done by hand anyway, due to macro
magic in public declarations.