From: Adam Dickmeiss Date: Thu, 11 Nov 2010 12:21:44 +0000 (+0100) Subject: Ensure facet norm is null (leave as is) by default X-Git-Tag: v1.5.1~15^2~2 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=ebad7ddfa52ac22000c1ff6178fd3bd962b46dcd;p=pazpar2-moved-to-github.git Ensure facet norm is null (leave as is) by default The facet character set normalization - unlike sort/mergekey/relevance must be null by default. For the 3 existing ones we uset the 7-bit ascii naive implementation. This fixes test_facets.sh test. --- diff --git a/src/charsets.c b/src/charsets.c index f867b6f..c78c911 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -51,6 +51,7 @@ struct pp2_charset_s { #endif }; +static const char *pp2_relevance_token_null(pp2_relevance_token_t prt); static const char *pp2_relevance_token_a_to_z(pp2_relevance_token_t prt); static const char *pp2_get_sort_ascii(pp2_relevance_token_t prt); @@ -109,11 +110,18 @@ void pp2_charset_incref(pp2_charset_t pct) (pct->ref_count)++; } -pp2_charset_t pp2_charset_create(struct icu_chain * icu_chn) +pp2_charset_t pp2_charset_create_a_to_z(void) +{ + pp2_charset_t pct = pp2_charset_create(0); + pct->token_next_handler = pp2_relevance_token_a_to_z; + return pct; +} + +pp2_charset_t pp2_charset_create(struct icu_chain *icu_chn) { pp2_charset_t pct = xmalloc(sizeof(*pct)); - pct->token_next_handler = pp2_relevance_token_a_to_z; + pct->token_next_handler = pp2_relevance_token_null; pct->get_sort_handler = pp2_get_sort_ascii; pct->ref_count = 1; #if YAZ_HAVE_ICU @@ -272,6 +280,16 @@ static const char *pp2_get_sort_ascii(pp2_relevance_token_t prt) } } +static const char *pp2_relevance_token_null(pp2_relevance_token_t prt) +{ + const char *cp = prt->cp; + + prt->last_cp = *cp ? cp : 0; + while (*cp) + cp++; + prt->cp = cp; + return prt->last_cp; +} #if YAZ_HAVE_ICU static const char *pp2_relevance_token_icu(pp2_relevance_token_t prt) diff --git a/src/charsets.h b/src/charsets.h index fbc6193..9d43524 100644 --- a/src/charsets.h +++ b/src/charsets.h @@ -34,6 +34,8 @@ typedef struct pp2_relevance_token_s *pp2_relevance_token_t; pp2_charset_t pp2_charset_create_xml(xmlNode *xml_node); pp2_charset_t pp2_charset_create(struct icu_chain * icu_chn); +pp2_charset_t pp2_charset_create_a_to_z(void); + void pp2_charset_destroy(pp2_charset_t pct); void pp2_charset_incref(pp2_charset_t pct); diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index b659848..208d2de 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -678,7 +678,7 @@ static void inherit_server_settings(struct conf_service *s) pp2_charset_incref(s->relevance_pct); } else - s->relevance_pct = pp2_charset_create(0); + s->relevance_pct = pp2_charset_create_a_to_z(); } if (!s->sort_pct) @@ -689,7 +689,7 @@ static void inherit_server_settings(struct conf_service *s) pp2_charset_incref(s->sort_pct); } else - s->sort_pct = pp2_charset_create(0); + s->sort_pct = pp2_charset_create_a_to_z(); } if (!s->mergekey_pct) @@ -700,7 +700,7 @@ static void inherit_server_settings(struct conf_service *s) pp2_charset_incref(s->mergekey_pct); } else - s->mergekey_pct = pp2_charset_create(0); + s->mergekey_pct = pp2_charset_create_a_to_z(); } if (!s->facet_pct)