Add version of next_codepoint without iconv_convenience.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 14:00:43 +0000 (16:00 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 14:00:43 +0000 (16:00 +0200)
lib/util/charset/charcnv.c
lib/util/charset/charset.h
lib/util/charset/tests/iconv.c
lib/util/charset/util_unistr.c
lib/util/ms_fnmatch.c
source4/ntvfs/posix/pvfs_rename.c
source4/ntvfs/posix/pvfs_resolve.c
source4/ntvfs/posix/pvfs_shortname.c
source4/ntvfs/posix/pvfs_util.c

index d63a9ce194d4f5ba59cf740643ceee2b89fa9649..2ae16c3250a9aa88d760452619ad20411aa5751e 100644 (file)
@@ -321,7 +321,7 @@ _PUBLIC_ ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx,
 
   return INVALID_CODEPOINT if the next character cannot be converted
 */
-_PUBLIC_ codepoint_t next_codepoint(struct smb_iconv_convenience *ic, 
+_PUBLIC_ codepoint_t next_codepoint_convenience(struct smb_iconv_convenience *ic, 
                                    const char *str, size_t *size)
 {
        /* it cannot occupy more than 4 bytes in UTF16 format */
index 51e019317316a89c3fcc049acb7ccfda8a517d64..f8b3f65548c20cdb8412351c0df6041e342e1099 100644 (file)
@@ -124,8 +124,10 @@ ssize_t convert_string(charset_t from, charset_t to,
 
 extern struct smb_iconv_convenience *global_iconv_convenience;
 
+_PUBLIC_ codepoint_t next_codepoint(const char *str, size_t *size);
+
 /* codepoints */
-codepoint_t next_codepoint(struct smb_iconv_convenience *ic, 
+codepoint_t next_codepoint_convenience(struct smb_iconv_convenience *ic, 
                            const char *str, size_t *size);
 ssize_t push_codepoint(struct smb_iconv_convenience *ic, 
                                char *str, codepoint_t c);
index aeb42c2fa13f84cc4a0c040bfe84282880b391f9..40e223b28f5f61f22bb8d9cecb055d0e8389a8b8 100644 (file)
@@ -299,7 +299,7 @@ static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint)
        buf[size+2] = random();
        buf[size+3] = random();
 
-       c = next_codepoint(lp_iconv_convenience(tctx->lp_ctx), (char *)buf, &size2);
+       c = next_codepoint_convenience(lp_iconv_convenience(tctx->lp_ctx), (char *)buf, &size2);
 
        torture_assert(tctx, c == codepoint, 
                       talloc_asprintf(tctx, 
index a40b4298a42d3b397d812a5d2b85181de1a9a962..c90b675ded67a8f87b0e16d1203b3381ceea7776 100644 (file)
@@ -45,8 +45,8 @@ _PUBLIC_ int strcasecmp_m(const char *s1, const char *s2)
        if (s2 == NULL) return 1;
 
        while (*s1 && *s2) {
-               c1 = next_codepoint(iconv_convenience, s1, &size1);
-               c2 = next_codepoint(iconv_convenience, s2, &size2);
+               c1 = next_codepoint_convenience(iconv_convenience, s1, &size1);
+               c2 = next_codepoint_convenience(iconv_convenience, s2, &size2);
 
                s1 += size1;
                s2 += size2;
@@ -132,8 +132,8 @@ _PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n)
        while (*s1 && *s2 && n) {
                n--;
 
-               c1 = next_codepoint(iconv_convenience, s1, &size1);
-               c2 = next_codepoint(iconv_convenience, s2, &size2);
+               c1 = next_codepoint_convenience(iconv_convenience, s1, &size1);
+               c2 = next_codepoint_convenienceconv_convenience, s2, &size2);
 
                s1 += size1;
                s2 += size2;
@@ -193,7 +193,7 @@ _PUBLIC_ void string_replace_m(char *s, char oldc, char newc)
        struct smb_iconv_convenience *ic = get_iconv_convenience();
        while (s && *s) {
                size_t size;
-               codepoint_t c = next_codepoint(ic, s, &size);
+               codepoint_t c = next_codepoint_convenience(ic, s, &size);
                if (c == oldc) {
                        *s = newc;
                }
@@ -314,7 +314,7 @@ _PUBLIC_ char *strchr_m(const char *s, char c)
 
        while (*s) {
                size_t size;
-               codepoint_t c2 = next_codepoint(ic, s, &size);
+               codepoint_t c2 = next_codepoint_convenience(ic, s, &size);
                if (c2 == c) {
                        return discard_const_p(char, s);
                }
@@ -365,7 +365,7 @@ _PUBLIC_ bool strhaslower(const char *string)
                codepoint_t s;
                codepoint_t t;
 
-               s = next_codepoint(ic, string, &c_size);
+               s = next_codepoint_convenience(ic, string, &c_size);
                string += c_size;
 
                t = toupper_m(s);
@@ -389,7 +389,7 @@ _PUBLIC_ bool strhasupper(const char *string)
                codepoint_t s;
                codepoint_t t;
 
-               s = next_codepoint(ic, string, &c_size);
+               s = next_codepoint_convenience(ic, string, &c_size);
                string += c_size;
 
                t = tolower_m(s);
@@ -420,7 +420,7 @@ _PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
 
        while (*src) {
                size_t c_size;
-               codepoint_t c = next_codepoint(iconv_convenience, src, &c_size);
+               codepoint_t c = next_codepoint_convenience(iconv_convenience, src, &c_size);
                src += c_size;
 
                c = tolower_m(c);
@@ -531,7 +531,7 @@ _PUBLIC_ void strlower_m(char *s)
 
        while (*s) {
                size_t c_size, c_size2;
-               codepoint_t c = next_codepoint(iconv_convenience, s, &c_size);
+               codepoint_t c = next_codepoint_convenience(iconv_convenience, s, &c_size);
                c_size2 = push_codepoint(iconv_convenience, d, tolower_m(c));
                if (c_size2 > c_size) {
                        DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strlower_m\n",
@@ -570,7 +570,7 @@ _PUBLIC_ void strupper_m(char *s)
 
        while (*s) {
                size_t c_size, c_size2;
-               codepoint_t c = next_codepoint(iconv_convenience, s, &c_size);
+               codepoint_t c = next_codepoint_convenience(iconv_convenience, s, &c_size);
                c_size2 = push_codepoint(iconv_convenience, d, toupper_m(c));
                if (c_size2 > c_size) {
                        DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strupper_m\n",
@@ -594,7 +594,7 @@ _PUBLIC_ size_t count_chars_m(const char *s, char c)
 
        while (*s) {
                size_t size;
-               codepoint_t c2 = next_codepoint(ic, s, &size);
+               codepoint_t c2 = next_codepoint_convenience(ic, s, &size);
                if (c2 == c) count++;
                s += size;
        }
@@ -958,3 +958,9 @@ _PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx,
        return convert_string_talloc_convenience(ctx, get_iconv_convenience(),
                                                                                         from, to, src, srclen, dest);
 }
+
+
+_PUBLIC_ codepoint_t next_codepoint(const char *str, size_t *size)
+{
+       return next_codepoint_convenience(get_iconv_convenience(), str, size);
+}
index 5e04ec1f4bb2c749ed9e91c941cad33001f1183c..dde35268eb4b37f695fa32d6ca44577ee283cfd1 100644 (file)
@@ -64,9 +64,8 @@ static int ms_fnmatch_core(const char *p, const char *n,
        codepoint_t c, c2;
        int i;
        size_t size, size_n;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
-       while ((c = next_codepoint(iconv_convenience, p, &size))) {
+       while ((c = next_codepoint(p, &size))) {
                p += size;
 
                switch (c) {
@@ -76,7 +75,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
                                return null_match(p);
                        }
                        for (i=0; n[i]; i += size_n) {
-                               next_codepoint(iconv_convenience, n+i, &size_n);
+                               next_codepoint(n+i, &size_n);
                                if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) {
                                        return 0;
                                }
@@ -95,7 +94,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
                                return -1;
                        }
                        for (i=0; n[i]; i += size_n) {
-                               next_codepoint(iconv_convenience, n+i, &size_n);
+                               next_codepoint(n+i, &size_n);
                                if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0;
                                if (n+i == ldot) {
                                        if (ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0;
@@ -111,7 +110,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
                        if (! *n) {
                                return -1;
                        }
-                       next_codepoint(iconv_convenience, n, &size_n);
+                       next_codepoint(n, &size_n);
                        n += size_n;
                        break;
 
@@ -125,7 +124,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
                                break;
                        }
                        if (! *n) return null_match(p);
-                       next_codepoint(iconv_convenience, n, &size_n);
+                       next_codepoint(n, &size_n);
                        n += size_n;
                        break;
 
@@ -135,12 +134,12 @@ static int ms_fnmatch_core(const char *p, const char *n,
                                return 0;
                        }
                        if (*n != '.') return -1;
-                       next_codepoint(iconv_convenience, n, &size_n);
+                       next_codepoint(n, &size_n);
                        n += size_n;
                        break;
 
                default:
-                       c2 = next_codepoint(iconv_convenience, n, &size_n);
+                       c2 = next_codepoint(n, &size_n);
                        if (c != c2 && codepoint_cmpi(c, c2) != 0) {
                                return -1;
                        }
index d8ea5896e560f417870d9709e8dc76559ac0743d..475ce3048f77f3aecd0bff3c0691a67f5e230946 100644 (file)
@@ -115,8 +115,8 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx,
        while (*p2) {
                codepoint_t c1, c2;
                size_t c_size1, c_size2;
-               c1 = next_codepoint(iconv_convenience, p1, &c_size1);
-               c2 = next_codepoint(iconv_convenience, p2, &c_size2);
+               c1 = next_codepoint_convenience(iconv_convenience, p1, &c_size1);
+               c2 = next_codepoint_convenience(iconv_convenience, p2, &c_size2);
                if (c2 == '?') {
                        d += push_codepoint(iconv_convenience, d, c1);
                } else if (c2 == '*') {
index 0f19788b9731d0587f5d3e6b50bb7f7aefd326c1..1e13474b9e972cfd95277ef6fcc353aa6b908adb 100644 (file)
@@ -265,7 +265,7 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
 
        while (*p) {
                size_t c_size;
-               codepoint_t c = next_codepoint(lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx), p, &c_size);
+               codepoint_t c = next_codepoint_convenience(lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx), p, &c_size);
                switch (c) {
                case '\\':
                        if (name->has_wildcard) {
@@ -358,7 +358,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx,
        if (s == NULL) return NT_STATUS_NO_MEMORY;
 
        for (num_components=1, p=s; *p; p += c_size) {
-               c = next_codepoint(iconv_convenience, p, &c_size);
+               c = next_codepoint_convenience(iconv_convenience, p, &c_size);
                if (c == '\\') num_components++;
        }
 
@@ -370,7 +370,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx,
 
        components[0] = s;
        for (i=0, p=s; *p; p += c_size) {
-               c = next_codepoint(iconv_convenience, p, &c_size);
+               c = next_codepoint_convenience(iconv_convenience, p, &c_size);
                if (c == '\\') {
                        *p = 0;
                        components[++i] = p+1;
index 923887debd28e0e0271ac03eb0292cb640272f90..530def9163063dde0787e86a656f2e69459718cb 100644 (file)
@@ -390,7 +390,7 @@ static bool is_legal_name(struct pvfs_mangle_context *ctx, const char *name)
 {
        while (*name) {
                size_t c_size;
-               codepoint_t c = next_codepoint(ctx->iconv_convenience, name, &c_size);
+               codepoint_t c = next_codepoint_convenience(ctx->iconv_convenience, name, &c_size);
                if (c == INVALID_CODEPOINT) {
                        return false;
                }
index 2aea15fbd1d281f9bd937c1bb78c8ba52ad9b89b..8f95992e9a800ff9adb1da7250ef5f34969613a3 100644 (file)
@@ -179,11 +179,10 @@ uint32_t pvfs_name_hash(const char *key, size_t length)
        const uint32_t fnv1_prime = 0x01000193;
        const uint32_t fnv1_init = 0xa6b93095;
        uint32_t value = fnv1_init;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        while (*key && length--) {
                size_t c_size;
-               codepoint_t c = next_codepoint(iconv_convenience, key, &c_size);
+               codepoint_t c = next_codepoint(key, &c_size);
                c = toupper_m(c);
                 value *= fnv1_prime;
                 value ^= (uint32_t)c;