@@ -247,7 +247,7 @@ std::string ErrorLogger::ErrorMessage::serialize() const
247247
248248 for (std::list<ErrorLogger::ErrorMessage::FileLocation>::const_iterator loc = callStack.begin (); loc != callStack.end (); ++loc) {
249249 std::ostringstream smallStream;
250- smallStream << (*loc).line << ' : ' << (*loc).column << ' : ' << (*loc).getfile () << ' \t ' << loc->getinfo ();
250+ smallStream << (*loc).line << ' \t ' << (*loc).column << ' \t ' << (*loc).getfile (false ) << ' \t ' << loc-> getOrigFile ( false ) << ' \t ' << loc->getinfo ();
251251 oss << smallStream.str ().length () << " " << smallStream.str ();
252252 }
253253
@@ -309,28 +309,29 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
309309 temp.append (1 , c);
310310 }
311311
312- const std::string::size_type colonPos1 = temp.find (' :' );
313- if (colonPos1 == std::string::npos)
314- throw InternalError (nullptr , " Internal Error: No colon found in <line:col:filename> pattern" );
315- const std::string::size_type colonPos2 = temp.find (' :' , colonPos1+1 );
316- if (colonPos2 == std::string::npos)
317- throw InternalError (nullptr , " Internal Error: second colon not found in <line:col:filename> pattern" );
318- const std::string::size_type tabPos = temp.find (' \t ' );
319- if (tabPos == std::string::npos)
320- throw InternalError (nullptr , " Internal Error: No tab found in <filename:line> pattern" );
321-
322- const std::string tempinfo = temp.substr (tabPos + 1 );
323- temp.erase (tabPos);
324- const std::string tempfile = temp.substr (colonPos2 + 1 );
325- temp.erase (colonPos2);
326- const std::string tempcolumn = temp.substr (colonPos1 + 1 );
327- temp.erase (colonPos1);
328- const std::string templine = temp;
329- ErrorLogger::ErrorMessage::FileLocation loc;
330- loc.setfile (tempfile);
331- loc.setinfo (tempinfo);
332- loc.column = MathLib::toLongNumber (tempcolumn);
333- loc.line = MathLib::toLongNumber (templine);
312+ std::vector<std::string> substrings;
313+ for (std::string::size_type pos = 0 ; pos < temp.size () && substrings.size () < 5 ; ++pos) {
314+ if (substrings.size () == 4 ) {
315+ substrings.push_back (temp.substr (pos));
316+ break ;
317+ }
318+ const std::string::size_type start = pos;
319+ pos = temp.find (" \t " , pos);
320+ if (pos == std::string::npos) {
321+ substrings.push_back (temp.substr (start));
322+ break ;
323+ }
324+ substrings.push_back (temp.substr (start, pos - start));
325+ }
326+ if (substrings.size () < 4 )
327+ throw InternalError (nullptr , " Internal Error: serializing/deserializing of error message failed!" );
328+
329+ // (*loc).line << '\t' << (*loc).column << '\t' << (*loc).getfile(false) << '\t' << loc->getOrigFile(false) << '\t' << loc->getinfo();
330+
331+ ErrorLogger::ErrorMessage::FileLocation loc (substrings[3 ], MathLib::toLongNumber (substrings[0 ]), MathLib::toLongNumber (substrings[1 ]));
332+ loc.setfile (substrings[2 ]);
333+ if (substrings.size () == 5 )
334+ loc.setinfo (substrings[4 ]);
334335
335336 callStack.push_back (loc);
336337
@@ -441,7 +442,7 @@ void ErrorLogger::ErrorMessage::findAndReplace(std::string &source, const std::s
441442}
442443
443444// TODO: read info from some shared resource instead?
444- static std::string readCode (const std::string &file, unsigned int linenr, unsigned int column, const char endl[])
445+ static std::string readCode (const std::string &file, int linenr, int column, const char endl[])
445446{
446447 std::ifstream fin (file);
447448 std::string line;
0 commit comments