This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 3.0 patch #21 patch #19, continued
[perl5.git] / handy.h
CommitLineData
0d3e774c 1/* $Header: handy.h,v 3.0.1.1 89/11/17 15:25:55 lwall Locked $
a687059c
LW
2 *
3 * Copyright (c) 1989, Larry Wall
4 *
5 * You may distribute under the terms of the GNU General Public License
6 * as specified in the README file that comes with the perl 3.0 kit.
8d063cd8
LW
7 *
8 * $Log: handy.h,v $
0d3e774c
LW
9 * Revision 3.0.1.1 89/11/17 15:25:55 lwall
10 * patch5: some machines already define TRUE and FALSE
11 *
a687059c
LW
12 * Revision 3.0 89/10/18 15:18:24 lwall
13 * 3.0 baseline
8d063cd8
LW
14 *
15 */
16
378cc40b
LW
17#ifdef NULL
18#undef NULL
19#endif
a687059c
LW
20#ifndef I286
21# define NULL 0
22#else
23# define NULL 0L
24#endif
378cc40b 25#define Null(type) ((type)NULL)
8d063cd8
LW
26#define Nullch Null(char*)
27#define Nullfp Null(FILE*)
28
a687059c
LW
29#ifdef UTS
30#define bool int
31#else
8d063cd8 32#define bool char
a687059c 33#endif
0d3e774c
LW
34
35#ifdef TRUE
36#undef TRUE
37#endif
38#ifdef FALSE
39#undef FALSE
40#endif
8d063cd8
LW
41#define TRUE (1)
42#define FALSE (0)
43
44#define Ctl(ch) (ch & 037)
45
46#define strNE(s1,s2) (strcmp(s1,s2))
47#define strEQ(s1,s2) (!strcmp(s1,s2))
48#define strLT(s1,s2) (strcmp(s1,s2) < 0)
49#define strLE(s1,s2) (strcmp(s1,s2) <= 0)
50#define strGT(s1,s2) (strcmp(s1,s2) > 0)
51#define strGE(s1,s2) (strcmp(s1,s2) >= 0)
52#define strnNE(s1,s2,l) (strncmp(s1,s2,l))
53#define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
378cc40b
LW
54
55#define MEM_SIZE unsigned int
56
57/* Line numbers are unsigned, 16 bits. */
58typedef unsigned short line_t;
59#ifdef lint
60#define NOLINE ((line_t)0)
61#else
62#define NOLINE ((line_t) 65535)
63#endif
64
a687059c
LW
65#ifndef lint
66#ifndef LEAKTEST
67char *safemalloc();
68char *saferealloc();
69void safefree();
70#define New(x,v,n,t) (v = (t*)safemalloc((MEM_SIZE)((n) * sizeof(t))))
71#define Newc(x,v,n,t,c) (v = (c*)safemalloc((MEM_SIZE)((n) * sizeof(t))))
72#define Newz(x,v,n,t) (v = (t*)safemalloc((MEM_SIZE)((n) * sizeof(t)))), \
73 bzero((char*)(v), (n) * sizeof(t))
74#define Renew(v,n,t) (v = (t*)saferealloc((char*)(v),(MEM_SIZE)((n)*sizeof(t))))
75#define Renewc(v,n,t,c) (v = (c*)saferealloc((char*)(v),(MEM_SIZE)((n)*sizeof(t))))
76#define Safefree(d) safefree((char*)d)
77#define Str_new(x,len) str_new(len)
78#else /* LEAKTEST */
79char *safexmalloc();
80char *safexrealloc();
81void safexfree();
82#define New(x,v,n,t) (v = (t*)safexmalloc(x,(MEM_SIZE)((n) * sizeof(t))))
83#define Newc(x,v,n,t,c) (v = (c*)safexmalloc(x,(MEM_SIZE)((n) * sizeof(t))))
84#define Newz(x,v,n,t) (v = (t*)safexmalloc(x,(MEM_SIZE)((n) * sizeof(t)))), \
85 bzero((char*)(v), (n) * sizeof(t))
86#define Renew(v,n,t) (v = (t*)safexrealloc((char*)(v),(MEM_SIZE)((n)*sizeof(t))))
87#define Renewc(v,n,t,c) (v = (c*)safexrealloc((char*)(v),(MEM_SIZE)((n)*sizeof(t))))
88#define Safefree(d) safexfree((char*)d)
89#define Str_new(x,len) str_new(x,len)
90#define MAXXCOUNT 1200
91long xcount[MAXXCOUNT];
92long lastxcount[MAXXCOUNT];
93#endif /* LEAKTEST */
94#define Copy(s,d,n,t) (void)bcopy((char*)(s),(char*)(d), (n) * sizeof(t))
95#define Zero(d,n,t) (void)bzero((char*)(d), (n) * sizeof(t))
96#else /* lint */
97#define New(x,v,n,s) (v = Null(s *))
98#define Newc(x,v,n,s,c) (v = Null(s *))
99#define Newz(x,v,n,s) (v = Null(s *))
100#define Renew(v,n,s) (v = Null(s *))
101#define Copy(s,d,n,t)
102#define Zero(d,n,t)
103#define Safefree(d) d = d
104#endif /* lint */