mirror of
https://github.com/adtools/clib2.git
synced 2026-05-09 14:44:57 +00:00
- Made the <ctype.h> macros more robust.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14797 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
tracks whether or not console output is possible. We now use the
|
||||
global "__no_standard_io" instead.
|
||||
|
||||
- Made the <ctype.h> macros more robust.
|
||||
|
||||
|
||||
c.lib 1.185 (2.1.2005)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: ctype_table.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $
|
||||
* $Id: ctype_table.c,v 1.3 2005-01-09 15:20:31 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -36,22 +36,8 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The construction of this table is rather peculiar. The assumption is that
|
||||
the table index from which a flag value could be fetched is in the range
|
||||
-128..255 since the character to be tested could be a signed or unsigned
|
||||
8 bit value. The table access pointer (declared below) therefore points
|
||||
to the 128th byte of '__ctype_data[]'. */
|
||||
static const unsigned char __ctype_data[3 * 128] =
|
||||
const unsigned char __ctype_table[2 * 128] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0 */ __CTYPE_CONTROL,
|
||||
/* 1 */ __CTYPE_CONTROL,
|
||||
/* 2 */ __CTYPE_CONTROL,
|
||||
@@ -190,7 +176,3 @@ static const unsigned char __ctype_data[3 * 128] =
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
const unsigned char * const __ctype_table = &__ctype_data[128];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: ctype.h,v 1.4 2005-01-02 09:07:21 obarthel Exp $
|
||||
* $Id: ctype.h,v 1.5 2005-01-09 15:20:33 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -66,15 +66,14 @@ extern int toupper(int c);
|
||||
/*
|
||||
* If requested, reimplement the character classification functions as macros;
|
||||
* note that the macro variants ignore the current locale and default to the
|
||||
* 'C' locale rules. Note that the characters to be tested must be either
|
||||
* signed or unsigned 8 bit values.
|
||||
* 'C' locale rules.
|
||||
*/
|
||||
|
||||
#ifdef __C_MACROS__
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
extern const unsigned char * const __ctype_table;
|
||||
extern const unsigned char __ctype_table[];
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -89,17 +88,17 @@ extern const unsigned char * const __ctype_table;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define isalnum(c) ((__ctype_table[c] & (__CTYPE_DIGIT|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define isalpha(c) ((__ctype_table[c] & (__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define iscntrl(c) ((__ctype_table[c] & __CTYPE_CONTROL) != 0)
|
||||
#define isdigit(c) ((__ctype_table[c] & __CTYPE_DIGIT) != 0)
|
||||
#define isxdigit(c) ((__ctype_table[c] & __CTYPE_HEX_DIGIT) != 0)
|
||||
#define isgraph(c) ((__ctype_table[c] & (__CTYPE_DIGIT|__CTYPE_PUNCTUATION|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define ispunct(c) ((__ctype_table[c] & __CTYPE_PUNCTUATION) != 0)
|
||||
#define isprint(c) ((__ctype_table[c] & __CTYPE_PRINTABLE) != 0)
|
||||
#define islower(c) ((__ctype_table[c] & __CTYPE_LOWER_CASE) != 0)
|
||||
#define isupper(c) ((__ctype_table[c] & __CTYPE_UPPER_CASE) != 0)
|
||||
#define isspace(c) ((__ctype_table[c] & __CTYPE_WHITE_SPACE) != 0)
|
||||
#define isalnum(c) ((__ctype_table[(c) & 255] & (__CTYPE_DIGIT|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define isalpha(c) ((__ctype_table[(c) & 255] & (__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define iscntrl(c) ((__ctype_table[(c) & 255] & __CTYPE_CONTROL) != 0)
|
||||
#define isdigit(c) ((__ctype_table[(c) & 255] & __CTYPE_DIGIT) != 0)
|
||||
#define isxdigit(c) ((__ctype_table[(c) & 255] & __CTYPE_HEX_DIGIT) != 0)
|
||||
#define isgraph(c) ((__ctype_table[(c) & 255] & (__CTYPE_DIGIT|__CTYPE_PUNCTUATION|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
|
||||
#define ispunct(c) ((__ctype_table[(c) & 255] & __CTYPE_PUNCTUATION) != 0)
|
||||
#define isprint(c) ((__ctype_table[(c) & 255] & __CTYPE_PRINTABLE) != 0)
|
||||
#define islower(c) ((__ctype_table[(c) & 255] & __CTYPE_LOWER_CASE) != 0)
|
||||
#define isupper(c) ((__ctype_table[(c) & 255] & __CTYPE_UPPER_CASE) != 0)
|
||||
#define isspace(c) ((__ctype_table[(c) & 255] & __CTYPE_WHITE_SPACE) != 0)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user