StelScriptMgr.cpp   StelScriptMgr.cpp 
skipping to change at line 197 skipping to change at line 197
return QString(); return QString();
} }
const QString StelScriptMgr::getHeaderSingleLineCommentText(const QString& s, const QString& id, const QString& notFoundText) const QString StelScriptMgr::getHeaderSingleLineCommentText(const QString& s, const QString& id, const QString& notFoundText)
{ {
try try
{ {
QFile file(StelFileMgr::findFile("scripts/" + s, StelFileMgr ::File)); QFile file(StelFileMgr::findFile("scripts/" + s, StelFileMgr ::File));
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
QString msg = QString("WARNING: script file %1 could not be opened for reading").arg(s); QString msg = QString("WARNING: script file %1 could not be opened for reading").arg(QDir::toNativeSeparators(s));
emit(scriptDebug(msg)); emit(scriptDebug(msg));
qWarning() << msg; qWarning() << msg;
return QString(); return QString();
} }
QRegExp nameExp("^\\s*//\\s*" + id + ":\\s*(.+)$"); QRegExp nameExp("^\\s*//\\s*" + id + ":\\s*(.+)$");
while (!file.atEnd()) while (!file.atEnd())
{ {
QString line = QString::fromUtf8(file.readLine()); QString line = QString::fromUtf8(file.readLine());
if (nameExp.exactMatch(line)) if (nameExp.exactMatch(line))
{ {
file.close(); file.close();
return nameExp.capturedTexts().at(1); return nameExp.capturedTexts().at(1);
} }
} }
file.close(); file.close();
return notFoundText; return notFoundText;
} }
catch(std::runtime_error& e) catch(std::runtime_error& e)
{ {
QString msg = QString("WARNING: script file %1 could not be found: %2").arg(s).arg(e.what()); QString msg = QString("WARNING: script file %1 could not be found: %2").arg(QDir::toNativeSeparators(s)).arg(e.what());
emit(scriptDebug(msg)); emit(scriptDebug(msg));
qWarning() << msg; qWarning() << msg;
return QString(); return QString();
} }
} }
const QString StelScriptMgr::getName(const QString& s) const QString StelScriptMgr::getName(const QString& s)
{ {
return getHeaderSingleLineCommentText(s, "Name", s); return getHeaderSingleLineCommentText(s, "Name", s);
} }
skipping to change at line 247 skipping to change at line 247
return getHeaderSingleLineCommentText(s, "License", ""); return getHeaderSingleLineCommentText(s, "License", "");
} }
const QString StelScriptMgr::getDescription(const QString& s) const QString StelScriptMgr::getDescription(const QString& s)
{ {
try try
{ {
QFile file(StelFileMgr::findFile("scripts/" + s, StelFileMgr ::File)); QFile file(StelFileMgr::findFile("scripts/" + s, StelFileMgr ::File));
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
QString msg = QString("WARNING: script file %1 could not be opened for reading").arg(s); QString msg = QString("WARNING: script file %1 could not be opened for reading").arg(QDir::toNativeSeparators(s));
emit(scriptDebug(msg)); emit(scriptDebug(msg));
qWarning() << msg; qWarning() << msg;
return QString(); return QString();
} }
QString desc = ""; QString desc = "";
bool inDesc = false; bool inDesc = false;
QRegExp descExp("^\\s*//\\s*Description:\\s*([^\\s].+)\\s*$" ); QRegExp descExp("^\\s*//\\s*Description:\\s*([^\\s].+)\\s*$" );
QRegExp descNewlineExp("^\\s*//\\s*$"); QRegExp descNewlineExp("^\\s*//\\s*$");
QRegExp descContExp("^\\s*//\\s*([^\\s].*)\\s*$"); QRegExp descContExp("^\\s*//\\s*([^\\s].*)\\s*$");
skipping to change at line 290 skipping to change at line 290
return desc; return desc;
} }
desc += d; desc += d;
} }
} }
file.close(); file.close();
return desc; return desc;
} }
catch(std::runtime_error& e) catch(std::runtime_error& e)
{ {
QString msg = QString("WARNING: script file %1 could not be found: %2").arg(s).arg(e.what()); QString msg = QString("WARNING: script file %1 could not be found: %2").arg(QDir::toNativeSeparators(s)).arg(e.what());
emit(scriptDebug(msg)); emit(scriptDebug(msg));
qWarning() << msg; qWarning() << msg;
return QString(); return QString();
} }
} }
bool StelScriptMgr::runPreprocessedScript(const QString &preprocessedScript ) bool StelScriptMgr::runPreprocessedScript(const QString &preprocessedScript )
{ {
if (engine.isEvaluating()) if (engine.isEvaluating())
{ {
skipping to change at line 339 skipping to change at line 339
{ {
if (QFileInfo(fileName).isAbsolute()) if (QFileInfo(fileName).isAbsolute())
absPath = fileName; absPath = fileName;
else else
absPath = StelFileMgr::findFile("scripts/" + fileNam e); absPath = StelFileMgr::findFile("scripts/" + fileNam e);
scriptDir = QFileInfo(absPath).dir().path(); scriptDir = QFileInfo(absPath).dir().path();
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
QString msg = QString("WARNING: could not find script file % 1: %2").arg(fileName).arg(e.what()); QString msg = QString("WARNING: could not find script file % 1: %2").arg(QDir::toNativeSeparators(fileName)).arg(e.what());
emit(scriptDebug(msg)); emit(scriptDebug(msg));
qWarning() << msg; qWarning() << msg;
return false; return false;
} }
QFile fic(absPath); QFile fic(absPath);
if (!fic.open(QIODevice::ReadOnly)) if (!fic.open(QIODevice::ReadOnly))
{ {
QString msg = QString("WARNING: cannot open script: %1").arg (fileName); QString msg = QString("WARNING: cannot open script: %1").arg (QDir::toNativeSeparators(fileName));
emit(scriptDebug(msg)); emit(scriptDebug(msg));
qWarning() << msg; qWarning() << msg;
return false; return false;
} }
scriptFileName = fileName; scriptFileName = fileName;
if (!includePath.isEmpty()) if (!includePath.isEmpty())
scriptDir = includePath; scriptDir = includePath;
QString preprocessedScript; QString preprocessedScript;
bool ok = false; bool ok = false;
skipping to change at line 486 skipping to change at line 486
if (QFileInfo(fileName).isAbsolute()) if (QFileInfo(fileName).isAbsolute())
path = fileName; path = fileName;
else else
{ {
try try
{ {
path = StelFileMgr::findFile(scriptD ir + "/" + fileName); path = StelFileMgr::findFile(scriptD ir + "/" + fileName);
} }
catch(std::runtime_error& e) catch(std::runtime_error& e)
{ {
qWarning() << "WARNING: script inclu de:" << fileName << e.what(); qWarning() << "WARNING: script inclu de:" << QDir::toNativeSeparators(fileName) << e.what();
return false; return false;
} }
} }
QFile fic(path); QFile fic(path);
bool ok = fic.open(QIODevice::ReadOnly); bool ok = fic.open(QIODevice::ReadOnly);
if (ok) if (ok)
{ {
qDebug() << "script include: " << path; qDebug() << "script include: " << QDir::toNa tiveSeparators(path);
preprocessScript(fic, output, scriptDir); preprocessScript(fic, output, scriptDir);
} }
else else
{ {
qWarning() << "WARNING: could not open scrip t include file for reading:" << path; qWarning() << "WARNING: could not open scrip t include file for reading:" << QDir::toNativeSeparators(path);
return false; return false;
} }
} }
else else
{ {
output += line; output += line;
output += '\n'; output += '\n';
} }
} }
return true; return true;
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/