diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2010-02-28 20:56:42 +0100 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2010-02-28 21:03:16 +0100 |
commit | a06c771d2b931f0e5ae600d22a3e07208f16b0a3 (patch) | |
tree | b7980a521dcbd8fea67954aaf7d19fa962090741 /dbus/dbus-string.c | |
parent | 46df8b52d970d7c4ec3a61b5c696a05d0cb55f5d (diff) | |
download | dbus-a06c771d2b931f0e5ae600d22a3e07208f16b0a3.tar.gz |
_dbus_string_tolower_ascii(): new function, reviewed by Colin Walters.
Diffstat (limited to 'dbus/dbus-string.c')
-rw-r--r-- | dbus/dbus-string.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 62a64609..6a307b82 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -2760,6 +2760,37 @@ _dbus_string_validate_ascii (const DBusString *str, } /** + * Converts the given range of the string to lower case. + * + * @param str the string + * @param start first byte index to convert + * @param len number of bytes to convert + */ +void +_dbus_string_tolower_ascii (const DBusString *str, + int start, + int len) +{ + unsigned char *s; + unsigned char *end; + DBUS_STRING_PREAMBLE (str); + _dbus_assert (start >= 0); + _dbus_assert (start <= real->len); + _dbus_assert (len >= 0); + _dbus_assert (len <= real->len - start); + + s = real->str + start; + end = s + len; + + while (s != end) + { + if (*s >= 'A' && *s <= 'Z') + *s += 'a' - 'A'; + ++s; + } +} + +/** * Checks that the given range of the string is valid UTF-8. If the * given range is not entirely contained in the string, returns * #FALSE. If the string contains any nul bytes in the given range, |