X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-string.c;h=e3766aad46a61e84a47595689ce7f213605d1719;hb=757b80b9711d9733798c927495d74c7323e95400;hp=6658abd4de9e66489989b47986b6abca99b469ca;hpb=68ecce599a176bb6ccf39ceb8382300a254d710b;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 6658abd..e3766aa 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -957,54 +957,6 @@ do { \ } while (0) #endif /* DBUS_HAVE_INT64 */ -#ifdef DBUS_BUILD_TESTS -/** - * Appends 4 bytes aligned on a 4 byte boundary - * with any alignment padding initialized to 0. - * - * @param str the DBusString - * @param octets 4 bytes to append - * @returns #FALSE if not enough memory. - */ -dbus_bool_t -_dbus_string_append_4_aligned (DBusString *str, - const unsigned char octets[4]) -{ - DBUS_STRING_PREAMBLE (str); - - if (!align_length_then_lengthen (str, 4, 4)) - return FALSE; - - ASSIGN_4_OCTETS (real->str + (real->len - 4), octets); - - return TRUE; -} -#endif /* DBUS_BUILD_TESTS */ - -#ifdef DBUS_BUILD_TESTS -/** - * Appends 8 bytes aligned on an 8 byte boundary - * with any alignment padding initialized to 0. - * - * @param str the DBusString - * @param octets 8 bytes to append - * @returns #FALSE if not enough memory. - */ -dbus_bool_t -_dbus_string_append_8_aligned (DBusString *str, - const unsigned char octets[8]) -{ - DBUS_STRING_PREAMBLE (str); - - if (!align_length_then_lengthen (str, 8, 8)) - return FALSE; - - ASSIGN_8_OCTETS (real->str + (real->len - 8), octets); - - return TRUE; -} -#endif /* DBUS_BUILD_TESTS */ - /** * Inserts 2 bytes aligned on a 2 byte boundary * with any alignment padding initialized to 0. @@ -1212,79 +1164,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, @@ -1698,68 +1577,11 @@ _dbus_string_split_on_byte (DBusString *source, * * The second check covers surrogate pairs (category Cs). * - * The last two checks cover "Noncharacter": defined as: - * "A code point that is permanently reserved for - * internal use, and that should never be interchanged. In - * Unicode 3.1, these consist of the values U+nFFFE and U+nFFFF - * (where n is from 0 to 10_16) and the values U+FDD0..U+FDEF." - * * @param Char the character */ #define UNICODE_VALID(Char) \ ((Char) < 0x110000 && \ - (((Char) & 0xFFFFF800) != 0xD800) && \ - ((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 */ + (((Char) & 0xFFFFF800) != 0xD800)) /** * Finds the given substring in the string, @@ -2352,7 +2174,6 @@ _dbus_string_equal_c_str (const DBusString *a, return TRUE; } -#ifdef DBUS_BUILD_TESTS /** * Checks whether a string starts with the given C string. * @@ -2388,7 +2209,6 @@ _dbus_string_starts_with_c_str (const DBusString *a, else return FALSE; } -#endif /* DBUS_BUILD_TESTS */ /** * Appends a two-character hex digit to a string, where the hex digit