I have old C code and would like to reformat it with clang-format. One problem im facing is, many of old functions are written with K&R parameter initializer lists. And clang-format does a strange reformatting on these lines.

For example following original code:

int tz_start_new( nr, start, old )
char    *nr;
char    *start;
char    *old;
{
return 0;
}

 
gets formatted to:
 
int tz_start_new( nr, start, old ) char *nr;
char    *start;
char    *old;
{
    return 0;
}

So the first parameter is written directly behind the function declaration. The others tays as they were before.

This is the format file i'm using:

---
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterDefinitionReturnType: None
BreakBeforeBraces: Custom
BraceWrapping:
  AfterClass: true
  AfterControlStatement: true
  AfterEnum: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: true
  AfterUnion: true
  AfterExternBlock: true
  BeforeCatch: true
  BeforeElse: true
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeTernaryOperators: 'false'
IndentCaseLabels: 'true'
ColumnLimit: '80'
IndentWidth: '4'
Language: Cpp
PointerAlignment: Right
SortIncludes: 'false'
SpaceAfterCStyleCast: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: Never
SpaceInEmptyParentheses: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInParentheses: 'true'
SpacesInSquareBrackets: 'true'
TabWidth: '4'
UseTab: ForIndentation

...
 
 
Is there an possibility to support K&R parameter lists and format them the 'right' way or leave they untouched?
 
 
 
Marco
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to