[Libreoffice-commits] .: Branch 'feature/killsdf' - l10ntools/Executable_cfgex.mk l10ntools/Executable_helpex.mk l10ntools/Executable_localize.mk l10ntools/Executable_propex.mk l10ntools/Executable_renewpo.mk l10ntools/Executable_transex3.mk l10ntools/Executable_treex.mk l10ntools/Executable_uiex.mk l10ntools/Executable_ulfex.mk l10ntools/Executable_xrmex.mk l10ntools/prj l10ntools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Nov 19 09:40:21 PST 2012


 l10ntools/Executable_cfgex.mk    |    6 ++-
 l10ntools/Executable_helpex.mk   |    3 +
 l10ntools/Executable_localize.mk |    6 ++-
 l10ntools/Executable_propex.mk   |    6 ++-
 l10ntools/Executable_renewpo.mk  |    6 ++-
 l10ntools/Executable_transex3.mk |    6 ++-
 l10ntools/Executable_treex.mk    |    3 +
 l10ntools/Executable_uiex.mk     |    3 +
 l10ntools/Executable_ulfex.mk    |    6 ++-
 l10ntools/Executable_xrmex.mk    |    3 +
 l10ntools/prj/build.lst          |    2 -
 l10ntools/source/po.cxx          |   77 +++++++++++++--------------------------
 12 files changed, 65 insertions(+), 62 deletions(-)

New commits:
commit 7429ab2e2caa49466a455ad3e2e04057524225d0
Author: Zolnai Tamás <zolnaitamas2000g at gmail.com>
Date:   Mon Nov 19 18:19:52 2012 +0100

    Use icu regex in l10ntools instead of i18nregexp
    
    Change-Id: I9062aafa2fefa26b7b1edf0440f4675b2f469e5d

diff --git a/l10ntools/Executable_cfgex.mk b/l10ntools/Executable_cfgex.mk
index 7804470..60b3166 100644
--- a/l10ntools/Executable_cfgex.mk
+++ b/l10ntools/Executable_cfgex.mk
@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,cfgex,\
 
 $(eval $(call gb_Executable_use_libraries,cfgex,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_use_unpacked,cfgex,boost))
@@ -50,4 +49,9 @@ $(eval $(call gb_Executable_add_exception_objects,cfgex,\
     l10ntools/source/cfgmerge \
 ))
 
+$(eval $(call gb_Executable_use_externals,cfgex,\
+    icuuc \
+    $(if $(filter MSC,$(COM)),icuin,icui18n) \
+))
+
 # vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/l10ntools/Executable_helpex.mk b/l10ntools/Executable_helpex.mk
index b7e6310..cd2469d 100644
--- a/l10ntools/Executable_helpex.mk
+++ b/l10ntools/Executable_helpex.mk
@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,helpex,\
 
 $(eval $(call gb_Executable_use_libraries,helpex,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_use_external,helpex,expat_utf8))
@@ -51,6 +50,8 @@ $(eval $(call gb_Executable_add_exception_objects,helpex,\
 
 $(eval $(call gb_Executable_use_externals,helpex,\
     libxml2 \
+    icuuc \
+    $(if $(filter MSC,$(COM)),icuin,icui18n) \
 ))
 
 # vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/l10ntools/Executable_localize.mk b/l10ntools/Executable_localize.mk
index e6e7f1f..a810b6c 100644
--- a/l10ntools/Executable_localize.mk
+++ b/l10ntools/Executable_localize.mk
@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,localize,\
 
 $(eval $(call gb_Executable_use_libraries,localize,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_use_static_libraries,localize,\
@@ -44,4 +43,9 @@ $(eval $(call gb_Executable_add_exception_objects,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:
diff --git a/l10ntools/Executable_propex.mk b/l10ntools/Executable_propex.mk
index d8dc16d..06080c6 100644
--- a/l10ntools/Executable_propex.mk
+++ b/l10ntools/Executable_propex.mk
@@ -17,7 +17,6 @@ $(eval $(call gb_Executable_set_include,propex,\
 
 $(eval $(call gb_Executable_use_libraries,propex,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_use_static_libraries,propex,\
@@ -29,4 +28,9 @@ $(eval $(call gb_Executable_add_exception_objects,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:
diff --git a/l10ntools/Executable_renewpo.mk b/l10ntools/Executable_renewpo.mk
index 5aa036a..db84a41 100644
--- a/l10ntools/Executable_renewpo.mk
+++ b/l10ntools/Executable_renewpo.mk
@@ -18,7 +18,6 @@ $(eval $(call gb_Executable_set_include,renewpo,\
 
 $(eval $(call gb_Executable_use_libraries,renewpo,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_use_static_libraries,renewpo,\
@@ -29,4 +28,9 @@ $(eval $(call gb_Executable_add_exception_objects,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:
diff --git a/l10ntools/Executable_transex3.mk b/l10ntools/Executable_transex3.mk
index 2d95906..d2b7952 100644
--- a/l10ntools/Executable_transex3.mk
+++ b/l10ntools/Executable_transex3.mk
@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,transex3,\
 
 $(eval $(call gb_Executable_use_libraries,transex3,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_add_scanners,transex3,\
@@ -50,4 +49,9 @@ $(eval $(call gb_Executable_add_exception_objects,transex3,\
     l10ntools/source/export \
 ))
 
+$(eval $(call gb_Executable_use_externals,transex3,\
+    icuuc \
+    $(if $(filter MSC,$(COM)),icuin,icui18n) \
+))
+
 # vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/l10ntools/Executable_treex.mk b/l10ntools/Executable_treex.mk
index 41af0a8..af77c71 100644
--- a/l10ntools/Executable_treex.mk
+++ b/l10ntools/Executable_treex.mk
@@ -17,7 +17,6 @@ $(eval $(call gb_Executable_set_include,treex,\
 
 $(eval $(call gb_Executable_use_libraries,treex,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_use_static_libraries,treex,\
@@ -31,6 +30,8 @@ $(eval $(call gb_Executable_add_exception_objects,treex,\
 
 $(eval $(call gb_Executable_use_externals,treex,\
     libxml2 \
+	icuuc \
+    $(if $(filter MSC,$(COM)),icuin,icui18n) \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/l10ntools/Executable_uiex.mk b/l10ntools/Executable_uiex.mk
index 520b010..de8d0c8 100644
--- a/l10ntools/Executable_uiex.mk
+++ b/l10ntools/Executable_uiex.mk
@@ -16,7 +16,6 @@ $(eval $(call gb_Executable_set_include,uiex,\
 
 $(eval $(call gb_Executable_use_libraries,uiex,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_use_unpacked,uiex,boost))
@@ -33,6 +32,8 @@ $(eval $(call gb_Executable_use_externals,uiex,\
     libexslt \
     libxml2 \
     libxslt \
+	icuuc \
+    $(if $(filter MSC,$(COM)),icuin,icui18n) \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/l10ntools/Executable_ulfex.mk b/l10ntools/Executable_ulfex.mk
index b975f5c..9a7040a 100644
--- a/l10ntools/Executable_ulfex.mk
+++ b/l10ntools/Executable_ulfex.mk
@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,ulfex,\
 
 $(eval $(call gb_Executable_use_libraries,ulfex,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_use_unpacked,ulfex,boost))
@@ -47,4 +46,9 @@ $(eval $(call gb_Executable_add_exception_objects,ulfex,\
     l10ntools/source/lngex \
 ))
 
+$(eval $(call gb_Executable_use_externals,ulfex,\
+    icuuc \
+    $(if $(filter MSC,$(COM)),icuin,icui18n) \
+))
+
 # vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/l10ntools/Executable_xrmex.mk b/l10ntools/Executable_xrmex.mk
index 73c56ab..ea0810f 100644
--- a/l10ntools/Executable_xrmex.mk
+++ b/l10ntools/Executable_xrmex.mk
@@ -33,7 +33,6 @@ $(eval $(call gb_Executable_set_include,xrmex,\
 
 $(eval $(call gb_Executable_use_libraries,xrmex,\
     sal \
-    i18nregexp \
 ))
 
 $(eval $(call gb_Executable_use_unpacked,xrmex,boost))
@@ -52,6 +51,8 @@ $(eval $(call gb_Executable_add_exception_objects,xrmex,\
 
 $(eval $(call gb_Executable_use_externals,xrmex,\
     libxml2 \
+    icuuc \
+    $(if $(filter MSC,$(COM)),icuin,icui18n) \
 ))
 
 # vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/l10ntools/prj/build.lst b/l10ntools/prj/build.lst
index 888b234..af0fdfe 100644
--- a/l10ntools/prj/build.lst
+++ b/l10ntools/prj/build.lst
@@ -1,3 +1,3 @@
-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\prj					nmake	-	all	tr_prj NULL
diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx
index 648634c..1be60ec 100644
--- a/l10ntools/source/po.cxx
+++ b/l10ntools/source/po.cxx
@@ -7,10 +7,6 @@
  * 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 <cstring>
@@ -21,12 +17,15 @@
 #include <string>
 
 #include <boost/crc.hpp>
+#include <unicode/regex.h>
 
 #include "po.hxx"
 
 #define POESCAPED OString("\\n\\t\\r\\\\\\\"")
 #define POUNESCAPED OString("\n\t\r\\\"")
 
+using namespace U_ICU_NAMESPACE;
+
 //Class GenPoEntry
 
 class GenPoEntry
@@ -317,61 +316,37 @@ namespace
             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
     static void lcl_FindAllTag(
         const OString& rText,std::vector<OString>& o_vFoundTags )
     {
-        ::com::sun::star::util::SearchOptions aOptions;
-        aOptions.algorithmType =
-            ::com::sun::star::util::SearchAlgorithms_REGEXP;
-        aOptions.searchFlag =
-            ::com::sun::star::util::SearchFlags::NORM_WORD_ONLY;
-        aOptions.searchString = "<[/]?[a-z_\\-]+(| +[a-z]+=\".*\") *[/]?>";
-        ::com::sun::star::uno::Reference<
-             ::com::sun::star::i18n::XExtendedTransliteration > xTrans;
-
-        Regexpr aRegExp(aOptions,xTrans);
-        const OUString sTemp(OStringToOUString(rText,RTL_TEXTENCODING_UTF8));
-        aRegExp.set_line(sTemp.getStr(),sTemp.getLength());
-
-        re_registers aRegs;
-        memset(static_cast<void*>(&aRegs), 0, sizeof(re_registers));
-        sal_Int32 nStart = 0;
-        o_vFoundTags.resize(0);
-        aRegExp.re_search(&aRegs,nStart);
-        while(aRegs.num_of_match)
+
+        UErrorCode nIcuErr = U_ZERO_ERROR;
+        sal_uInt32 nSearchFlags = UREGEX_DOTALL | UREGEX_CASE_INSENSITIVE;
+        OUString sLocaleText( OStringToOUString(rText,RTL_TEXTENCODING_UTF8) );
+        OUString sPattern( "<[/]??[a-z_-]+?(?:| +[a-z]+?=\".*?\") *[/]??>" );
+        UnicodeString sSearchPat(
+            reinterpret_cast<const UChar*>(
+                sPattern.getStr()), sPattern.getLength() );
+        UnicodeString sSource(
+            reinterpret_cast<const UChar*>(
+                sLocaleText.getStr()), sLocaleText.getLength() );
+
+        RegexMatcher aRegexMatcher( sSearchPat, nSearchFlags, nIcuErr );
+        aRegexMatcher.reset( sSource );
+        int64_t nStartPos = 0;
+        while( aRegexMatcher.find(nStartPos, nIcuErr) &&
+            nIcuErr == U_ZERO_ERROR )
         {
-            lcl_Minimize(sTemp,aRegExp,aRegs);
+            UnicodeString sMatch =
+                aRegexMatcher.group(nIcuErr);
             o_vFoundTags.push_back(
                 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));
-            nStart = aRegs.end[0];
-            memset(static_cast<void*>(&aRegs), 0, sizeof(re_registers));
-            aRegExp.re_search(&aRegs,nStart);
+            nStartPos = aRegexMatcher.start(nIcuErr)+1;
         }
     }
 


More information about the Libreoffice-commits mailing list