diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/util_str.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 65a616ad41..2c0cae1d73 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1208,6 +1208,12 @@ char *strchr_m(const char *src, char c) smb_ucs2_t *p; const char *s; + /* characters below 0x3F are guaranteed to not appear in + non-initial position in multi-byte charsets */ + if ((c & 0xC0) == 0) { + return strchr(s, c); + } + /* this is quite a common operation, so we want it to be fast. We optimise for the ascii case, knowing that all our supported multi-byte character sets are ascii-compatible @@ -1237,6 +1243,12 @@ char *strchr_m(const char *src, char c) char *strrchr_m(const char *s, char c) { + /* characters below 0x3F are guaranteed to not appear in + non-initial position in multi-byte charsets */ + if ((c & 0xC0) == 0) { + return strrchr(s, c); + } + /* this is quite a common operation, so we want it to be fast. We optimise for the ascii case, knowing that all our supported multi-byte character sets are ascii-compatible |