diff options
Diffstat (limited to 'src/hb-common.cc')
-rw-r--r-- | src/hb-common.cc | 98 |
1 files changed, 42 insertions, 56 deletions
diff --git a/src/hb-common.cc b/src/hb-common.cc index 140ee0a..05a1f9c 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -57,14 +57,14 @@ _hb_options_init (void) /** * hb_tag_from_string: - * @str: (array length=len) (element-type uint8_t): + * @str: (array length=len): * @len: * * * * Return value: * - * Since: 0.9.2 + * Since: 1.0 **/ hb_tag_t hb_tag_from_string (const char *str, int len) @@ -92,7 +92,7 @@ hb_tag_from_string (const char *str, int len) * * * - * Since: 0.9.5 + * Since: 1.0 **/ void hb_tag_to_string (hb_tag_t tag, char *buf) @@ -115,14 +115,14 @@ const char direction_strings[][4] = { /** * hb_direction_from_string: - * @str: (array length=len) (element-type uint8_t): + * @str: (array length=len): * @len: * * * * Return value: * - * Since: 0.9.2 + * Since: 1.0 **/ hb_direction_t hb_direction_from_string (const char *str, int len) @@ -149,7 +149,7 @@ hb_direction_from_string (const char *str, int len) * * Return value: (transfer none): * - * Since: 0.9.2 + * Since: 1.0 **/ const char * hb_direction_to_string (hb_direction_t direction) @@ -179,7 +179,7 @@ static const char canon_map[256] = { 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, 0 }; -static bool +static hb_bool_t lang_equal (hb_language_t v1, const void *v2) { @@ -281,51 +281,46 @@ retry: /** * hb_language_from_string: - * @str: (array length=len) (element-type uint8_t): a string representing - * ISO 639 language code - * @len: length of the @str, or -1 if it is %NULL-terminated. + * @str: (array length=len): + * @len: * - * Converts @str representing an ISO 639 language code to the corresponding - * #hb_language_t. + * * - * Return value: (transfer none): - * The #hb_language_t corresponding to the ISO 639 language code. + * Return value: * - * Since: 0.9.2 + * Since: 1.0 **/ hb_language_t hb_language_from_string (const char *str, int len) { + char strbuf[64]; + if (!str || !len || !*str) return HB_LANGUAGE_INVALID; - hb_language_item_t *item = NULL; if (len >= 0) { /* NUL-terminate it. */ - char strbuf[64]; len = MIN (len, (int) sizeof (strbuf) - 1); memcpy (strbuf, str, len); strbuf[len] = '\0'; - item = lang_find_or_insert (strbuf); + str = strbuf; } - else - item = lang_find_or_insert (str); + + hb_language_item_t *item = lang_find_or_insert (str); return likely (item) ? item->lang : HB_LANGUAGE_INVALID; } /** * hb_language_to_string: - * @language: an #hb_language_t to convert. + * @language: * - * See hb_language_from_string(). + * * - * Return value: (transfer none): - * A %NULL-terminated string representing the @language. Must not be freed by - * the caller. + * Return value: (transfer none): * - * Since: 0.9.2 + * Since: 1.0 **/ const char * hb_language_to_string (hb_language_t language) @@ -339,9 +334,9 @@ hb_language_to_string (hb_language_t language) * * * - * Return value: (transfer none): + * Return value: * - * Since: 0.9.2 + * Since: 1.0 **/ hb_language_t hb_language_get_default (void) @@ -362,14 +357,13 @@ hb_language_get_default (void) /** * hb_script_from_iso15924_tag: - * @tag: an #hb_tag_t representing an ISO 15924 tag. + * @tag: * - * Converts an ISO 15924 script tag to a corresponding #hb_script_t. + * * * Return value: - * An #hb_script_t corresponding to the ISO 15924 tag. * - * Since: 0.9.2 + * Since: 1.0 **/ hb_script_t hb_script_from_iso15924_tag (hb_tag_t tag) @@ -407,35 +401,30 @@ hb_script_from_iso15924_tag (hb_tag_t tag) /** * hb_script_from_string: - * @str: (array length=len) (element-type uint8_t): a string representing an - * ISO 15924 tag. - * @len: length of the @str, or -1 if it is %NULL-terminated. + * @s: (array length=len): + * @len: * - * Converts a string @str representing an ISO 15924 script tag to a - * corresponding #hb_script_t. Shorthand for hb_tag_from_string() then - * hb_script_from_iso15924_tag(). + * * * Return value: - * An #hb_script_t corresponding to the ISO 15924 tag. * - * Since: 0.9.2 + * Since: 1.0 **/ hb_script_t -hb_script_from_string (const char *str, int len) +hb_script_from_string (const char *s, int len) { - return hb_script_from_iso15924_tag (hb_tag_from_string (str, len)); + return hb_script_from_iso15924_tag (hb_tag_from_string (s, len)); } /** * hb_script_to_iso15924_tag: - * @script: an #hb_script_ to convert. + * @script: * - * See hb_script_from_iso15924_tag(). + * * - * Return value: - * An #hb_tag_t representing an ISO 15924 script tag. + * Return value: * - * Since: 0.9.2 + * Since: 1.0 **/ hb_tag_t hb_script_to_iso15924_tag (hb_script_t script) @@ -451,7 +440,7 @@ hb_script_to_iso15924_tag (hb_script_t script) * * Return value: * - * Since: 0.9.2 + * Since: 1.0 **/ hb_direction_t hb_script_get_horizontal_direction (hb_script_t script) @@ -504,9 +493,6 @@ hb_script_get_horizontal_direction (hb_script_t script) case HB_SCRIPT_PALMYRENE: case HB_SCRIPT_PSALTER_PAHLAVI: - /* Unicode-8.0 additions */ - case HB_SCRIPT_OLD_HUNGARIAN: - return HB_DIRECTION_RTL; } @@ -532,7 +518,7 @@ hb_user_data_array_t::set (hb_user_data_key_t *key, } } hb_user_data_item_t item = {key, data, destroy}; - bool ret = !!items.replace_or_insert (item, lock, (bool) replace); + bool ret = !!items.replace_or_insert (item, lock, replace); return ret; } @@ -540,7 +526,7 @@ hb_user_data_array_t::set (hb_user_data_key_t *key, void * hb_user_data_array_t::get (hb_user_data_key_t *key) { - hb_user_data_item_t item = {NULL, NULL, NULL}; + hb_user_data_item_t item = {NULL }; return items.find (key, &item, lock) ? item.data : NULL; } @@ -556,7 +542,7 @@ hb_user_data_array_t::get (hb_user_data_key_t *key) * * Returns library version as three integer components. * - * Since: 0.9.2 + * Since: 1.0 **/ void hb_version (unsigned int *major, @@ -575,7 +561,7 @@ hb_version (unsigned int *major, * * Return value: library version string. * - * Since: 0.9.2 + * Since: 1.0 **/ const char * hb_version_string (void) @@ -593,7 +579,7 @@ hb_version_string (void) * * Return value: * - * Since: 0.9.30 + * Since: 1.0 **/ hb_bool_t hb_version_atleast (unsigned int major, |