BSD 4_3_Net_2 release
[unix-history] / usr / src / lib / libg++ / g++-include / grot / ctype.h
CommitLineData
dbb879ad
C
1// Here's a ctype.h for SunOS-3 and vax 4.3BSD.
2// It will probably work on most BSD derived systems.
3// Just compare it to the C version to verify.
4// No big deal, but it will save you some typing.
5
6#ifndef _ctype_h
7#ifdef __GNUG__
8#pragma once
9#pragma interface
10#endif
11#define _ctype_h
12
13int isalpha(char c);
14int isupper(char c);
15int islower(char c);
16int isdigit(char c);
17int isxdigit(char c);
18int isspace(char c);
19int ispunct(char c);
20int isalnum(char c);
21int isprint(char c);
22int isgraph(char c);
23int iscntrl(char c);
24int isascii(char c);
25int toupper(char c);
26int tolower(char c);
27int toascii(char c);
28
29#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
30
31#include <stdio.h> /* sorry, but needed for USG stuff */
32
33static const int _U = 01;
34static const int _L = 02;
35static const int _N = 04;
36static const int _S = 010;
37static const int _P = 020;
38static const int _C = 040;
39
40
41#if defined(USG) || defined(DGUX)
42static const int _B = 0100; /* different from BSD */
43static const int _X = 0200; /* different from BSD */
44#else
45static const int _X = 0100;
46static const int _B = 0200;
47#endif
48
49
50#ifdef DGUX
51#define CTYPE_TYPE short
52#else
53#define CTYPE_TYPE char
54#endif
55
56#if defined(DGUX) || defined(USG) || defined(hpux)
57#define _ctype_ _ctype
58#endif
59
60extern "C" {
61extern CTYPE_TYPE _ctype_[];
62}
63
64/*
65* The following bit of ugliness is to ensure that the __ctype__[]
66* initialization is brought in from the VAX-11 "C" runtime library
67*/
68#ifdef VMS
69#define _ctype_ $$PsectAttributes_NOWRT$$_ctype_
70extern char _ctype_[];
71extern "C" {
72 extern c$v_ctypedefs();
73 static __ctype__dummy(){c$v_ctypedefs();}
74 }
75#endif
76
77
78#ifdef VMS
79inline int isalpha(char c) { return ((_ctype_)[c]&(_U|_L)); }
80inline int isupper(char c) { return ((_ctype_)[c]&_U); }
81inline int islower(char c) { return ((_ctype_)[c]&_L); }
82inline int isdigit(char c) { return ((_ctype_)[c]&_N); }
83inline int isxdigit(char c) { return ((_ctype_)[c]&_X); }
84inline int isspace(char c) { return ((_ctype_)[c]&_S); }
85inline int ispunct(char c) { return ((_ctype_)[c]&_P); }
86inline int isalnum(char c) { return ((_ctype_)[c]&(_U|_L|_N)); }
87inline int isprint(char c) { return ((_ctype_)[c]&(_P|_U|_L|_N|_B)); }
88inline int isgraph(char c) { return ((_ctype_)[c]&(_P|_U|_L|_N)); }
89inline int iscntrl(char c) { return ((_ctype_)[c]&_C); }
90inline int isascii(char c) { return ((unsigned)(c)<=0177); }
91inline int toupper(char c) { return ((c)-'a'+'A'); }
92inline int tolower(char c) { return ((c)-'A'+'a'); }
93inline int toascii(char c) { return ((c)&0177); }
94#else
95inline int isalpha(char c) { return ((_ctype_+1)[c]&(_U|_L)); }
96inline int isupper(char c) { return ((_ctype_+1)[c]&_U); }
97inline int islower(char c) { return ((_ctype_+1)[c]&_L); }
98inline int isdigit(char c) { return ((_ctype_+1)[c]&_N); }
99inline int isxdigit(char c) { return ((_ctype_+1)[c]&_X); }
100inline int isspace(char c) { return ((_ctype_+1)[c]&_S); }
101inline int ispunct(char c) { return ((_ctype_+1)[c]&_P); }
102inline int isalnum(char c) { return ((_ctype_+1)[c]&(_U|_L|_N)); }
103inline int isprint(char c) { return ((_ctype_+1)[c]&(_P|_U|_L|_N|_B)); }
104inline int isgraph(char c) { return ((_ctype_+1)[c]&(_P|_U|_L|_N)); }
105inline int iscntrl(char c) { return ((_ctype_+1)[c]&_C); }
106inline int isascii(char c) { return ((unsigned)(c)<=0177); }
107inline int toupper(char c) { return islower(c)? (c-'a'+'A') : c; }
108inline int tolower(char c) { return isupper(c)? (c-'A'+'a') : c; }
109inline int toascii(char c) { return ((c)&0177); }
110#endif
111
112#ifdef _ctype_
113#undef _ctype_
114#endif
115
116#ifdef CTYPE_TYPE
117#undef CTYPE_TYPE
118#endif
119
120#endif /* __OPTIMIZE__ */
121
122#endif _ctype_h