Date: Sat, 25 Apr 2009 06:18:54 +0400 From: Dmitry Marakasov <amdmi3@amdmi3.ru> To: freebsd-current@FreeBSD.org Subject: [patch] kernel iconv improvements Message-ID: <20090425021854.GA1361@hades.panopticon>
next in thread | raw e-mail | index | archive | help
Hi! Here's a little improvement for kernel iconv. It makes kiconv ignore case of character set names (and also store them in uppercase for consistency), so mount_cd9660 -C koi8-r /dev/acd0 /mnt mount_cd9660 -C KOI8-r /dev/acd0 /mnt mount_cd9660 -C KOI8-R /dev/acd0 /mnt mount_cd9660 -C Koi8-r /dev/acd0 /mnt will no longer lead to loading four similar charset conversion tables instead of one. See also ports/sysutils/kiconvtool - can it be integrated into the base system? The purpose of all this is more convenient and effective handling of filesystem charset conversion (especially for usermounts). --- iconv.c.patch begins here --- Index: sys/libkern/iconv.c =================================================================== --- sys/libkern/iconv.c (revision 191469) +++ sys/libkern/iconv.c (working copy) @@ -33,6 +33,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/ctype.h> #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> @@ -171,8 +172,8 @@ struct iconv_cspair *csp; TAILQ_FOREACH(csp, &iconv_cslist, cp_link) { - if (strcmp(csp->cp_to, to) == 0 && - strcmp(csp->cp_from, from) == 0) { + if (strcasecmp(csp->cp_to, to) == 0 && + strcasecmp(csp->cp_from, from) == 0) { if (cspp) *cspp = csp; return 0; @@ -207,12 +208,16 @@ if (!ucsto) { strcpy(cp, to); csp->cp_to = cp; - cp += strlen(cp) + 1; + for (; *cp; cp++) + *cp = toupper(*cp); + cp++; } else csp->cp_to = iconv_unicode_string; if (!ucsfrom) { strcpy(cp, from); csp->cp_from = cp; + for (; *cp; cp++) + *cp = toupper(*cp); } else csp->cp_from = iconv_unicode_string; csp->cp_data = data; --- iconv.c.patch ends here --- -- Dmitry Marakasov . 55B5 0596 FF1E 8D84 5F56 9510 D35A 80DD F9D2 F77D amdmi3@amdmi3.ru ..: jabber: amdmi3@jabber.ru http://www.amdmi3.ru
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090425021854.GA1361>