2019-03-08 09:00:55 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
2020-09-27 17:33:48 +02:00
|
|
|
// OS on Kaleid //
|
2019-03-08 09:00:55 +01:00
|
|
|
// //
|
|
|
|
// Desc: Character types //
|
|
|
|
// //
|
|
|
|
// //
|
2021-02-18 19:54:35 +01:00
|
|
|
// Copyright © 2018-2021 The OS/K Team //
|
2019-03-08 09:00:55 +01:00
|
|
|
// //
|
|
|
|
// This file is part of OS/K. //
|
|
|
|
// //
|
|
|
|
// OS/K is free software: you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or //
|
|
|
|
// any later version. //
|
|
|
|
// //
|
|
|
|
// OS/K is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
2019-05-13 23:22:27 +02:00
|
|
|
#include <libc.h>
|
2019-03-08 09:00:55 +01:00
|
|
|
|
|
|
|
#define SH(x) (1 << x)
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CT = SH(0), // control
|
|
|
|
PR = SH(1), // printing
|
|
|
|
GR = SH(2)|PR, // graphical
|
|
|
|
DX = SH(3)|GR, // hex digit
|
|
|
|
DG = SH(4)|DX, // decimal digit
|
|
|
|
SP = SH(5), // space
|
|
|
|
BK = SH(6)|SP, // blank
|
|
|
|
PT = SH(7)|GR, // punctuation
|
|
|
|
AL = SH(8)|GR, // alpha
|
|
|
|
UP = SH(9)|AL, // upper alpha
|
|
|
|
LW = SH(10)|AL // lower alpha
|
|
|
|
};
|
|
|
|
|
|
|
|
int __ctype[] = {
|
|
|
|
// ASCII ctype table
|
|
|
|
/* 0 */ CT, CT, CT, CT, CT, CT, CT, CT, CT, BK|CT,
|
|
|
|
/* 10 */ SP|CT, SP|CT, SP|CT, SP|CT, CT, CT, CT, CT, CT, CT,
|
|
|
|
/* 20 */ CT, CT, CT, CT, CT, CT, CT, CT, CT, CT,
|
|
|
|
/* 30 */ CT, CT, BK|PR, PT, PT, PT, PT, PT, PT, PT,
|
|
|
|
/* 40 */ PT, PT, PT, PT, PT, PT, PT, PT, DG, DG,
|
|
|
|
/* 50 */ DG, DG, DG, DG, DG, DG, DG, DG, PT, PT,
|
|
|
|
/* 60 */ PT, PT, PT, PT, PT, UP|DX, UP|DX, UP|DX, UP|DX, UP|DX,
|
|
|
|
/* 70 */ UP|DX, UP, UP, UP, UP, UP, UP, UP, UP, UP,
|
|
|
|
/* 80 */ UP, UP, UP, UP, UP, UP, UP, UP, UP, UP,
|
|
|
|
/* 90 */ UP, PT, PT, PT, PT, PT, PT, LW|DX, LW|DX, LW|DX,
|
|
|
|
/* 100 */ LW|DX, LW|DX, LW|DX, LW, LW, LW, LW, LW, LW, LW,
|
|
|
|
/* 110 */ LW, LW, LW, LW, LW, LW, LW, LW, LW, LW,
|
|
|
|
/* 120 */ LW, LW, LW, PT, PT, PT, PT, CT,
|
|
|
|
};
|
|
|
|
|
2020-01-09 12:55:19 +01:00
|
|
|
static_assert(sizeof(__ctype) == 128 * sizeof(int),
|
|
|
|
"ctype table: invalid size");
|
2019-03-08 09:00:55 +01:00
|
|
|
|
|
|
|
int tolower(int c)
|
|
|
|
{
|
|
|
|
if (isupper(c)) return c + ('a' - 'A');
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
int toupper(int c)
|
|
|
|
{
|
|
|
|
if (islower(c)) return c - ('a' - 'A');
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|