Fix regression introduced in commit 7cfac95

Commit 7cfac95 got rid of empty lines that were created by removing \usepackage
statements. However, it added an additional newline in case the \usepackage
was not at the end of the line. This is now fixed.
This commit is contained in:
Georg Baum 2012-10-05 22:16:46 +02:00
parent 63612ca99b
commit 28dc8a77ee
2 changed files with 20 additions and 12 deletions

View File

@ -552,7 +552,7 @@ void Parser::tokenize_one()
push_back(Token(s, catSpace));
break;
}
case catNewline: {
++lineno_;
docstring s(1, getNewline(is_, c));
@ -565,7 +565,7 @@ void Parser::tokenize_one()
push_back(Token(s, catNewline));
break;
}
case catComment: {
// We don't treat "%\n" combinations here specially because
// we want to preserve them in the preamble
@ -581,7 +581,7 @@ void Parser::tokenize_one()
push_back(Token(s, catComment));
break;
}
case catEscape: {
is_.get(c);
if (!is_) {
@ -599,12 +599,12 @@ void Parser::tokenize_one()
}
break;
}
case catIgnore: {
cerr << "ignoring a char: " << c << "\n";
break;
}
default:
push_back(Token(docstring(1, c), catcode(c)));
}

View File

@ -648,10 +648,8 @@ void Preamble::handle_package(Parser &p, string const & name,
}
// roman fonts
if (is_known(name, known_roman_fonts)) {
if (is_known(name, known_roman_fonts))
h_font_roman = name;
p.skip_spaces();
}
if (name == "fourier") {
h_font_roman = "utopia";
@ -816,10 +814,16 @@ void Preamble::handle_package(Parser &p, string const & name,
else if (is_known(name, known_lyx_packages) && options.empty()) {
if (name == "splitidx")
h_use_indices = "true";
if (!in_lyx_preamble)
if (!in_lyx_preamble) {
h_preamble << package_beg_sep << name
<< package_mid_sep << "\\usepackage{"
<< name << "}\n" << package_end_sep;
<< name << '}';
if (p.next_token().cat() == catNewline ||
(p.next_token().cat() == catSpace &&
p.next_next_token().cat() == catNewline))
h_preamble << '\n';
h_preamble << package_end_sep;
}
}
else if (name == "geometry")
@ -859,12 +863,16 @@ void Preamble::handle_package(Parser &p, string const & name,
else if (!in_lyx_preamble) {
if (options.empty())
h_preamble << "\\usepackage{" << name << "}\n";
h_preamble << "\\usepackage{" << name << '}';
else {
h_preamble << "\\usepackage[" << opts << "]{"
<< name << "}\n";
<< name << '}';
options.clear();
}
if (p.next_token().cat() == catNewline ||
(p.next_token().cat() == catSpace &&
p.next_next_token().cat() == catNewline))
h_preamble << '\n';
}
// We need to do something with the options...