From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 27 16:10:17 2009 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44D6910656E8 for ; Mon, 27 Apr 2009 16:10:17 +0000 (UTC) (envelope-from amdmi3@amdmi3.ru) Received: from smtp.timeweb.ru (smtp.timeweb.ru [217.170.79.85]) by mx1.freebsd.org (Postfix) with ESMTP id 006B38FC20 for ; Mon, 27 Apr 2009 16:10:16 +0000 (UTC) (envelope-from amdmi3@amdmi3.ru) Received: from [213.148.20.85] (helo=hive.panopticon) by smtp.timeweb.ru with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1LyTPO-0002iu-OI for freebsd-hackers@FreeBSD.org; Mon, 27 Apr 2009 20:10:18 +0400 Received: from hades.panopticon (hades.panopticon [192.168.0.32]) by hive.panopticon (Postfix) with ESMTP id AB26FF895 for ; Mon, 27 Apr 2009 20:10:51 +0400 (MSD) Received: by hades.panopticon (Postfix, from userid 1000) id 24352108841; Mon, 27 Apr 2009 20:09:30 +0400 (MSD) Date: Mon, 27 Apr 2009 20:09:30 +0400 From: Dmitry Marakasov To: freebsd-hackers@FreeBSD.org Message-ID: <20090427160930.GB48365@hades.panopticon> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Cc: Subject: [patch] kernel iconv improvements X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2009 16:10:17 -0000 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 __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -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