X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,TW_WW X-Spam-Check-By: sourceware.org X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRbfA44+iwyQ== X-RZG-CLASS-ID: mo00 From: Bruno Haible To: bug-gnulib AT gnu DOT org, cygwin , "bug-coreutils" , Eric Blake Subject: Re: 16-bit wchar_t on Windows and Cygwin Date: Wed, 2 Feb 2011 17:02:56 +0100 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110202122102.GD2675@calimero.vinschen.de> References: <20110202122102 DOT GD2675 AT calimero DOT vinschen DOT de> <201102021229 DOT 04623 DOT bruno AT clisp DOT org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201102021702.57387.bruno@clisp.org> Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hello Corinna, > And, please note the wording in SUSv4, for instance in > http://calimero.vinschen.de/susv4/functions/iswalpha.html Likewise in POSIX:2008, at the URL http://www.opengroup.org/onlinepubs/9699919799/functions/iswalpha.html > The wc argument is a wint_t, the value of which the application shall > ^^^^^^ ^^^^^^^^^^^ > ensure is a wide-character code corresponding to a valid character in ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > the current locale, or equal to the value of the macro WEOF. If the > argument has any other value, the behavior is undefined. What this sentence means in formulas, is that when an application passes a 'wint_t x' to iswalpha(), it has to satisfy x == (wint_t) (wchar_t) x || x == EOF > iswalpha takes wint_t, not wchar_t. Since sizeof (wint_t) is 4 byte, > the function can return the correct value, provided that the application > converts the UTF-16 surrogate to UTF-32 before calling iswalpha. When an application does this, is passes an invalid wint_t value to iswalpha(), according to the spec paragraph that you have just cited. So the application uses an extension to POSIX functionality, not POSIX itself. I see that Cygwin 1.7.x iswalpha() works in this way you describe (but mingw's iswalpha() doesn't). So this means that gnulib's proposed iswwalpha(wwchar_t) function could be implemented using iswalpha() on Cygwin 1.7.x and will not cause the Unicode based tables to be included in the executable. This is good and nice. But if you say that the application should convert UTF-16 surrogates to UTF-32 before calling iswalpha: That's certainly a requirement for Cygwin 1.7.x application that want to support the entire Unicode character set. But it's outside of POSIX, and many GNU programs will not want to include this added complexity. Just try to apply this suggestion to gnulib's quotearg.c, then estimate the time someone would need to apply it also to regcomp.c, strftime.c, mbscasestr.c, coreutils/src/wc.c, and so on. For this reason I propose the wwchar_t type with an API that is similar to POSIX but includes the surrogate handling, rather than pushing it into each application's code. Bruno -- In memoriam Carl Friedrich Goerdeler -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple