Fix bug #253 (Incorrect protection of closing quotation marks)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39420 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2011-08-05 11:23:00 +00:00
parent a255f19ca7
commit 2de1163efc
3 changed files with 23 additions and 4 deletions

View File

@ -287,8 +287,11 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
}
// Always guard against unfortunate ligatures (!` ?`)
if (prefixIs(qstr, "`"))
qstr.insert(0, "{}");
if (prefixIs(qstr, "`")) {
char_type const lastchar = os.lastChar();
if (lastchar == '!' || lastchar == '?')
qstr.insert(0, "{}");
}
os << from_ascii(qstr);
}

View File

@ -411,6 +411,7 @@ void otexstream::put(char_type const & c)
protectspace_ = false;
}
os_.put(c);
lastchar_ = c;
if (c == '\n') {
texrow_.newline();
canbreakline_ = false;
@ -427,6 +428,7 @@ otexstream & operator<<(otexstream & ots, BreakLine)
{
if (ots.canBreakLine()) {
ots.os().put('\n');
ots.lastChar('\n');
ots.canBreakLine(false);
ots.texrow().newline();
}
@ -439,6 +441,7 @@ otexstream & operator<<(otexstream & ots, SafeBreakLine)
{
if (ots.canBreakLine()) {
ots.os() << "%\n";
ots.lastChar('\n');
ots.canBreakLine(false);
ots.texrow().newline();
}
@ -450,8 +453,10 @@ otexstream & operator<<(otexstream & ots, SafeBreakLine)
otexstream & operator<<(otexstream & ots, odocstream_manip pf)
{
ots.os() << pf;
if (pf == static_cast<odocstream_manip>(endl))
if (pf == static_cast<odocstream_manip>(endl)) {
ots.lastChar('\n');
ots.texrow().newline();
}
return ots;
}
@ -470,6 +475,7 @@ otexstream & operator<<(otexstream & ots, docstring const & s)
ots.protectSpace(false);
}
ots.os() << s;
ots.lastChar(s[len - 1]);
ots.texrow().newlines(count(s.begin(), s.end(), '\n'));
ots.canBreakLine(s[len - 1] != '\n');
return ots;
@ -490,6 +496,7 @@ otexstream & operator<<(otexstream & ots, char const * s)
ots.protectSpace(false);
}
ots.os() << s;
ots.lastChar(s[len - 1]);
ots.texrow().newlines(count(s, s + len, '\n'));
ots.canBreakLine(s[len - 1] != '\n');
return ots;
@ -504,6 +511,7 @@ otexstream & operator<<(otexstream & ots, char c)
ots.protectSpace(false);
}
ots.os() << c;
ots.lastChar(c);
if (c == '\n')
ots.texrow().newline();
ots.canBreakLine(c != '\n');
@ -515,6 +523,7 @@ template <typename Type>
otexstream & operator<<(otexstream & ots, Type value)
{
ots.os() << value;
ots.lastChar(0);
ots.canBreakLine(true);
ots.protectSpace(false);
return ots;

View File

@ -93,6 +93,7 @@ typedef odocstream & (*odocstream_manip)(odocstream &);
they were iomanip's to ensure that the next output will start at the
beginning of a line. Using "breakln", a '\n' char will be output if needed,
while using "safebreakln", "%\n" will be output if needed.
The class also records the last output character.
*/
class otexstream {
@ -100,7 +101,7 @@ public:
///
otexstream(odocstream & os, TexRow & texrow)
: os_(os), texrow_(texrow),
canbreakline_(false), protectspace_(false) {}
canbreakline_(false), protectspace_(false), lastchar_(0) {}
///
odocstream & os() { return os_; }
///
@ -115,6 +116,10 @@ public:
void protectSpace(bool protectspace) { protectspace_ = protectspace; }
///
bool protectSpace() const { return protectspace_; }
///
void lastChar(char_type const & c) { lastchar_ = c; }
///
char_type lastChar() const { return lastchar_; }
private:
///
odocstream & os_;
@ -124,6 +129,8 @@ private:
bool canbreakline_;
///
bool protectspace_;
///
char_type lastchar_;
};
/// Helper structs for breaking a line