improved token handling

This commit is contained in:
nemu 2011-07-13 14:32:14 +00:00
parent 1e115c7bd3
commit 5672c43d2e
2 changed files with 20 additions and 20 deletions

View File

@ -670,7 +670,7 @@ bool PTextEdit::validRunList(const QString runList)
int val; int val;
bool ok; bool ok;
while (!done) { while (!done) {
subStr = runList.section(' ', i, i); subStr = runList.section(' ', i, i, QString::SectionSkipEmpty);
if (subStr.isEmpty()) { if (subStr.isEmpty()) {
done = true; done = true;
continue; continue;
@ -1798,7 +1798,7 @@ void PTextEdit::musrMsr2Data()
break; break;
case 1: case 1:
end = 0; end = 0;
while (!runList.section(' ', end, end).isEmpty()) { while (!runList.section(' ', end, end, QString::SectionSkipEmpty).isEmpty()) {
end++; end++;
} }
// first element // first element
@ -1806,14 +1806,14 @@ void PTextEdit::musrMsr2Data()
str = "[" + runList + "]"; str = "[" + runList + "]";
cmd.append(str); cmd.append(str);
} else { } else {
str = "[" + runList.section(' ', 0, 0); str = "[" + runList.section(' ', 0, 0, QString::SectionSkipEmpty);
cmd.append(str); cmd.append(str);
// middle elements // middle elements
for (i=1; i<end-1; i++) { for (i=1; i<end-1; i++) {
cmd.append(runList.section(' ', i, i)); cmd.append(runList.section(' ', i, i, QString::SectionSkipEmpty));
} }
// last element // last element
str = runList.section(' ', end-1, end-1) + "]"; str = runList.section(' ', end-1, end-1, QString::SectionSkipEmpty) + "]";
cmd.append(str); cmd.append(str);
} }
break; break;
@ -1930,11 +1930,11 @@ void PTextEdit::musrMsr2Data()
break; break;
case 1: // run list case 1: // run list
end = 0; end = 0;
while (!runList.section(' ', end, end).isEmpty()) { while (!runList.section(' ', end, end, QString::SectionSkipEmpty).isEmpty()) {
end++; end++;
} }
for (int i=0; i<end; i++) { for (int i=0; i<end; i++) {
fln = runList.section(' ', i, i); fln = runList.section(' ', i, i, QString::SectionSkipEmpty);
if (fMsr2DataParam->msrFileExtension.isEmpty()) if (fMsr2DataParam->msrFileExtension.isEmpty())
fln += ".msr"; fln += ".msr";
else else
@ -1956,7 +1956,7 @@ void PTextEdit::musrMsr2Data()
str = stream->readLine(); // line of text excluding '\n' str = stream->readLine(); // line of text excluding '\n'
str.trimmed(); str.trimmed();
if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) { if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) {
fln = str.section(' ', 0, 0); fln = str.section(' ', 0, 0, QString::SectionSkipEmpty);
if (fMsr2DataParam->msrFileExtension.isEmpty()) if (fMsr2DataParam->msrFileExtension.isEmpty())
fln += ".msr"; fln += ".msr";
else else
@ -1983,7 +1983,7 @@ void PTextEdit::musrMsr2Data()
fln = QString("%1").arg(fMsr2DataParam->firstRun) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); fln = QString("%1").arg(fMsr2DataParam->firstRun) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
break; break;
case 1: // run list case 1: // run list
fln = runList.section(" ", 0, 0) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); fln = runList.section(" ", 0, 0, QString::SectionSkipEmpty) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
break; break;
case 2: // run list file name case 2: // run list file name
file = new QFile(fMsr2DataParam->runListFileName); file = new QFile(fMsr2DataParam->runListFileName);
@ -1998,7 +1998,7 @@ void PTextEdit::musrMsr2Data()
str = stream->readLine(); // line of text excluding '\n' str = stream->readLine(); // line of text excluding '\n'
str.trimmed(); str.trimmed();
if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) { if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) {
fln = str.section(' ', 0, 0); fln = str.section(' ', 0, 0, QString::SectionSkipEmpty);
break; break;
} }
} }

View File

@ -499,7 +499,7 @@ bool PTextEdit::validRunList(const QString runList)
int val; int val;
bool ok; bool ok;
while (!done) { while (!done) {
subStr = runList.section(' ', i, i); subStr = runList.section(' ', i, i, QString::SectionSkipEmpty);
if (subStr.isEmpty()) { if (subStr.isEmpty()) {
done = true; done = true;
continue; continue;
@ -1525,7 +1525,7 @@ void PTextEdit::musrMsr2Data()
break; break;
case 1: case 1:
end = 0; end = 0;
while (!runList.section(' ', end, end).isEmpty()) { while (!runList.section(' ', end, end, QString::SectionSkipEmpty).isEmpty()) {
end++; end++;
} }
// first element // first element
@ -1533,14 +1533,14 @@ void PTextEdit::musrMsr2Data()
str = "[" + runList + "]"; str = "[" + runList + "]";
cmd.append(str); cmd.append(str);
} else { } else {
str = "[" + runList.section(' ', 0, 0); str = "[" + runList.section(' ', 0, 0, QString::SectionSkipEmpty);
cmd.append(str); cmd.append(str);
// middle elements // middle elements
for (i=1; i<end-1; i++) { for (i=1; i<end-1; i++) {
cmd.append(runList.section(' ', i, i)); cmd.append(runList.section(' ', i, i, QString::SectionSkipEmpty));
} }
// last element // last element
str = runList.section(' ', end-1, end-1) + "]"; str = runList.section(' ', end-1, end-1, QString::SectionSkipEmpty) + "]";
cmd.append(str); cmd.append(str);
} }
break; break;
@ -1655,11 +1655,11 @@ void PTextEdit::musrMsr2Data()
break; break;
case 1: // run list case 1: // run list
end = 0; end = 0;
while (!runList.section(' ', end, end).isEmpty()) { while (!runList.section(' ', end, end, QString::SectionSkipEmpty).isEmpty()) {
end++; end++;
} }
for (int i=0; i<end; i++) { for (int i=0; i<end; i++) {
fln = runList.section(' ', i, i); fln = runList.section(' ', i, i, QString::SectionSkipEmpty);
if (fMsr2DataParam->msrFileExtension.isEmpty()) if (fMsr2DataParam->msrFileExtension.isEmpty())
fln += ".msr"; fln += ".msr";
else else
@ -1681,7 +1681,7 @@ void PTextEdit::musrMsr2Data()
str = stream->readLine(); // line of text excluding '\n' str = stream->readLine(); // line of text excluding '\n'
str.stripWhiteSpace(); str.stripWhiteSpace();
if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", false)) { if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", false)) {
fln = str.section(' ', 0, 0); fln = str.section(' ', 0, 0, QString::SectionSkipEmpty);
if (fMsr2DataParam->msrFileExtension.isEmpty()) if (fMsr2DataParam->msrFileExtension.isEmpty())
fln += ".msr"; fln += ".msr";
else else
@ -1707,7 +1707,7 @@ void PTextEdit::musrMsr2Data()
fln = QString("%1").arg(fMsr2DataParam->firstRun) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); fln = QString("%1").arg(fMsr2DataParam->firstRun) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
break; break;
case 1: // run list case 1: // run list
fln = runList.section(" ", 0, 0) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); fln = runList.section(" ", 0, 0, QString::SectionSkipEmpty) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
break; break;
case 2: // run list file name case 2: // run list file name
file = new QFile(fMsr2DataParam->runListFileName); file = new QFile(fMsr2DataParam->runListFileName);
@ -1722,7 +1722,7 @@ void PTextEdit::musrMsr2Data()
str = stream->readLine(); // line of text excluding '\n' str = stream->readLine(); // line of text excluding '\n'
str.stripWhiteSpace(); str.stripWhiteSpace();
if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", false)) { if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", false)) {
fln = str.section(' ', 0, 0); fln = str.section(' ', 0, 0, QString::SectionSkipEmpty);
break; break;
} }
} }