Use 'strcasecmp' to compare encoding names.
authorMark H Weaver <mhw@netris.org>
Wed, 3 Apr 2013 17:26:01 +0000 (13:26 -0400)
committerMark H Weaver <mhw@netris.org>
Wed, 3 Apr 2013 17:31:51 +0000 (13:31 -0400)
Reported by Ludovic Courtès <ludo@gnu.org>.

* libguile/ports.c (scm_new_port_table_entry,
  scm_i_set_default_port_encoding, scm_i_set_port_encoding_x):
  libguile/read.c (scm_i_scan_for_encoding): Use 'strcasecmp' to compare
  encoding names.

libguile/ports.c
libguile/read.c

index 51145e6..61f8006 100644 (file)
@@ -633,7 +633,7 @@ scm_new_port_table_entry (scm_t_bits tag)
   encoding = scm_i_default_port_encoding ();
   entry->ilseq_handler = scm_i_default_port_conversion_handler ();
   entry->encoding = encoding ? scm_gc_strdup (encoding, "port") : NULL;
-  if (encoding && strcmp (encoding, "UTF-8") == 0)
+  if (encoding && strcasecmp (encoding, "UTF-8") == 0)
     pti->encoding_mode = SCM_PORT_ENCODING_MODE_UTF8;
   else
     pti->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
@@ -2235,9 +2235,9 @@ scm_i_set_default_port_encoding (const char *encoding)
                    SCM_EOL);
 
   if (encoding == NULL
-      || !strcmp (encoding, "ASCII")
-      || !strcmp (encoding, "ANSI_X3.4-1968")
-      || !strcmp (encoding, "ISO-8859-1"))
+      || !strcasecmp (encoding, "ASCII")
+      || !strcasecmp (encoding, "ANSI_X3.4-1968")
+      || !strcasecmp (encoding, "ISO-8859-1"))
     scm_fluid_set_x (SCM_VARIABLE_REF (default_port_encoding_var), SCM_BOOL_F);
   else
     scm_fluid_set_x (SCM_VARIABLE_REF (default_port_encoding_var),
@@ -2383,7 +2383,7 @@ scm_i_set_port_encoding_x (SCM port, const char *encoding)
   /* If ENCODING is UTF-8, then no conversion descriptor is opened
      because we do I/O ourselves.  This saves 100+ KiB for each
      descriptor.  */
-  if (strcmp (encoding, "UTF-8") == 0)
+  if (strcasecmp (encoding, "UTF-8") == 0)
     {
       pt->encoding = "UTF-8";
       pti->encoding_mode = SCM_PORT_ENCODING_MODE_UTF8;
index 6457952..3c5f0a4 100644 (file)
@@ -2102,7 +2102,7 @@ scm_i_scan_for_encoding (SCM port)
     /* This wasn't in a comment */
     return NULL;
 
-  if (utf8_bom && strcmp(encoding, "UTF-8"))
+  if (utf8_bom && strcasecmp(encoding, "UTF-8"))
     scm_misc_error (NULL,
                    "the port input declares the encoding ~s but is encoded as UTF-8",
                    scm_list_1 (scm_from_locale_string (encoding)));