mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Cleanup in order to better understand bug 3043 and 3561.
* switchEncoding(): simplify return logic (transform 'and -> do' to 'or ->return') git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18224 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
93bca90c8e
commit
b5ff27fdd1
@ -603,25 +603,34 @@ int switchEncoding(odocstream & os, BufferParams const & bparams,
|
||||
bool moving_arg, Encoding const & oldEnc,
|
||||
Encoding const & newEnc)
|
||||
{
|
||||
if ((bparams.inputenc != "auto" || moving_arg)
|
||||
&& bparams.inputenc != "default")
|
||||
return 0;
|
||||
|
||||
// Do nothing if the encoding is unchanged.
|
||||
if (oldEnc.name() == newEnc.name())
|
||||
return 0;
|
||||
|
||||
// FIXME We ignore encoding switches from/to encodings that do
|
||||
// neither support the inputenc package nor the CJK package here.
|
||||
// This does of course only work in special cases (e.g. switch from
|
||||
// tis620-0 to latin1, but the text in latin1 contains ASCII only,
|
||||
// but it is the best we can do
|
||||
if (((bparams.inputenc == "auto" && !moving_arg) ||
|
||||
bparams.inputenc == "default") &&
|
||||
oldEnc.name() != newEnc.name() &&
|
||||
oldEnc.package() != Encoding::none &&
|
||||
newEnc.package() != Encoding::none) {
|
||||
if (oldEnc.package() == Encoding::none
|
||||
|| newEnc.package() == Encoding::none)
|
||||
return 0;
|
||||
|
||||
LYXERR(Debug::LATEX) << "Changing LaTeX encoding from "
|
||||
<< oldEnc.name() << " to "
|
||||
<< newEnc.name() << endl;
|
||||
os << setEncoding(newEnc.iconvName());
|
||||
if (bparams.inputenc != "default") {
|
||||
if (bparams.inputenc == "default")
|
||||
return 0;
|
||||
|
||||
docstring const inputenc(from_ascii(newEnc.latexName()));
|
||||
switch (newEnc.package()) {
|
||||
case Encoding::none:
|
||||
break;
|
||||
return 0;
|
||||
case Encoding::inputenc: {
|
||||
int count = inputenc.length();
|
||||
if (oldEnc.package() == Encoding::CJK) {
|
||||
@ -641,8 +650,7 @@ int switchEncoding(odocstream & os, BufferParams const & bparams,
|
||||
return count + 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Dead code to avoid a warning:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user