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