diff options
author | Jeremy Allison <jra@samba.org> | 2003-07-02 20:01:51 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-07-02 20:01:51 +0000 |
commit | af4d65889420eb3bb71be67d619dbc0c62e21101 (patch) | |
tree | 25dc0166e23606c72c4426d18aaa82744ef0b0f9 /source3/lib/util_unistr.c | |
parent | 93e995159f843e7f6acdbc33d1f329844e1a9973 (diff) | |
download | samba-af4d65889420eb3bb71be67d619dbc0c62e21101.tar.gz samba-af4d65889420eb3bb71be67d619dbc0c62e21101.tar.bz2 samba-af4d65889420eb3bb71be67d619dbc0c62e21101.zip |
Added fix for Japanese case names in statcache - these can change
size on upper casing. Based on patch from monyo@home.monyo.com.
Jeremy.
(This used to be commit 72e382e99b92666acdaf50a040b14aa16d48b80d)
Diffstat (limited to 'source3/lib/util_unistr.c')
-rw-r--r-- | source3/lib/util_unistr.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 5df0828295..ae000fba02 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -391,8 +391,9 @@ size_t strnlen_w(const smb_ucs2_t *src, size_t max) } /******************************************************************* -wide strchr() + Wide strchr(). ********************************************************************/ + smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c) { while (*s != 0) { @@ -409,6 +410,10 @@ smb_ucs2_t *strchr_wa(const smb_ucs2_t *s, char c) return strchr_w(s, UCS2_CHAR(c)); } +/******************************************************************* + Wide strrchr(). +********************************************************************/ + smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c) { const smb_ucs2_t *p = s; @@ -422,8 +427,30 @@ smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c) } /******************************************************************* -wide strstr() + Wide version of strrchr that returns after doing strrchr 'n' times. ********************************************************************/ + +smb_ucs2_t *strnrchr_w(const smb_ucs2_t *s, smb_ucs2_t c, unsigned int n) +{ + const smb_ucs2_t *p = s; + int len = strlen_w(s); + if (len == 0 || !n) + return NULL; + p += (len - 1); + do { + if (c == *p) + n--; + + if (!n) + return (smb_ucs2_t *)p; + } while (p-- != s); + return NULL; +} + +/******************************************************************* + Wide strstr(). +********************************************************************/ + smb_ucs2_t *strstr_w(const smb_ucs2_t *s, const smb_ucs2_t *ins) { smb_ucs2_t *r; |