diff options
author | Andrew Bartlett <abartlet@samba.org> | 2008-08-25 08:27:06 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2008-08-25 08:27:06 +1000 |
commit | 9eacc3a8f396e74b0deed193f0f2ecffa3ba8e93 (patch) | |
tree | 28d045a42a9b09b42e34b9009a6635026ff3d9c8 /source4/lib/charset | |
parent | 5631ebaf78fee35880aafe29578b8925c655e5f4 (diff) | |
parent | a22b9d648553e5e7e0ee19606d9bceeb3b356241 (diff) | |
download | samba-9eacc3a8f396e74b0deed193f0f2ecffa3ba8e93.tar.gz samba-9eacc3a8f396e74b0deed193f0f2ecffa3ba8e93.tar.bz2 samba-9eacc3a8f396e74b0deed193f0f2ecffa3ba8e93.zip |
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-local
(This used to be commit a555334db67527b57bc6172e3d08f65caf1e6760)
Diffstat (limited to 'source4/lib/charset')
-rw-r--r-- | source4/lib/charset/charset.h | 1 | ||||
-rw-r--r-- | source4/lib/charset/iconv.c | 7 | ||||
-rw-r--r-- | source4/lib/charset/util_unistr.c | 17 |
3 files changed, 22 insertions, 3 deletions
diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index baa7df532b..c49745cd7f 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -97,6 +97,7 @@ size_t count_chars_w(const char *s, char c); void strupper_m(char *s); void strlower_m(char *s); char *strupper_talloc(TALLOC_CTX *ctx, const char *src); +char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n); char *strlower_talloc(TALLOC_CTX *ctx, const char *src); bool strhasupper(const char *string); bool strhaslower(const char *string); diff --git a/source4/lib/charset/iconv.c b/source4/lib/charset/iconv.c index 4f4bc8fd2d..d4f930b462 100644 --- a/source4/lib/charset/iconv.c +++ b/source4/lib/charset/iconv.c @@ -469,6 +469,9 @@ static size_t iconv_copy(void *cd, const char **inbuf, size_t *inbytesleft, return 0; } +/* + this takes a UTF8 sequence and produces a UTF16 sequence + */ static size_t utf8_pull(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { @@ -586,6 +589,10 @@ error: return -1; } + +/* + this takes a UTF16 sequence and produces a UTF8 sequence + */ static size_t utf8_push(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c index 19a4f3236c..09ec7b0471 100644 --- a/source4/lib/charset/util_unistr.c +++ b/source4/lib/charset/util_unistr.c @@ -518,8 +518,9 @@ _PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src) /** Convert a string to UPPER case, allocated with talloc + source length limited to n bytes **/ -_PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src) +_PUBLIC_ char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n) { size_t size=0; char *dest; @@ -531,12 +532,12 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src) /* this takes advantage of the fact that upper/lower can't change the length of a character by more than 1 byte */ - dest = talloc_array(ctx, char, 2*(strlen(src))+1); + dest = talloc_array(ctx, char, 2*(n+1)); if (dest == NULL) { return NULL; } - while (*src) { + while (*src && n--) { size_t c_size; codepoint_t c = next_codepoint(iconv_convenience, src, &c_size); src += c_size; @@ -562,6 +563,16 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src) } /** + Convert a string to UPPER case, allocated with talloc +**/ +_PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src) +{ + return strupper_talloc_n(ctx, src, src?strlen(src):0); +} + + + +/** Convert a string to lower case. **/ _PUBLIC_ void strlower_m(char *s) |