1 /* Copyright (c) 2002 Thomas Fitzsimmons <fitzsim@redhat.com> */
2 /*
3 FUNCTION
4 	<<isblank>>, <<isblank_l>>---blank character predicate
5 
6 INDEX
7 	isblank
8 
9 INDEX
10 	isblank_l
11 
12 SYNOPSIS
13 	#include <ctype.h>
14 	int isblank(int <[c]>);
15 
16 	#include <ctype.h>
17 	int isblank_l(int <[c]>, locale_t <[locale]>);
18 
19 DESCRIPTION
20 <<isblank>> is a function which classifies singlebyte charset values by table
21 lookup.  It is a predicate returning non-zero for blank characters, and 0
22 for other characters.  It is defined only if <[c]> is representable as an
23 unsigned char or if <[c]> is EOF.
24 
25 <<isblank_l>> is like <<isblank>> but performs the check based on the
26 locale specified by the locale object locale.  If <[locale]> is
27 LC_GLOBAL_LOCALE or not a valid locale object, the behaviour is undefined.
28 
29 RETURNS
30 <<isblank>>, <<isblank_l>> return non-zero if <[c]> is a blank character.
31 
32 PORTABILITY
33 <<isblank>> is C99.
34 <<isblank_l>> is POSIX-1.2008.
35 
36 No supporting OS subroutines are required.
37 */
38 
39 #include <ctype.h>
40 
41 #undef isblank
42 int
isblank(int c)43 isblank (int c)
44 {
45 #if _PICOLIBC_CTYPE_SMALL
46     return c == ' ' || c == '\t';
47 #else
48     return(__CTYPE_PTR[c+1] & _B) || c == '\t';
49 #endif
50 }
51