svn commit: samba r4267 - in branches/SAMBA_4_0/source/lib: .
tridge at samba.org
tridge at samba.org
Sun Dec 19 00:13:25 GMT 2004
Author: tridge
Date: 2004-12-19 00:13:24 +0000 (Sun, 19 Dec 2004)
New Revision: 4267
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4267
Log:
fixed the charset code to use the builtin_functions.
Jelmer, please be more careful about testing new code. Your charsets
register change completely broke charset handling on systems without
iconv, and slowed every system down as the builtins were not being
used at all.
Modified:
branches/SAMBA_4_0/source/lib/iconv.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/iconv.c
===================================================================
--- branches/SAMBA_4_0/source/lib/iconv.c 2004-12-19 00:11:18 UTC (rev 4266)
+++ branches/SAMBA_4_0/source/lib/iconv.c 2004-12-19 00:13:24 UTC (rev 4267)
@@ -67,8 +67,7 @@
{"UTF8", utf8_pull, utf8_push},
{"UTF-8", utf8_pull, utf8_push},
{"ASCII", ascii_pull, ascii_push},
- {"UCS2-HEX", ucs2hex_pull, ucs2hex_push},
- {NULL, NULL, NULL}
+ {"UCS2-HEX", ucs2hex_pull, ucs2hex_push}
};
static struct charset_functions *charsets = NULL;
@@ -161,10 +160,8 @@
smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
{
smb_iconv_t ret;
- struct charset_functions *from, *to;
-
- from = charsets;
- to = charsets;
+ const struct charset_functions *from=NULL, *to=NULL;
+ int i;
ret = (smb_iconv_t)talloc_named(NULL, sizeof(*ret),
"iconv(%s,%s)", tocode, fromcode);
@@ -180,16 +177,27 @@
return ret;
}
- while (from) {
- if (strcasecmp(from->name, fromcode) == 0) break;
- from = from->next;
+ for (i=0;i<ARRAY_SIZE(builtin_functions);i++) {
+ if (strcasecmp(fromcode, builtin_functions[i].name) == 0) {
+ from = &builtin_functions[i];
+ }
+ if (strcasecmp(tocode, builtin_functions[i].name) == 0) {
+ to = &builtin_functions[i];
+ }
}
- while (to) {
- if (strcasecmp(to->name, tocode) == 0) break;
- to = to->next;
+ if (from == NULL) {
+ for (from=charsets; from; from=from->next) {
+ if (strcasecmp(from->name, fromcode) == 0) break;
+ }
}
+ if (to == NULL) {
+ for (to=charsets; to; to=to->next) {
+ if (strcasecmp(to->name, tocode) == 0) break;
+ }
+ }
+
#ifdef HAVE_NATIVE_ICONV
if (!from) {
ret->pull = sys_iconv;
More information about the samba-cvs
mailing list