2015-04-27 11:09 GMT+02:00 Jürgen Spitzmüller:

> 2015-04-27 9:56 GMT+02:00 Jürgen Spitzmüller:
>
>> 2015-04-26 21:40 GMT+02:00 Jean-Marc Lasgouttes:
>>
>>> I think it should treat tab like space. It is probably not that hard to
>>> look up all the uses of eatLine in the code. The only place I would be
>>> scared about is the parsing on .lyx files
>>>
>>
>> So should eatLine itself care about the \t -> blank conversion, or should
>> we do it at the places where eatLine is used (which are only a few)?
>>
>
> I inspected the (actually not so few) uses now, and I think that getString
> and getDocString is the place where tabs should be replaced by blanks.
> Doing it in eatLine breaks parsing of LANGUAGES.
>
> See attached patch. Opinions?
>

Further testing revealed that this is a change that needs careful testing.
I have learned that readParToken also uses getDocString() in order to read
normal paragraph lines, and thus obviously must not be trimmed.

The attached patch solves this particular issue.

Jürgen
diff --git a/src/Lexer.cpp b/src/Lexer.cpp
index c4b738f..84fac5a 100644
--- a/src/Lexer.cpp
+++ b/src/Lexer.cpp
@@ -700,18 +700,18 @@ string const Lexer::getString() const
        lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
 
        if (lastReadOk_)
-       return pimpl_->getString();
+               return ltrim(pimpl_->getString(), "\t ");
 
        return string();
 }
 
 
-docstring const Lexer::getDocString() const
+docstring const Lexer::getDocString(bool trim) const
 {
        lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
 
        if (lastReadOk_)
-               return pimpl_->getDocString();
+               return trim ? ltrim(pimpl_->getDocString(), "\t ") : 
pimpl_->getDocString();
 
        return docstring();
 }
diff --git a/src/Lexer.h b/src/Lexer.h
index dc56a4a..c6309a9 100644
--- a/src/Lexer.h
+++ b/src/Lexer.h
@@ -139,7 +139,7 @@ public:
        ///
        std::string const getString() const;
        ///
-       docstring const getDocString() const;
+       docstring const getDocString(bool trim = true) const;
        /** Get a long string, ended by the tag `endtag'.
            This string can span several lines. The first line
            serves as a template for how many spaces the lines
diff --git a/src/Text.cpp b/src/Text.cpp
index 1eecee1..020f121 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -365,7 +365,7 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
        BufferParams const & bp = buf->params();
 
        if (token[0] != '\\') {
-               docstring dstr = lex.getDocString();
+               docstring dstr = lex.getDocString(false);
                par.appendString(dstr, font, change);
 
        } else if (token == "\\begin_layout") {
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index 02fc86e..5326247 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -981,7 +981,6 @@ bool TextClass::readCiteEngine(Lexer & lexrc)
                lexrc.eatLine();
                def = lexrc.getString();
                def = subst(def, " ", "");
-               def = subst(def, "\t", "");
                if (compare_ascii_no_case(def, "end") == 0) {
                        getout = true;
                        continue;

Reply via email to