From: tomo Date: Sun, 30 Oct 2011 20:36:01 +0000 (+0000) Subject: (chise_char_load_decomposition): New function. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b102ba86e099aa861cba5e5a75b7a11cf3a7b699;p=chise%2Flibchise.git (chise_char_load_decomposition): New function. --- diff --git a/chise.c b/chise.c index 476a005..dbdbaf3 100644 --- a/chise.c +++ b/chise.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003,2004,2005 MORIOKA Tomohiko +/* Copyright (C) 2003,2004,2005,2011 MORIOKA Tomohiko This file is part of the CHISE Library. The CHISE Library is free software; you can redistribute it and/or @@ -152,6 +152,46 @@ chise_char_load_feature_value (CHISE_Char_ID cid, return concord_obj_get_feature_value_string (key_buf, feature, valdatum); } +int +chise_char_load_decomposition (CHISE_Char_ID cid, + CHISE_Feature feature, + CHISE_Char_ID* base_char, CHISE_Char_ID* comb_char) +{ + unsigned char key_buf[8]; + CHISE_Value value; + int status; + unsigned char* vp; + unsigned char* vp_ret; + int len; + + chise_format_char_id (cid, key_buf, 8); + if ( status = concord_obj_get_feature_value_string (key_buf, feature, &value) ) + return status; + len = chise_value_size (&value); + if ( len < (1 + 2 + 1 + 2 + 1) ) + return -1; + + vp = chise_value_data (&value); + if ( *vp++ != '(' ) + return -1; + len--; + + if ( ( vp_ret = memchr (vp, ' ', len) ) == NULL ) + return -1; + *base_char = chise_char_id_parse_c_string (vp, vp_ret - vp + 1); + if ( *base_char == -1 ) + return -1; + vp = vp_ret + 1; + len -= vp - chise_value_data (&value); + if ( len <= 1 ) + return -1; + + *comb_char = chise_char_id_parse_c_string (vp, len); + if ( *comb_char == -1 ) + return -1; + return 0; +} + unsigned char* chise_char_gets_feature_value (CHISE_Char_ID cid, CHISE_Feature feature,