Kaydet (Commit) fff70bf9 authored tarafından Tomofumi Yagi's avatar Tomofumi Yagi Kaydeden (comit) Kohei Yoshida

fdo#68790: fix build error on Win when system locale=="Japanese(Japan)"

This patch modifies transex3.
Modified transex3 outputs a file with BOM(if MergeMode is true).
*.[hs]rc files with BOM avoid this problem.
This problem is that MSVC interprets UTF-8 source code without BOM as
 local codepage when system locale is "Japanese(Japan)".

Change-Id: I3e12499a91a954236f48e6d7e360d26c93d19ed6
Reviewed-on: https://gerrit.libreoffice.org/5851Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
Reviewed-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
üst 60486dda
......@@ -28,12 +28,14 @@ struct HandledArgs
OString m_sMergeSrc;
OString m_sLanguage;
bool m_bMergeMode;
bool m_bUTF8BOM;
HandledArgs()
: m_sInputFile( OString() )
, m_sOutputFile( OString() )
, m_sMergeSrc( OString() )
, m_sLanguage( OString() )
, m_bMergeMode( false )
, m_bUTF8BOM( false )
{}
};
......
......@@ -226,9 +226,11 @@ private:
void CutComment( OString &rText );
void WriteUTF8ByteOrderMarkToOutput() { *aOutput.mSimple << '\xEF' << '\xBB' << '\xBF'; }
public:
Export( const OString &rOutput );
Export(const OString &rMergeSource, const OString &rOutput, const OString &rLanguage);
Export(const OString &rMergeSource, const OString &rOutput, const OString &rLanguage, bool bUTF8BOM);
~Export();
void Init();
......
......@@ -43,6 +43,10 @@ bool handleArguments(
{
nState = STATE_LANGUAGES;
}
else if ( OString( argv[ i ] ).toAsciiUpperCase() == "-B" )
{
o_aHandledArgs.m_bUTF8BOM = true;
}
else
{
switch ( nState )
......@@ -90,12 +94,13 @@ void writeUsage(const OString& rName, const OString& rFileType)
{
std::cout
<< " Syntax: " << rName.getStr()
<< " -i FileIn -o FileOut [-m DataBase] [-l Lang]\n"
<< " -i FileIn -o FileOut [-m DataBase] [-l Lang] [-b]\n"
<< " FileIn: Source files (" << rFileType.getStr() << ")\n"
<< " FileOut: Destination file (*.*)\n"
<< " DataBase: Mergedata (*.po)\n"
<< " Lang: Restrict the handled language; one element of\n"
<< " (de, en-US, ...) or all\n";
<< " (de, en-US, ...) or all\n"
<< " -b: Add UTF-8 Byte Order Mark to FileOut(use with -m option)\n";
}
void writePoEntry(
......
......@@ -69,8 +69,8 @@ FILE * init(int argc, char ** argv) {
}
if (aArgs.m_bMergeMode) {
global::exporter.reset(
new Export(aArgs.m_sMergeSrc, aArgs.m_sOutputFile, aArgs.m_sLanguage));
global::exporter.reset(new Export(aArgs.m_sMergeSrc, aArgs.m_sOutputFile,
aArgs.m_sLanguage, aArgs.m_bUTF8BOM));
} else {
global::exporter.reset(new Export(aArgs.m_sOutputFile));
}
......@@ -198,7 +198,7 @@ Export::Export(const OString &rOutput)
Export::Export(
const OString &rMergeSource, const OString &rOutput,
const OString &rLanguage )
const OString &rLanguage, bool bUTF8BOM)
:
bDefine( sal_False ),
bNextMustBeDefineEOL( sal_False ),
......@@ -218,6 +218,8 @@ Export::Export(
{
aOutput.mSimple = new std::ofstream();
aOutput.mSimple->open(rOutput.getStr(), std::ios_base::out | std::ios_base::trunc);
if ( bUTF8BOM ) WriteUTF8ByteOrderMarkToOutput();
}
void Export::Init()
......
......@@ -50,7 +50,8 @@ $(call gb_Helper_abbreviate_dirs,\
-i $(3) \
-o $(1) \
-m $${MERGEINPUT} \
-l all) && \
-l all \
$(if $(filter MSC,$(COM)),$(if $(strip $(gb_WITH_LANG)),-b))) && \
rm -rf $${MERGEINPUT}
endef
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment