amoralej / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 years ago
Clone
Blob Blame History Raw
From d30ca340657d858ca416e5c8bc3600607ca49e80 Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Wed, 2 Oct 2013 10:56:42 -0700
Subject: [PATCH 30/39] Ticket #54 - locale "nl" not supported by collation plugin

Bug description: In the recent version of ICU, some locales do not
have its specific collator, but are included in the default (root)
locale.  "nl", "en", and "fr" are in the class.  ICU API ucol_open
takes the locale string and returns the collator with the status.
If the locale has no dedicated collator and the root collator is
picked up, status U_USING_DEFAULT_WARNING is returned, which is not
an error.  But collation_indexer_create (collate.c) treats it as an
error and stops the collation.

Fix description: As ICU doc suggests, error checking for ucol_open
is replaced with "(U_SUCCESS(err)", by which the status U_USING_
DEFAULT_WARNING is correctlly handled.

https://fedorahosted.org/389/ticket/54

Reviewed by rmeggins (Thank you, Rich!!)
(cherry picked from commit c8d1cf570882a55329c11d8fba418c575671d131)
(cherry picked from commit 0a45dc28399ab878866d8a23fd289e309a5d73c8)
---
 ldap/servers/plugins/collation/collate.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/ldap/servers/plugins/collation/collate.c b/ldap/servers/plugins/collation/collate.c
index 2a73ee1..a02040f 100644
--- a/ldap/servers/plugins/collation/collate.c
+++ b/ldap/servers/plugins/collation/collate.c
@@ -449,20 +449,17 @@ collation_indexer_create (const char* oid)
 		 * or if we found a fallback one, or if we are happy with
 		 * the default, use it.
 		 */
-		if (err == U_ZERO_ERROR || err == U_USING_FALLBACK_WARNING ||
-		    (err == U_USING_DEFAULT_WARNING && is_default)) {
+		if (U_SUCCESS(err)) {
 		    etc = (collation_indexer_t*) slapi_ch_calloc (1, sizeof (collation_indexer_t));
 		    ix = (indexer_t*) slapi_ch_calloc (1, sizeof (indexer_t));
 		    ucol_setAttribute (coll, UCOL_STRENGTH, profile->strength, &err);
-		    if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
-			&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
+		    if (U_FAILURE(err)) {
 		    	LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
 				   "set the collator strength for oid %s to %d: err %d\n",
 				   oid, profile->strength, err);
 		    }
 		    ucol_setAttribute (coll, UCOL_DECOMPOSITION_MODE, profile->decomposition, &err);
-		    if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
-			&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
+		    if (U_FAILURE(err)) {
 		    	LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
 				   "set the collator decomposition mode for oid %s to %d: err %d\n",
 				   oid, profile->decomposition, err);
-- 
1.7.1