2016-07-25 22:38:47 +02:00
|
|
|
//---
|
|
|
|
//
|
|
|
|
// standard library module: ctype
|
|
|
|
//
|
|
|
|
// Some character manipulation.
|
|
|
|
//
|
|
|
|
//---
|
|
|
|
|
2016-07-25 09:04:22 +02:00
|
|
|
#ifndef _CTYPE_H
|
2017-03-26 18:38:32 +02:00
|
|
|
#define _CTYPE_H
|
2016-05-20 22:04:15 +02:00
|
|
|
|
2017-01-22 18:35:02 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
extern uint8_t ctype_classes[0x80];
|
|
|
|
|
2017-03-26 18:38:32 +02:00
|
|
|
// Character classes.
|
|
|
|
#define isalnum(c) (ctype_classes[(int)(c)] & 0xf0)
|
|
|
|
#define isalpha(c) (ctype_classes[(int)(c)] & 0x30)
|
|
|
|
#define iscntrl(c) (ctype_classes[(int)(c)] & 0x01)
|
|
|
|
#define isdigit(c) (ctype_classes[(int)(c)] & 0x40)
|
|
|
|
#define isgraph(c) (ctype_classes[(int)(c)] & 0xf4)
|
|
|
|
#define islower(c) (ctype_classes[(int)(c)] & 0x10)
|
|
|
|
#define isprint(c) (ctype_classes[(int)(c)] & 0x08)
|
|
|
|
#define ispunct(c) (ctype_classes[(int)(c)] & 0x04)
|
|
|
|
#define isspace(c) (ctype_classes[(int)(c)] & 0x02)
|
|
|
|
#define isupper(c) (ctype_classes[(int)(c)] & 0x20)
|
|
|
|
#define isxdigit(c) (ctype_classes[(int)(c)] & 0x80)
|
|
|
|
#define isascii(c) ((unsigned)c <= 0x7f)
|
|
|
|
#define isblank(c) (c == '\t' || c == ' ')
|
|
|
|
|
|
|
|
// Character manipulation.
|
|
|
|
#define tolower(c) ((c) | isupper(c))
|
|
|
|
#define toupper(c) ((c) & ~(islower(c) << 1))
|
2016-05-20 22:04:15 +02:00
|
|
|
|
2016-07-25 09:04:22 +02:00
|
|
|
#endif // _CTYPE_H
|