mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
Update JSBaker.cpp
This commit is contained in:
parent
a9aab67a06
commit
0b387f5b38
1 changed files with 9 additions and 11 deletions
|
@ -34,7 +34,7 @@ void JSBaker::importJS() {
|
||||||
// Import the file to be processed from _jsURL
|
// Import the file to be processed from _jsURL
|
||||||
QFile jsFile(_jsURL.toLocalFile());
|
QFile jsFile(_jsURL.toLocalFile());
|
||||||
if (!jsFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!jsFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
handleError("Error opening " + _originalJSFilePath + " for reading");
|
handleError("Error opening " + _jsURL.fileName() + " for reading");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,18 +85,16 @@ void JSBaker::bakeJS(QFile* inputFile) {
|
||||||
// If '/' is not followed by '/' or '*' print '/'
|
// If '/' is not followed by '/' or '*' print '/'
|
||||||
out << currentCharacter;
|
out << currentCharacter;
|
||||||
}
|
}
|
||||||
} else if (isControlCharacter(currentCharacter)) {
|
} else if (isSpaceOrTab(currentCharacter)) {
|
||||||
// Check if white space or tab
|
// Check if white space or tab
|
||||||
|
|
||||||
// Skip multiple spaces or tabs
|
// Skip multiple spaces or tabs
|
||||||
if (isControlCharacter(nextCharacter)) {
|
while (isSpaceOrTab(nextCharacter)) {
|
||||||
while (isControlCharacter(nextCharacter)) {
|
|
||||||
in >> nextCharacter;
|
in >> nextCharacter;
|
||||||
if (nextCharacter == '\n') {
|
if (nextCharacter == '\n') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// check if space can be omitted
|
// check if space can be omitted
|
||||||
if (!canOmitSpace(previousCharacter, nextCharacter)) {
|
if (!canOmitSpace(previousCharacter, nextCharacter)) {
|
||||||
|
@ -107,7 +105,7 @@ void JSBaker::bakeJS(QFile* inputFile) {
|
||||||
|
|
||||||
//Skip multiple new lines
|
//Skip multiple new lines
|
||||||
//Skip new line followed by space or tab
|
//Skip new line followed by space or tab
|
||||||
while (nextCharacter == '\n' || isControlCharacter(nextCharacter)) {
|
while (nextCharacter == '\n' || isSpaceOrTab(nextCharacter)) {
|
||||||
in >> nextCharacter;
|
in >> nextCharacter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +244,7 @@ bool JSBaker::isSpecialCharacterNext(QChar c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if white space or tab
|
// Check if white space or tab
|
||||||
bool JSBaker::isControlCharacter(QChar c) {
|
bool JSBaker::isSpaceOrTab(QChar c) {
|
||||||
return (c == ' ' || c == '\t');
|
return (c == ' ' || c == '\t');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue