Is the change from the while loop to find_first_no_of correct ? Just
double checking

regards
john

diff -u -r1.32 lyxlex.C
--- lyxlex.C    28 Jul 2002 22:50:05 -0000      1.32
+++ lyxlex.C    2 Aug 2002 12:53:00 -0000
@@ -168,29 +168,28 @@
 
                // We do a case independent comparison, like search_kw
                // does.
-               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 (compare_ascii_no_case(token, endtoken) == 0)
+                       break;
 
-                       if (!prefix.empty()
-                           && prefixIs(tmpstr, prefix)) {
-                               tmpstr.erase(0, prefix.length() - 1);
-                       }
-                       str += ltrim(tmpstr, "\t") + '\n';
+               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;
                }
-               else // token == endtoken
-                       break;
+
+               // 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';
        }
+
        if (!isOK()) {
                printError("Long string not ended by `" + endtoken + '\'');
        }

-- 
"The simpler it is, the harder it is." 
        - Tim Van Holder

Reply via email to