/* Copyright (C) 2008 Emmanuel Varoquaux
This file is part of XOS.
This program 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
(at your option) any later version.
This program 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 this program. If not, see . */
#include "ctype.h"
#include
/* classes de caracteres */
#define CC_ISUPPER 0001
#define CC_ISLOWER 0002
#define CC_ISCNTRL 0004
#define CC_ISDIGIT 0010
#define CC_ISSPACE 0020
#define CC_ISHEX 0040
#define CC_ISPUNCT 0100
#define CC_NOGRAPH 0200
#define CC_ISBLANK 0400
#define CC_ISALPHA (CC_ISUPPER | CC_ISLOWER)
#define CC_ISALNUM (CC_ISALPHA | CC_ISDIGIT)
#define CC_ISXDIGIT (CC_ISDIGIT | CC_ISHEX)
#define CC_ISGRAPH (CC_ISALNUM | CC_ISPUNCT)
#define CC_ISPRINT (CC_ISGRAPH | CC_NOGRAPH)
static const unsigned short _cc_table[257] = {
0,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL | CC_ISSPACE | CC_ISBLANK,
CC_ISCNTRL | CC_ISSPACE,
CC_ISCNTRL | CC_ISSPACE,
CC_ISCNTRL | CC_ISSPACE,
CC_ISCNTRL | CC_ISSPACE,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL,
CC_ISCNTRL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ISLOWER | CC_ISHEX,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISLOWER,
CC_ISPUNCT,
CC_ISPUNCT,
CC_ISPUNCT,
CC_ISPUNCT,
CC_ISCNTRL,
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
};
static const short _tolower_table[257] = {
EOF,
'\000',
'\001',
'\002',
'\003',
'\004',
'\005',
'\006',
'\007',
'\010',
'\011',
'\012',
'\013',
'\014',
'\015',
'\016',
'\017',
'\020',
'\021',
'\022',
'\023',
'\024',
'\025',
'\026',
'\027',
'\030',
'\031',
'\032',
'\033',
'\034',
'\035',
'\036',
'\037',
'\040',
'!',
'"',
'#',
'$',
'%',
'&',
'\'',
'(',
')',
'*',
'+',
',',
'-',
'.',
'/',
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
':',
';',
'<',
'=',
'>',
'?',
'@',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'[',
'\\',
']',
'^',
'_',
'`',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'{',
'|',
'}',
'~',
'\177',
'\200',
'\201',
'\202',
'\203',
'\204',
'\205',
'\206',
'\207',
'\210',
'\211',
'\212',
'\213',
'\214',
'\215',
'\216',
'\217',
'\220',
'\221',
'\222',
'\223',
'\224',
'\225',
'\226',
'\227',
'\230',
'\231',
'\232',
'\233',
'\234',
'\235',
'\236',
'\237',
'\240',
'\241',
'\242',
'\243',
'\244',
'\245',
'\246',
'\247',
'\250',
'\251',
'\252',
'\253',
'\254',
'\255',
'\256',
'\257',
'\260',
'\261',
'\262',
'\263',
'\264',
'\265',
'\266',
'\267',
'\270',
'\271',
'\272',
'\273',
'\274',
'\275',
'\276',
'\277',
'\300',
'\301',
'\302',
'\303',
'\304',
'\305',
'\306',
'\307',
'\310',
'\311',
'\312',
'\313',
'\314',
'\315',
'\316',
'\317',
'\320',
'\321',
'\322',
'\323',
'\324',
'\325',
'\326',
'\327',
'\330',
'\331',
'\332',
'\333',
'\334',
'\335',
'\336',
'\337',
'\340',
'\341',
'\342',
'\343',
'\344',
'\345',
'\346',
'\347',
'\350',
'\351',
'\352',
'\353',
'\354',
'\355',
'\356',
'\357',
'\360',
'\361',
'\362',
'\363',
'\364',
'\365',
'\366',
'\367',
'\370',
'\371',
'\372',
'\373',
'\374',
'\375',
'\376',
'\377'
};
static const short _toupper_table[257] = {
EOF,
'\000',
'\001',
'\002',
'\003',
'\004',
'\005',
'\006',
'\007',
'\010',
'\011',
'\012',
'\013',
'\014',
'\015',
'\016',
'\017',
'\020',
'\021',
'\022',
'\023',
'\024',
'\025',
'\026',
'\027',
'\030',
'\031',
'\032',
'\033',
'\034',
'\035',
'\036',
'\037',
'\040',
'!',
'"',
'#',
'$',
'%',
'&',
'\'',
'(',
')',
'*',
'+',
',',
'-',
'.',
'/',
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
':',
';',
'<',
'=',
'>',
'?',
'@',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'[',
'\\',
']',
'^',
'_',
'`',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'{',
'|',
'}',
'~',
'\177',
'\200',
'\201',
'\202',
'\203',
'\204',
'\205',
'\206',
'\207',
'\210',
'\211',
'\212',
'\213',
'\214',
'\215',
'\216',
'\217',
'\220',
'\221',
'\222',
'\223',
'\224',
'\225',
'\226',
'\227',
'\230',
'\231',
'\232',
'\233',
'\234',
'\235',
'\236',
'\237',
'\240',
'\241',
'\242',
'\243',
'\244',
'\245',
'\246',
'\247',
'\250',
'\251',
'\252',
'\253',
'\254',
'\255',
'\256',
'\257',
'\260',
'\261',
'\262',
'\263',
'\264',
'\265',
'\266',
'\267',
'\270',
'\271',
'\272',
'\273',
'\274',
'\275',
'\276',
'\277',
'\300',
'\301',
'\302',
'\303',
'\304',
'\305',
'\306',
'\307',
'\310',
'\311',
'\312',
'\313',
'\314',
'\315',
'\316',
'\317',
'\320',
'\321',
'\322',
'\323',
'\324',
'\325',
'\326',
'\327',
'\330',
'\331',
'\332',
'\333',
'\334',
'\335',
'\336',
'\337',
'\340',
'\341',
'\342',
'\343',
'\344',
'\345',
'\346',
'\347',
'\350',
'\351',
'\352',
'\353',
'\354',
'\355',
'\356',
'\357',
'\360',
'\361',
'\362',
'\363',
'\364',
'\365',
'\366',
'\367',
'\370',
'\371',
'\372',
'\373',
'\374',
'\375',
'\376',
'\377'
};
static const unsigned short *cc_table = _cc_table + 1;
static const short *tolower_table = _tolower_table + 1;
static const short *toupper_table = _toupper_table + 1;
int __attribute__ ((weak, visibility ("default"))) isalnum(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISALNUM;
}
typeof (isalnum) __isalnum __attribute__ ((alias ("isalnum")));
int __attribute__ ((weak, visibility ("default"))) isalpha(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISALPHA;
}
typeof (isalpha) __isalpha __attribute__ ((alias ("isalpha")));
int __attribute__ ((weak, visibility ("default"))) isascii(int c)
{
return (c & (1 << 7)) == 0;
}
typeof (isascii) __isascii __attribute__ ((alias ("isascii")));
int __attribute__ ((weak, visibility ("default"))) isblank(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISBLANK;
}
typeof (isblank) __isblank __attribute__ ((alias ("isblank")));
int __attribute__ ((weak, visibility ("default"))) iscntrl(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISCNTRL;
}
typeof (iscntrl) __iscntrl __attribute__ ((alias ("iscntrl")));
int __attribute__ ((weak, visibility ("default"))) isdigit(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISDIGIT;
}
typeof (isdigit) __isdigit __attribute__ ((alias ("isdigit")));
int __attribute__ ((weak, visibility ("default"))) isgraph(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISGRAPH;
}
typeof (isgraph) __isgraph __attribute__ ((alias ("isgraph")));
int __attribute__ ((weak, visibility ("default"))) islower(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISLOWER;
}
typeof (islower) __islower __attribute__ ((alias ("islower")));
int __attribute__ ((weak, visibility ("default"))) isprint(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISPRINT;
}
typeof (isprint) __isprint __attribute__ ((alias ("isprint")));
int __attribute__ ((weak, visibility ("default"))) ispunct(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISPUNCT;
}
typeof (ispunct) __ispunct __attribute__ ((alias ("ispunct")));
int __attribute__ ((weak, visibility ("default"))) isspace(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISSPACE;
}
typeof (isspace) __isspace __attribute__ ((alias ("isspace")));
int __attribute__ ((weak, visibility ("default"))) isupper(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISUPPER;
}
typeof (isupper) __isupper __attribute__ ((alias ("isupper")));
int __attribute__ ((weak, visibility ("default"))) isxdigit(int c)
{
return cc_table[c == EOF ? -1 : c] & CC_ISHEX;
}
typeof (isxdigit) __isxdigit __attribute__ ((alias ("isxdigit")));
int __attribute__ ((weak, visibility ("default"))) toascii(int c)
{
return c & 0x7f;
}
typeof (toascii) __toascii __attribute__ ((alias ("toascii")));
int __attribute__ ((weak, visibility ("default"))) tolower(int c)
{
return c == EOF ? tolower_table[-1] : (unsigned char)tolower_table[c];
}
typeof (tolower) __tolower __attribute__ ((alias ("tolower")));
int __attribute__ ((weak, visibility ("default"))) toupper(int c)
{
return c == EOF ? toupper_table[-1] : (unsigned char)toupper_table[c];
}
typeof (toupper) __toupper __attribute__ ((alias ("toupper")));