summaryrefslogtreecommitdiff
path: root/components/libc/minilibc/ctype.c
blob: fed8f583a69ba328ffef8e53d031daecc80fd8bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * File      : ctype.c
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2008, RT-Thread Development Team
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rt-thread.org/license/LICENSE
 *
 * Change Logs:
 * Date           Author       Notes
 * 2008-08-14     Bernard      the first version
 */

#include <rtthread.h>
#include <sys/types.h>

#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC)
#include "ctype.h"

int isprint (int ch)
{
	ch&=0x7f;
	return (ch>=32 && ch<127);
}

int isalpha(int ch)
{
	return (unsigned int)((ch | 0x20) - 'a') < 26u;
}

int isdigit (int ch)
{
	return (unsigned int)(ch - '0') < 10u;
}

int isspace(int ch)
{
	switch(ch)
	{
	case ' ':
	case '\n':
	case '\f':
	case '\r':
	case '\t':
	case '\v':
		return 1;
	default:
		return 0; 
	}    
}

#endif