Skip to content

Commit 1453e4e

Browse files
authored
use initializer lists without assignment (#624)
1 parent 10c9681 commit 1453e4e

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

simplecpp.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ static void portabilityBackslash(simplecpp::OutputList *outputList, const simple
620620
{
621621
if (!outputList)
622622
return;
623-
simplecpp::Output err = {
623+
simplecpp::Output err{
624624
simplecpp::Output::PORTABILITY_BACKSLASH,
625625
location,
626626
"Combination 'backslash space newline' is not portable."
@@ -669,7 +669,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
669669

670670
if (ch >= 0x80) {
671671
if (outputList) {
672-
simplecpp::Output err = {
672+
simplecpp::Output err{
673673
simplecpp::Output::UNHANDLED_CHAR_ERROR,
674674
location,
675675
"The code contains unhandled character(s) (character code=" + std::to_string(static_cast<int>(ch)) + "). Neither unicode nor extended ascii is supported."
@@ -871,7 +871,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
871871
}
872872
if (!stream.good() || ch == '\n') {
873873
if (outputList) {
874-
Output err = {
874+
Output err{
875875
Output::SYNTAX_ERROR,
876876
location,
877877
"Invalid newline in raw string delimiter."
@@ -885,7 +885,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
885885
currentToken += stream.readChar();
886886
if (!endsWith(currentToken, endOfRawString)) {
887887
if (outputList) {
888-
Output err = {
888+
Output err{
889889
Output::SYNTAX_ERROR,
890890
location,
891891
"Raw string missing terminating delimiter."
@@ -1429,7 +1429,7 @@ std::string simplecpp::TokenList::readUntil(Stream &stream, const Location &loca
14291429
if (!stream.good() || ch != end) {
14301430
clear();
14311431
if (outputList) {
1432-
Output err = {
1432+
Output err{
14331433
Output::SYNTAX_ERROR,
14341434
location,
14351435
std::string("No pair for character (") + start + "). Can't process file. File is either invalid or unicode, which is currently not supported."
@@ -2692,7 +2692,7 @@ static void simplifyName(simplecpp::TokenList &expr)
26922692
{
26932693
for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
26942694
if (tok->name) {
2695-
static const std::set<std::string> altop = {"and","or","bitand","bitor","compl","not","not_eq","xor"};
2695+
static const std::set<std::string> altop{"and","or","bitand","bitor","compl","not","not_eq","xor"};
26962696
if (altop.find(tok->str()) != altop.end()) {
26972697
bool alt;
26982698
if (tok->str() == "not" || tok->str() == "compl") {
@@ -3178,7 +3178,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31783178

31793179
if (filedata == nullptr) {
31803180
if (outputList) {
3181-
simplecpp::Output err = {
3181+
simplecpp::Output err{
31823182
simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND,
31833183
{},
31843184
"Can not open include file '" + filename + "' that is explicitly included."
@@ -3252,7 +3252,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
32523252
tok1 = it->second.expand(value, tok, macros, files);
32533253
} catch (const simplecpp::Macro::Error &err) {
32543254
if (outputList) {
3255-
simplecpp::Output out = {
3255+
simplecpp::Output out{
32563256
simplecpp::Output::SYNTAX_ERROR,
32573257
err.location,
32583258
"failed to expand \'" + tok->str() + "\', " + err.what
@@ -3347,7 +3347,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33473347
macros.insert(std::pair<TokenString,Macro>(macro.name(), macro));
33483348
} catch (const std::runtime_error& e) {
33493349
if (outputList) {
3350-
simplecpp::Output err = {
3350+
simplecpp::Output err{
33513351
Output::DUI_ERROR,
33523352
{},
33533353
e.what()
@@ -3366,7 +3366,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33663366
macros.insert(std::make_pair("__FILE__", Macro("__FILE__", "__FILE__", dummy)));
33673367
macros.insert(std::make_pair("__LINE__", Macro("__LINE__", "__LINE__", dummy)));
33683368
macros.insert(std::make_pair("__COUNTER__", Macro("__COUNTER__", "__COUNTER__", dummy)));
3369-
struct tm ltime = {};
3369+
struct tm ltime {};
33703370
getLocaltime(ltime);
33713371
macros.insert(std::make_pair("__DATE__", Macro("__DATE__", getDateDefine(&ltime), dummy)));
33723372
macros.insert(std::make_pair("__TIME__", Macro("__TIME__", getTimeDefine(&ltime), dummy)));
@@ -3381,7 +3381,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33813381
const cppstd_t cpp_std = simplecpp::getCppStd(dui.std);
33823382
if (cpp_std == CPPUnknown) {
33833383
if (outputList) {
3384-
simplecpp::Output err = {
3384+
simplecpp::Output err{
33853385
Output::DUI_ERROR,
33863386
{},
33873387
"unknown standard specified: '" + dui.std + "'"
@@ -3438,7 +3438,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34383438

34393439
if (ifstates.size() <= 1U && (rawtok->str() == ELIF || rawtok->str() == ELSE || rawtok->str() == ENDIF)) {
34403440
if (outputList) {
3441-
simplecpp::Output err = {
3441+
simplecpp::Output err{
34423442
Output::SYNTAX_ERROR,
34433443
rawtok->location,
34443444
"#" + rawtok->str() + " without #if"
@@ -3458,7 +3458,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34583458
msg += tok->str();
34593459
}
34603460
msg = '#' + rawtok->str() + ' ' + msg;
3461-
simplecpp::Output err = {
3461+
simplecpp::Output err{
34623462
rawtok->str() == ERROR ? Output::ERROR : Output::WARNING,
34633463
rawtok->location,
34643464
std::move(msg)
@@ -3486,7 +3486,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34863486
}
34873487
} catch (const std::runtime_error &) {
34883488
if (outputList) {
3489-
simplecpp::Output err = {
3489+
simplecpp::Output err{
34903490
Output::SYNTAX_ERROR,
34913491
rawtok->location,
34923492
"Failed to parse #define"
@@ -3497,7 +3497,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34973497
return;
34983498
} catch (const simplecpp::Macro::Error &err) {
34993499
if (outputList) {
3500-
simplecpp::Output out = {
3500+
simplecpp::Output out{
35013501
simplecpp::Output::SYNTAX_ERROR,
35023502
err.location,
35033503
"Failed to parse #define, " + err.what
@@ -3538,7 +3538,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35383538

35393539
if (inc2.empty() || inc2.cfront()->str().size() <= 2U) {
35403540
if (outputList) {
3541-
simplecpp::Output err = {
3541+
simplecpp::Output err{
35423542
Output::SYNTAX_ERROR,
35433543
rawtok->location,
35443544
"No header in #include"
@@ -3556,7 +3556,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35563556
const FileData *const filedata = cache.get(rawtokens.file(rawtok->location), header, dui, systemheader, files, outputList).first;
35573557
if (filedata == nullptr) {
35583558
if (outputList) {
3559-
simplecpp::Output out = {
3559+
simplecpp::Output out{
35603560
simplecpp::Output::MISSING_HEADER,
35613561
rawtok->location,
35623562
"Header not found: " + inctok->str()
@@ -3565,7 +3565,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35653565
}
35663566
} else if (includetokenstack.size() >= 400) {
35673567
if (outputList) {
3568-
simplecpp::Output out = {
3568+
simplecpp::Output out{
35693569
simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY,
35703570
rawtok->location,
35713571
"#include nested too deeply"
@@ -3580,7 +3580,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35803580
} else if (rawtok->str() == IF || rawtok->str() == IFDEF || rawtok->str() == IFNDEF || rawtok->str() == ELIF) {
35813581
if (!sameline(rawtok,rawtok->next)) {
35823582
if (outputList) {
3583-
simplecpp::Output out = {
3583+
simplecpp::Output out{
35843584
simplecpp::Output::SYNTAX_ERROR,
35853585
rawtok->location,
35863586
"Syntax error in #" + rawtok->str()
@@ -3626,7 +3626,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36263626
tok = tok ? tok->next : nullptr;
36273627
if (!tok || !sameline(rawtok,tok) || (par && tok->op != ')')) {
36283628
if (outputList) {
3629-
Output out = {
3629+
Output out{
36303630
Output::SYNTAX_ERROR,
36313631
rawtok->location,
36323632
"failed to evaluate " + std::string(rawtok->str() == IF ? "#if" : "#elif") + " condition"
@@ -3669,7 +3669,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36693669
tok = tok ? tok->next : nullptr;
36703670
if (!tok || !sameline(rawtok,tok) || (par && tok->op != ')') || (!closingAngularBracket)) {
36713671
if (outputList) {
3672-
Output out = {
3672+
Output out{
36733673
Output::SYNTAX_ERROR,
36743674
rawtok->location,
36753675
"failed to evaluate " + std::string(rawtok->str() == IF ? "#if" : "#elif") + " condition"
@@ -3710,7 +3710,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37103710
std::string msg = "failed to evaluate " + std::string(rawtok->str() == IF ? "#if" : "#elif") + " condition";
37113711
if (e.what() && *e.what())
37123712
msg += std::string(", ") + e.what();
3713-
Output out = {
3713+
Output out{
37143714
Output::SYNTAX_ERROR,
37153715
rawtok->location,
37163716
std::move(msg)

0 commit comments

Comments
 (0)