From 3f1a78fbeb103a580e14a517f0ed632efa42c2a2 Mon Sep 17 00:00:00 2001 From: John Levon Date: Fri, 2 Aug 2002 13:43:43 +0000 Subject: [PATCH] small cleanup git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4841 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/lyxlex.C | 41 ++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 4217ea24bd..f9375e9de7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -4,6 +4,10 @@ * lyxfunc.C (moveCursorUpdate, dispatch, view_status_message): changes due to LyXView::view() now returning a boost::shared_ptr. +2002-08-02 John Levon + + * lyxlex.C: small cleanup + 2002-08-02 John Levon * text2.C (status): small cleanup, no logic change diff --git a/src/lyxlex.C b/src/lyxlex.C index e9c8beb0c4..a6aca998a6 100644 --- a/src/lyxlex.C +++ b/src/lyxlex.C @@ -168,29 +168,28 @@ string const LyXLex::getLongString(string const & endtoken) // 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 (!prefix.empty() - && prefixIs(tmpstr, prefix)) { - tmpstr.erase(0, prefix.length() - 1); - } - str += ltrim(tmpstr, "\t") + '\n'; - } - else // token == endtoken + 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; + } + + // 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 + '\''); }