From 6b1631a8c5bab965678c423174fc4ee01162d45d Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 31 Oct 2006 20:16:47 +0000 Subject: [PATCH] Output a space if pendingSpace() is true and it is actually needed * src/mathed/MathStream.C (isAlpha): new, test whether a lyx::char_type is an ascii letter. (operator<<): output a space if pendingSpace() is true and what follows begins with an ascii letter. Also update the number of lines written. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15645 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/MathStream.C | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/mathed/MathStream.C b/src/mathed/MathStream.C index a1bdc8efe9..e51819dc71 100644 --- a/src/mathed/MathStream.C +++ b/src/mathed/MathStream.C @@ -25,6 +25,12 @@ bool isAlpha(char c) return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'); } + +bool isAlpha(lyx::char_type c) +{ + return c < 0x80 && isAlpha(static_cast(c)); +} + } @@ -93,7 +99,19 @@ NormalStream & operator<<(NormalStream & ns, int i) WriteStream & operator<<(WriteStream & ws, docstring const & s) { + if (ws.pendingSpace() && s.length() > 0) { + if (isAlpha(s[0])) + ws.os() << ' '; + ws.pendingSpace(false); + } ws.os() << s; + int lf = 0; + docstring::const_iterator dit = s.begin(); + docstring::const_iterator end = s.end(); + for (; dit != end; ++dit) + if ((*dit) == '\n') + ++lf; + ws.addlines(lf); return ws; } -- 2.39.2