From e08d580655f4d37a2be9a542efe799e36d106215 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Tue, 29 Nov 2005 00:10:07 +0000 Subject: [PATCH] ICU-4739 add "no fallback" flag to resource bundles X-SVN-Rev: 18836 --- icu4c/source/data/Makefile.in | 6 +- icu4c/source/data/coll/colfiles.mk | 2 +- icu4c/source/data/makedata.mak | 6 +- icu4c/source/data/misc/CurrencyData.txt | 2 +- icu4c/source/data/misc/zoneinfo.txt | 2 +- icu4c/source/test/cintltst/crestst.c | 82 ++++++++++++++++++- .../test/testdata/DataDrivenCollationTest.txt | 2 +- icu4c/source/test/testdata/casing.txt | 2 +- icu4c/source/test/testdata/conversion.txt | 2 +- icu4c/source/test/testdata/icuio.txt | 2 +- icu4c/source/test/testdata/idna_rules.txt | 4 +- icu4c/source/test/testdata/iscii.bin | 4 +- icu4c/source/test/testdata/structLocale.txt | 2 +- 13 files changed, 96 insertions(+), 22 deletions(-) diff --git a/icu4c/source/data/Makefile.in b/icu4c/source/data/Makefile.in index 6b2430febf8..86e9c5641f1 100644 --- a/icu4c/source/data/Makefile.in +++ b/icu4c/source/data/Makefile.in @@ -412,7 +412,7 @@ $(OUTTMPDIR)/$(COLLATION_TREE)/$(INDEX_NAME).txt: $(SRCLISTDEPS) @echo "generating $@ (list of installed collation locales)"; \ $(RMV) $@; \ echo "// Warning this file is automatically generated" > $@; \ - echo "$(INDEX_NAME) {" >> $@; \ + echo "$(INDEX_NAME):table(nofallback) {" >> $@; \ echo " InstalledLocales {" >> $@; \ for file in $(INSTALLED_COL_FILES); do \ echo " $$file {\"\"}" >> $@; \ @@ -431,7 +431,7 @@ $(OUTTMPDIR)/$(RBNF_TREE)/$(INDEX_NAME).txt: $(SRCLISTDEPS) @echo "generating $@ (list of installed RBNF locales)"; \ $(RMV) $@; \ echo "// Warning this file is automatically generated" > $@; \ - echo "$(INDEX_NAME) {" >> $@; \ + echo "$(INDEX_NAME):table(nofallback) {" >> $@; \ echo " InstalledLocales {" >> $@; \ for file in $(INSTALLED_RBNF_FILES); do \ echo " $$file {\"\"}" >> $@; \ @@ -457,7 +457,7 @@ $(OUTTMPDIR)/$(INDEX_NAME).txt: $(SRCLISTDEPS) @echo "generating $@ (list of installed locales)"; \ $(RMV) $@; \ echo "// Warning this file is automatically generated" > $@; \ - echo "$(INDEX_NAME) {" >> $@; \ + echo "$(INDEX_NAME):table(nofallback) {" >> $@; \ echo " InstalledLocales {" >> $@; \ for file in $(INSTALLED_RB_FILES); do \ echo " $$file {\"\"}" >> $@; \ diff --git a/icu4c/source/data/coll/colfiles.mk b/icu4c/source/data/coll/colfiles.mk index 642eefff99b..561cbd61d01 100644 --- a/icu4c/source/data/coll/colfiles.mk +++ b/icu4c/source/data/coll/colfiles.mk @@ -25,7 +25,7 @@ # Generated by LDML2ICUConverter, from LDML source files. # Aliases which do not have a corresponding xx.xml file (see deprecatedList.xml) -COLLATION_SYNTHETIC_ALIAS = de__PHONEBOOK.txt es__TRADITIONAL.txt hi__DIRECT.txt in.txt\ +COLLATION_SYNTHETIC_ALIAS = de_.txt es_.txt hi_.txt zh_.txt de__PHONEBOOK.txt es__TRADITIONAL.txt hi__DIRECT.txt in.txt\ in_ID.txt iw.txt iw_IL.txt zh_TW_STROKE.txt zh__PINYIN.txt diff --git a/icu4c/source/data/makedata.mak b/icu4c/source/data/makedata.mak index 9fd2fe36faa..41847b67fb2 100644 --- a/icu4c/source/data/makedata.mak +++ b/icu4c/source/data/makedata.mak @@ -484,7 +484,7 @@ CLEAN : GODATA res_index.res: @echo Generating <> !!! >>> DO NOT EDIT <<< !!! << //--------------------------------------------------------- -zoneinfo { +zoneinfo:table(nofallback) { Zones:array { /* ACT */ :int { 310 } //Z#0 , /* AET */ :int { 321 } //Z#1 diff --git a/icu4c/source/test/cintltst/crestst.c b/icu4c/source/test/cintltst/crestst.c index b6cec878f69..dce4e10fd6a 100644 --- a/icu4c/source/test/cintltst/crestst.c +++ b/icu4c/source/test/cintltst/crestst.c @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2004, International Business Machines Corporation and + * Copyright (c) 1997-2005, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************* @@ -459,7 +459,7 @@ static void TestFallback() static void TestOpenDirect(void) { - UResourceBundle *idna_rules, *item; + UResourceBundle *idna_rules, *casing, *te_IN, *ne, *item; UErrorCode errorCode; /* @@ -468,7 +468,7 @@ TestOpenDirect(void) { * from root or similar */ errorCode=U_ZERO_ERROR; - idna_rules=ures_openDirect("testdata", "idna_rules", &errorCode); + idna_rules=ures_openDirect(loadTestData(&errorCode), "idna_rules", &errorCode); if(U_FAILURE(errorCode)) { log_err("ures_openDirect(\"idna_rules\") failed: %s\n", u_errorName(errorCode)); return; @@ -489,7 +489,7 @@ TestOpenDirect(void) { } /* try an item in root, must fail */ - item=ures_getByKey(idna_rules, "Languages", NULL, &errorCode); + item=ures_getByKey(idna_rules, "ShortLanguage", NULL, &errorCode); if(U_FAILURE(errorCode)) { errorCode=U_ZERO_ERROR; } else { @@ -527,6 +527,80 @@ TestOpenDirect(void) { return; } ures_close(idna_rules); + + /* + * ICU 3.6 has new resource bundle syntax and data for bundles that do not + * participate in locale fallback. Now, + * - ures_open() works like ures_openDirect() on a bundle with a top-level + * type of ":table(nofallback)" _if_ the bundle exists + * - ures_open() will continue to find a root bundle if the requested one + * does not exist, unlike ures_openDirect() + * + * Test with a different bundle than above to avoid confusion in the cache. + */ + + /* + * verify that ures_open("casing"), which now has a nofallback declaration, + * does not enable fallbacks + */ + errorCode=U_ZERO_ERROR; + casing=ures_open("testdata", "casing", &errorCode); + if(U_FAILURE(errorCode)) { + log_err("ures_open(\"casing\") failed: %s\n", u_errorName(errorCode)); + return; + } + + errorCode=U_ZERO_ERROR; + item=ures_getByKey(casing, "Info", NULL, &errorCode); + if(U_FAILURE(errorCode)) { + log_err("casing.getByKey(Info) failed - %s\n", u_errorName(errorCode)); + } else { + ures_close(item); + } + + errorCode=U_ZERO_ERROR; + item=ures_getByKey(casing, "ShortLanguage", NULL, &errorCode); + if(U_SUCCESS(errorCode)) { + log_err("casing.getByKey(root key) succeeded despite nofallback declaration - %s\n", u_errorName(errorCode)); + ures_close(item); + } + ures_close(casing); + + /* + * verify that ures_open("ne") finds the root bundle but + * ures_openDirect("ne") does not + */ + errorCode=U_ZERO_ERROR; + ne=ures_open("testdata", "ne", &errorCode); + if(U_FAILURE(errorCode)) { + log_err("ures_open(\"ne\") failed (expected to get root): %s\n", u_errorName(errorCode)); + } + if(errorCode!=U_USING_DEFAULT_WARNING || 0!=uprv_strcmp("root", ures_getLocale(ne, &errorCode))) { + log_err("ures_open(\"ne\") found something other than \"root\" - %s\n", u_errorName(errorCode)); + } + ures_close(ne); + + errorCode=U_ZERO_ERROR; + ne=ures_openDirect("testdata", "ne", &errorCode); + if(U_SUCCESS(errorCode)) { + log_err("ures_openDirect(\"ne\") succeeded unexpectedly\n"); + ures_close(ne); + } + + /* verify that ures_openDirect("te_IN") does not enable fallbacks */ + errorCode=U_ZERO_ERROR; + te_IN=ures_openDirect("testdata", "te_IN", &errorCode); + if(U_FAILURE(errorCode)) { + log_err("ures_open(\"te_IN\") failed: %s\n", u_errorName(errorCode)); + return; + } + errorCode=U_ZERO_ERROR; + item=ures_getByKey(te_IN, "ShortLanguage", NULL, &errorCode); + if(U_SUCCESS(errorCode)) { + log_err("te_IN.getByKey(root key) succeeded despite use of ures_openDirect() - %s\n", u_errorName(errorCode)); + ures_close(item); + } + ures_close(te_IN); } static int32_t diff --git a/icu4c/source/test/testdata/DataDrivenCollationTest.txt b/icu4c/source/test/testdata/DataDrivenCollationTest.txt index ad4f7095977..511f7f21c36 100644 --- a/icu4c/source/test/testdata/DataDrivenCollationTest.txt +++ b/icu4c/source/test/testdata/DataDrivenCollationTest.txt @@ -1,6 +1,6 @@ // Copyright (c) 2001-2005 International Business Machines // Corporation and others. All Rights Reserved. -DataDrivenCollationTest { +DataDrivenCollationTest:table(nofallback) { Info { Headers { "sequence" } Description { "These are the data driven tests" } diff --git a/icu4c/source/test/testdata/casing.txt b/icu4c/source/test/testdata/casing.txt index 1e1c95c23e6..fb3702ca5ab 100644 --- a/icu4c/source/test/testdata/casing.txt +++ b/icu4c/source/test/testdata/casing.txt @@ -5,7 +5,7 @@ //* //******************************************************************************* -casing { +casing:table(nofallback) { Info { Description { "This is test data file for string casing." } diff --git a/icu4c/source/test/testdata/conversion.txt b/icu4c/source/test/testdata/conversion.txt index 773e5e4e08e..07a00b26819 100644 --- a/icu4c/source/test/testdata/conversion.txt +++ b/icu4c/source/test/testdata/conversion.txt @@ -15,7 +15,7 @@ // //******************************************************************************* -conversion { +conversion:table(nofallback) { Info { Description { "Test data for conversion" } LongDescription { diff --git a/icu4c/source/test/testdata/icuio.txt b/icu4c/source/test/testdata/icuio.txt index e83fb3d5461..e4b07fdc098 100644 --- a/icu4c/source/test/testdata/icuio.txt +++ b/icu4c/source/test/testdata/icuio.txt @@ -15,7 +15,7 @@ // //***************************************************************************** -icuio { +icuio:table(nofallback) { Info { Description { "Test data for ICU I/O" } LongDescription { diff --git a/icu4c/source/test/testdata/idna_rules.txt b/icu4c/source/test/testdata/idna_rules.txt index ebfd6e3be55..7ef6404e951 100644 --- a/icu4c/source/test/testdata/idna_rules.txt +++ b/icu4c/source/test/testdata/idna_rules.txt @@ -1,8 +1,8 @@ -// Copyright (C) 2003, International Business Machines +// Copyright (C) 2003-2005, International Business Machines // WARNING: This file is machine generated by debug\genidn tool. Please DO NOT edit. -idna_rules{ +idna_rules:table(nofallback){ UnassignedSet{"[ \\u0221 \\u0234-\\u024F \\u02AE-\\u02AF \\u02EF-\\u02FF \\u0350-\\u035F \\u0370-\\u0373 " "\\u0376-\\u0379 \\u037B-\\u037D \\u037F-\\u0383 \\u038B \\u038D \\u03A2 \\u03CF " diff --git a/icu4c/source/test/testdata/iscii.bin b/icu4c/source/test/testdata/iscii.bin index fa0356571dc..433333eb54d 100644 --- a/icu4c/source/test/testdata/iscii.bin +++ b/icu4c/source/test/testdata/iscii.bin @@ -1,10 +1,10 @@ //******************************************************************************* //* -//*Copyright(C)1998-2000InternationalBusinessMachines +//*Copyright(C)1998-2005InternationalBusinessMachines //*Corporationandothers.AllRightsReserved. //* //******************************************************************************* -iscii{ +iscii:table(nofallback){ str{ " ï4ï3ÍÝï4ï3Æá×è³å .³á .¬³ .¤ÅèÍÍÆ .³á ¤ÆÝ×ÚÏ 1990 ³ ³¢ÈèÍÞ½Ï-ÈèÏÊ¢ÅÛ ×Þ¸ÆÚ" "ÈèÏÁÚÑÜ .³á .ÍåµÄÚÆ .³á .ÉÑ×èÔÏÞÈ .ÔÛÕèÔ .Ìᢠ.×ÚÑÚÆÚ .2200 ¤ÏÊ ÏÝÈÍá ÌÞÑèÍ" diff --git a/icu4c/source/test/testdata/structLocale.txt b/icu4c/source/test/testdata/structLocale.txt index f39d4062066..07f3c239b79 100644 --- a/icu4c/source/test/testdata/structLocale.txt +++ b/icu4c/source/test/testdata/structLocale.txt @@ -9,7 +9,7 @@ // Since ICU doesn't follow the traditional fallback model where all keys fallback to root, // root can't be used to validate the structure. // This file was generated from en.txt, and all ".*" were replaced with "". -structLocale{ +structLocale:table(nofallback){ BreakDictionaryData:bin {00} Countries{ 001{""}