commit 7144f8dad84b5b321f7c87143efec9eb2b6195dc
Author: Enrico Forestieri <[email protected]>
Date: Thu May 14 01:02:37 2015 +0200
Update tex2lyx and tests after 306b136c
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 35bb506..0ae9a27 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -1046,7 +1046,7 @@ void Preamble::handle_if(Parser & p, bool in_lyx_preamble)
}
-bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
+bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const &
outfiledir)
{
// set the quote language
// LyX only knows the following quotes languages:
@@ -1088,11 +1088,13 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
// output the LyX file settings
// Important: Keep the version formatting in sync with LyX and
// lyx2lyx (bug 7951)
+ string const origin = roundtripMode() ? "roundtrip" : outfiledir;
os << "#LyX file created by tex2lyx " << lyx_version_major << '.'
<< lyx_version_minor << '\n'
<< "\\lyxformat " << LYX_FORMAT << '\n'
<< "\\begin_document\n"
<< "\\begin_header\n"
+ << "\\origin " << origin << "\n"
<< "\\textclass " << h_textclass << "\n";
string const raw = subdoc ? empty_string() : h_preamble.str();
if (!raw.empty()) {
diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h
index ffc9bda..71367b1 100644
--- a/src/tex2lyx/Preamble.h
+++ b/src/tex2lyx/Preamble.h
@@ -93,7 +93,8 @@ public:
void parse(Parser & p, std::string const & forceclass,
TeX2LyXDocClass & tc);
/// Writes the LyX file header from internal data
- bool writeLyXHeader(std::ostream & os, bool subdoc);
+ bool writeLyXHeader(std::ostream & os, bool subdoc,
+ std::string const & outfiledir);
/// known polyglossia language names (including variants)
static const char * const polyglossia_languages[];
diff --git a/src/tex2lyx/test/CJK.lyx.lyx b/src/tex2lyx/test/CJK.lyx.lyx
index 6b5186c..3eeccc5 100644
--- a/src/tex2lyx/test/CJK.lyx.lyx
+++ b/src/tex2lyx/test/CJK.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\begin_preamble
\usepackage{babel}
diff --git a/src/tex2lyx/test/CJKutf8.lyx.lyx b/src/tex2lyx/test/CJKutf8.lyx.lyx
index e398d23..0baa3b8 100644
--- a/src/tex2lyx/test/CJKutf8.lyx.lyx
+++ b/src/tex2lyx/test/CJKutf8.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\begin_preamble
\usepackage{babel}
diff --git a/src/tex2lyx/test/DummyDocument.lyx.lyx
b/src/tex2lyx/test/DummyDocument.lyx.lyx
index eb38e22..91f33fa 100644
--- a/src/tex2lyx/test/DummyDocument.lyx.lyx
+++ b/src/tex2lyx/test/DummyDocument.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\use_default_options false
\maintain_unincluded_children false
diff --git a/src/tex2lyx/test/Dummy~Document.lyx.lyx
b/src/tex2lyx/test/Dummy~Document.lyx.lyx
index b4c7ef1..0bd5c29 100644
--- a/src/tex2lyx/test/Dummy~Document.lyx.lyx
+++ b/src/tex2lyx/test/Dummy~Document.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\use_default_options false
\maintain_unincluded_children false
diff --git a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
index 99cc9eb..0e177ac 100644
--- a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
+++ b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\begin_preamble
diff --git a/src/tex2lyx/test/algo2e.lyx.lyx b/src/tex2lyx/test/algo2e.lyx.lyx
index add9e0e..9d317ff 100644
--- a/src/tex2lyx/test/algo2e.lyx.lyx
+++ b/src/tex2lyx/test/algo2e.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\begin_preamble
diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
index 199483d..4518d8a 100644
--- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
+++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\begin_preamble
diff --git a/src/tex2lyx/test/test-insets.lyx.lyx
b/src/tex2lyx/test/test-insets.lyx.lyx
index 2a7ccee..1395837 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\begin_preamble
diff --git a/src/tex2lyx/test/test-memoir.lyx.lyx
b/src/tex2lyx/test/test-memoir.lyx.lyx
index 34c1983..ee8c8d8 100644
--- a/src/tex2lyx/test/test-memoir.lyx.lyx
+++ b/src/tex2lyx/test/test-memoir.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass memoir
\begin_preamble
diff --git a/src/tex2lyx/test/test-modules.lyx.lyx
b/src/tex2lyx/test/test-modules.lyx.lyx
index ce2de10..b1e2247 100644
--- a/src/tex2lyx/test/test-modules.lyx.lyx
+++ b/src/tex2lyx/test/test-modules.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass amsart
\begin_preamble
\usepackage{babel}
diff --git a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
index deb69c4..55b1266 100644
--- a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
+++ b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass book
\begin_preamble
\usepackage{babel}
diff --git a/src/tex2lyx/test/test-scr.lyx.lyx
b/src/tex2lyx/test/test-scr.lyx.lyx
index 95723c9..323dbed 100644
--- a/src/tex2lyx/test/test-scr.lyx.lyx
+++ b/src/tex2lyx/test/test-scr.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass scrbook
\begin_preamble
\usepackage{babel}
diff --git a/src/tex2lyx/test/test-structure.lyx.lyx
b/src/tex2lyx/test/test-structure.lyx.lyx
index bfcf8ac..3c25024 100644
--- a/src/tex2lyx/test/test-structure.lyx.lyx
+++ b/src/tex2lyx/test/test-structure.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\begin_preamble
%% Special footnote code from the package 'stblftnt.sty'
diff --git a/src/tex2lyx/test/test.lyx.lyx b/src/tex2lyx/test/test.lyx.lyx
index a8b8240..0cc0fb6 100644
--- a/src/tex2lyx/test/test.lyx.lyx
+++ b/src/tex2lyx/test/test.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\begin_preamble
% This is a test document for tex2lyx
diff --git a/src/tex2lyx/test/verbatim.lyx.lyx
b/src/tex2lyx/test/verbatim.lyx.lyx
index 3e7c6e5..52f71ae 100644
--- a/src/tex2lyx/test/verbatim.lyx.lyx
+++ b/src/tex2lyx/test/verbatim.lyx.lyx
@@ -1,7 +1,8 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 489
+\lyxformat 490
\begin_document
\begin_header
+\origin roundtrip
\textclass article
\use_default_options false
\maintain_unincluded_children false
diff --git a/src/tex2lyx/tex2lyx.cpp b/src/tex2lyx/tex2lyx.cpp
index 57790ab..5001ad0 100644
--- a/src/tex2lyx/tex2lyx.cpp
+++ b/src/tex2lyx/tex2lyx.cpp
@@ -839,7 +839,8 @@ namespace {
* You must ensure that \p parentFilePathTeX is properly set before calling
* this function!
*/
-bool tex2lyx(idocstream & is, ostream & os, string encoding)
+bool tex2lyx(idocstream & is, ostream & os, string encoding,
+ string const & outfiledir)
{
// Set a sensible default encoding.
// This is used until an encoding command is found.
@@ -905,7 +906,7 @@ bool tex2lyx(idocstream & is, ostream & os, string encoding)
for (; it != end; ++it)
preamble.addModule(*it);
}
- if (!preamble.writeLyXHeader(os, !active_environments.empty())) {
+ if (!preamble.writeLyXHeader(os, !active_environments.empty(),
outfiledir)) {
cerr << "Could not write LyX file header." << endl;
return false;
}
@@ -924,7 +925,8 @@ bool tex2lyx(idocstream & is, ostream & os, string encoding)
/// convert TeX from \p infilename to LyX and write it to \p os
-bool tex2lyx(FileName const & infilename, ostream & os, string const &
encoding)
+bool tex2lyx(FileName const & infilename, ostream & os, string const &
encoding,
+ string const & outfiledir)
{
ifdocstream is;
// forbid buffering on this stream
@@ -937,7 +939,7 @@ bool tex2lyx(FileName const & infilename, ostream & os,
string const & encoding)
}
string const oldParentFilePath = parentFilePathTeX;
parentFilePathTeX = onlyPath(infilename.absFileName());
- bool retval = tex2lyx(is, os, encoding);
+ bool retval = tex2lyx(is, os, encoding, outfiledir);
parentFilePathTeX = oldParentFilePath;
return retval;
}
@@ -970,7 +972,8 @@ bool tex2lyx(string const & infilename, FileName const &
outfilename,
cerr << "Input file: " << infilename << "\n";
cerr << "Output file: " << outfilename << "\n";
#endif
- return tex2lyx(FileName(infilename), os, encoding);
+ return tex2lyx(FileName(infilename), os, encoding,
+ outfilename.onlyPath().absFileName() + '/');
}
@@ -1122,7 +1125,7 @@ int TeX2LyXApp::run()
if (outfilename == "-") {
// assume same directory as input file
masterFilePathLyX = masterFilePathTeX;
- if (tex2lyx(FileName(infilename), cout, default_encoding))
+ if (tex2lyx(FileName(infilename), cout, default_encoding,
masterFilePathLyX))
return EXIT_SUCCESS;
} else {
masterFilePathLyX = onlyPath(outfilename);