summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-09-01 17:39:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:34 -0500
commitc5b11b56aa3c54193f7c16356f1a944354c89eb1 (patch)
treebadb0d4e0a3382ef0402b6f618a88885f145aac6
parentd9a1327474853c62e7059edcf9e7772eb574a501 (diff)
downloadsamba-c5b11b56aa3c54193f7c16356f1a944354c89eb1.tar.gz
samba-c5b11b56aa3c54193f7c16356f1a944354c89eb1.tar.bz2
samba-c5b11b56aa3c54193f7c16356f1a944354c89eb1.zip
r2175: Fix for #1546 from fumiya@samba.gr.jp. Preserve errno in MB strupper_m/strlower_m.
Jeremy. (This used to be commit 615aa6e914e6bc3691156a3b80244fc98d8ecc56)
-rw-r--r--source3/lib/util_str.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 250d6ed6a0..6eee62c14a 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -1391,6 +1391,7 @@ char *strstr_m(const char *src, const char *findstr)
void strlower_m(char *s)
{
size_t len;
+ int errno_save;
/* this is quite a common operation, so we want it to be
fast. We optimise for the ascii case, knowing that all our
@@ -1408,11 +1409,13 @@ void strlower_m(char *s)
/* I assume that lowercased string takes the same number of bytes
* as source string even in UTF-8 encoding. (VIV) */
len = strlen(s) + 1;
+ errno_save = errno;
errno = 0;
unix_strlower(s,len,s,len);
/* Catch mb conversion errors that may not terminate. */
if (errno)
s[len-1] = '\0';
+ errno = errno_save;
}
/**
@@ -1422,6 +1425,7 @@ void strlower_m(char *s)
void strupper_m(char *s)
{
size_t len;
+ int errno_save;
/* this is quite a common operation, so we want it to be
fast. We optimise for the ascii case, knowing that all our
@@ -1439,11 +1443,13 @@ void strupper_m(char *s)
/* I assume that lowercased string takes the same number of bytes
* as source string even in multibyte encoding. (VIV) */
len = strlen(s) + 1;
+ errno_save = errno;
errno = 0;
unix_strupper(s,len,s,len);
/* Catch mb conversion errors that may not terminate. */
if (errno)
s[len-1] = '\0';
+ errno = errno_save;
}
/**