1995-02-18 01:27:10 +00:00
|
|
|
/* Copyright (C) 1991, 1992, 1993, 1995 Free Software Foundation, Inc.
|
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library 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
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
|
|
|
not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
|
|
|
|
Cambridge, MA 02139, USA. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ANSI Standard 4.3: CHARACTER HANDLING <ctype.h>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CTYPE_H
|
|
|
|
|
|
|
|
#define _CTYPE_H 1
|
|
|
|
#include <features.h>
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
1995-03-06 19:57:00 +00:00
|
|
|
/* These are all the characteristics of characters.
|
|
|
|
If there get to be more than 16 distinct characteristics,
|
|
|
|
many things must be changed that use `unsigned short int's.
|
|
|
|
|
|
|
|
The characteristics are stored always in network byte order (big
|
|
|
|
endian). We define the bit value interpretations here dependent on the
|
|
|
|
machine's byte order. */
|
|
|
|
|
|
|
|
#include <endian.h>
|
|
|
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
|
|
|
#define _ISbit(bit) (1 << bit)
|
|
|
|
#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
|
1995-03-10 05:01:07 +00:00
|
|
|
#define _ISbit(bit) (bit < 8 ? ((1 << bit) << 8) : ((1 << bit) >> 8))
|
1995-03-06 19:57:00 +00:00
|
|
|
#endif
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
enum
|
|
|
|
{
|
1995-03-06 19:57:00 +00:00
|
|
|
_ISupper = _ISbit (0), /* UPPERCASE. */
|
|
|
|
_ISlower = _ISbit (1), /* lowercase. */
|
|
|
|
_ISalpha = _ISbit (2), /* Alphabetic. */
|
|
|
|
_ISdigit = _ISbit (3), /* Numeric. */
|
|
|
|
_ISxdigit = _ISbit (4), /* Hexadecimal numeric. */
|
|
|
|
_ISspace = _ISbit (5), /* Whitespace. */
|
|
|
|
_ISprint = _ISbit (6), /* Printing. */
|
|
|
|
_ISgraph = _ISbit (7), /* Graphical. */
|
|
|
|
_ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */
|
|
|
|
_IScntrl = _ISbit (9), /* Control character. */
|
|
|
|
_ISpunct = _ISbit (10), /* Punctuation. */
|
Sun Mar 5 19:40:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/localeinfo.h: Rewritten for new locale system, using
locale data files and with <langinfo.h> interface.
* locale/setlocale.c: Rewritten to use locale data files.
* langinfo.h: New file.
* locale/langinfo.h: New file.
* locale/nl_langinfo.c: New file.
* locale/loadlocale.c: New file.
* locale/lc-ctype.c: New file.
* locale/lc-messages.c: New file.
* locale/lc-monetary.c: New file.
* locale/lc-numeric.c: New file.
* locale/lc-time.c: New file.
* locale/categories.def: New file.
* locale/Makefile (headers): Remove localeinfo.h.
(distribute): New variable; put localeinfo.h here, and categories.def.
(routines): Add loadlocale.
(categories): New variable.
(aux): Use that to get C-category and lc-category.
* ctype/ctype.h (_IS*): Use independent bits for all but _ISalnum.
* locale/C-ctype.c, locale/C-messages.c: New files.
* locale/C-monetary.c, locale/C-numeric.c, locale/C-time.c:
Default "C" locale data updated for new locale system.
* locale/C-collate.c: File removed.
* locale/C-ctype_ct.c: File removed.
* locale/C-ctype_mb.c: File removed.
* locale/C-response.c: File removed.
* locale/localeconv.c: Use _NL_CURRENT macro to access locale data.
* stdio/printf_fp.c, stdio/vfprintf.c, stdio/vfscanf.c,
stdlib/strtod.c, time/asctime.c, time/strftime.c:
Include ../locale/localeinfo.h and use _NL_CURRENT macro to access
locale data.
* time/localtime.c: Don't include <localeinfo.h>.
* time/tzset.c: Don't use locale items for default TZ value or
"GMT" string (use "UTC").
* stdio/vfprintf.c [USE_IN_LIBIO] (PAD): Only call the function if
WIDTH>0; update DONE.
* malloc/malloc.c (morecore): Fix last change to calculate by
blocks instead of bytes.
1995-03-06 03:00:08 +00:00
|
|
|
|
|
|
|
/* The following are defined in POSIX.2 as being combinations of the
|
|
|
|
classes above. */
|
|
|
|
_ISalnum = _ISalpha | _ISdigit /* Alphanumeric. */
|
1995-02-18 01:27:10 +00:00
|
|
|
};
|
|
|
|
|
1995-03-06 19:57:00 +00:00
|
|
|
/* These are defined in ctype-info.c.
|
1995-02-18 01:27:10 +00:00
|
|
|
The declarations here must match those in localeinfo.h.
|
|
|
|
|
1995-03-06 19:57:00 +00:00
|
|
|
These point into arrays of 384, so they can be indexed by any `unsigned
|
|
|
|
char' value [0,255]; by EOF (-1); or by any `signed char' value
|
|
|
|
[-128,-1). ANSI requires that the ctype functions work for `unsigned
|
|
|
|
char' values and for EOF; we also support negative `signed char' values
|
Wed Mar 8 13:38:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* posix/glob/configure.bat: Fixes from DJ.
* time/backward, time/europe, time/northamerica, time/pacificnew,
time/zdump.c, time/zic.c, time/tzfile.h, time/private.h,
time/ialloc.c: Code and data updated from ADO's 95b.
* time/emkdir.c: File removed.
* time/Makefile (distribute, extra-objs, zic): Omit it.
* time/localtime.c: Deansideclized. Never #define __tzname et al
to non-__ names.
* locale/lc-ctype.c (__ctype_tolower, __ctype_toupper): Use int *
instead of short int *.
* ctype/ctype-info.c: Likewise.
* ctype/ctype.h: Likewise.
* locale/langinfo.h (_NL_CTYPE_CLASS): Use this (just one) instead
of EB and EL versions.
1995-03-09 10:00:12 +00:00
|
|
|
for broken old programs. The case conversion arrays are of `int's
|
1995-03-06 19:57:00 +00:00
|
|
|
rather than `unsigned char's because tolower (EOF) must be EOF, which
|
|
|
|
doesn't fit into an `unsigned char'. */
|
1995-02-18 01:27:10 +00:00
|
|
|
extern __const unsigned short int *__ctype_b; /* Characteristics. */
|
Wed Mar 8 13:38:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* posix/glob/configure.bat: Fixes from DJ.
* time/backward, time/europe, time/northamerica, time/pacificnew,
time/zdump.c, time/zic.c, time/tzfile.h, time/private.h,
time/ialloc.c: Code and data updated from ADO's 95b.
* time/emkdir.c: File removed.
* time/Makefile (distribute, extra-objs, zic): Omit it.
* time/localtime.c: Deansideclized. Never #define __tzname et al
to non-__ names.
* locale/lc-ctype.c (__ctype_tolower, __ctype_toupper): Use int *
instead of short int *.
* ctype/ctype-info.c: Likewise.
* ctype/ctype.h: Likewise.
* locale/langinfo.h (_NL_CTYPE_CLASS): Use this (just one) instead
of EB and EL versions.
1995-03-09 10:00:12 +00:00
|
|
|
extern __const int *__ctype_tolower; /* Case conversions. */
|
|
|
|
extern __const int *__ctype_toupper; /* Case conversions. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
#define __isctype(c, type) \
|
|
|
|
(__ctype_b[(int) (c)] & (unsigned short int) type)
|
|
|
|
|
|
|
|
#define __isascii(c) (((c) & (1 << 7)) == 0) /* If high bit is set. */
|
|
|
|
#define __toascii(c) ((c) & 0x7f) /* Mask off high bit. */
|
|
|
|
|
|
|
|
#define __tolower(c) ((int) __ctype_tolower[(int) (c)])
|
|
|
|
#define __toupper(c) ((int) __ctype_toupper[(int) (c)])
|
|
|
|
|
|
|
|
#define __exctype(name) extern int name __P ((int))
|
|
|
|
|
|
|
|
/* The following names are all functions:
|
|
|
|
int isCHARACTERISTIC(int c);
|
|
|
|
which return nonzero iff C has CHARACTERISTIC.
|
|
|
|
For the meaning of the characteristic names, see the `enum' above. */
|
|
|
|
__exctype (isalnum);
|
|
|
|
__exctype (isalpha);
|
|
|
|
__exctype (iscntrl);
|
|
|
|
__exctype (isdigit);
|
|
|
|
__exctype (islower);
|
|
|
|
__exctype (isgraph);
|
|
|
|
__exctype (isprint);
|
|
|
|
__exctype (ispunct);
|
|
|
|
__exctype (isspace);
|
|
|
|
__exctype (isupper);
|
|
|
|
__exctype (isxdigit);
|
|
|
|
|
|
|
|
#ifdef __USE_GNU
|
|
|
|
__exctype (isblank);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the lowercase version of C. */
|
|
|
|
extern int tolower __P ((int __c));
|
|
|
|
|
|
|
|
/* Return the uppercase version of C. */
|
|
|
|
extern int toupper __P ((int __c));
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__USE_SVID) || defined(__USE_MISC)
|
|
|
|
|
|
|
|
/* Return nonzero iff C is in the ASCII set
|
|
|
|
(i.e., is no more than 7 bits wide). */
|
|
|
|
extern int isascii __P ((int __c));
|
|
|
|
|
|
|
|
/* Return the part of C that is in the ASCII set
|
|
|
|
(i.e., the low-order 7 bits of C). */
|
|
|
|
extern int toascii __P ((int __c));
|
|
|
|
|
|
|
|
#endif /* Use SVID or use misc. */
|
|
|
|
|
|
|
|
#ifdef __USE_SVID
|
Sun Mar 5 19:40:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/localeinfo.h: Rewritten for new locale system, using
locale data files and with <langinfo.h> interface.
* locale/setlocale.c: Rewritten to use locale data files.
* langinfo.h: New file.
* locale/langinfo.h: New file.
* locale/nl_langinfo.c: New file.
* locale/loadlocale.c: New file.
* locale/lc-ctype.c: New file.
* locale/lc-messages.c: New file.
* locale/lc-monetary.c: New file.
* locale/lc-numeric.c: New file.
* locale/lc-time.c: New file.
* locale/categories.def: New file.
* locale/Makefile (headers): Remove localeinfo.h.
(distribute): New variable; put localeinfo.h here, and categories.def.
(routines): Add loadlocale.
(categories): New variable.
(aux): Use that to get C-category and lc-category.
* ctype/ctype.h (_IS*): Use independent bits for all but _ISalnum.
* locale/C-ctype.c, locale/C-messages.c: New files.
* locale/C-monetary.c, locale/C-numeric.c, locale/C-time.c:
Default "C" locale data updated for new locale system.
* locale/C-collate.c: File removed.
* locale/C-ctype_ct.c: File removed.
* locale/C-ctype_mb.c: File removed.
* locale/C-response.c: File removed.
* locale/localeconv.c: Use _NL_CURRENT macro to access locale data.
* stdio/printf_fp.c, stdio/vfprintf.c, stdio/vfscanf.c,
stdlib/strtod.c, time/asctime.c, time/strftime.c:
Include ../locale/localeinfo.h and use _NL_CURRENT macro to access
locale data.
* time/localtime.c: Don't include <localeinfo.h>.
* time/tzset.c: Don't use locale items for default TZ value or
"GMT" string (use "UTC").
* stdio/vfprintf.c [USE_IN_LIBIO] (PAD): Only call the function if
WIDTH>0; update DONE.
* malloc/malloc.c (morecore): Fix last change to calculate by
blocks instead of bytes.
1995-03-06 03:00:08 +00:00
|
|
|
/* These are the same as `toupper' and `tolower'. */
|
1995-02-18 01:27:10 +00:00
|
|
|
__exctype (_toupper);
|
|
|
|
__exctype (_tolower);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __NO_CTYPE
|
|
|
|
#define isalnum(c) __isctype((c), _ISalnum)
|
|
|
|
#define isalpha(c) __isctype((c), _ISalpha)
|
|
|
|
#define iscntrl(c) __isctype((c), _IScntrl)
|
|
|
|
#define isdigit(c) __isctype((c), _ISdigit)
|
|
|
|
#define islower(c) __isctype((c), _ISlower)
|
|
|
|
#define isgraph(c) __isctype((c), _ISgraph)
|
|
|
|
#define isprint(c) __isctype((c), _ISprint)
|
|
|
|
#define ispunct(c) __isctype((c), _ISpunct)
|
|
|
|
#define isspace(c) __isctype((c), _ISspace)
|
|
|
|
#define isupper(c) __isctype((c), _ISupper)
|
|
|
|
#define isxdigit(c) __isctype((c), _ISxdigit)
|
|
|
|
|
|
|
|
#ifdef __USE_GNU
|
|
|
|
#define isblank(c) __isctype((c), _ISblank)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define tolower(c) __tolower(c)
|
|
|
|
#define toupper(c) __toupper(c)
|
|
|
|
|
|
|
|
#if defined(__USE_SVID) || defined(__USE_MISC)
|
|
|
|
#define isascii(c) __isascii(c)
|
|
|
|
#define toascii(c) __toascii(c)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* Not __NO_CTYPE. */
|
|
|
|
|
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif /* ctype.h */
|