[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-indent] Suggested enhancements
From: |
Matt Ball |
Subject: |
[Bug-indent] Suggested enhancements |
Date: |
Wed, 11 Feb 2004 10:56:56 -0700 |
Hello,
I'm looking into using indent to enforce Quantum's C coding standard.
Indent mostly fills this bill, except for a couple areas. Here is a list of
possible enhancements to indent:
Preprocessor additions:
--indent-preprocessor-with-code
Place the # operator in preprocessor directives with the same indentation as
the code
--dont-indent-preprocessor-with-code
Place the # operator in preprocessor directives in column 1. (same as
current default)
--preprocessor-indent-from-code n
Indent preprocessor directives by n spaces from current code indentation.
Only works with --indent-preprocessor-with-code. Similar to
--line-comments-indentation.
For example, these flags would produce the following code:
--indent-preprocessor-with-code
--preprocessor-indent-from-code2
--indent-level4
#include <stdio.h>
int main(void)
{
#if 1
printf("Hello World\n");
#endif
return 0;
}
Comment spacing:
Currently, It appears that the comments following a } character use the same
indentation as other comments. It would be useful to have a separate flag
to specify the column into which to place comments following a }. Here is
an example:
--comment-indentation-after-brace17
for (i = 0; i < 10; i++)
{
printf("%d ",i);
} // for (i = 0; i < 10; i++)
We would set this to zero (--comment-indentation-after-brace0), so that
comments aren't spaced away from the brace.
Spacing between parentheses:
--honor-space-after-parentheses
This option uses the existing space after an opening parenthesis '(' to
determine the amount of space to place before the matching closing
parenthesis ')'. This option overrides both --no-space-after-parentheses
and --space-after-parentheses.
Example:
Given this code:
int function( int x, int y)
{
if ( (x == 10) &&( y==2))
{
printf("Condition met\n" );
}
}
The output would be as follows, using --honor-space-after-parentheses:
int function( int x, int y )
{
if ( (x == 10) && ( y == 2 ) )
{
printf("Condition met\n");
}
}
If the implementation for --honor-space-after-parentheses is too
complicated, then it would be nice to define this switch to not adjust any
space inside a parenthesis.
Soft Margin:
It could be useful to have the concept of the 'soft margin', where the
pretty-printer would not absolutely have to break the lines, but would have
a slight preference to do so. For example, we have a 'soft margin' of 80
characters, and a 'hard margin' of 132 characters. Most code would tend to
exist in the 80 character area, but would extend beyond 80 characters if the
pretty printer doesn't encounter a good place to break the line.
Example: --soft-margin80
Please let me know if anyone has either time or willingness to work on some
of these. Depending on my workload, I might have a little time to make code
patches for some of these.
Thanks!
-Matt Ball
Quantum Corp.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-indent] Suggested enhancements,
Matt Ball <=