Skip to content

Commit

Permalink
Add clang-format
Browse files Browse the repository at this point in the history
Use clang-format-3.6 for now.
  • Loading branch information
tatsuhiro-t committed Dec 23, 2015
1 parent bc1c9ca commit 0a63a7e
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .clang-format
@@ -0,0 +1,65 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: true
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
BinPackArguments: true
ColumnLimit: 80
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: false
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: true
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
SpacesBeforeTrailingComments: 1
Cpp11BracedListStyle: true
Standard: Cpp11
IndentWidth: 2
TabWidth: 8
UseTab: Never
BreakBeforeBraces: Stroustrup
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: ControlStatements
DisableFormat: false
...

10 changes: 10 additions & 0 deletions Makefile.am
Expand Up @@ -15,6 +15,8 @@ EXTRA_DIST = config.rpath \

dist_doc_DATA = README README.rst README.html

.PHONY: clang-format

if HAVE_RST2HTML
README.html: README.rst
$(RST2HTML) $< > $@
Expand All @@ -27,3 +29,11 @@ endif # !HAVE_RST2HTML

dist_noinst_DATA = LICENSE.OpenSSL

# Format source files using clang-format. Don't format source files
# under deps directory since we are not responsible for thier coding
# style.
clang-format:
CLANGFORMAT=`git config --get clangformat.binary`; \
test -z $${CLANGFORMAT} && CLANGFORMAT="clang-format"; \
$${CLANGFORMAT} -i src/*.{c,cc,h} src/includes/aria2/*.h \
examples/*.cc test/*.{cc,h}
5 changes: 5 additions & 0 deletions src/message.h
Expand Up @@ -37,6 +37,8 @@

#include "common.h"

// clang-format off

#define MSG_SEGMENT_DOWNLOAD_COMPLETED \
"CUID#%" PRId64 " - The download for one segment completed successfully."
#define MSG_NO_SEGMENT_AVAILABLE "CUID#%" PRId64 " - No segment available."
Expand Down Expand Up @@ -286,4 +288,7 @@
#define EX_EXCEPTION_CAUGHT _("Exception caught")
#define EX_TOO_LONG_PAYLOAD _("Max payload length exceeded or invalid. length = %u")
#define EX_FILE_LENGTH_MISMATCH_BETWEEN_LOCAL_AND_REMOTE _("Invalid file length. Cannot continue download %s: local %s, remote %s")

// clang-format on

#endif // D_MESSAGE_H

0 comments on commit 0a63a7e

Please sign in to comment.