wctype.h (fwd)
H.J. Lu
hjl@lucon.org
Sun May 23 10:27:00 GMT 1999
>From lawson_whitney@juno.com Sat May 22 20:28:42 1999
Return-Path: <lawson_whitney@juno.com>
Delivered-To: hjl@lucon.org
Received: from mescaline.gnu.org (mescaline.gnu.org [158.121.106.21])
by ocean.lucon.org (Postfix) with ESMTP id 2DC3E57BB
for <hjl@lucon.org>; Sat, 22 May 1999 20:28:41 -0700 (PDT)
Received: from x9.boston.juno.com (x9.boston.juno.com [205.231.100.25])
by mescaline.gnu.org (8.9.1a/8.9.1) with ESMTP id XAA32139
for <hjl@gnu.org>; Sat, 22 May 1999 23:28:39 -0400
From: lawson_whitney@juno.com
Received: (from lawson_whitney@juno.com)
by x9.boston.juno.com (queuemail) id EA99BQ9K; Sat, 22 May 1999 23:28:14 EDT
To: hjl@gnu.org
Date: Sat, 22 May 1999 23:37:09 ric
Subject: wctype.h
Message-ID: <19990522.233811.2191.1.lawson_whitney@juno.com>
X-Mailer: Juno 1.49
X-Juno-Line-Breaks: 0-31,33,35,37,39-58,60-101
I'm sending you a copy because I think it applies to libc5 also. Thanks
for your work on libc, binutils and I know not what all else.
Good day!
If I am reporting a bug that has already been fixed, please forgive me.
I have glibc-2.0.6, i586-gnu-linux, gcc-2.7.2.3. I am sorry, I did not
save config.make and config.status when I removed the source to make
way for the next release of Wine. I don't think they matter in this
case anyway.
Including wctype.h provokes the compiler to issue 4 spurious warnings.
Also, I believe the result of _ISwbit(bit) to be wrong for 15 <bit <24.
Rather than fix the compiler, I propose to fix the header.
Here is the text case:
Script started on Sat May 22 19:04:20 1999
witsend:/usr/src/bull$ cat isw.c
#include <wctype.h>
#include <stdio.h>
void main()
{ int o, thefire;
for (o = 0 ; o < 4; o++)
{ for (thefire = o * 8; thefire < o * 8 + 8; thefire ++)
{ printf(" %8x", _ISwbit(thefire));}
printf("\n");}
}
witsend:/usr/src/bull$ gcc -O2 -o isw isw.c
In file included from isw.c:1:
/usr/local/include/wctype.h:84: warning: left shift count >= width of
type
/usr/local/include/wctype.h:85: warning: left shift count >= width of
type
/usr/local/include/wctype.h:86: warning: left shift count >= width of
type
/usr/local/include/wctype.h:87: warning: left shift count >= width of
type
witsend:/usr/src/bull$ isw
1000000 2000000 4000000 8000000 10000000 20000000 40000000 80000000
10000 20000 40000 80000 100000 200000 400000 800000
1000000 2000000 4000000 8000000 10000000 20000000 40000000 80000000
1 2 4 8 10 20 40 80
witsend:/usr/src/bull$ exit
exit
Script done on Sat May 22 19:05:21 1999
Here, how I propose to fix it:
diff -urN was/wctype.h is/wctype.h
--- was/wctype.h Sat May 22 19:12:06 1999
+++ is/wctype.h Sat May 22 19:33:16 1999
@@ -68,7 +68,7 @@
#if __BYTE_ORDER == __BIG_ENDIAN
#define _ISwbit(bit) (1 << bit)
#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
-#define _ISwbit(bit) ((bit < 8) ? 1UL << (bit + 24) : 1UL << (bit
+ 8))
+#define _ISwbit(bit) ((1UL << (bit + 24 - (bit / 8) * 16)))
#endif
enum
And here, a retest:
Script started on Sat May 22 19:34:10 1999
witsend:/usr/src/bull$ gcc -O2 -o isw isw.c
witsend:/usr/src/bull$ isw
1000000 2000000 4000000 8000000 10000000 20000000 40000000 80000000
10000 20000 40000 80000 100000 200000 400000 800000
100 200 400 800 1000 2000 4000 8000
1 2 4 8 10 20 40 80
witsend:/usr/src/bull$ exit
exit
Script done on Sat May 22 19:34:31 1999
This is also relevant to libc5, I think. I hope this is useful, or at
least amusing. And last, the patch gzipped and uuencoded, in case the
mail has dealt unkindly with the text.
Lawson <lawson_whitney@juno.com>
>< Microsoft free environment
This mail client runs on Wine. Your mileage may vary.
begin 644 wctype.diff.gz
M'XL(",T^1S<``W=C<&%T8V@`=8Y!2\-`$(7/W5_QP$LWZS9N*C$)*49ID$",
MT,9#3TO:[.*"!K$IH?_>;%I00SW,S)N9-Q]3&ZW!#U\%NFKO=KOV^*EF;S`_
MFG#._RPGZZK%<W6$YT&$D?"B&[\784@88[\O1\;Y/!)G8Y*`^\'U'=B0DX3@
MRFA(^;@I4_FR6J8K+!:VSYYD6BRSAZ)WU$J;1D%FZVYKVFD?=#(5B&-8V1O4
M^U[!=2YP\JPL\_2,@N,2?IEF"V($%/<0K[EE#R,&[Y8B<"2@G[!S2^!C]I
:U\(=")_2X>6F-IJ`0#6'#_(-L/58U8X!``!E
`
end
___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]
--
H.J. Lu (hjl@gnu.org)
More information about the Libc-hacker
mailing list