Skip to content
Snippets Groups Projects
Commit d092a925 authored by Herman A.J. ten Brugge's avatar Herman A.J. ten Brugge Committed by Richard Henderson
Browse files

safe-ctype.h: Make code work on all targets and not just on targets where a char is 8 bits.

        * safe-ctype.h: Make code work on all targets and not just on
        targets where a char is 8 bits.

From-SVN: r38312
parent 68c7dea8
No related branches found
No related tags found
No related merge requests found
2000-12-16 Herman A.J. ten Brugge <Haj.Ten.Brugge@net.HCC.nl>
* safe-ctype.h: Make code work on all targets and not just on
targets where a char is 8 bits.
2000-12-07 Zack Weinberg <zack@wolery.stanford.edu> 2000-12-07 Zack Weinberg <zack@wolery.stanford.edu>
* safe-ctype.h: New file. * safe-ctype.h: New file.
......
...@@ -66,15 +66,10 @@ enum { ...@@ -66,15 +66,10 @@ enum {
_sch_iscppsp = _sch_isvsp|_sch_isnvsp /* isspace + \0 */ _sch_iscppsp = _sch_isvsp|_sch_isnvsp /* isspace + \0 */
}; };
/* This code fundamentally assumes that a byte is 8 bits. Test this
at compile time. */
extern int a_byte_isnt_eight_bits[(unsigned char)256 == 0 ? 1 : -1];
/* Character classification. */ /* Character classification. */
extern const unsigned short _sch_istable[256]; extern const unsigned short _sch_istable[256];
#define _sch_test(c, bit) (_sch_istable[(int)(unsigned char)(c)] & (bit)) #define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (bit))
#define ISALPHA(c) _sch_test(c, _sch_isalpha) #define ISALPHA(c) _sch_test(c, _sch_isalpha)
#define ISALNUM(c) _sch_test(c, _sch_isalnum) #define ISALNUM(c) _sch_test(c, _sch_isalnum)
...@@ -98,8 +93,8 @@ extern const unsigned short _sch_istable[256]; ...@@ -98,8 +93,8 @@ extern const unsigned short _sch_istable[256];
/* Character transformation. */ /* Character transformation. */
extern const unsigned char _sch_toupper[256]; extern const unsigned char _sch_toupper[256];
extern const unsigned char _sch_tolower[256]; extern const unsigned char _sch_tolower[256];
#define TOUPPER(c) _sch_toupper[(int)(unsigned char)(c)] #define TOUPPER(c) _sch_toupper[(c) & 0xff]
#define TOLOWER(c) _sch_tolower[(int)(unsigned char)(c)] #define TOLOWER(c) _sch_tolower[(c) & 0xff]
#endif /* no ctype.h */ #endif /* no ctype.h */
#endif /* SAFE_CTYPE_H */ #endif /* SAFE_CTYPE_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment