Author: jhb
Date: Mon Jun  9 19:27:47 2014
New Revision: 267291
URL: http://svnweb.freebsd.org/changeset/base/267291

Log:
  Use strcasecmp() instead of strcmp() when checking user-supplied encoding
  names so that encoding names are treated as case-insensitive.  This allows
  the use of 'utf-8' instead of 'UTF-8' for example and matches the behavior
  of iconv(1).
  
  PR:           167977
  Submitted by: bugan...@gmail.com
  MFC after:    1 week

Modified:
  head/sys/libkern/iconv.c
  head/sys/libkern/iconv_ucs.c

Modified: head/sys/libkern/iconv.c
==============================================================================
--- head/sys/libkern/iconv.c    Mon Jun  9 18:15:05 2014        (r267290)
+++ head/sys/libkern/iconv.c    Mon Jun  9 19:27:47 2014        (r267291)
@@ -168,8 +168,8 @@ iconv_lookupcs(const char *to, const cha
        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;

Modified: head/sys/libkern/iconv_ucs.c
==============================================================================
--- head/sys/libkern/iconv_ucs.c        Mon Jun  9 18:15:05 2014        
(r267290)
+++ head/sys/libkern/iconv_ucs.c        Mon Jun  9 19:27:47 2014        
(r267291)
@@ -102,9 +102,9 @@ iconv_ucs_open(struct iconv_converter_cl
        if (cspf)
                dp->convtype |= KICONV_UCS_COMBINE;
        for (i = 0; unicode_family[i].name; i++) {
-               if (strcmp(from, unicode_family[i].name) == 0)
+               if (strcasecmp(from, unicode_family[i].name) == 0)
                        dp->convtype |= unicode_family[i].from_flag;
-               if (strcmp(to, unicode_family[i].name) == 0)
+               if (strcasecmp(to, unicode_family[i].name) == 0)
                        dp->convtype |= unicode_family[i].to_flag;
        }
        if (strcmp(ENCODING_UNICODE, ENCODING_UTF16) == 0)
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to