delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-0.6 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,TW_RJ,TW_XF,T_TO_NO_BRKTS_FREEMAIL |
X-Spam-Check-By: | sourceware.org |
To: | cygwin AT cygwin DOT com |
Subject: | Re: Interesting discovery in the C library that Cygwin uses |
References: | <AANLkTimvCA12jm3SNDaDs7yckO9GLwPd01P_U7mCqYju AT mail DOT gmail DOT com> |
Date: | Fri, 09 Jul 2010 09:58:23 +0200 |
MIME-Version: | 1.0 |
From: | "Matthias Andree" <matthias DOT andree AT gmx DOT de> |
Message-ID: | <op.vfkgflch1e62zd@merlin.emma.line.org> |
In-Reply-To: | <AANLkTimvCA12jm3SNDaDs7yckO9GLwPd01P_U7mCqYju@mail.gmail.com> |
User-Agent: | Opera Mail/10.60 (Linux) |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Am 09.07.2010, 01:34 Uhr, schrieb Gregg Levine: (warnings about char subscripts) > Basically the program supporter there wants the people here for Cygwin > to, ah, fix their C library. I'm not convinced that's necessary, but > which C library is used here? And what could be fixed? The C library (newlib) is fine, it is actually helpful here by emitting warnings for actual program defects. The supporter should be sold a clue, in the form of a copy of IEEE Standard 1003.1 or a deep link to the opengroup.org website. The urjtag source however should be fixed. It abuses the ctype.h interfaces. Arguments to the tolower() and other to*() and isspace() and other is*() functions MUST be cast to unsigned char (unless they are already unsigned char). Background is that these functions need to support the usual 8bit character range plus the 257th "character" EOF (-1). So the is*() functions will have to use a wider type than char, and now sign extension matters. If you don't cast the input to unsigned char, an argument of 0xff will alias EOF although it is not the same, and 0x80...0xfe will lead to undefined behaviour, possibly even crashes. Note: the warning may be specific to Cygwin, but the underlying program will show on more systems with input outside ASCII. I recall that at least some versions of Solaris would misbehave if you passed non-ASCII characters (think umlauts or accented characters, or Asian/Cyrillic/other national scripts) to these ctype.h functions. There are probably more... -- Matthias Andree -- 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |