Skip to content

Commit

Permalink
Add a clang-format file and prepare for clang-formatting
Browse files Browse the repository at this point in the history
Create .clang-format to describe the current C++ style used in Mosh.

Mark one carefully-formatted array with `// clang-format off`. Also turn
off clang-format in src/crypto/ocb_internal.cc, since it was imported
almost wholesale from another project and is written in a style
different from the rest of Mosh.
  • Loading branch information
bbarenblat committed Aug 8, 2023
1 parent f2904f9 commit 77a6730
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
Language: Cpp
BasedOnStyle: Mozilla
ColumnLimit: 116
SpacesInParentheses: true
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
SpaceBeforeCpp11BracedList: true
BreakBeforeBinaryOperators: All
Cpp11BracedListStyle: true
AllowShortBlocksOnASingleLine: Always
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: Never
AfterFunction: true
AfterStruct: true
AfterEnum: true
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakConstructorInitializers: BeforeColon
...
2 changes: 2 additions & 0 deletions src/crypto/base64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

static const unsigned char reverse[] = {
// clang-format off
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f,
Expand All @@ -55,6 +56,7 @@ static const unsigned char reverse[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
// clang-format on
};

/* Reverse maps from an ASCII char to a base64 sixbit value. Returns > 0x3f on failure. */
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/ocb_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/ Comments are welcome: Ted Krovetz <[email protected]> - Dedicated to Laurel K
/------------------------------------------------------------------------- */

// clang-format off

#include "src/include/config.h"

/* This module implements the ae.h interface for OpenSSL, Apple Common
Expand Down

0 comments on commit 77a6730

Please sign in to comment.