From d59b5c5e4c9abc0e007bc5409922f480125be6e3 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 11 Jun 2008 21:52:29 +0000 Subject: [PATCH] ICU-6344 uconfigtest / hdrtest fixes X-SVN-Rev: 24157 --- icu4c/source/common/unicode/uconfig.h | 15 ++++++++- icu4c/source/i18n/brktrans.cpp | 2 +- icu4c/source/i18n/brktrans.h | 2 +- icu4c/source/i18n/msgfmt_impl.h | 10 ++++++ icu4c/source/i18n/plurfmt.cpp | 4 +-- icu4c/source/i18n/translit.cpp | 16 +++++++--- icu4c/source/i18n/usearch.cpp | 2 ++ icu4c/source/test/hdrtst/Makefile.in | 44 ++++++++++++++++++++------ icu4c/source/test/intltest/loctest.cpp | 3 +- icu4c/source/test/intltest/ssearch.cpp | 6 ++++ icu4c/source/test/intltest/ssearch.h | 4 +++ 11 files changed, 88 insertions(+), 20 deletions(-) diff --git a/icu4c/source/common/unicode/uconfig.h b/icu4c/source/common/unicode/uconfig.h index 24cfe4518e7..8006ea2434c 100644 --- a/icu4c/source/common/unicode/uconfig.h +++ b/icu4c/source/common/unicode/uconfig.h @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2002-2007, International Business Machines +* Copyright (C) 2002-2008, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * file name: uconfig.h @@ -15,6 +15,7 @@ #ifndef __UCONFIG_H__ #define __UCONFIG_H__ + /*! * \file * \brief Switches for excluding parts of ICU library code modules. @@ -34,6 +35,18 @@ * @stable ICU 2.4 */ +/** + * \def UCONFIG_USE_LOCAL + * If this switch is defined, ICU will attempt to load a header file named "uconfig_local.h" + * prior to determining default settings for uconfig variables. + * + * @internal ICU 4.0 + * + */ +#if defined(UCONFIG_USE_LOCAL) +#include "uconfig_local.h" +#endif + /** * \def UCONFIG_ONLY_COLLATION * This switch turns off modules that are not needed for collation. diff --git a/icu4c/source/i18n/brktrans.cpp b/icu4c/source/i18n/brktrans.cpp index b5b62262b17..9459741b2d6 100644 --- a/icu4c/source/i18n/brktrans.cpp +++ b/icu4c/source/i18n/brktrans.cpp @@ -10,7 +10,7 @@ #include "unicode/utypes.h" -#if !UCONFIG_NO_TRANSLITERATION +#if !UCONFIG_NO_TRANSLITERATION && !UCONFIG_NO_BREAK_ITERATION #include "unicode/unifilt.h" #include "unicode/uchar.h" diff --git a/icu4c/source/i18n/brktrans.h b/icu4c/source/i18n/brktrans.h index b5db373ce06..355d63dadb3 100644 --- a/icu4c/source/i18n/brktrans.h +++ b/icu4c/source/i18n/brktrans.h @@ -12,7 +12,7 @@ #include "unicode/utypes.h" -#if !UCONFIG_NO_TRANSLITERATION +#if !UCONFIG_NO_TRANSLITERATION && !UCONFIG_NO_BREAK_ITERATION #include "unicode/translit.h" diff --git a/icu4c/source/i18n/msgfmt_impl.h b/icu4c/source/i18n/msgfmt_impl.h index f37765a2613..699dc37002c 100644 --- a/icu4c/source/i18n/msgfmt_impl.h +++ b/icu4c/source/i18n/msgfmt_impl.h @@ -12,6 +12,14 @@ #ifndef __MSGFMT_IMPL_H__ #define __MSGFMT_IMPL_H__ +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING + +#include "unicode/msgfmt.h" +#include "uvector.h" +#include "unicode/strenum.h" + U_NAMESPACE_BEGIN class FormatNameEnumeration : public StringEnumeration { @@ -31,3 +39,5 @@ private: U_NAMESPACE_END #endif + +#endif diff --git a/icu4c/source/i18n/plurfmt.cpp b/icu4c/source/i18n/plurfmt.cpp index ebf7854fe86..03da811e45b 100644 --- a/icu4c/source/i18n/plurfmt.cpp +++ b/icu4c/source/i18n/plurfmt.cpp @@ -18,10 +18,10 @@ #include "unicode/plurrule.h" #include "plurrule_impl.h" -U_NAMESPACE_BEGIN - #if !UCONFIG_NO_FORMATTING +U_NAMESPACE_BEGIN + U_CDECL_BEGIN static void U_CALLCONV deleteHashStrings(void *obj) { diff --git a/icu4c/source/i18n/translit.cpp b/icu4c/source/i18n/translit.cpp index f12a7387bc0..a39d6e91c55 100644 --- a/icu4c/source/i18n/translit.cpp +++ b/icu4c/source/i18n/translit.cpp @@ -1579,12 +1579,17 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) { TitlecaseTransliterator* tempTitlecaseTranslit = new TitlecaseTransliterator(); UnicodeNameTransliterator* tempUnicodeTranslit = new UnicodeNameTransliterator(); NameUnicodeTransliterator* tempNameUnicodeTranslit = new NameUnicodeTransliterator(); - BreakTransliterator* tempBreakTranslit = new BreakTransliterator(); - +#if !UCONFIG_NO_BREAK_ITERATION + // TODO: could or should these transliterators be referenced polymorphically once constructed? + BreakTransliterator* tempBreakTranslit = new BreakTransliterator(); +#endif // Check for null pointers if (tempNullTranslit == NULL || tempLowercaseTranslit == NULL || tempUppercaseTranslit == NULL || tempTitlecaseTranslit == NULL || tempUnicodeTranslit == NULL || - tempNameUnicodeTranslit == NULL || tempBreakTranslit == NULL) +#if !UCONFIG_NO_BREAK_ITERATION + tempBreakTranslit == NULL || +#endif + tempNameUnicodeTranslit == NULL ) { delete tempNullTranslit; delete tempLowercaseTranslit; @@ -1592,8 +1597,9 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) { delete tempTitlecaseTranslit; delete tempUnicodeTranslit; delete tempNameUnicodeTranslit; +#if !UCONFIG_NO_BREAK_ITERATION delete tempBreakTranslit; - +#endif // Since there was an error, remove registry delete registry; registry = NULL; @@ -1608,7 +1614,9 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) { registry->put(tempTitlecaseTranslit, TRUE, status); registry->put(tempUnicodeTranslit, TRUE, status); registry->put(tempNameUnicodeTranslit, TRUE, status); +#if !UCONFIG_NO_BREAK_ITERATION registry->put(tempBreakTranslit, FALSE, status); // FALSE means invisible. +#endif RemoveTransliterator::registerIDs(); // Must be within mutex EscapeTransliterator::registerIDs(); diff --git a/icu4c/source/i18n/usearch.cpp b/icu4c/source/i18n/usearch.cpp index f320f7c2ccf..b54780d00c4 100644 --- a/icu4c/source/i18n/usearch.cpp +++ b/icu4c/source/i18n/usearch.cpp @@ -2810,9 +2810,11 @@ U_CAPI void U_EXPORT2 usearch_close(UStringSearch *strsrch) ucol_close((UCollator *)strsrch->collator); } +#if !UCONFIG_NO_BREAK_ITERATION if (strsrch->search->internalBreakIter) { ubrk_close(strsrch->search->internalBreakIter); } +#endif uprv_free(strsrch->search); uprv_free(strsrch); diff --git a/icu4c/source/test/hdrtst/Makefile.in b/icu4c/source/test/hdrtst/Makefile.in index ff8d964b095..f1705c73636 100644 --- a/icu4c/source/test/hdrtst/Makefile.in +++ b/icu4c/source/test/hdrtst/Makefile.in @@ -1,5 +1,5 @@ ## -## Copyright (c) 1999-2006, International Business Machines Corporation and +## Copyright (c) 1999-2008, International Business Machines Corporation and ## others. All Rights Reserved. ## ## @@ -23,15 +23,33 @@ ## ## +## Source directory information +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ + +top_builddir = ../.. +subdir = test/hdrtst include $(shell icu-config --incfile) -srcdir=@srcdir@ DIRS=$(prefix)/include/unicode LDIRS=$(prefix)/include/layout +ECHO_T=@ECHO_T@ +ECHO_C=@ECHO_C@ +ECHO_N=@ECHO_N@ all: @echo Please read this Makefile for more information. @echo run \'$(MAKE) check\' to run the test + +E_NUM=8 +E_D="[1/$(E_NUM)] Deprecated: " +E_C="[2/$(E_NUM)] C : " +E_CXX="[3/$(E_NUM)] C++: " +E_CXX_L="[4/$(E_NUM)] C++ layout: " +E_DRF="[5/$(E_NUM)] Hide Draft: " +E_DEP="[6/$(E_NUM)] Hide Deprecated: " +E_INT="[7/$(E_NUM)] Hide Internal: " +E_OBS="[8/$(E_NUM)] Hide Obsolete: " check: dtest ctest cpptest lotest doclean drafttest deprtest internaltest obsoletetest @echo "All header tests have finished. If deprecation #errors appeared, " @@ -50,7 +68,7 @@ cpptest: @echo 'the number after the hyphen (-) refers to the exit code - should be zero!' @for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ incfile=`basename $$file .h` ; \ - echo -n "C++ unicode/$$incfile.h - " ; \ + echo $(ECHO_N) "$(E_CXX) unicode/$$incfile.h - $(ECHO_C)" ; \ echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \ echo 'void junk(){}' >> ht_$$incfile.cpp ; \ $(COMPILE.cc) -c $(cppflags) ht_$$incfile.cpp ; \ @@ -64,7 +82,7 @@ lotest: @echo 'the number after the hyphen (-) refers to the exit code - should be zero!' @for file in $(prefix)/include/layout/*.h; do \ incfile=`basename $$file .h` ; \ - echo -n "C++ layout/$$incfile.h - " ; \ + echo $(ECHO_N) "$(E_CXX_L) layout/$$incfile.h - $(ECHO_C)" ; \ echo '#include "'layout/$$incfile'.h"' > ht_$$incfile.cpp ; \ echo 'void junk(){}' >> ht_$$incfile.cpp ; \ $(COMPILE.cc) -c $(cppflags) -I$(prefix)/include/layout ht_$$incfile.cpp ; \ @@ -78,7 +96,7 @@ dtest: @for stub in `cat $(srcdir)/dfiles.txt | grep -v '^#'` ; do \ file=unicode/$$stub \ incfile=`basename $$file .h` ; \ - echo -n "C++ unicode/$$incfile.h - " ; \ + echo $(ECHO_N) "$(E_D) unicode/$$incfile.h - $(ECHO_C)" ; \ echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \ echo 'void junk(){}' >> ht_$$incfile.cpp ; \ echo > ht_dep.junk ; \ @@ -88,6 +106,7 @@ dtest: fgrep -q "$$incfile.h header is obsolete" ht_dep.junk || echo "** FAIL Header unicode/$$incfile.h is not obsoleted properly" ; \ rm -f unicode/$$stub ; \ done + @echo "$(E_D): Done. (It is possible there are no deprecated headers at the moment.)" # < ht_dep.junk && ; \ @@ -100,7 +119,7 @@ ctest: @echo 'the number after the hyphen (-) refers to the exit code - should be zero!' @for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/cxxfiles.txt | tee cfiles.txt`; do \ incfile=`basename $$file .h` ; \ - echo -n "C unicode/$$incfile.h - " ; \ + echo $(ECHO_N) "$(E_C) unicode/$$incfile.h - $(ECHO_C)" ; \ echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.c ; \ echo 'void junk(void);' >> ht_$$incfile.c ; \ echo 'void junk(){}' >> ht_$$incfile.c ; \ @@ -116,7 +135,7 @@ drafttest: @echo 'the number after the hyphen (-) refers to the exit code - should be zero!' @for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ incfile=`basename $$file .h` ; \ - echo -n " unicode/$$incfile.h - " ; \ + echo $(ECHO_N) "$(E_DRF) unicode/$$incfile.h - $(ECHO_C)" ; \ echo '#define U_HIDE_DRAFT_API' > hd_$$incfile.c; \ echo '#include "'unicode/$$incfile'.h"' >> ht_$$incfile.c ; \ echo 'void junk(void);' >> hd_$$incfile.c ; \ @@ -133,7 +152,7 @@ deprtest: @echo 'the number after the hyphen (-) refers to the exit code - should be zero!' @for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ incfile=`basename $$file .h` ; \ - echo -n " unicode/$$incfile.h - " ; \ + echo $(ECHO_N) "$(E_DEP) unicode/$$incfile.h - $(ECHO_C)" ; \ echo '#define U_HIDE_DEPRECATED_API' > hdp_$$incfile.c; \ echo '#include "'unicode/$$incfile'.h"' >> hdp_$$incfile.c ; \ echo 'void junk(void);' >> hdp_$$incfile.c ; \ @@ -150,7 +169,7 @@ internaltest: @echo 'the number after the hyphen (-) refers to the exit code - should be zero!' @for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ incfile=`basename $$file .h` ; \ - echo -n " unicode/$$incfile.h - " ; \ + echo $(ECHO_N) "$(E_INT) unicode/$$incfile.h - $(ECHO_C)" ; \ echo '#define U_HIDE_INTERNAL_API' > hin_$$incfile.c; \ echo '#include "'unicode/$$incfile'.h"' >> hin_$$incfile.c ; \ echo 'void junk(void);' >> hin_$$incfile.c ; \ @@ -167,7 +186,7 @@ obsoletetest: @echo 'the number after the hyphen (-) refers to the exit code - should be zero!' @for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ incfile=`basename $$file .h` ; \ - echo -n " unicode/$$incfile.h - " ; \ + echo $(ECHO_N) "$(E_OBS) unicode/$$incfile.h - $(ECHO_C)" ; \ echo '#define U_HIDE_OBSOLETE_API' > hob_$$incfile.c; \ echo '#include "'unicode/$$incfile'.h"' >> hob_$$incfile.c ; \ echo 'void junk(void);' >> hob_$$incfile.c ; \ @@ -183,6 +202,11 @@ clean: distclean: clean -@rm -f Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + .PHONY: doclean check all cpptest lotest dtest ctest clean distclean diff --git a/icu4c/source/test/intltest/loctest.cpp b/icu4c/source/test/intltest/loctest.cpp index 2313299ea5a..9dcc2674822 100644 --- a/icu4c/source/test/intltest/loctest.cpp +++ b/icu4c/source/test/intltest/loctest.cpp @@ -2140,6 +2140,7 @@ void LocaleTest::TestCanonicalization(void) void LocaleTest::TestCurrencyByDate(void) { +#if !UCONFIG_NO_FORMATTING UErrorCode status = U_ZERO_ERROR; UDate date = uprv_getUTCtime(); UChar TMP[4]; @@ -2452,5 +2453,5 @@ void LocaleTest::TestCurrencyByDate(void) errln("Fail: en_US_Q didn't fallback to en_US"); } status = U_ZERO_ERROR; // reset - +#endif } diff --git a/icu4c/source/test/intltest/ssearch.cpp b/icu4c/source/test/intltest/ssearch.cpp index 0812e54c66e..9e8a1fc72d9 100644 --- a/icu4c/source/test/intltest/ssearch.cpp +++ b/icu4c/source/test/intltest/ssearch.cpp @@ -7,6 +7,9 @@ #include "unicode/utypes.h" + +#if !UCONFIG_NO_COLLATION + #include "unicode/unistr.h" #include "unicode/putil.h" #include "unicode/usearch.h" @@ -1482,6 +1485,7 @@ static int32_t getIntParam(UnicodeString name, UnicodeString ¶ms, int32_t d } #endif +#if !UCONFIG_NO_COLLATION int32_t SSearchTest::monkeyTestCase(UCollator *coll, const UnicodeString &testCase, const UnicodeString &pattern, const UnicodeString &altPattern, const char *name, const char *strength, uint32_t seed) { @@ -1543,6 +1547,7 @@ int32_t SSearchTest::monkeyTestCase(UCollator *coll, const UnicodeString &testCa return notFoundCount; } +#endif void SSearchTest::monkeyTest(char *params) { @@ -1686,3 +1691,4 @@ void SSearchTest::monkeyTest(char *params) } +#endif diff --git a/icu4c/source/test/intltest/ssearch.h b/icu4c/source/test/intltest/ssearch.h index f59cf17b648..5868134bfa3 100644 --- a/icu4c/source/test/intltest/ssearch.h +++ b/icu4c/source/test/intltest/ssearch.h @@ -14,6 +14,8 @@ #include "intltest.h" +#if !UCONFIG_NO_COLLATION + // // Test of the function usearch_search() // @@ -38,3 +40,5 @@ private: }; #endif + +#endif