changeset 16385:a9e289a3a38d

streq: Rename macro. * lib/streq.h (STREQ_OPT): Renamed from STREQ. * NEWS: Mention the change. * lib/mbrtowc.c (mbrtowc): Update. * lib/uniwidth/cjk.h (is_cjk_encoding): Update. * lib/wcwidth.c (wcwidth): Update. Suggested by Akim Demaille and Jim Meyering.
author Bruno Haible <bruno@clisp.org>
date Fri, 24 Feb 2012 12:33:07 +0100
parents dde8c368829d
children bb8c8cc1050d
files ChangeLog NEWS lib/mbrtowc.c lib/streq.h lib/uniwidth/cjk.h lib/wcwidth.c
diffstat 6 files changed, 40 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-02-24  Bruno Haible  <bruno@clisp.org>
+
+	streq: Rename macro.
+	* lib/streq.h (STREQ_OPT): Renamed from STREQ.
+	* NEWS: Mention the change.
+	* lib/mbrtowc.c (mbrtowc): Update.
+	* lib/uniwidth/cjk.h (is_cjk_encoding): Update.
+	* lib/wcwidth.c (wcwidth): Update.
+	Suggested by Akim Demaille and Jim Meyering.
+
 2012-02-20  Paul Eggert  <eggert@cs.ucla.edu>
 
 	regex: fix typo in definition of MIN
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,9 @@
 
 Date        Modules         Changes
 
+2012-02-24  streq           This module no longer provides the STREQ macro.
+                            Use STREQ_OPT instead.
+
 2012-01-10  ignore-value    This module no longer provides the ignore_ptr
                             function.  It was deprecated a year ago, but existed
                             so briefly before then that it never came into use.
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -128,7 +128,7 @@
       {
         const char *encoding = locale_charset ();
 
-        if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
+        if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
           {
             /* Cf. unistr/u8-mblen.c.  */
             unsigned char c = (unsigned char) p[0];
@@ -185,7 +185,8 @@
         /* As a reference for this code, you can use the GNU libiconv
            implementation.  Look for uses of the RET_TOOFEW macro.  */
 
-        if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
+        if (STREQ_OPT (encoding,
+                       "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
           {
             if (m == 1)
               {
@@ -208,9 +209,12 @@
               }
             goto invalid;
           }
-        if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
-            || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
-            || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
+        if (STREQ_OPT (encoding,
+                       "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+            || STREQ_OPT (encoding,
+                          "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
+            || STREQ_OPT (encoding,
+                          "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
           {
             if (m == 1)
               {
@@ -221,7 +225,8 @@
               }
             goto invalid;
           }
-        if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
+        if (STREQ_OPT (encoding,
+                       "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
           {
             if (m == 1)
               {
@@ -239,7 +244,8 @@
               }
             goto invalid;
           }
-        if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
+        if (STREQ_OPT (encoding,
+                       "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
           {
             if (m == 1)
               {
@@ -272,7 +278,7 @@
               }
             goto invalid;
           }
-        if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
+        if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
           {
             if (m == 1)
               {
--- a/lib/streq.h
+++ b/lib/streq.h
@@ -21,8 +21,8 @@
 
 #include <string.h>
 
-/* STREQ allows to optimize string comparison with a small literal string.
-     STREQ (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+/* STREQ_OPT allows to optimize string comparison with a small literal string.
+     STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
    is semantically equivalent to
      strcmp (s, "EUC-KR") == 0
    just faster.  */
@@ -163,12 +163,12 @@
     return 0;
 }
 
-#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
   streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28)
 
 #else
 
-#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
   (strcmp (s1, s2) == 0)
 
 #endif
--- a/lib/uniwidth/cjk.h
+++ b/lib/uniwidth/cjk.h
@@ -22,16 +22,16 @@
 {
   if (0
       /* Legacy Japanese encodings */
-      || STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)
+      || STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)
       /* Legacy Chinese encodings */
-      || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
-      || STREQ (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0)
-      || STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)
-      || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)
+      || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
+      || STREQ_OPT (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0)
+      || STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)
+      || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)
       /* Legacy Korean encodings */
-      || STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
-      || STREQ (encoding, "CP949", 'C', 'P', '9', '4', '9', 0, 0, 0, 0)
-      || STREQ (encoding, "JOHAB", 'J', 'O', 'H', 'A', 'B', 0, 0, 0, 0))
+      || STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+      || STREQ_OPT (encoding, "CP949", 'C', 'P', '9', '4', '9', 0, 0, 0, 0)
+      || STREQ_OPT (encoding, "JOHAB", 'J', 'O', 'H', 'A', 'B', 0, 0, 0, 0))
     return 1;
   return 0;
 }
--- a/lib/wcwidth.c
+++ b/lib/wcwidth.c
@@ -32,7 +32,7 @@
 {
   /* In UTF-8 locales, use a Unicode aware width function.  */
   const char *encoding = locale_charset ();
-  if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0 ,0))
+  if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0 ,0))
     {
       /* We assume that in a UTF-8 locale, a wide character is the same as a
          Unicode character.  */