@@ -466,20 +466,13 @@ simplecpp::TokenList::TokenList(std::istream &istr, std::vector<std::string> &fi
466466 readfile (stream,filename,outputList);
467467}
468468
469- simplecpp::TokenList::TokenList (const unsigned char * data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList)
469+ simplecpp::TokenList::TokenList (const unsigned char * data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList, int /* unused */ )
470470 : frontToken(nullptr ), backToken(nullptr ), files(filenames)
471471{
472472 StdCharBufStream stream (data, size);
473473 readfile (stream,filename,outputList);
474474}
475475
476- simplecpp::TokenList::TokenList (const char * data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList)
477- : frontToken(nullptr ), backToken(nullptr ), files(filenames)
478- {
479- StdCharBufStream stream (reinterpret_cast <const unsigned char *>(data), size);
480- readfile (stream,filename,outputList);
481- }
482-
483476simplecpp::TokenList::TokenList (const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList)
484477 : frontToken(nullptr ), backToken(nullptr ), files(filenames)
485478{
@@ -611,7 +604,7 @@ static void portabilityBackslash(simplecpp::OutputList *outputList, const std::v
611604 err.type = simplecpp::Output::PORTABILITY_BACKSLASH;
612605 err.location = location;
613606 err.msg = " Combination 'backslash space newline' is not portable." ;
614- outputList->push_back (err);
607+ outputList->push_back (std::move ( err) );
615608}
616609
617610static bool isStringLiteralPrefix (const std::string &str)
@@ -761,18 +754,18 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
761754 while (stream.good () && ch != ' \n ' ) {
762755 currentToken += ch;
763756 ch = stream.readChar ();
764- if (ch == ' \\ ' ) {
757+ if (ch == ' \\ ' ) {
765758 TokenString tmp;
766759 char tmp_ch = ch;
767- while ((stream.good ()) && (tmp_ch == ' \\ ' || tmp_ch == ' ' || tmp_ch == ' \t ' )) {
760+ while ((stream.good ()) && (tmp_ch == ' \\ ' || tmp_ch == ' ' || tmp_ch == ' \t ' )) {
768761 tmp += tmp_ch;
769762 tmp_ch = stream.readChar ();
770763 }
771- if (!stream.good ()) {
764+ if (!stream.good ()) {
772765 break ;
773766 }
774767
775- if (tmp_ch != ' \n ' ) {
768+ if (tmp_ch != ' \n ' ) {
776769 currentToken += tmp;
777770 } else {
778771 const TokenString check_portability = currentToken + tmp;
@@ -855,7 +848,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
855848 err.type = Output::SYNTAX_ERROR;
856849 err.location = location;
857850 err.msg = " Raw string missing terminating delimiter." ;
858- outputList->push_back (err);
851+ outputList->push_back (std::move ( err) );
859852 }
860853 return ;
861854 }
@@ -1397,7 +1390,7 @@ std::string simplecpp::TokenList::readUntil(Stream &stream, const Location &loca
13971390 err.type = Output::SYNTAX_ERROR;
13981391 err.location = location;
13991392 err.msg = std::string (" No pair for character (" ) + start + " ). Can't process file. File is either invalid or unicode, which is currently not supported." ;
1400- outputList->push_back (err);
1393+ outputList->push_back (std::move ( err) );
14011394 }
14021395 return " " ;
14031396 }
@@ -1667,7 +1660,7 @@ namespace simplecpp {
16671660 }
16681661
16691662 invalidHashHash (const Location &loc, const std::string ¯oName, const std::string &message)
1670- : Error(loc, format(macroName, message)) { }
1663+ : Error(loc, format(macroName, message)) {}
16711664
16721665 static inline invalidHashHash unexpectedToken (const Location &loc, const std::string ¯oName, const Token *tokenA) {
16731666 return invalidHashHash (loc, macroName, " Unexpected token '" + tokenA->str ()+" '" );
@@ -2178,7 +2171,7 @@ namespace simplecpp {
21782171 if (it != macros.end () && !partok->isExpandedFrom (&it->second ) && (partok->str () == name () || expandedmacros.find (partok->str ()) == expandedmacros.end ())) {
21792172 std::set<TokenString> expandedmacros2 (expandedmacros); // temporary amnesia to allow reexpansion of currently expanding macros during argument evaluation
21802173 expandedmacros2.erase (name ());
2181- partok = it->second .expand (output, loc, partok, macros, expandedmacros2);
2174+ partok = it->second .expand (output, loc, partok, macros, std::move ( expandedmacros2) );
21822175 } else {
21832176 output->push_back (newMacroToken (partok->str (), loc, isReplaced (expandedmacros), partok));
21842177 output->back ()->macro = partok->macro ;
@@ -2385,12 +2378,17 @@ namespace simplecpp {
23852378namespace simplecpp {
23862379
23872380#ifdef __CYGWIN__
2381+ static bool startsWith (const std::string &s, const std::string &p)
2382+ {
2383+ return (s.size () >= p.size ()) && std::equal (p.begin (), p.end (), s.begin ());
2384+ }
2385+
23882386 std::string convertCygwinToWindowsPath (const std::string &cygwinPath)
23892387 {
23902388 std::string windowsPath;
23912389
23922390 std::string::size_type pos = 0 ;
2393- if (cygwinPath.size () >= 11 && startsWith_ (cygwinPath, " /cygdrive/" )) {
2391+ if (cygwinPath.size () >= 11 && startsWith (cygwinPath, " /cygdrive/" )) {
23942392 const unsigned char driveLetter = cygwinPath[10 ];
23952393 if (std::isalpha (driveLetter)) {
23962394 if (cygwinPath.size () == 11 ) {
@@ -2667,7 +2665,7 @@ static unsigned long long stringToULLbounded(
26672665 int base = 0 ,
26682666 std::ptrdiff_t minlen = 1 ,
26692667 std::size_t maxlen = std::string::npos
2670- )
2668+ )
26712669{
26722670 const std::string sub = s.substr (pos, maxlen);
26732671 const char * const start = sub.c_str ();
@@ -3024,8 +3022,7 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(FileDat
30243022 return {id_it->second , false };
30253023 }
30263024
3027- std::ifstream f (path);
3028- FileData *const data = new FileData {path, TokenList (f, filenames, path, outputList)};
3025+ FileData *const data = new FileData {path, TokenList (path, filenames, outputList)};
30293026
30303027 if (dui.removeComments )
30313028 data->tokens .removeComments ();
@@ -3132,7 +3129,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31323129 err.type = simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND;
31333130 err.location = Location (filenames);
31343131 err.msg = " Can not open include file '" + filename + " ' that is explicitly included." ;
3135- outputList->push_back (err);
3132+ outputList->push_back (std::move ( err) );
31363133 }
31373134 continue ;
31383135 }
@@ -3205,7 +3202,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
32053202 out.type = simplecpp::Output::SYNTAX_ERROR;
32063203 out.location = err.location ;
32073204 out.msg = " failed to expand \' " + tok->str () + " \' , " + err.what ;
3208- outputList->push_back (out);
3205+ outputList->push_back (std::move ( out) );
32093206 }
32103207 return false ;
32113208 }
@@ -3349,7 +3346,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33493346 includetokenstack.push (filedata->tokens .cfront ());
33503347 }
33513348
3352- std::map<std::string, std::list<Location> > maybeUsedMacros;
3349+ std::map<std::string, std::list<Location>> maybeUsedMacros;
33533350
33543351 for (const Token *rawtok = nullptr ; rawtok || !includetokenstack.empty ();) {
33553352 if (rawtok == nullptr ) {
@@ -3392,7 +3389,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33923389 err.msg += tok->str ();
33933390 }
33943391 err.msg = ' #' + rawtok->str () + ' ' + err.msg ;
3395- outputList->push_back (err);
3392+ outputList->push_back (std::move ( err) );
33963393 }
33973394/* Patched for PythonQt generator: Do not stop on #error directive:
33983395 if (rawtok->str() == ERROR) {
@@ -3554,7 +3551,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35543551 out.type = Output::SYNTAX_ERROR;
35553552 out.location = rawtok->location ;
35563553 out.msg = " failed to evaluate " + std::string (rawtok->str () == IF ? " #if" : " #elif" ) + " condition" ;
3557- outputList->push_back (out);
3554+ outputList->push_back (std::move ( out) );
35583555 }
35593556 output.clear ();
35603557 return ;
@@ -3733,7 +3730,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37333730 mu.macroName = macro.name ();
37343731 mu.macroLocation = macro.defineLocation ();
37353732 mu.useLocation = *usageIt;
3736- macroUsage->push_back (mu );
3733+ macroUsage->push_back (std::move (mu) );
37373734 }
37383735 }
37393736 }
@@ -3748,11 +3745,11 @@ simplecpp::cstd_t simplecpp::getCStd(const std::string &std)
37483745{
37493746 if (std == " c90" || std == " c89" || std == " iso9899:1990" || std == " iso9899:199409" || std == " gnu90" || std == " gnu89" )
37503747 return C89;
3751- if (std == " c99" || std == " c9x" || std == " iso9899:1999" || std == " iso9899:199x" || std == " gnu99" || std == " gnu9x" )
3748+ if (std == " c99" || std == " c9x" || std == " iso9899:1999" || std == " iso9899:199x" || std == " gnu99" || std == " gnu9x" )
37523749 return C99;
37533750 if (std == " c11" || std == " c1x" || std == " iso9899:2011" || std == " gnu11" || std == " gnu1x" )
37543751 return C11;
3755- if (std == " c17" || std == " c18" || std == " iso9899:2017" || std == " iso9899:2018" || std == " gnu17" || std == " gnu18" )
3752+ if (std == " c17" || std == " c18" || std == " iso9899:2017" || std == " iso9899:2018" || std == " gnu17" || std == " gnu18" )
37563753 return C17;
37573754 if (std == " c23" || std == " gnu23" || std == " c2x" || std == " gnu2x" )
37583755 return C23;
0 commit comments