[Libreoffice-commits] .: 3 commits - build/win32 configure.ac src/lib
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Jan 23 01:42:35 PST 2013
build/win32/libcdr.vcproj | 4 ++--
build/win32/libcdr.vcxproj | 4 ++--
configure.ac | 27 ++++++++++++++++++---------
src/lib/CDRDocument.cpp | 2 +-
src/lib/libcdr_utils.cpp | 33 ++++++++++++++++++---------------
5 files changed, 41 insertions(+), 29 deletions(-)
New commits:
commit 2b7062a1a9405a652a36acb72befa0d9d6d06595
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Wed Jan 23 10:42:10 2013 +0100
Make ICU dependency optional (opt-out)
diff --git a/build/win32/libcdr.vcproj b/build/win32/libcdr.vcproj
index 7cf7334..8ee406e 100755
--- a/build/win32/libcdr.vcproj
+++ b/build/win32/libcdr.vcproj
@@ -42,7 +42,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(LIBWPD_INCLUDE_DIR),$(LIBWPG_INCLUDE_DIR),$(LCMS2_INCLUDE_DIR),$(ZLIB_INCLUDE_DIR),$(ICU_INCLUDE_DIR)"
- PreprocessorDefinitions="_DEBUG;DEBUG;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS"
+ PreprocessorDefinitions="_DEBUG;DEBUG;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS;ENABLE_LANGUAGE_GUESSING"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
TreatWChar_tAsBuiltInType="false"
@@ -117,7 +117,7 @@
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="$(LIBWPD_INCLUDE_DIR),$(LIBWPG_INCLUDE_DIR),$(LCMS2_INCLUDE_DIR),$(ZLIB_INCLUDE_DIR),$(ICU_INCLUDE_DIR)"
- PreprocessorDefinitions="NDEBUG;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS"
+ PreprocessorDefinitions="NDEBUG;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS;ENABLE_LANGUAGE_GUESSING"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
diff --git a/build/win32/libcdr.vcxproj b/build/win32/libcdr.vcxproj
index 355ec43..46be0de 100755
--- a/build/win32/libcdr.vcxproj
+++ b/build/win32/libcdr.vcxproj
@@ -44,7 +44,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(LIBWPD_INCLUDE_DIR);$(LIBWPG_INCLUDE_DIR);$(LCMS2_INCLUDE_DIR);$(ZLIB_INCLUDE_DIR);$(ICU_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_DEBUG;DEBUG;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_DEBUG;DEBUG;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS;ENABLE_LANGUAGE_GUESSING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
@@ -75,7 +75,7 @@
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>$(LIBWPD_INCLUDE_DIR);$(LIBWPG_INCLUDE_DIR);$(LCMS2_INCLUDE_DIR);$(ZLIB_INCLUDE_DIR);$(ICU_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>NDEBUG;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>NDEBUG;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS;ENABLE_LANGUAGE_GUESSING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
diff --git a/configure.ac b/configure.ac
index f5ec74f..8807a1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,18 +62,27 @@ PKG_CHECK_MODULES([ZLIB],[zlib],[],[
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(ZLIB_LIBS)
+AC_ARG_ENABLE([language-guessing],
+ [AS_HELP_STRING([--disable-language-guessing], [Disable language guessing using ICU])],
+ [enable_language_guessing="$enableval"],
+ [enable_language_guessing=yes]
+)
+
# ========
# Find icu
# ========
-AC_PATH_PROG([ICU_CONFIG],[icu-config])
-AC_MSG_CHECKING([ICU installation])
-if ${ICU_CONFIG} --cflags >/dev/null 2>&1; then
- ICU_CFLAGS=`${ICU_CONFIG} --cppflags-searchpath`
- ICU_LIBS=`${ICU_CONFIG} --ldflags`
- AC_MSG_RESULT([found])
-else
- AC_MSG_ERROR([libicu config program icu-config not found])
-fi
+AS_IF([test x$enable_language_guessing = xyes], [
+ AC_PATH_PROG([ICU_CONFIG],[icu-config])
+ AC_MSG_CHECKING([ICU installation])
+ if ${ICU_CONFIG} --cflags >/dev/null 2>&1; then
+ ICU_CFLAGS=`${ICU_CONFIG} --cppflags-searchpath`
+ ICU_LIBS=`${ICU_CONFIG} --ldflags`
+ AC_MSG_RESULT([found])
+ AC_DEFINE([ENABLE_LANGUAGE_GUESSING], [1], [Enable language guessing using ICU])
+ else
+ AC_MSG_ERROR([libicu config program icu-config not found])
+ fi],
+)
AC_SUBST(ICU_CFLAGS)
AC_SUBST(ICU_LIBS)
diff --git a/src/lib/libcdr_utils.cpp b/src/lib/libcdr_utils.cpp
index 48cf6c5..76b7116 100644
--- a/src/lib/libcdr_utils.cpp
+++ b/src/lib/libcdr_utils.cpp
@@ -28,16 +28,20 @@
*/
#include <string.h>
-#include <unicode/ucsdet.h>
+
#include "libcdr_utils.h"
+#ifdef ENABLE_LANGUAGE_GUESSING
+#include <unicode/ucsdet.h>
+#endif
+
#define CDR_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
#define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000)
namespace
{
-
+#ifdef ENABLE_LANGUAGE_GUESSING
static unsigned short getEncodingFromICUName(const char *name)
{
// ANSI
@@ -113,6 +117,7 @@ static unsigned short getEncoding(const unsigned char *buffer, unsigned bufferLe
return 0;
}
}
+#endif
static void _appendUCS4(WPXString &text, unsigned ucs4Character)
{
@@ -529,8 +534,10 @@ void libcdr::appendCharacters(WPXString &text, std::vector<unsigned char> charac
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF
};
+#ifdef ENABLE_LANGUAGE_GUESSING
if (!charset && characters.size())
charset = getEncoding(&characters[0], characters.size());
+#endif
for (std::vector<unsigned char>::const_iterator iter = characters.begin();
iter != characters.end(); ++iter)
commit e7489f20cf800a61820fad3c94c370c2c35ea73c
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Wed Jan 23 10:40:41 2013 +0100
Avoid null pointer crashes inside ICU
diff --git a/src/lib/libcdr_utils.cpp b/src/lib/libcdr_utils.cpp
index 28162e3..48cf6c5 100644
--- a/src/lib/libcdr_utils.cpp
+++ b/src/lib/libcdr_utils.cpp
@@ -81,35 +81,31 @@ static unsigned short getEncodingFromICUName(const char *name)
return 0;
}
-
static unsigned short getEncoding(const unsigned char *buffer, unsigned bufferLength)
{
+ if (!buffer || !bufferLength)
+ return 0;
UErrorCode status = U_ZERO_ERROR;
UCharsetDetector *csd = 0;
const UCharsetMatch *csm = 0;
try
{
csd = ucsdet_open(&status);
- if (U_FAILURE(status))
- throw libcdr::EncodingException();
+ if (U_FAILURE(status) || !csd)
+ return 0;
+ ucsdet_enableInputFilter(csd, TRUE);
ucsdet_setText(csd, (const char *)buffer, bufferLength, &status);
if (U_FAILURE(status))
throw libcdr::EncodingException();
- ucsdet_enableInputFilter(csd, TRUE);
csm = ucsdet_detect(csd, &status);
- if (U_FAILURE(status))
+ if (U_FAILURE(status) || !csm)
throw libcdr::EncodingException();
const char *name = ucsdet_getName(csm, &status);
- if (U_FAILURE(status))
+ if (U_FAILURE(status) || !name)
throw libcdr::EncodingException();
- if (name)
- {
- unsigned short encoding = getEncodingFromICUName(name);
- ucsdet_close(csd);
- return encoding;
- }
+ unsigned short encoding = getEncodingFromICUName(name);
ucsdet_close(csd);
- return 0;
+ return encoding;
}
catch (const libcdr::EncodingException &)
{
commit d2489548a97c3d1b200cf51fa26d20966076b47c
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Wed Jan 23 10:38:11 2013 +0100
astyle
diff --git a/src/lib/CDRDocument.cpp b/src/lib/CDRDocument.cpp
index 2633954..a1ae8d2 100644
--- a/src/lib/CDRDocument.cpp
+++ b/src/lib/CDRDocument.cpp
@@ -134,7 +134,7 @@ bool libcdr::CDRDocument::parse(::WPXInputStream *input, libwpg::WPGPaintInterfa
{
version = getCDRVersion(input);
}
- catch (libcdr::EndOfStreamException const&)
+ catch (libcdr::EndOfStreamException const &)
{
// This can only happen if isSupported() has not been called before
return false;
More information about the Libreoffice-commits
mailing list