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