From: Adam Dickmeiss Date: Fri, 18 Jan 2013 09:46:01 +0000 (+0100) Subject: Reformat some source for ICU X-Git-Tag: v4.2.49~6 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=5a2b1f41cd0b3e0f5441a4cfb3b9484a1c4b017d;p=yaz-moved-to-github.git Reformat some source for ICU --- diff --git a/src/icu_casemap.c b/src/icu_casemap.c index 4204f8a..f06f64e 100644 --- a/src/icu_casemap.c +++ b/src/icu_casemap.c @@ -30,9 +30,9 @@ struct icu_casemap char action; }; -struct icu_casemap * icu_casemap_create(char action, UErrorCode *status) +struct icu_casemap *icu_casemap_create(char action, UErrorCode *status) { - struct icu_casemap * casemap + struct icu_casemap *casemap = (struct icu_casemap *) xmalloc(sizeof(struct icu_casemap)); casemap->action = action; @@ -67,9 +67,9 @@ void icu_casemap_destroy(struct icu_casemap * casemap) xfree(casemap); } -int icu_casemap_casemap(struct icu_casemap * casemap, - struct icu_buf_utf16 * dest16, - struct icu_buf_utf16 * src16, +int icu_casemap_casemap(struct icu_casemap *casemap, + struct icu_buf_utf16 *dest16, + struct icu_buf_utf16 *src16, UErrorCode *status, const char *locale) { @@ -81,8 +81,8 @@ int icu_casemap_casemap(struct icu_casemap * casemap, } -static uint32_t icu_utf16_sub(struct icu_buf_utf16 * dest16, - struct icu_buf_utf16 * src16, +static uint32_t icu_utf16_sub(struct icu_buf_utf16 *dest16, + struct icu_buf_utf16 *src16, const char *locale, char action, UErrorCode *status) { @@ -119,8 +119,8 @@ static uint32_t icu_utf16_sub(struct icu_buf_utf16 * dest16, } -int icu_utf16_casemap(struct icu_buf_utf16 * dest16, - struct icu_buf_utf16 * src16, +int icu_utf16_casemap(struct icu_buf_utf16 *dest16, + struct icu_buf_utf16 *src16, const char *locale, char action, UErrorCode *status) { diff --git a/src/icu_sortkey.c b/src/icu_sortkey.c index 69c9f57..e4decac 100644 --- a/src/icu_sortkey.c +++ b/src/icu_sortkey.c @@ -27,8 +27,8 @@ #include /* char names */ void icu_sortkey8_from_utf16(UCollator *coll, - struct icu_buf_utf8 * dest8, - struct icu_buf_utf16 * src16, + struct icu_buf_utf8 *dest8, + struct icu_buf_utf16 *src16, UErrorCode * status) { int32_t sortkey_len = 0; diff --git a/src/icu_tokenizer.c b/src/icu_tokenizer.c index e09960f..67246ea 100644 --- a/src/icu_tokenizer.c +++ b/src/icu_tokenizer.c @@ -78,7 +78,7 @@ struct icu_tokenizer *icu_tokenizer_clone(struct icu_tokenizer *old) struct icu_tokenizer *icu_tokenizer_create(const char *locale, char action, UErrorCode *status) { - struct icu_tokenizer * tokenizer + struct icu_tokenizer *tokenizer = (struct icu_tokenizer *) xmalloc(sizeof(struct icu_tokenizer)); icu_tokenizer_reset(tokenizer, action); @@ -119,7 +119,7 @@ struct icu_tokenizer *icu_tokenizer_create(const char *locale, char action, return 0; } -void icu_tokenizer_destroy(struct icu_tokenizer * tokenizer) +void icu_tokenizer_destroy(struct icu_tokenizer *tokenizer) { if (tokenizer) { @@ -130,8 +130,8 @@ void icu_tokenizer_destroy(struct icu_tokenizer * tokenizer) } } -int icu_tokenizer_attach(struct icu_tokenizer * tokenizer, - struct icu_buf_utf16 * src16, +int icu_tokenizer_attach(struct icu_tokenizer *tokenizer, + struct icu_buf_utf16 *src16, UErrorCode *status) { if (!tokenizer || !tokenizer->bi || !src16) @@ -153,8 +153,8 @@ int icu_tokenizer_attach(struct icu_tokenizer * tokenizer, return 1; } -int32_t icu_tokenizer_next_token(struct icu_tokenizer * tokenizer, - struct icu_buf_utf16 * tkn16, +int32_t icu_tokenizer_next_token(struct icu_tokenizer *tokenizer, + struct icu_buf_utf16 *tkn16, UErrorCode *status) { int32_t tkn_start = 0; @@ -217,7 +217,7 @@ int32_t icu_tokenizer_next_token(struct icu_tokenizer * tokenizer, return tkn_len; } -int32_t icu_tokenizer_token_count(struct icu_tokenizer * tokenizer) +int32_t icu_tokenizer_token_count(struct icu_tokenizer *tokenizer) { return tokenizer->token_count; } diff --git a/src/icu_transform.c b/src/icu_transform.c index 6879bc4..05214b7 100644 --- a/src/icu_transform.c +++ b/src/icu_transform.c @@ -30,7 +30,7 @@ struct icu_transform { char action; UParseError parse_error; - UTransliterator * trans; + UTransliterator *trans; }; struct icu_transform *icu_transform_clone(struct icu_transform *old) @@ -46,9 +46,9 @@ struct icu_transform *icu_transform_clone(struct icu_transform *old) return transform; } -struct icu_transform * icu_transform_create(const char *id, char action, - const char *rules, - UErrorCode *status) +struct icu_transform *icu_transform_create(const char *id, char action, + const char *rules, + UErrorCode *status) { struct icu_buf_utf16 *id16 = icu_buf_utf16_create(0); struct icu_buf_utf16 *rules16 = icu_buf_utf16_create(0); @@ -102,7 +102,7 @@ struct icu_transform * icu_transform_create(const char *id, char action, return 0; } -void icu_transform_destroy(struct icu_transform * transform) +void icu_transform_destroy(struct icu_transform *transform) { if (transform) { @@ -112,9 +112,9 @@ void icu_transform_destroy(struct icu_transform * transform) } } -int icu_transform_trans(struct icu_transform * transform, - struct icu_buf_utf16 * dest16, - const struct icu_buf_utf16 * src16, +int icu_transform_trans(struct icu_transform *transform, + struct icu_buf_utf16 *dest16, + const struct icu_buf_utf16 *src16, UErrorCode *status) { if (!transform || !transform->trans diff --git a/src/icu_utf16.c b/src/icu_utf16.c index 466f7af..5bb74ec 100644 --- a/src/icu_utf16.c +++ b/src/icu_utf16.c @@ -27,9 +27,9 @@ #include /* some more string fcns*/ #include /* char names */ -struct icu_buf_utf16 * icu_buf_utf16_create(size_t capacity) +struct icu_buf_utf16 *icu_buf_utf16_create(size_t capacity) { - struct icu_buf_utf16 * buf16 + struct icu_buf_utf16 *buf16 = (struct icu_buf_utf16 *) xmalloc(sizeof(struct icu_buf_utf16)); buf16->utf16 = 0; @@ -45,7 +45,7 @@ struct icu_buf_utf16 * icu_buf_utf16_create(size_t capacity) return buf16; } -struct icu_buf_utf16 * icu_buf_utf16_clear(struct icu_buf_utf16 * buf16) +struct icu_buf_utf16 *icu_buf_utf16_clear(struct icu_buf_utf16 *buf16) { if (buf16) { @@ -56,8 +56,8 @@ struct icu_buf_utf16 * icu_buf_utf16_clear(struct icu_buf_utf16 * buf16) return buf16; } -struct icu_buf_utf16 * icu_buf_utf16_resize(struct icu_buf_utf16 * buf16, - size_t capacity) +struct icu_buf_utf16 *icu_buf_utf16_resize(struct icu_buf_utf16 *buf16, + size_t capacity) { if (!buf16) return 0; @@ -81,8 +81,8 @@ struct icu_buf_utf16 * icu_buf_utf16_resize(struct icu_buf_utf16 * buf16, } -struct icu_buf_utf16 * icu_buf_utf16_copy(struct icu_buf_utf16 * dest16, - const struct icu_buf_utf16 * src16) +struct icu_buf_utf16 *icu_buf_utf16_copy(struct icu_buf_utf16 *dest16, + const struct icu_buf_utf16 *src16) { if (!dest16 || !src16 || dest16 == src16) return 0; @@ -98,7 +98,7 @@ struct icu_buf_utf16 * icu_buf_utf16_copy(struct icu_buf_utf16 * dest16, struct icu_buf_utf16 *icu_buf_utf16_append(struct icu_buf_utf16 *dest16, - const struct icu_buf_utf16 * src16) + const struct icu_buf_utf16 *src16) { assert(dest16); if (!src16) @@ -117,7 +117,7 @@ struct icu_buf_utf16 *icu_buf_utf16_append(struct icu_buf_utf16 *dest16, } -void icu_buf_utf16_destroy(struct icu_buf_utf16 * buf16) +void icu_buf_utf16_destroy(struct icu_buf_utf16 *buf16) { if (buf16) xfree(buf16->utf16); diff --git a/src/icu_utf8.c b/src/icu_utf8.c index ff9e9d6..dd392d1 100644 --- a/src/icu_utf8.c +++ b/src/icu_utf8.c @@ -28,7 +28,7 @@ struct icu_buf_utf8 *icu_buf_utf8_create(size_t capacity) { - struct icu_buf_utf8 * buf8 + struct icu_buf_utf8 *buf8 = (struct icu_buf_utf8 *) xmalloc(sizeof(struct icu_buf_utf8)); buf8->utf8 = 0; @@ -44,7 +44,7 @@ struct icu_buf_utf8 *icu_buf_utf8_create(size_t capacity) return buf8; } -struct icu_buf_utf8 * icu_buf_utf8_clear(struct icu_buf_utf8 * buf8) +struct icu_buf_utf8 *icu_buf_utf8_clear(struct icu_buf_utf8 *buf8) { if (buf8) { @@ -55,8 +55,8 @@ struct icu_buf_utf8 * icu_buf_utf8_clear(struct icu_buf_utf8 * buf8) return buf8; } -struct icu_buf_utf8 * icu_buf_utf8_resize(struct icu_buf_utf8 * buf8, - size_t capacity) +struct icu_buf_utf8 *icu_buf_utf8_resize(struct icu_buf_utf8 *buf8, + size_t capacity) { if (!buf8) return 0; @@ -95,16 +95,16 @@ const char *icu_buf_utf8_to_cstr(struct icu_buf_utf8 *src8) return (const char *) src8->utf8; } -void icu_buf_utf8_destroy(struct icu_buf_utf8 * buf8) +void icu_buf_utf8_destroy(struct icu_buf_utf8 *buf8) { if (buf8) xfree(buf8->utf8); xfree(buf8); } -UErrorCode icu_utf16_from_utf8_cstr(struct icu_buf_utf16 * dest16, - const char * src8cstr, - UErrorCode * status) +UErrorCode icu_utf16_from_utf8_cstr(struct icu_buf_utf16 *dest16, + const char *src8cstr, + UErrorCode *status) { size_t src8cstr_len = 0; int32_t utf16_len = 0; @@ -136,7 +136,7 @@ UErrorCode icu_utf16_from_utf8_cstr(struct icu_buf_utf16 * dest16, UErrorCode icu_utf16_to_utf8(struct icu_buf_utf8 *dest8, const struct icu_buf_utf16 *src16, - UErrorCode * status) + UErrorCode *status) { int32_t utf8_len = 0; diff --git a/test/test_icu.c b/test/test_icu.c index 391e66e..b1de907 100644 --- a/test/test_icu.c +++ b/test/test_icu.c @@ -51,16 +51,16 @@ static int icu_termmap_cmp(const void *vp1, const void *vp2) } -static int test_icu_casemap(const char * locale, char action, - const char * src8cstr, const char * chk8cstr) +static int test_icu_casemap(const char *locale, char action, + const char *src8cstr, const char *chk8cstr) { int success = 0; UErrorCode status = U_ZERO_ERROR; - struct icu_buf_utf8 * src8 = icu_buf_utf8_create(0); - struct icu_buf_utf8 * dest8 = icu_buf_utf8_create(0); - struct icu_buf_utf16 * src16 = icu_buf_utf16_create(0); - struct icu_buf_utf16 * dest16 = icu_buf_utf16_create(0); + struct icu_buf_utf8 *src8 = icu_buf_utf8_create(0); + struct icu_buf_utf8 *dest8 = icu_buf_utf8_create(0); + struct icu_buf_utf16 *src16 = icu_buf_utf16_create(0); + struct icu_buf_utf16 *dest16 = icu_buf_utf16_create(0); int src8cstr_len = strlen(src8cstr); @@ -165,19 +165,19 @@ static void check_icu_casemap(void) } -static int test_icu_sortmap(const char * locale, int src_list_len, - const char ** src_list, const char ** chk_list) +static int test_icu_sortmap(const char *locale, int src_list_len, + const char **src_list, const char **chk_list) { int success = 1; UErrorCode status = U_ZERO_ERROR; - struct icu_buf_utf8 * buf8 = icu_buf_utf8_create(0); - struct icu_buf_utf16 * buf16 = icu_buf_utf16_create(0); + struct icu_buf_utf8 *buf8 = icu_buf_utf8_create(0); + struct icu_buf_utf16 *buf16 = icu_buf_utf16_create(0); int i; - struct icu_termmap * list[src_list_len]; + struct icu_termmap *list[src_list_len]; UCollator *coll = ucol_open(locale, &status); icu_check_status(status); @@ -249,8 +249,8 @@ static void check_icu_sortmap(void) { /* successful tests */ size_t en_1_len = 6; - const char * en_1_src[6] = {"z", "K", "a", "A", "Z", "k"}; - const char * en_1_cck[6] = {"a", "A", "k", "K", "z", "Z"}; + const char *en_1_src[6] = {"z", "K", "a", "A", "Z", "k"}; + const char *en_1_cck[6] = {"a", "A", "k", "K", "z", "Z"}; YAZ_CHECK(test_icu_sortmap("en", en_1_len, en_1_src, en_1_cck)); YAZ_CHECK(test_icu_sortmap("en_AU", en_1_len, en_1_src, en_1_cck)); YAZ_CHECK(test_icu_sortmap("en_CA", en_1_len, en_1_src, en_1_cck)); @@ -260,34 +260,34 @@ static void check_icu_sortmap(void) /* successful tests */ { size_t da_1_len = 6; - const char * da_1_src[6] = {"z", "å", "o", "æ", "a", "ø"}; - const char * da_1_cck[6] = {"a", "o", "z", "æ", "ø", "å"}; + const char *da_1_src[6] = {"z", "å", "o", "æ", "a", "ø"}; + const char *da_1_cck[6] = {"a", "o", "z", "æ", "ø", "å"}; YAZ_CHECK(test_icu_sortmap("da", da_1_len, da_1_src, da_1_cck)); YAZ_CHECK(test_icu_sortmap("da_DK", da_1_len, da_1_src, da_1_cck)); } /* successful tests */ { size_t de_1_len = 9; - const char * de_1_src[9] = {"u", "ä", "o", "t", "s", "ß", "ü", "ö", "a"}; - const char * de_1_cck[9] = {"a","ä", "o", "ö", "s", "ß", "t", "u", "ü"}; + const char *de_1_src[9] = {"u", "ä", "o", "t", "s", "ß", "ü", "ö", "a"}; + const char *de_1_cck[9] = {"a","ä", "o", "ö", "s", "ß", "t", "u", "ü"}; YAZ_CHECK(test_icu_sortmap("de", de_1_len, de_1_src, de_1_cck)); YAZ_CHECK(test_icu_sortmap("de_AT", de_1_len, de_1_src, de_1_cck)); YAZ_CHECK(test_icu_sortmap("de_DE", de_1_len, de_1_src, de_1_cck)); } } -static int test_icu_normalizer(const char * rules8cstr, - const char * src8cstr, - const char * chk8cstr) +static int test_icu_normalizer(const char *rules8cstr, + const char *src8cstr, + const char *chk8cstr) { int success = 0; UErrorCode status = U_ZERO_ERROR; - struct icu_buf_utf16 * src16 = icu_buf_utf16_create(0); - struct icu_buf_utf16 * dest16 = icu_buf_utf16_create(0); - struct icu_buf_utf8 * dest8 = icu_buf_utf8_create(0); - struct icu_transform * transform + struct icu_buf_utf16 *src16 = icu_buf_utf16_create(0); + struct icu_buf_utf16 *dest16 = icu_buf_utf16_create(0); + struct icu_buf_utf8 *dest8 = icu_buf_utf8_create(0); + struct icu_transform *transform = icu_transform_create(rules8cstr, 'f', 0, &status); icu_check_status(status); @@ -354,16 +354,16 @@ static void check_icu_normalizer(void) "a cote de l'alcove ovoide")); } -static int test_icu_tokenizer(const char * locale, char action, - const char * src8cstr, int count) +static int test_icu_tokenizer(const char *locale, char action, + const char *src8cstr, int count) { int success = 1; UErrorCode status = U_ZERO_ERROR; - struct icu_buf_utf16 * src16 = icu_buf_utf16_create(0); - struct icu_buf_utf16 * tkn16 = icu_buf_utf16_create(0); - struct icu_buf_utf8 * tkn8 = icu_buf_utf8_create(0); - struct icu_tokenizer * tokenizer = 0; + struct icu_buf_utf16 *src16 = icu_buf_utf16_create(0); + struct icu_buf_utf16 *tkn16 = icu_buf_utf16_create(0); + struct icu_buf_utf8 *tkn8 = icu_buf_utf8_create(0); + struct icu_tokenizer *tokenizer = 0; /* transforming to UTF16 */ icu_utf16_from_utf8_cstr(src16, src8cstr, &status); @@ -406,7 +406,7 @@ static int test_icu_tokenizer(const char * locale, char action, static void check_icu_tokenizer(void) { - const char * en_str + const char *en_str = "O Romeo, Romeo! wherefore art thou Romeo?"; YAZ_CHECK(test_icu_tokenizer("en", 's', en_str, 2)); @@ -415,7 +415,7 @@ static void check_icu_tokenizer(void) YAZ_CHECK(test_icu_tokenizer("en", 'c', en_str, 41)); { - const char * da_str + const char *da_str = "Blåbærtærte. Denne kage stammer fra Finland. " "Den er med blåbær, men alle sommerens forskellige bær kan bruges."; @@ -428,13 +428,13 @@ static void check_icu_tokenizer(void) static void check_icu_chain(void) { - const char * en_str + const char *en_str = "O Romeo, Romeo! wherefore art thou\t Romeo?"; UErrorCode status = U_ZERO_ERROR; - struct icu_chain * chain = 0; + struct icu_chain *chain = 0; - const char * xml_str = "" + const char *xml_str = "" "" "" "" @@ -487,9 +487,9 @@ static void check_icu_chain(void) static void check_bug_1140(void) { UErrorCode status = U_ZERO_ERROR; - struct icu_chain * chain = 0; + struct icu_chain *chain = 0; - const char * xml_str = "" + const char *xml_str = "" /* if the first rule is normalize instead. Then it works */ #if 0 @@ -550,9 +550,9 @@ static void check_bug_1140(void) static void check_chain_empty_token(void) { UErrorCode status = U_ZERO_ERROR; - struct icu_chain * chain = 0; + struct icu_chain *chain = 0; - const char * xml_str = "" + const char *xml_str = "" "" "" ""; @@ -587,13 +587,13 @@ static void check_chain_empty_token(void) static void check_chain_empty_chain(void) { UErrorCode status = U_ZERO_ERROR; - struct icu_chain * chain = 0; + struct icu_chain *chain = 0; - const char * xml_str = "" + const char *xml_str = "" ""; - const char * src8 = "some 5487 weired !¤%&(/& sTuFf"; - char * dest8 = 0; + const char *src8 = "some 5487 weired !¤%&(/& sTuFf"; + char *dest8 = 0; xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str)); xmlNode *xml_node = xmlDocGetRootElement(doc); @@ -628,11 +628,11 @@ static void check_chain_empty_chain(void) static void check_icu_iter1(void) { UErrorCode status = U_ZERO_ERROR; - struct icu_chain * chain = 0; + struct icu_chain *chain = 0; xmlNode *xml_node; yaz_icu_iter_t iter; - const char * xml_str = "" + const char *xml_str = "" "" "" ""; @@ -767,10 +767,10 @@ static void check_iter_threads(struct icu_chain *chain) static void check_icu_iter2(void) { UErrorCode status = U_ZERO_ERROR; - struct icu_chain * chain = 0; + struct icu_chain *chain = 0; xmlNode *xml_node; - const char * xml_str = "" + const char *xml_str = "" "" "" "" @@ -809,10 +809,10 @@ static void check_icu_iter2(void) static void check_icu_iter3(void) { UErrorCode status = U_ZERO_ERROR; - struct icu_chain * chain = 0; + struct icu_chain *chain = 0; xmlNode *xml_node; - const char * xml_str = + const char *xml_str = "\n" "\n" "\n" @@ -850,10 +850,10 @@ static void check_icu_iter3(void) static void check_icu_iter4(void) { UErrorCode status = U_ZERO_ERROR; - struct icu_chain * chain = 0; + struct icu_chain *chain = 0; xmlNode *xml_node; - const char * xml_str = "" + const char *xml_str = "" "" "" ""