summaryrefslogtreecommitdiff
path: root/source4/lib/charset/util_unistr.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-08-22 17:37:43 +1000
committerAndrew Tridgell <tridge@samba.org>2008-08-22 17:37:43 +1000
commit0a27ff953e17670aecc7aedb56c0f872cc4bb75d (patch)
tree18ed167d94e1a50acf04bc22fc6d8f01bf7f1a5f /source4/lib/charset/util_unistr.c
parent8acc7f7da7718c7750387c1043391618be46e15b (diff)
parentcc43037f19056ed24d7fffa54456d597c63ad105 (diff)
downloadsamba-0a27ff953e17670aecc7aedb56c0f872cc4bb75d.tar.gz
samba-0a27ff953e17670aecc7aedb56c0f872cc4bb75d.tar.bz2
samba-0a27ff953e17670aecc7aedb56c0f872cc4bb75d.zip
Merge branch 'abartlet-4-0-local' into v4-0-test
(This used to be commit 469fac2669991b130dec219e1a109a8b2ce224be)
Diffstat (limited to 'source4/lib/charset/util_unistr.c')
-rw-r--r--source4/lib/charset/util_unistr.c17
1 files changed, 14 insertions, 3 deletions
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)