[PATCH] Add "@cjknarrow" modifier (was Re: [Fwd: [1.7] wcwidth failing configure tests])

IWAMURO Motonori deenheart@gmail.com
Mon Jun 15 15:58:00 GMT 2009


2009/6/15 Corinna Vinschen <corinna-cygwin@cygwin.com>:
>> Yes, but the guideline exists.
>> http://cygwin.com/ml/cygwin/2009-05/msg00444.html
>
> A single mail in a single mailing list of a single project.  That's rather
> a suggestion than a guideline...

Sorry, my writing was bad. My quotation is a part of Unicode Standard
Annex #11 EAST ASIAN WIDTH.
Please see "When processing or displaying data" of "5 Recommendations"
at http://www.unicode.org/unicode/reports/tr11/ .

> If everybody agrees to this suggestion, here's the patch.

Is the name of modifier prefix "cjk-" good? It influences not CJK
characters but a part of symbols and European characters.
Please refer to Andy's opinion:
http://cygwin.com/ml/cygwin/2009-06/msg00240.html

It personally proposes "ambinarrow" because the switch of Vim is "ambiwidth".

And, I don't think that it is symmetrical. How about the following
patch? (I have not changed the name of modifier prefix)

--- libc/locale/locale.c.ORIG	2009-06-15 23:05:40.812500000 +0900
+++ libc/locale/locale.c	2009-06-15 22:56:35.546875000 +0900
@@ -398,7 +398,8 @@
   int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t,
 		   const char *, mbstate_t *);
 #ifdef _MB_CAPABLE
-  int cjknarrow = 0;
+#define CJK_DEFAULT -1
+  int cjk_lang = CJK_DEFAULT;
 #endif

   /* "POSIX" is translated to "C", as on Linux. */
@@ -453,11 +454,14 @@
       if (c[0] == '@')
 	{
 	  /* Modifier */
-	  /* Only one modifier is recognized right now.	 "cjknarrow" is used
-	     to modify the behaviour of wcwidth() for East Asian languages.
-	     For details see the comment at the end of this function. */
+	  /* Only one modifier is recognized right now.	 "cjknarrow" and
+	     "cjkwide" are used to modify the behaviour of wcwidth() for
+	     East Asian languages. For details see the comment at the
+	     end of this function. */
 	  if (!strcmp (c + 1, "cjknarrow"))
-	    cjknarrow = 1;
+	    cjk_lang = 0;
+	  else if (!strcmp (c + 1, "cjkwide"))
+	    cjk_lang = 1;
 	}
 #endif
     }
@@ -627,10 +631,11 @@
 	The result is stored in lc_ctype_cjk_lang and tested in wcwidth()
 	to figure out the width to return (1 or 2) for the "CJK Ambiguous
 	Width" category of characters. */
-      lc_ctype_cjk_lang = !cjknarrow
-			 && ((strncmp (locale, "ja", 2) == 0
-			     || strncmp (locale, "ko", 2) == 0
-			     || strncmp (locale, "zh", 2) == 0));
+      lc_ctype_cjk_lang = cjk_lang != CJK_DEFAULT
+			? cjk_lang
+			: ((strncmp (locale, "ja", 2) == 0
+			   || strncmp (locale, "ko", 2) == 0
+			   || strncmp (locale, "zh", 2) == 0));
 #endif
     }
   else if (category == LC_MESSAGES)
-- 
IWAMURO Motnori <http://vmi.jp/>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list