diff --git a/docs/userguide/icu_data/buildtool.md b/docs/userguide/icu_data/buildtool.md index 1741575d8b4..b0930bdf0a4 100644 --- a/docs/userguide/icu_data/buildtool.md +++ b/docs/userguide/icu_data/buildtool.md @@ -222,7 +222,7 @@ There are two concrete differences between additive and subtractive mode: | | Additive | Subtractive | |-------------------------|-------------|-------------| | Default Feature Filter | `"exclude"` | `"include"` | -| Default Resource Filter | `"-/*"` | `"+/*"` | +| Default Resource Filter | `"-/"` | `"+/"` | To enable additive mode, add the following setting to your filter file: diff --git a/icu4c/source/python/icutools/databuilder/filtration.py b/icu4c/source/python/icutools/databuilder/filtration.py index a74a7a743c6..9150eb28f20 100644 --- a/icu4c/source/python/icutools/databuilder/filtration.py +++ b/icu4c/source/python/icutools/databuilder/filtration.py @@ -319,9 +319,9 @@ class ResourceFilterInfo(object): ) ] if self.strategy == "additive": - self.rules_by_file = [["-/*"] for _ in range(len(files))] + self.rules_by_file = [["-/"] for _ in range(len(files))] else: - self.rules_by_file = [["+/*"] for _ in range(len(files))] + self.rules_by_file = [["+/"] for _ in range(len(files))] def add_rules(self, file_filter, rules): for file, rule_list in zip(self.input_files, self.rules_by_file): diff --git a/icu4c/source/python/icutools/databuilder/filtration_schema.json b/icu4c/source/python/icutools/databuilder/filtration_schema.json index a68011f929d..ba027edce11 100644 --- a/icu4c/source/python/icutools/databuilder/filtration_schema.json +++ b/icu4c/source/python/icutools/databuilder/filtration_schema.json @@ -38,7 +38,7 @@ "type": "array", "items": { "type": "string", - "pattern": "^[+-]/[\\S]+$" + "pattern": "^[+-]/[\\S]*$" } } }, diff --git a/icu4c/source/test/intltest/restsnew.cpp b/icu4c/source/test/intltest/restsnew.cpp index 6f86709af88..0a6a121e67b 100644 --- a/icu4c/source/test/intltest/restsnew.cpp +++ b/icu4c/source/test/intltest/restsnew.cpp @@ -1270,13 +1270,11 @@ void NewResourceBundleTest::TestFilter() { assertEquals("fornia", fornia.getType(), URES_TABLE); { + // Filter: hawaii should not be included based on parent inheritance ResourceBundle hawaii = fornia.get("hawaii", status); - REQUIRE_SUCCESS(status); - assertEquals("hawaii", hawaii.getType(), URES_STRING); - assertEquals("hawaii", u"idaho", hawaii.getString(status)); - REQUIRE_SUCCESS(status); + REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status); - // Filter: illinois should not be included + // Filter: illinois should not be included based on direct rule ResourceBundle illinois = fornia.get("illinois", status); REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status); } @@ -1350,6 +1348,20 @@ void NewResourceBundleTest::TestFilter() { REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status); } } + + // Filter: northCarolina should be included based on direct rule, + // and so should its child, northDakota + ResourceBundle northCarolina = rb.get("northCarolina", status); + REQUIRE_SUCCESS(status); + assertEquals("northCarolina", northCarolina.getType(), URES_TABLE); + + { + ResourceBundle northDakota = northCarolina.get("northDakota", status); + REQUIRE_SUCCESS(status); + assertEquals("northDakota", northDakota.getType(), URES_STRING); + assertEquals("northDakota", u"west-virginia", northDakota.getString(status)); + REQUIRE_SUCCESS(status); + } } #if U_ENABLE_TRACING diff --git a/icu4c/source/test/testdata/filters/filtertest.txt b/icu4c/source/test/testdata/filters/filtertest.txt index 91c780146e5..f884dd124cd 100644 --- a/icu4c/source/test/testdata/filters/filtertest.txt +++ b/icu4c/source/test/testdata/filters/filtertest.txt @@ -1,6 +1,7 @@ # Copyright (C) 2018 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html +-/ -/alabama +/alabama/alaska/arizona -/fornia/illinois @@ -9,3 +10,4 @@ +/mississippi/*/maine -/mississippi/*/iowa +/mississippi/louisiana/iowa ++/northCarolina diff --git a/icu4c/source/test/testdata/filtertest.txt b/icu4c/source/test/testdata/filtertest.txt index 4d9aeb50d55..1fbc71c01ec 100644 --- a/icu4c/source/test/testdata/filtertest.txt +++ b/icu4c/source/test/testdata/filtertest.txt @@ -34,4 +34,7 @@ filtertest { missouri {"new-york"} } } + northCarolina { + northDakota {"west-virginia"} + } } diff --git a/icu4c/source/tools/genrb/filterrb.cpp b/icu4c/source/tools/genrb/filterrb.cpp index d62d185d773..dcc02fc6210 100644 --- a/icu4c/source/tools/genrb/filterrb.cpp +++ b/icu4c/source/tools/genrb/filterrb.cpp @@ -23,6 +23,9 @@ ResKeyPath::ResKeyPath(const std::string& path, UErrorCode& status) { status = U_PARSE_ERROR; return; } + if (path.length() == 1) { + return; + } size_t i; size_t j = 0; while (true) {