Kaydet (Commit) 7429ab2e authored tarafından Zolnai Tamás's avatar Zolnai Tamás

Use icu regex in l10ntools instead of i18nregexp

Change-Id: I9062aafa2fefa26b7b1edf0440f4675b2f469e5d
üst c82935d5
...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,cfgex,\ ...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,cfgex,\
$(eval $(call gb_Executable_use_libraries,cfgex,\ $(eval $(call gb_Executable_use_libraries,cfgex,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_use_unpacked,cfgex,boost)) $(eval $(call gb_Executable_use_unpacked,cfgex,boost))
...@@ -50,4 +49,9 @@ $(eval $(call gb_Executable_add_exception_objects,cfgex,\ ...@@ -50,4 +49,9 @@ $(eval $(call gb_Executable_add_exception_objects,cfgex,\
l10ntools/source/cfgmerge \ l10ntools/source/cfgmerge \
)) ))
$(eval $(call gb_Executable_use_externals,cfgex,\
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab: # vim:set shiftwidth=4 softtabstop=4 expandtab:
...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,helpex,\ ...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,helpex,\
$(eval $(call gb_Executable_use_libraries,helpex,\ $(eval $(call gb_Executable_use_libraries,helpex,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_use_external,helpex,expat_utf8)) $(eval $(call gb_Executable_use_external,helpex,expat_utf8))
...@@ -51,6 +50,8 @@ $(eval $(call gb_Executable_add_exception_objects,helpex,\ ...@@ -51,6 +50,8 @@ $(eval $(call gb_Executable_add_exception_objects,helpex,\
$(eval $(call gb_Executable_use_externals,helpex,\ $(eval $(call gb_Executable_use_externals,helpex,\
libxml2 \ libxml2 \
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
)) ))
# vim:set shiftwidth=4 softtabstop=4 expandtab: # vim:set shiftwidth=4 softtabstop=4 expandtab:
...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,localize,\ ...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,localize,\
$(eval $(call gb_Executable_use_libraries,localize,\ $(eval $(call gb_Executable_use_libraries,localize,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_use_static_libraries,localize,\ $(eval $(call gb_Executable_use_static_libraries,localize,\
...@@ -44,4 +43,9 @@ $(eval $(call gb_Executable_add_exception_objects,localize,\ ...@@ -44,4 +43,9 @@ $(eval $(call gb_Executable_add_exception_objects,localize,\
l10ntools/source/localize \ l10ntools/source/localize \
)) ))
$(eval $(call gb_Executable_use_externals,localize,\
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab: # vim:set shiftwidth=4 softtabstop=4 expandtab:
...@@ -17,7 +17,6 @@ $(eval $(call gb_Executable_set_include,propex,\ ...@@ -17,7 +17,6 @@ $(eval $(call gb_Executable_set_include,propex,\
$(eval $(call gb_Executable_use_libraries,propex,\ $(eval $(call gb_Executable_use_libraries,propex,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_use_static_libraries,propex,\ $(eval $(call gb_Executable_use_static_libraries,propex,\
...@@ -29,4 +28,9 @@ $(eval $(call gb_Executable_add_exception_objects,propex,\ ...@@ -29,4 +28,9 @@ $(eval $(call gb_Executable_add_exception_objects,propex,\
l10ntools/source/propex \ l10ntools/source/propex \
)) ))
$(eval $(call gb_Executable_use_externals,propex,\
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -18,7 +18,6 @@ $(eval $(call gb_Executable_set_include,renewpo,\ ...@@ -18,7 +18,6 @@ $(eval $(call gb_Executable_set_include,renewpo,\
$(eval $(call gb_Executable_use_libraries,renewpo,\ $(eval $(call gb_Executable_use_libraries,renewpo,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_use_static_libraries,renewpo,\ $(eval $(call gb_Executable_use_static_libraries,renewpo,\
...@@ -29,4 +28,9 @@ $(eval $(call gb_Executable_add_exception_objects,renewpo,\ ...@@ -29,4 +28,9 @@ $(eval $(call gb_Executable_add_exception_objects,renewpo,\
l10ntools/source/renewpo \ l10ntools/source/renewpo \
)) ))
$(eval $(call gb_Executable_use_externals,renewpo,\
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,transex3,\ ...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,transex3,\
$(eval $(call gb_Executable_use_libraries,transex3,\ $(eval $(call gb_Executable_use_libraries,transex3,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_add_scanners,transex3,\ $(eval $(call gb_Executable_add_scanners,transex3,\
...@@ -50,4 +49,9 @@ $(eval $(call gb_Executable_add_exception_objects,transex3,\ ...@@ -50,4 +49,9 @@ $(eval $(call gb_Executable_add_exception_objects,transex3,\
l10ntools/source/export \ l10ntools/source/export \
)) ))
$(eval $(call gb_Executable_use_externals,transex3,\
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab: # vim:set shiftwidth=4 softtabstop=4 expandtab:
...@@ -17,7 +17,6 @@ $(eval $(call gb_Executable_set_include,treex,\ ...@@ -17,7 +17,6 @@ $(eval $(call gb_Executable_set_include,treex,\
$(eval $(call gb_Executable_use_libraries,treex,\ $(eval $(call gb_Executable_use_libraries,treex,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_use_static_libraries,treex,\ $(eval $(call gb_Executable_use_static_libraries,treex,\
...@@ -31,6 +30,8 @@ $(eval $(call gb_Executable_add_exception_objects,treex,\ ...@@ -31,6 +30,8 @@ $(eval $(call gb_Executable_add_exception_objects,treex,\
$(eval $(call gb_Executable_use_externals,treex,\ $(eval $(call gb_Executable_use_externals,treex,\
libxml2 \ libxml2 \
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
)) ))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -16,7 +16,6 @@ $(eval $(call gb_Executable_set_include,uiex,\ ...@@ -16,7 +16,6 @@ $(eval $(call gb_Executable_set_include,uiex,\
$(eval $(call gb_Executable_use_libraries,uiex,\ $(eval $(call gb_Executable_use_libraries,uiex,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_use_unpacked,uiex,boost)) $(eval $(call gb_Executable_use_unpacked,uiex,boost))
...@@ -33,6 +32,8 @@ $(eval $(call gb_Executable_use_externals,uiex,\ ...@@ -33,6 +32,8 @@ $(eval $(call gb_Executable_use_externals,uiex,\
libexslt \ libexslt \
libxml2 \ libxml2 \
libxslt \ libxslt \
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
)) ))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,ulfex,\ ...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,ulfex,\
$(eval $(call gb_Executable_use_libraries,ulfex,\ $(eval $(call gb_Executable_use_libraries,ulfex,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_use_unpacked,ulfex,boost)) $(eval $(call gb_Executable_use_unpacked,ulfex,boost))
...@@ -47,4 +46,9 @@ $(eval $(call gb_Executable_add_exception_objects,ulfex,\ ...@@ -47,4 +46,9 @@ $(eval $(call gb_Executable_add_exception_objects,ulfex,\
l10ntools/source/lngex \ l10ntools/source/lngex \
)) ))
$(eval $(call gb_Executable_use_externals,ulfex,\
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab: # vim:set shiftwidth=4 softtabstop=4 expandtab:
...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,xrmex,\ ...@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,xrmex,\
$(eval $(call gb_Executable_use_libraries,xrmex,\ $(eval $(call gb_Executable_use_libraries,xrmex,\
sal \ sal \
i18nregexp \
)) ))
$(eval $(call gb_Executable_use_unpacked,xrmex,boost)) $(eval $(call gb_Executable_use_unpacked,xrmex,boost))
...@@ -52,6 +51,8 @@ $(eval $(call gb_Executable_add_exception_objects,xrmex,\ ...@@ -52,6 +51,8 @@ $(eval $(call gb_Executable_add_exception_objects,xrmex,\
$(eval $(call gb_Executable_use_externals,xrmex,\ $(eval $(call gb_Executable_use_externals,xrmex,\
libxml2 \ libxml2 \
icuuc \
$(if $(filter MSC,$(COM)),icuin,icui18n) \
)) ))
# vim:set shiftwidth=4 softtabstop=4 expandtab: # vim:set shiftwidth=4 softtabstop=4 expandtab:
tr l10ntools : EXPAT:expat LIBXSLT:libxslt sal regexp NULL tr l10ntools : EXPAT:expat LIBXSLT:libxslt ICU:icu sal NULL
tr l10ntools usr1 - all tr_mkout NULL tr l10ntools usr1 - all tr_mkout NULL
tr l10ntools\prj nmake - all tr_prj NULL tr l10ntools\prj nmake - all tr_prj NULL
...@@ -7,10 +7,6 @@ ...@@ -7,10 +7,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#include <com/sun/star/util/SearchOptions.hpp>
#include <com/sun/star/util/SearchFlags.hpp>
#include <com/sun/star/i18n/XExtendedTransliteration.hpp>
#include <regexp/reclass.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <cstring> #include <cstring>
...@@ -21,12 +17,15 @@ ...@@ -21,12 +17,15 @@
#include <string> #include <string>
#include <boost/crc.hpp> #include <boost/crc.hpp>
#include <unicode/regex.h>
#include "po.hxx" #include "po.hxx"
#define POESCAPED OString("\\n\\t\\r\\\\\\\"") #define POESCAPED OString("\\n\\t\\r\\\\\\\"")
#define POUNESCAPED OString("\n\t\r\\\"") #define POUNESCAPED OString("\n\t\r\\\"")
using namespace U_ICU_NAMESPACE;
//Class GenPoEntry //Class GenPoEntry
class GenPoEntry class GenPoEntry
...@@ -317,61 +316,37 @@ namespace ...@@ -317,61 +316,37 @@ namespace
return lcl_UnEscapeText(rText,"\\n\\t\\r","\n\t\r"); return lcl_UnEscapeText(rText,"\\n\\t\\r","\n\t\r");
} }
//Miminize the length of the regular expression result
static void lcl_Minimize(
const OUString& rText, Regexpr& io_rRegExp, re_registers& io_rRegs )
{
re_registers aPrevRegs;
const sal_Int32 nStart = io_rRegs.start[0];
do
{
const OUString sTemp = rText.copy(0,io_rRegs.end[0]-1);
memcpy(
static_cast<void*>(&aPrevRegs),
static_cast<void*>(&io_rRegs),
sizeof(re_registers));
memset(static_cast<void*>(&io_rRegs), 0, sizeof(re_registers));
io_rRegExp.set_line(sTemp.getStr(),sTemp.getLength());
io_rRegExp.re_search(&io_rRegs,nStart);
} while(io_rRegs.num_of_match);
memcpy(static_cast<void*>(&io_rRegs),static_cast<void*>(&aPrevRegs),
sizeof(re_registers));
io_rRegExp.set_line(rText.getStr(),rText.getLength());
}
//Find all special tag in a string using a regular expression //Find all special tag in a string using a regular expression
static void lcl_FindAllTag( static void lcl_FindAllTag(
const OString& rText,std::vector<OString>& o_vFoundTags ) const OString& rText,std::vector<OString>& o_vFoundTags )
{ {
::com::sun::star::util::SearchOptions aOptions;
aOptions.algorithmType = UErrorCode nIcuErr = U_ZERO_ERROR;
::com::sun::star::util::SearchAlgorithms_REGEXP; sal_uInt32 nSearchFlags = UREGEX_DOTALL | UREGEX_CASE_INSENSITIVE;
aOptions.searchFlag = OUString sLocaleText( OStringToOUString(rText,RTL_TEXTENCODING_UTF8) );
::com::sun::star::util::SearchFlags::NORM_WORD_ONLY; OUString sPattern( "<[/]??[a-z_-]+?(?:| +[a-z]+?=\".*?\") *[/]??>" );
aOptions.searchString = "<[/]?[a-z_\\-]+(| +[a-z]+=\".*\") *[/]?>"; UnicodeString sSearchPat(
::com::sun::star::uno::Reference< reinterpret_cast<const UChar*>(
::com::sun::star::i18n::XExtendedTransliteration > xTrans; sPattern.getStr()), sPattern.getLength() );
UnicodeString sSource(
Regexpr aRegExp(aOptions,xTrans); reinterpret_cast<const UChar*>(
const OUString sTemp(OStringToOUString(rText,RTL_TEXTENCODING_UTF8)); sLocaleText.getStr()), sLocaleText.getLength() );
aRegExp.set_line(sTemp.getStr(),sTemp.getLength());
RegexMatcher aRegexMatcher( sSearchPat, nSearchFlags, nIcuErr );
re_registers aRegs; aRegexMatcher.reset( sSource );
memset(static_cast<void*>(&aRegs), 0, sizeof(re_registers)); int64_t nStartPos = 0;
sal_Int32 nStart = 0; while( aRegexMatcher.find(nStartPos, nIcuErr) &&
o_vFoundTags.resize(0); nIcuErr == U_ZERO_ERROR )
aRegExp.re_search(&aRegs,nStart);
while(aRegs.num_of_match)
{ {
lcl_Minimize(sTemp,aRegExp,aRegs); UnicodeString sMatch =
aRegexMatcher.group(nIcuErr);
o_vFoundTags.push_back( o_vFoundTags.push_back(
OUStringToOString( OUStringToOString(
sTemp.copy(aRegs.start[0],aRegs.end[0]-aRegs.start[0]), OUString(
reinterpret_cast<const sal_Unicode*>(
sMatch.getBuffer()),sMatch.length()),
RTL_TEXTENCODING_UTF8)); RTL_TEXTENCODING_UTF8));
nStart = aRegs.end[0]; nStartPos = aRegexMatcher.start(nIcuErr)+1;
memset(static_cast<void*>(&aRegs), 0, sizeof(re_registers));
aRegExp.re_search(&aRegs,nStart);
} }
} }
......
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