Skip to content

Commit 4f106fe

Browse files
committed
formatting
1 parent 692175d commit 4f106fe

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed

runformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ else
3636
export CPUCOUNT="1"
3737
fi
3838

39-
$UNCRUSTIFY -c .uncrustify.cfg --no-backup *.cpp *.h
39+
$UNCRUSTIFY -c .uncrustify.cfg --no-backup -l CPP *.cpp *.h

simplecpp.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -762,18 +762,18 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
762762
while (stream.good() && ch != '\n') {
763763
currentToken += ch;
764764
ch = stream.readChar();
765-
if(ch == '\\') {
765+
if (ch == '\\') {
766766
TokenString tmp;
767767
char tmp_ch = ch;
768-
while((stream.good()) && (tmp_ch == '\\' || tmp_ch == ' ' || tmp_ch == '\t')) {
768+
while ((stream.good()) && (tmp_ch == '\\' || tmp_ch == ' ' || tmp_ch == '\t')) {
769769
tmp += tmp_ch;
770770
tmp_ch = stream.readChar();
771771
}
772-
if(!stream.good()) {
772+
if (!stream.good()) {
773773
break;
774774
}
775775

776-
if(tmp_ch != '\n') {
776+
if (tmp_ch != '\n') {
777777
currentToken += tmp;
778778
} else {
779779
const TokenString check_portability = currentToken + tmp;
@@ -1668,7 +1668,7 @@ namespace simplecpp {
16681668
}
16691669

16701670
invalidHashHash(const Location &loc, const std::string &macroName, const std::string &message)
1671-
: Error(loc, format(macroName, message)) { }
1671+
: Error(loc, format(macroName, message)) {}
16721672

16731673
static inline invalidHashHash unexpectedToken(const Location &loc, const std::string &macroName, const Token *tokenA) {
16741674
return invalidHashHash(loc, macroName, "Unexpected token '"+ tokenA->str()+"'");
@@ -2668,7 +2668,7 @@ static unsigned long long stringToULLbounded(
26682668
int base = 0,
26692669
std::ptrdiff_t minlen = 1,
26702670
std::size_t maxlen = std::string::npos
2671-
)
2671+
)
26722672
{
26732673
const std::string sub = s.substr(pos, maxlen);
26742674
const char * const start = sub.c_str();
@@ -3350,7 +3350,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33503350
includetokenstack.push(filedata->tokens.cfront());
33513351
}
33523352

3353-
std::map<std::string, std::list<Location> > maybeUsedMacros;
3353+
std::map<std::string, std::list<Location>> maybeUsedMacros;
33543354

33553355
for (const Token *rawtok = nullptr; rawtok || !includetokenstack.empty();) {
33563356
if (rawtok == nullptr) {
@@ -3747,11 +3747,11 @@ simplecpp::cstd_t simplecpp::getCStd(const std::string &std)
37473747
{
37483748
if (std == "c90" || std == "c89" || std == "iso9899:1990" || std == "iso9899:199409" || std == "gnu90" || std == "gnu89")
37493749
return C89;
3750-
if (std == "c99" || std == "c9x" || std == "iso9899:1999" || std == "iso9899:199x" || std == "gnu99"|| std == "gnu9x")
3750+
if (std == "c99" || std == "c9x" || std == "iso9899:1999" || std == "iso9899:199x" || std == "gnu99" || std == "gnu9x")
37513751
return C99;
37523752
if (std == "c11" || std == "c1x" || std == "iso9899:2011" || std == "gnu11" || std == "gnu1x")
37533753
return C11;
3754-
if (std == "c17" || std == "c18" || std == "iso9899:2017" || std == "iso9899:2018" || std == "gnu17"|| std == "gnu18")
3754+
if (std == "c17" || std == "c18" || std == "iso9899:2017" || std == "iso9899:2018" || std == "gnu17" || std == "gnu18")
37553755
return C17;
37563756
if (std == "c23" || std == "gnu23" || std == "c2x" || std == "gnu2x")
37573757
return C23;

simplecpp.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ namespace simplecpp {
114114
}
115115

116116
Token(const Token &tok) :
117-
macro(tok.macro), op(tok.op), comment(tok.comment), name(tok.name), number(tok.number), whitespaceahead(tok.whitespaceahead), location(tok.location), previous(nullptr), next(nullptr), nextcond(nullptr), string(tok.string), mExpandedFrom(tok.mExpandedFrom) {
118-
}
117+
macro(tok.macro), op(tok.op), comment(tok.comment), name(tok.name), number(tok.number), whitespaceahead(tok.whitespaceahead), location(tok.location), previous(nullptr), next(nullptr), nextcond(nullptr), string(tok.string), mExpandedFrom(tok.mExpandedFrom) {}
119118

120119
void flags() {
121120
name = (std::isalpha(static_cast<unsigned char>(string[0])) || string[0] == '_' || string[0] == '$')
@@ -325,9 +324,9 @@ namespace simplecpp {
325324
struct SIMPLECPP_LIB MacroUsage {
326325
explicit MacroUsage(const std::vector<std::string> &f, bool macroValueKnown_) : macroLocation(f), useLocation(f), macroValueKnown(macroValueKnown_) {}
327326
std::string macroName;
328-
Location macroLocation;
329-
Location useLocation;
330-
bool macroValueKnown;
327+
Location macroLocation;
328+
Location useLocation;
329+
bool macroValueKnown;
331330
};
332331

333332
/** Tracking #if/#elif expressions */

test.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
static int numberOfFailedAssertions = 0;
2323

2424
#define ASSERT_EQUALS(expected, actual) (assertEquals((expected), (actual), __LINE__))
25-
#define ASSERT_THROW_EQUALS(stmt, e, expected) do { try { stmt; assertThrowFailed(__LINE__); } catch (const e& ex) { assertEquals((expected), (ex.what()), __LINE__); } } while(false)
25+
#define ASSERT_THROW_EQUALS(stmt, e, expected) do { try { stmt; assertThrowFailed(__LINE__); } catch (const e& ex) { assertEquals((expected), (ex.what()), __LINE__); } } while (false)
2626

2727
static std::string pprint(const std::string &in)
2828
{
@@ -250,10 +250,10 @@ static void characterLiteral()
250250
ASSERT_EQUALS('\u0012', simplecpp::characterLiteralToLL("'\\u0012'"));
251251
ASSERT_EQUALS('\U00000012', simplecpp::characterLiteralToLL("'\\U00000012'"));
252252

253-
ASSERT_EQUALS((static_cast<unsigned int>(static_cast<unsigned char>('b')) << 8) | static_cast<unsigned char>('c'), simplecpp::characterLiteralToLL("'bc'"));
253+
ASSERT_EQUALS((static_cast<unsigned int>(static_cast<unsigned char>('b')) << 8) | static_cast<unsigned char>('c'), simplecpp::characterLiteralToLL("'bc'"));
254254
ASSERT_EQUALS((static_cast<unsigned int>(static_cast<unsigned char>('\x23')) << 8) | static_cast<unsigned char>('\x45'), simplecpp::characterLiteralToLL("'\\x23\\x45'"));
255-
ASSERT_EQUALS((static_cast<unsigned int>(static_cast<unsigned char>('\11')) << 8) | static_cast<unsigned char>('\222'), simplecpp::characterLiteralToLL("'\\11\\222'"));
256-
ASSERT_EQUALS((static_cast<unsigned int>(static_cast<unsigned char>('\a')) << 8) | static_cast<unsigned char>('\b'), simplecpp::characterLiteralToLL("'\\a\\b'"));
255+
ASSERT_EQUALS((static_cast<unsigned int>(static_cast<unsigned char>('\11')) << 8) | static_cast<unsigned char>('\222'), simplecpp::characterLiteralToLL("'\\11\\222'"));
256+
ASSERT_EQUALS((static_cast<unsigned int>(static_cast<unsigned char>('\a')) << 8) | static_cast<unsigned char>('\b'), simplecpp::characterLiteralToLL("'\\a\\b'"));
257257
if (sizeof(int) <= 4)
258258
ASSERT_EQUALS(-1, simplecpp::characterLiteralToLL("'\\xff\\xff\\xff\\xff'"));
259259
else
@@ -438,14 +438,14 @@ static void comment_multiline()
438438
ASSERT_EQUALS("\n\nvoid f ( ) {", preprocess(code));
439439

440440
const char code1[] = "#define ABC {// \\\r\n"
441-
"}\n"
442-
"void f() ABC\n";
441+
"}\n"
442+
"void f() ABC\n";
443443
ASSERT_EQUALS("\n\nvoid f ( ) {", preprocess(code1));
444444

445445
const char code2[] = "#define A 1// \\\r"
446-
"\r"
447-
"2\r"
448-
"A\r";
446+
"\r"
447+
"2\r"
448+
"A\r";
449449
ASSERT_EQUALS("\n\n2\n1", preprocess(code2));
450450

451451
const char code3[] = "void f() {// \\ \n}\n";
@@ -1960,7 +1960,7 @@ static void location1()
19601960
const char *code;
19611961

19621962
code = "# 1 \"main.c\"\n\n\n"
1963-
"x";
1963+
"x";
19641964
ASSERT_EQUALS("\n#line 3 \"main.c\"\nx", preprocess(code));
19651965
}
19661966

@@ -2290,7 +2290,7 @@ static void include2()
22902290
static void include3() // #16 - crash when expanding macro from header
22912291
{
22922292
const char code_c[] = "#include \"A.h\"\n"
2293-
"glue(1,2,3,4)\n" ;
2293+
"glue(1,2,3,4)\n";
22942294
const char code_h[] = "#define glue(a,b,c,d) a##b##c##d\n";
22952295

22962296
std::vector<std::string> files;
@@ -2317,7 +2317,7 @@ static void include3() // #16 - crash when expanding macro from header
23172317

23182318
static void include4() // #27 - -include
23192319
{
2320-
const char code_c[] = "X\n" ;
2320+
const char code_c[] = "X\n";
23212321
const char code_h[] = "#define X 123\n";
23222322

23232323
std::vector<std::string> files;

0 commit comments

Comments
 (0)