1 /* $Header: handy.h,v 3.0.1.1 89/11/17 15:25:55 lwall Locked $
3 * Copyright (c) 1989, Larry Wall
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.
9 * Revision 3.0.1.1 89/11/17 15:25:55 lwall
10 * patch5: some machines already define TRUE and FALSE
12 * Revision 3.0 89/10/18 15:18:24 lwall
25 #define Null(type) ((type)NULL)
26 #define Nullch Null(char*)
27 #define Nullfp Null(FILE*)
44 #define Ctl(ch) (ch & 037)
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))
55 #define MEM_SIZE unsigned int
57 /* Line numbers are unsigned, 16 bits. */
58 typedef unsigned short line_t;
60 #define NOLINE ((line_t)0)
62 #define NOLINE ((line_t) 65535)
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)
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
91 long xcount[MAXXCOUNT];
92 long lastxcount[MAXXCOUNT];
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))
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)
103 #define Safefree(d) d = d