diff --git a/src/mathed/math_mathmlstream.C b/src/mathed/math_mathmlstream.C index 5a1f6017d8..a1f73f0e3f 100644 --- a/src/mathed/math_mathmlstream.C +++ b/src/mathed/math_mathmlstream.C @@ -3,6 +3,7 @@ #include "math_mathmlstream.h" #include "math_inset.h" #include "math_extern.h" +#include "debug.h" #include "support/lyxalgo.h" #include "support/LOstream.h" @@ -23,12 +24,27 @@ WriteStream::WriteStream(ostream & os) {} +WriteStream::~WriteStream() +{ + if (pendingspace_) + os_ << ' '; +} + + void WriteStream::addlines(unsigned int n) { line_ += n; } +void WriteStream::pendingSpace(bool how) +{ + if (how) + os_ << ' '; + pendingspace_ = how; +} + + WriteStream & operator<<(WriteStream & ws, MathAtom const & at) { at->write(ws); @@ -45,6 +61,11 @@ WriteStream & operator<<(WriteStream & ws, MathArray const & ar) WriteStream & operator<<(WriteStream & ws, char const * s) { + if (ws.pendingSpace()) { + lyxerr << "writing a space in a string\n"; + ws.os() << ' '; + ws.pendingSpace(false); + } ws.os() << s; ws.addlines(int(lyx::count(s, s + strlen(s), '\n'))); return ws; @@ -54,8 +75,12 @@ WriteStream & operator<<(WriteStream & ws, char const * s) WriteStream & operator<<(WriteStream & ws, char c) { if (ws.pendingSpace()) { - if (isalpha(c)) - ws.os() << ' '; + //if (isalpha(c)) + // ws.os() << ' '; + if (!isalpha(c)) { + lyxerr << "I'd like to suppress writing a space\n"; + } + ws.os() << ' '; ws.pendingSpace(false); } ws.os() << c; diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h index 9f1ac9fed2..ebd7c65242 100644 --- a/src/mathed/math_mathmlstream.h +++ b/src/mathed/math_mathmlstream.h @@ -25,6 +25,8 @@ public: /// explicit WriteStream(std::ostream & os_); /// + ~WriteStream(); + /// int line() const { return line_; } /// bool fragile() const { return fragile_; } @@ -37,7 +39,7 @@ public: /// void addlines(unsigned int); /// writes space if next thing is isalpha() - void pendingSpace(bool how) { pendingspace_ = how; } + void pendingSpace(bool how); /// writes space if next thing is isalpha() bool pendingSpace() const { return pendingspace_; } private: