// We do a case independent comparison, like search_kw
// does.
- if (compare_ascii_no_case(token, endtoken) == 0)
- break;
-
- string tmpstr = getString();
- if (firstline) {
- string::size_type i(tmpstr.find_first_not_of(' '));
- if (i != string::npos)
- prefix = tmpstr.substr(0, i);
- firstline = false;
- lyxerr[Debug::PARSER]
- << "Prefix = `" << prefix << "\'" << endl;
+ if (compare_ascii_no_case(token, endtoken) != 0) {
+ string tmpstr = getString();
+ if (firstline) {
+ unsigned int i = 0;
+ while (i < tmpstr.length()
+ && tmpstr[i] == ' ') {
+ ++i;
+ prefix += ' ';
+ }
+ firstline = false;
+ lyxerr[Debug::PARSER] << "Prefix = `" << prefix
+ << '\'' << endl;
+ }
+
+ if (!prefix.empty()
+ && prefixIs(tmpstr, prefix)) {
+ tmpstr.erase(0, prefix.length() - 1);
+ }
+ str += ltrim(tmpstr, "\t") + '\n';
}
-
- // further lines in long strings may have the same
- // whitespace prefix as the first line. Remove it.
- if (prefixIs(tmpstr, prefix)) {
- tmpstr.erase(0, prefix.length() - 1);
- }
-
- str += ltrim(tmpstr, "\t") + '\n';
+ else // token == endtoken
+ break;
}
-
if (!isOK()) {
printError("Long string not ended by `" + endtoken + '\'');
}