Georg Baum wrote:
Dov Feldstern wrote:
Index: lyx-devel/src/output_latex.cpp
===================================================================
--- lyx-devel.orig/src/output_latex.cpp 2007-06-29
16:02:45.000000000 +0300
+++ lyx-devel/src/output_latex.cpp 2007-07-01 20:52:31.000000000 >
@@ -315,7 +319,7 @@
pit->getFontSettings(bparams,
i).language()->encoding();
if (encoding->package() == Encoding::inputenc &&
switchEncoding(os, bparams, false,
- *(runparams.encoding),
*encoding) > 0) {
+ *(runparams.encoding),
*encoding).first) {
runparams.encoding = encoding;
os << '\n';
texrow.newline();
@@ -598,17 +602,17 @@
}
This is wrong. The old condition is correct for
os << '\n';
texrow.newline();
, and the new one is correct for
runparams.encoding = encoding;
.
Right, thanks. So here's the question: Do we assume that the count can
only be greater than 0 if there was an encoding switch, or is even that
assuming too much? Should the code read:
if (... && enc_switch.first) {
runparams.encoding = encoding;
if (enc_switch.second > 0) {
newline stuff...
}
}
or
if (... && enc_switch.first)
runparams.encoding = encoding;
if (... && enc_switch.second > 0) {
newline stuff...
}
? Also, is the first part of the condition (encoding->package() ==
Encoding::inputenc) necessary/correct for the encoding switch? (I see
that it is necessary for the newline stuff, because we're only
outputting in that case)
@@ -617,19 +621,20 @@
// but it is the best we can do
if (oldEnc.package() == Encoding::none
|| newEnc.package() == Encoding::none)
- return 0;
+ return make_pair(false, 0);
LYXERR(Debug::LATEX) << "Changing LaTeX encoding from "
<< oldEnc.name() << " to "
<< newEnc.name() << endl;
os << setEncoding(newEnc.iconvName());
if (bparams.inputenc == "default")
- return 0;
+ return make_pair(true, 0);
docstring const inputenc(from_ascii(newEnc.latexName()));
switch (newEnc.package()) {
case Encoding::none:
- return 0;
+ // shouldn't ever reach here, see above
+ return make_pair(false, 0);
make_pair(true, 0) is slightly better (because the encoding has been changed
already).
OK.
// Dead code to avoid a warning:
- return 0;
+ return make_pair(false, 0);
Ditto.
OK.
Index: lyx-devel/src/output_latex.h
===================================================================
--- lyx-devel.orig/src/output_latex.h 2007-07-01 20:28:13.000000000
+0300
+++ lyx-devel/src/output_latex.h 2007-07-01 20:30:52.000000000
+0300
@@ -17,6 +17,8 @@
namespace lyx {
+using std::pair;
'using' is forbiden in header files.
Is any kind of include necessary for using pair, or do I just use it,
and the using in the .cpp file is enough?
I did not test anything, but the rest looks good.
Georg