Use 'c_strcasecmp' instead of 'strcasecmp'.
authorMark H Weaver <mhw@netris.org>
Fri, 5 Apr 2013 18:04:53 +0000 (14:04 -0400)
committerMark H Weaver <mhw@netris.org>
Fri, 5 Apr 2013 18:10:28 +0000 (14:10 -0400)
* libguile/ports.c (scm_new_port_table_entry, get_codepoint,
  scm_i_set_default_port_encoding, scm_i_port_iconv_descriptors,
  scm_i_set_port_encoding_x):
* libguile/print.c (display_string_using_iconv):
* libguile/read.c (scm_i_scan_for_encoding): Use 'c_strcasecmp'.

libguile/ports.c
libguile/print.c
libguile/read.c

index 3656766..47dc165 100644 (file)
@@ -35,6 +35,7 @@
 #include <uniconv.h>
 #include <unistr.h>
 #include <striconveh.h>
+#include <c-strcase.h>
 
 #include <assert.h>
 
@@ -645,7 +646,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 && strcasecmp (encoding, "UTF-8") == 0)
+  if (encoding && c_strcasecmp (encoding, "UTF-8") == 0)
     pti->encoding_mode = SCM_PORT_ENCODING_MODE_UTF8;
   else
     pti->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
@@ -1427,8 +1428,8 @@ get_codepoint (SCM port, scm_t_wchar *codepoint,
           if (SCM_UNLIKELY
               (*codepoint == SCM_UNICODE_BOM
                && (pti->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8
-                   || strcasecmp (pt->encoding, "UTF-16") == 0
-                   || strcasecmp (pt->encoding, "UTF-32") == 0)))
+                   || c_strcasecmp (pt->encoding, "UTF-16") == 0
+                   || c_strcasecmp (pt->encoding, "UTF-32") == 0)))
             return get_codepoint (port, codepoint, buf, len);
         }
       update_port_lf (*codepoint, port);
@@ -2299,9 +2300,9 @@ scm_i_set_default_port_encoding (const char *encoding)
                    SCM_EOL);
 
   if (encoding == NULL
-      || !strcasecmp (encoding, "ASCII")
-      || !strcasecmp (encoding, "ANSI_X3.4-1968")
-      || !strcasecmp (encoding, "ISO-8859-1"))
+      || c_strcasecmp (encoding, "ASCII") == 0
+      || c_strcasecmp (encoding, "ANSI_X3.4-1968") == 0
+      || c_strcasecmp (encoding, "ISO-8859-1") == 0)
     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),
@@ -2489,9 +2490,9 @@ scm_i_port_iconv_descriptors (SCM port, scm_t_port_rw_active mode)
 
       /* If the specified encoding is UTF-16 or UTF-32, then make
          that more precise by deciding what byte order to use. */
-      if (strcasecmp (pt->encoding, "UTF-16") == 0)
+      if (c_strcasecmp (pt->encoding, "UTF-16") == 0)
         precise_encoding = decide_utf16_encoding (port, mode);
-      else if (strcasecmp (pt->encoding, "UTF-32") == 0)
+      else if (c_strcasecmp (pt->encoding, "UTF-32") == 0)
         precise_encoding = decide_utf32_encoding (port, mode);
       else
         precise_encoding = pt->encoding;
@@ -2532,7 +2533,7 @@ scm_i_set_port_encoding_x (SCM port, const char *encoding)
      because we do I/O ourselves.  This saves 100+ KiB for each
      descriptor.  */
   pt->encoding = scm_gc_strdup (encoding, "port");
-  if (strcasecmp (encoding, "UTF-8") == 0)
+  if (c_strcasecmp (encoding, "UTF-8") == 0)
     pti->encoding_mode = SCM_PORT_ENCODING_MODE_UTF8;
   else
     pti->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
index 3f72810..fa84990 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <uniconv.h>
 #include <unictype.h>
+#include <c-strcase.h>
 
 #include "libguile/_scm.h"
 #include "libguile/chars.h"
@@ -895,8 +896,8 @@ display_string_using_iconv (const void *str, int narrow_p, size_t len,
         pti->at_stream_start_for_bom_read = 0;
 
       /* Write a BOM if appropriate.  */
-      if (SCM_UNLIKELY (strcasecmp(pt->encoding, "UTF-16") == 0
-                        || strcasecmp(pt->encoding, "UTF-32") == 0))
+      if (SCM_UNLIKELY (c_strcasecmp(pt->encoding, "UTF-16") == 0
+                        || c_strcasecmp(pt->encoding, "UTF-32") == 0))
         display_character (SCM_UNICODE_BOM, port, iconveh_error);
     }
 
index 3c5f0a4..64b55c3 100644 (file)
@@ -30,6 +30,7 @@
 #include <unistd.h>
 #include <unicase.h>
 #include <unictype.h>
+#include <c-strcase.h>
 
 #include "libguile/_scm.h"
 #include "libguile/bytevectors.h"
@@ -2102,7 +2103,7 @@ scm_i_scan_for_encoding (SCM port)
     /* This wasn't in a comment */
     return NULL;
 
-  if (utf8_bom && strcasecmp(encoding, "UTF-8"))
+  if (utf8_bom && c_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)));