The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 28dc8a77ee281f606de3bd7c56d467466ee28b64
Author: Georg Baum <[email protected]>
Date:   Fri Oct 5 22:16:46 2012 +0200

    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.

diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp
index 530e73a..01f14b8 100644
--- a/src/tex2lyx/Parser.cpp
+++ b/src/tex2lyx/Parser.cpp
@@ -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)));
        }
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index afa0997..6486307 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -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...

-----------------------------------------------------------------------

Summary of changes:
 src/tex2lyx/Parser.cpp   |   10 +++++-----
 src/tex2lyx/Preamble.cpp |   22 +++++++++++++++-------
 2 files changed, 20 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to