From 5e2edc122c799b42f75401926dc7a47334a3d73d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 22 Jun 2011 15:07:23 +0100 Subject: [PATCH] _dbus_string_append_unichar, _dbus_string_get_unichar: remove These are unused (except by their regression test!) and not visible to external callers. --- dbus/dbus-string-util.c | 16 ------ dbus/dbus-string.c | 122 ----------------------------------------------- dbus/dbus-string.h | 6 -- 3 files changed, 0 insertions(+), 144 deletions(-) diff --git a/dbus/dbus-string-util.c b/dbus/dbus-string-util.c index 421ac1b..1cd12a3 100644 --- a/dbus/dbus-string-util.c +++ b/dbus/dbus-string-util.c @@ -546,22 +546,6 @@ _dbus_string_test (void) _dbus_string_free (&str); _dbus_string_free (&other); - /* Check append/get unichar */ - - if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); - - ch = 0; - if (!_dbus_string_append_unichar (&str, 0xfffc)) - _dbus_assert_not_reached ("failed to append unichar"); - - _dbus_string_get_unichar (&str, 0, &ch, &i); - - _dbus_assert (ch == 0xfffc); - _dbus_assert (i == _dbus_string_get_length (&str)); - - _dbus_string_free (&str); - /* Check insert/set/get byte */ if (!_dbus_string_init (&str)) diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 6658abd..b6ac9e5 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -1212,79 +1212,6 @@ _dbus_string_append_byte (DBusString *str, return TRUE; } -#ifdef DBUS_BUILD_TESTS -/** - * Appends a single Unicode character, encoding the character - * in UTF-8 format. - * - * @param str the string - * @param ch the Unicode character - */ -dbus_bool_t -_dbus_string_append_unichar (DBusString *str, - dbus_unichar_t ch) -{ - int len; - int first; - int i; - unsigned char *out; - - DBUS_STRING_PREAMBLE (str); - - /* this code is from GLib but is pretty standard I think */ - - len = 0; - - if (ch < 0x80) - { - first = 0; - len = 1; - } - else if (ch < 0x800) - { - first = 0xc0; - len = 2; - } - else if (ch < 0x10000) - { - first = 0xe0; - len = 3; - } - else if (ch < 0x200000) - { - first = 0xf0; - len = 4; - } - else if (ch < 0x4000000) - { - first = 0xf8; - len = 5; - } - else - { - first = 0xfc; - len = 6; - } - - if (len > (_DBUS_STRING_MAX_LENGTH - real->len)) - return FALSE; /* real->len + len would overflow */ - - if (!set_length (real, real->len + len)) - return FALSE; - - out = real->str + (real->len - len); - - for (i = len - 1; i > 0; --i) - { - out[i] = (ch & 0x3f) | 0x80; - ch >>= 6; - } - out[0] = ch | first; - - return TRUE; -} -#endif /* DBUS_BUILD_TESTS */ - static void delete (DBusRealString *real, int start, @@ -1712,55 +1639,6 @@ _dbus_string_split_on_byte (DBusString *source, ((Char) < 0xFDD0 || (Char) > 0xFDEF) && \ ((Char) & 0xFFFE) != 0xFFFE) -#ifdef DBUS_BUILD_TESTS -/** - * Gets a unicode character from a UTF-8 string. Does no validation; - * you must verify that the string is valid UTF-8 in advance and must - * pass in the start of a character. - * - * @param str the string - * @param start the start of the UTF-8 character. - * @param ch_return location to return the character - * @param end_return location to return the byte index of next character - */ -void -_dbus_string_get_unichar (const DBusString *str, - int start, - dbus_unichar_t *ch_return, - int *end_return) -{ - int i, mask, len; - dbus_unichar_t result; - unsigned char c; - unsigned char *p; - DBUS_CONST_STRING_PREAMBLE (str); - _dbus_assert (start >= 0); - _dbus_assert (start <= real->len); - - if (ch_return) - *ch_return = 0; - if (end_return) - *end_return = real->len; - - mask = 0; - p = real->str + start; - c = *p; - - UTF8_COMPUTE (c, mask, len); - if (len == 0) - return; - UTF8_GET (result, p, i, mask, len); - - if (result == (dbus_unichar_t)-1) - return; - - if (ch_return) - *ch_return = result; - if (end_return) - *end_return = start + len; -} -#endif /* DBUS_BUILD_TESTS */ - /** * Finds the given substring in the string, * returning #TRUE and filling in the byte index diff --git a/dbus/dbus-string.h b/dbus/dbus-string.h index 2f1fe87..10f07e3 100644 --- a/dbus/dbus-string.h +++ b/dbus/dbus-string.h @@ -154,8 +154,6 @@ dbus_bool_t _dbus_string_append_double (DBusString *str, double value); dbus_bool_t _dbus_string_append_byte (DBusString *str, unsigned char byte); -dbus_bool_t _dbus_string_append_unichar (DBusString *str, - dbus_unichar_t ch); dbus_bool_t _dbus_string_append_4_aligned (DBusString *str, const unsigned char octets[4]); dbus_bool_t _dbus_string_append_8_aligned (DBusString *str, @@ -208,10 +206,6 @@ dbus_bool_t _dbus_string_replace_len (const DBusString *source, dbus_bool_t _dbus_string_split_on_byte (DBusString *source, unsigned char byte, DBusString *tail); -void _dbus_string_get_unichar (const DBusString *str, - int start, - dbus_unichar_t *ch_return, - int *end_return); dbus_bool_t _dbus_string_parse_int (const DBusString *str, int start, long *value_return, -- 1.7.5.4