@@ -497,17 +497,21 @@ void clangimport::AstNode::dumpAst(int num, int indent) const
497497void clangimport::AstNode::setLocations (TokenList *tokenList, int file, int line, int col)
498498{
499499 for (const std::string &ext: mExtTokens ) {
500- if (ext.compare (0 ,5 , " <col:" ) == 0 )
500+ if (ext.compare (0 , 5 , " <col:" ) == 0 )
501501 col = std::atoi (ext.substr (5 ).c_str ());
502- else if (ext.compare (0 ,6 , " <line:" ) == 0 ) {
502+ else if (ext.compare (0 , 6 , " <line:" ) == 0 ) {
503503 line = std::atoi (ext.substr (6 ).c_str ());
504504 if (ext.find (" , col:" ) != std::string::npos)
505505 col = std::atoi (ext.c_str () + ext.find (" , col:" ) + 6 );
506- } else if (ext[0 ] == ' <' && ext.find (" :" ) != std::string::npos) {
507- std::string::size_type sep1 = ext.find (" :" );
508- std::string::size_type sep2 = ext.find (" :" , sep1+1 );
509- file = tokenList->appendFileIfNew (ext.substr (1 , sep1 - 1 ));
510- line = MathLib::toLongNumber (ext.substr (sep1+1 , sep2-sep1));
506+ } else if (ext[0 ] == ' <' ) {
507+ const std::string::size_type colon = ext.find (' :' );
508+ if (colon != std::string::npos) {
509+ const bool windowsPath = colon == 2 && ext.size () > 4 && ext[3 ] == ' \\ ' ;
510+ std::string::size_type sep1 = windowsPath ? ext.find (' :' , 4 ) : colon;
511+ std::string::size_type sep2 = ext.find (' :' , sep1 + 1 );
512+ file = tokenList->appendFileIfNew (ext.substr (1 , sep1 - 1 ));
513+ line = MathLib::toLongNumber (ext.substr (sep1 + 1 , sep2 - sep1 - 1 ));
514+ }
511515 }
512516 }
513517 mFile = file;
0 commit comments