From 625bc9086ef51eaa7f3d12473a46833234e0424b Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Mon, 4 May 2009 05:45:27 +0000 Subject: [PATCH] ICU-4790 Spoof detection build failures with UCONFIG_NO_REGULAR_EXPRESSIONS X-SVN-Rev: 25981 --- icu4c/source/i18n/uspoof_build.cpp | 9 +++++---- icu4c/source/i18n/uspoof_buildconf.cpp | 6 ++++-- icu4c/source/i18n/uspoof_buildconf.h | 5 ++++- icu4c/source/i18n/uspoof_buildwsconf.cpp | 7 ++++--- icu4c/source/i18n/uspoof_buildwsconf.h | 5 +++++ icu4c/source/test/cintltst/calltest.c | 2 ++ icu4c/source/test/cintltst/spooftest.c | 2 ++ icu4c/source/test/intltest/itmajor.cpp | 3 ++- icu4c/source/test/intltest/itspoof.cpp | 4 ++-- icu4c/source/test/intltest/itspoof.h | 3 ++- icu4c/source/tools/gencfu/gencfu.cpp | 13 +++++++------ 11 files changed, 39 insertions(+), 20 deletions(-) diff --git a/icu4c/source/i18n/uspoof_build.cpp b/icu4c/source/i18n/uspoof_build.cpp index 0fd65a10d0..0da4af8ed7 100644 --- a/icu4c/source/i18n/uspoof_build.cpp +++ b/icu4c/source/i18n/uspoof_build.cpp @@ -37,13 +37,9 @@ #include "uspoof_buildconf.h" #include "uspoof_buildwsconf.h" - -#include // DEBUG - U_NAMESPACE_USE - // The main data building function U_CAPI USpoofChecker * U_EXPORT2 @@ -54,6 +50,10 @@ uspoof_openFromSource(const char *confusables, int32_t confusablesLen, if (U_FAILURE(*status)) { return NULL; } +#if UCONFIG_NO_REGULAR_EXPRESSIONS + *status = U_UNSUPPORTED_ERROR; + return NULL; +#else if (errorType!=NULL) { *errorType = 0; } @@ -77,5 +77,6 @@ uspoof_openFromSource(const char *confusables, int32_t confusablesLen, This = NULL; } return (USpoofChecker *)This; +#endif // UCONFIG_NO_REGULAR_EXPRESSIONS } diff --git a/icu4c/source/i18n/uspoof_buildconf.cpp b/icu4c/source/i18n/uspoof_buildconf.cpp index 3299c28c00..57cc7b3478 100644 --- a/icu4c/source/i18n/uspoof_buildconf.cpp +++ b/icu4c/source/i18n/uspoof_buildconf.cpp @@ -18,6 +18,7 @@ #include "unicode/utypes.h" #include "unicode/uspoof.h" +#if !UCONFIG_NO_REGULAR_EXPRESSIONS #include "unicode/unorm.h" #include "unicode/uregex.h" #include "unicode/ustring.h" @@ -29,8 +30,6 @@ #include "uarrsort.h" #include "uspoof_buildconf.h" -#include "stdio.h" // DEBUG. Remove. - U_NAMESPACE_USE @@ -591,3 +590,6 @@ UnicodeString ConfusabledataBuilder::getMapping(int32_t index) { } return UnicodeString(); } + +#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS + diff --git a/icu4c/source/i18n/uspoof_buildconf.h b/icu4c/source/i18n/uspoof_buildconf.h index 0d094e4546..12b10141d1 100644 --- a/icu4c/source/i18n/uspoof_buildconf.h +++ b/icu4c/source/i18n/uspoof_buildconf.h @@ -19,6 +19,8 @@ #ifndef __USPOOF_BUILDCONF_H__ #define __USPOOF_BUILDCONF_H__ +#if !UCONFIG_NO_REGULAR_EXPRESSIONS + #include "uspoof_impl.h" // SPUString @@ -120,4 +122,5 @@ class ConfusabledataBuilder : public UMemory { int32_t confusablesLen, int32_t *errorType, UParseError *pe, UErrorCode &status); }; -#endif +#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS +#endif // __USPOOF_BUILDCONF_H__ diff --git a/icu4c/source/i18n/uspoof_buildwsconf.cpp b/icu4c/source/i18n/uspoof_buildwsconf.cpp index a71e856f3d..fb9d817288 100644 --- a/icu4c/source/i18n/uspoof_buildwsconf.cpp +++ b/icu4c/source/i18n/uspoof_buildwsconf.cpp @@ -20,6 +20,9 @@ #include "unicode/utypes.h" #include "unicode/uspoof.h" + +#if !UCONFIG_NO_REGULAR_EXPRESSIONS + #include "unicode/unorm.h" #include "unicode/uregex.h" #include "unicode/ustring.h" @@ -30,8 +33,6 @@ #include "uassert.h" #include "uspoof_buildwsconf.h" - -//#include // TODO: debug. remove. U_NAMESPACE_USE @@ -427,5 +428,5 @@ BuilderScriptSet::~BuilderScriptSet() { } } - +#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS diff --git a/icu4c/source/i18n/uspoof_buildwsconf.h b/icu4c/source/i18n/uspoof_buildwsconf.h index f542d5c9a2..76940b543d 100644 --- a/icu4c/source/i18n/uspoof_buildwsconf.h +++ b/icu4c/source/i18n/uspoof_buildwsconf.h @@ -20,6 +20,10 @@ #ifndef __USPOOF_BUILDWSCONF_H__ #define __USPOOF_BUILDWSCONF_H__ +#include "unicode/utypes.h" + +#if !UCONFIG_NO_REGULAR_EXPRESSIONS + #include "uspoof_impl.h" #include "utrie2.h" @@ -53,4 +57,5 @@ void buildWSConfusableData(SpoofImpl *spImpl, const char * confusablesWS, int32_t confusablesWSLen, UParseError *pe, UErrorCode &status); +#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS #endif diff --git a/icu4c/source/test/cintltst/calltest.c b/icu4c/source/test/cintltst/calltest.c index 1f5b76b22b..5068f6e9bf 100644 --- a/icu4c/source/test/cintltst/calltest.c +++ b/icu4c/source/test/cintltst/calltest.c @@ -76,7 +76,9 @@ void addAllTests(TestNode** root) #if !UCONFIG_NO_TRANSLITERATION addUTransTest(root); #endif +#if !UCONFIG_NO_REGULAR_EXPRESSIONS addUSpoofTest(root); +#endif } diff --git a/icu4c/source/test/cintltst/spooftest.c b/icu4c/source/test/cintltst/spooftest.c index fbbe7a5ba1..ac759280cf 100644 --- a/icu4c/source/test/cintltst/spooftest.c +++ b/icu4c/source/test/cintltst/spooftest.c @@ -18,6 +18,7 @@ **/ #include "unicode/utypes.h" +#if !UCONFIG_NO_REGULAR_EXPRESSIONS #include #include @@ -518,3 +519,4 @@ static void TestUSpoofCAPI(void) { TEST_TEARDOWN; } +#endif /* UCONFIG_NO_REGULAR_EXPRESSIONS */ diff --git a/icu4c/source/test/intltest/itmajor.cpp b/icu4c/source/test/intltest/itmajor.cpp index 14189ec543..1d8fe4f0b7 100644 --- a/icu4c/source/test/intltest/itmajor.cpp +++ b/icu4c/source/test/intltest/itmajor.cpp @@ -181,12 +181,13 @@ void MajorTestLevel::runIndexedTest( int32_t index, UBool exec, const char* &nam break; case 14: name = "spoof"; +#if !UCONFIG_NO_REGULAR_EXPRESSIONS if (exec) { logln("TestSuite SpoofDetection---"); logln(); IntlTestSpoof test; callTest(test, par); } - +#endif break; default: name = ""; break; diff --git a/icu4c/source/test/intltest/itspoof.cpp b/icu4c/source/test/intltest/itspoof.cpp index 5e0a16b302..79c834853a 100644 --- a/icu4c/source/test/intltest/itspoof.cpp +++ b/icu4c/source/test/intltest/itspoof.cpp @@ -10,7 +10,7 @@ #include "unicode/utypes.h" -#if !UCONFIG_NO_SPOOF_DETECT +#if !UCONFIG_NO_REGULAR_EXPRESSIONS #include "itspoof.h" #include "unicode/uspoof.h" @@ -245,5 +245,5 @@ void IntlTestSpoof::testInvisible() { TEST_ASSERT_EQ(7, position); TEST_TEARDOWN; } +#endif // UCONFIG_NO_REGULAR_EXPRESSIONS -#endif /* #if !UCONFIG_NO_SPOOF_DETECT*/ diff --git a/icu4c/source/test/intltest/itspoof.h b/icu4c/source/test/intltest/itspoof.h index 8b662c7e57..2327c50ef8 100644 --- a/icu4c/source/test/intltest/itspoof.h +++ b/icu4c/source/test/intltest/itspoof.h @@ -13,6 +13,7 @@ #define INTLTESTSPOOF_H #include "unicode/utypes.h" +#if !UCONFIG_NO_REGULAR_EXPRESSIONS #include "unicode/uspoof.h" #include "intltest.h" @@ -36,5 +37,5 @@ public: const char *input, const char *expected, int32_t lineNum); }; +#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS #endif - diff --git a/icu4c/source/tools/gencfu/gencfu.cpp b/icu4c/source/tools/gencfu/gencfu.cpp index a12134fe69..ed3b30cd65 100644 --- a/icu4c/source/tools/gencfu/gencfu.cpp +++ b/icu4c/source/tools/gencfu/gencfu.cpp @@ -74,7 +74,7 @@ void usageAndDie(int retCode) { } -#if UCONFIG_NO_BREAK_ITERATION +#if UCONFIG_NO_REGULAR_EXPRESSIONS /* dummy UDataInfo cf. udata.h */ static UDataInfo dummyDataInfo = { @@ -181,14 +181,16 @@ int main(int argc, char **argv) { copyright = U_COPYRIGHT_STRING; } -#if UCONFIG_NO_SPOOF_DETECTION - // TOOD: implement UCONFIG_NO_SPOOF_DETECTION in uconfig.h, or decide we don't want it and take this out. +#if UCONFIG_NO_REGULAR_EXPRESSIONS + // spoof detection data file parsing is dependent on regular expressions. + // TODO: have the tool return an error status. Requires fixing the ICU data build + // so that it doesn't abort entirely on that error. UNewDataMemory *pData; char msg[1024]; /* write message with just the name */ - sprintf(msg, "gencfu writes dummy %s because of UCONFIG_NO_SPOOF_DETECTION, see uconfig.h", outFileName); + sprintf(msg, "gencfu writes dummy %s because of UCONFIG_NO_REGULAR_EXPRESSIONS, see uconfig.h", outFileName); fprintf(stderr, "%s\n", msg); /* write the dummy data file */ @@ -289,8 +291,7 @@ int main(int argc, char **argv) { u_cleanup(); printf("gencfu: tool completed successfully.\n"); return 0; - -#endif /* #if !UCONFIG_NO_BREAK_ITERATION */ +#endif // UCONFIG_NO_REGULAR_EXPRESSIONS }