From owner-freebsd-standards Mon Sep 2 11:12: 6 2002 Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AF77837B401 for ; Mon, 2 Sep 2002 11:11:51 -0700 (PDT) Received: from espresso.q9media.com (espresso.q9media.com [65.39.129.122]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4B32F43E6E for ; Mon, 2 Sep 2002 11:11:51 -0700 (PDT) (envelope-from mike@espresso.q9media.com) Received: by espresso.q9media.com (Postfix, from userid 1002) id 642719E57; Mon, 2 Sep 2002 14:05:49 -0400 (EDT) Date: Mon, 2 Sep 2002 14:05:49 -0400 From: Mike Barcroft To: standards@FreeBSD.org Cc: Bruce Evans Subject: Conformance bugs in , by way of Message-ID: <20020902140549.E94253@espresso.q9media.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="fdj2RfSjLxBAspz7" Content-Disposition: inline Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline From rev 1.5 of ctype.h: ... o TODO: fix conformance bugs brought by including . I'd appreciate comments of the attached patch which fixes this issue and brings up to conformance. Best regards, Mike Barcroft --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ctype.diff" ctype.diff o Fix namespace scope issues in by using the relatively new visibility primitives. o Implement _tolower() and _toupper() POSIX.1-2001 (XSI) macros in . o Make pollutant-free so that it can safely be included in . o Add a typedef in to compensate for being pollutant-free. Index: ctype.h =================================================================== RCS file: /work/repo/src/include/ctype.h,v retrieving revision 1.22 diff -u -r1.22 ctype.h --- ctype.h 21 Aug 2002 16:19:55 -0000 1.22 +++ ctype.h 2 Sep 2002 18:07:04 -0000 @@ -45,10 +45,6 @@ #ifndef _CTYPE_H_ #define _CTYPE_H_ -/* - * XXX brings massive namespace pollution (rune_t and struct - * member names). - */ #include #define _CTYPE_A 0x00000100L /* Alpha */ @@ -85,9 +81,15 @@ int tolower(int); int toupper(int); -#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) -int digittoint(int); +#if __XSI_VISIBLE +int _tolower(int); +int _toupper(int); int isascii(int); +int toascii(int); +#endif + +#if __BSD_VISIBLE +int digittoint(int); int isblank(int); int ishexnumber(int); int isideogram(int); @@ -95,7 +97,6 @@ int isphonogram(int); int isrune(int); int isspecial(int); -int toascii(int); #endif __END_DECLS @@ -113,9 +114,23 @@ #define tolower(c) __tolower(c) #define toupper(c) __toupper(c) -#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) -#define digittoint(c) __maskrune((c), 0xFF) +#if __XSI_VISIBLE +/* + * POSIX.1-2001 specifies _tolower() and _toupper() to be macros equivalent to + * tolower() and toupper() respectively, minus extra checking to ensure that + * the argument is a lower or uppercase letter respectively. We've chosen to + * implement these macros with the same error checking as tolower() and + * toupper() since this doesn't violate the specification itself, only its + * intent. + */ +#define _tolower(c) __tolower(c) +#define _toupper(c) __toupper(c) #define isascii(c) (((c) & ~0x7F) == 0) +#define toascii(c) ((c) & 0x7F) +#endif + +#if __BSD_VISIBLE +#define digittoint(c) __maskrune((c), 0xFF) #define isblank(c) __istype((c), _CTYPE_B) #define ishexnumber(c) __istype((c), _CTYPE_X) #define isideogram(c) __istype((c), _CTYPE_I) @@ -123,10 +138,9 @@ #define isphonogram(c) __istype((c), _CTYPE_Q) #define isrune(c) __istype((c), 0xFFFFFF00L) #define isspecial(c) __istype((c), _CTYPE_T) -#define toascii(c) ((c) & 0x7F) #endif -/* See comments in about __ct_rune_t. */ +/* See comments in about __ct_rune_t. */ __BEGIN_DECLS unsigned long ___runetype(__ct_rune_t); __ct_rune_t ___tolower(__ct_rune_t); Index: rune.h =================================================================== RCS file: /work/repo/src/include/rune.h,v retrieving revision 1.2 diff -u -r1.2 rune.h --- rune.h 23 Mar 2002 17:24:53 -0000 1.2 +++ rune.h 1 Sep 2002 18:27:08 -0000 @@ -40,8 +40,13 @@ #ifndef _RUNE_H_ #define _RUNE_H_ -#include #include +#include + +#ifndef _RUNE_T_DECLARED +#define _RUNE_T_DECLARED +typedef __rune_t rune_t; +#endif #define _PATH_LOCALE "/usr/share/locale" Index: runetype.h =================================================================== RCS file: /work/repo/src/include/runetype.h,v retrieving revision 1.7 diff -u -r1.7 runetype.h --- runetype.h 21 Aug 2002 16:19:55 -0000 1.7 +++ runetype.h 2 Sep 2002 17:18:18 -0000 @@ -43,23 +43,6 @@ #include #include -#ifndef _RUNE_T_DECLARED -typedef __rune_t rune_t; -#define _RUNE_T_DECLARED -#endif - -#ifndef _SIZE_T_DECLARED -typedef __size_t size_t; -#define _SIZE_T_DECLARED -#endif - -#ifndef __cplusplus -#ifndef _WCHAR_T_DECLARED -typedef __wchar_t wchar_t; -#define _WCHAR_T_DECLARED -#endif -#endif - #define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ #define _CRMASK (~(_CACHED_RUNES - 1)) @@ -67,9 +50,9 @@ * The lower 8 bits of runetype[] contain the digit value of the rune. */ typedef struct { - rune_t min; /* First rune of the range */ - rune_t max; /* Last rune (inclusive) of the range */ - rune_t map; /* What first maps to in maps */ + __rune_t min; /* First rune of the range */ + __rune_t max; /* Last rune (inclusive) of the range */ + __rune_t map; /* What first maps to in maps */ unsigned long *types; /* Array of types in range */ } _RuneEntry; @@ -82,13 +65,13 @@ char magic[8]; /* Magic saying what version we are */ char encoding[32]; /* ASCII name of this encoding */ - rune_t (*sgetrune)(const char *, size_t, char const **); - int (*sputrune)(rune_t, char *, size_t, char **); - rune_t invalid_rune; + __rune_t (*sgetrune)(const char *, __size_t, char const **); + int (*sputrune)(__rune_t, char *, __size_t, char **); + __rune_t invalid_rune; unsigned long runetype[_CACHED_RUNES]; - rune_t maplower[_CACHED_RUNES]; - rune_t mapupper[_CACHED_RUNES]; + __rune_t maplower[_CACHED_RUNES]; + __rune_t mapupper[_CACHED_RUNES]; /* * The following are to deal with Runes larger than _CACHED_RUNES - 1. --fdj2RfSjLxBAspz7-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message