Commit | Line | Data |
ee0007ab |
1 | /* $RCSfile: perl.h,v $$Revision: 4.0.1.6 $$Date: 92/06/08 14:55:10 $ |
a687059c |
2 | * |
352d5a3a |
3 | * Copyright (c) 1991, Larry Wall |
a687059c |
4 | * |
352d5a3a |
5 | * You may distribute under the terms of either the GNU General Public |
6 | * License or the Artistic License, as specified in the README file. |
8d063cd8 |
7 | * |
8 | * $Log: perl.h,v $ |
ee0007ab |
9 | * Revision 4.0.1.6 92/06/08 14:55:10 lwall |
10 | * patch20: added Atari ST portability |
11 | * patch20: bcopy() and memcpy() now tested for overlap safety |
12 | * patch20: Perl now distinguishes overlapped copies from non-overlapped |
13 | * patch20: removed implicit int declarations on functions |
14 | * |
988174c1 |
15 | * Revision 4.0.1.5 91/11/11 16:41:07 lwall |
16 | * patch19: uts wrongly defines S_ISDIR() et al |
17 | * patch19: too many preprocessors can't expand a macro right in #if |
18 | * patch19: added little-endian pack/unpack options |
19 | * |
45d8adaa |
20 | * Revision 4.0.1.4 91/11/05 18:06:10 lwall |
21 | * patch11: various portability fixes |
22 | * patch11: added support for dbz |
23 | * patch11: added some support for 64-bit integers |
24 | * patch11: hex() didn't understand leading 0x |
25 | * |
1462b684 |
26 | * Revision 4.0.1.3 91/06/10 01:25:10 lwall |
27 | * patch10: certain pattern optimizations were botched |
28 | * |
352d5a3a |
29 | * Revision 4.0.1.2 91/06/07 11:28:33 lwall |
30 | * patch4: new copyright notice |
31 | * patch4: made some allowances for "semi-standard" C |
32 | * patch4: many, many itty-bitty portability fixes |
33 | * |
35c8bce7 |
34 | * Revision 4.0.1.1 91/04/11 17:49:51 lwall |
35 | * patch1: hopefully straightened out some of the Xenix mess |
36 | * |
fe14fcc3 |
37 | * Revision 4.0 91/03/20 01:37:56 lwall |
38 | * 4.0 baseline. |
8d063cd8 |
39 | * |
40 | */ |
41 | |
35c8bce7 |
42 | #define VOIDWANT 1 |
ac58e20f |
43 | #include "config.h" |
44 | |
45d8adaa |
45 | #ifdef MYMALLOC |
46 | # ifdef HIDEMYMALLOC |
47 | # define malloc Mymalloc |
48 | # define realloc Myremalloc |
49 | # define free Myfree |
50 | # endif |
51 | # define safemalloc malloc |
52 | # define saferealloc realloc |
53 | # define safefree free |
54 | #endif |
55 | |
56 | /* work around some libPW problems */ |
57 | #define fatal Myfatal |
58 | #ifdef DOINIT |
59 | char Error[1]; |
60 | #endif |
61 | |
ee0007ab |
62 | /* define this once if either system, instead of cluttering up the src */ |
63 | #if defined(MSDOS) || defined(atarist) |
64 | #define DOSISH 1 |
65 | #endif |
66 | |
67 | #ifdef DOSISH |
fe14fcc3 |
68 | /* This stuff now in the MS-DOS config.h file. */ |
0f85fab0 |
69 | #else /* !MSDOS */ |
70 | |
71 | /* |
72 | * The following symbols are defined if your operating system supports |
73 | * functions by that name. All Unixes I know of support them, thus they |
74 | * are not checked by the configuration script, but are directly defined |
75 | * here. |
76 | */ |
fe14fcc3 |
77 | #define HAS_ALARM |
78 | #define HAS_CHOWN |
79 | #define HAS_CHROOT |
80 | #define HAS_FORK |
81 | #define HAS_GETLOGIN |
82 | #define HAS_GETPPID |
83 | #define HAS_KILL |
84 | #define HAS_LINK |
85 | #define HAS_PIPE |
86 | #define HAS_WAIT |
87 | #define HAS_UMASK |
0f85fab0 |
88 | /* |
89 | * The following symbols are defined if your operating system supports |
90 | * password and group functions in general. All Unix systems do. |
91 | */ |
fe14fcc3 |
92 | #define HAS_GROUP |
93 | #define HAS_PASSWD |
0f85fab0 |
94 | |
95 | #endif /* !MSDOS */ |
96 | |
352d5a3a |
97 | #if defined(__STDC__) || defined(_AIX) || defined(__stdc__) |
98 | # define STANDARD_C 1 |
99 | #endif |
100 | |
101 | #if defined(HASVOLATILE) || defined(STANDARD_C) |
663a0e37 |
102 | #define VOLATILE volatile |
663a0e37 |
103 | #else |
104 | #define VOLATILE |
663a0e37 |
105 | #endif |
106 | |
a687059c |
107 | #ifdef IAMSUID |
108 | # ifndef TAINT |
109 | # define TAINT |
110 | # endif |
111 | #endif |
112 | |
fe14fcc3 |
113 | #ifndef HAS_VFORK |
03a14243 |
114 | # define vfork fork |
115 | #endif |
116 | |
fe14fcc3 |
117 | #ifdef HAS_GETPGRP2 |
118 | # ifndef HAS_GETPGRP |
119 | # define HAS_GETPGRP |
663a0e37 |
120 | # endif |
121 | # define getpgrp getpgrp2 |
122 | #endif |
123 | |
fe14fcc3 |
124 | #ifdef HAS_SETPGRP2 |
125 | # ifndef HAS_SETPGRP |
126 | # define HAS_SETPGRP |
663a0e37 |
127 | # endif |
128 | # define setpgrp setpgrp2 |
129 | #endif |
130 | |
fe14fcc3 |
131 | #include <stdio.h> |
132 | #include <ctype.h> |
133 | #include <setjmp.h> |
134 | #ifndef MSDOS |
352d5a3a |
135 | #ifdef PARAM_NEEDS_TYPES |
136 | #include <sys/types.h> |
03a14243 |
137 | #endif |
352d5a3a |
138 | #include <sys/param.h> |
139 | #endif |
140 | #ifdef STANDARD_C |
fe14fcc3 |
141 | /* Use all the "standard" definitions */ |
142 | #include <stdlib.h> |
143 | #include <string.h> |
ee0007ab |
144 | #define MEM_SIZE size_t |
145 | #else |
146 | typedef unsigned int MEM_SIZE; |
352d5a3a |
147 | #endif /* STANDARD_C */ |
03a14243 |
148 | |
ee0007ab |
149 | #if defined(HAS_MEMCMP) && defined(mips) && defined(ultrix) |
fe14fcc3 |
150 | #undef HAS_MEMCMP |
663a0e37 |
151 | #endif |
fe14fcc3 |
152 | |
153 | #ifdef HAS_MEMCPY |
352d5a3a |
154 | # ifndef STANDARD_C |
fe14fcc3 |
155 | # ifndef memcpy |
ee0007ab |
156 | extern char * memcpy(); |
157 | # endif |
158 | # endif |
159 | #else |
160 | # ifndef memcpy |
161 | # ifdef HAS_BCOPY |
162 | # define memcpy(d,s,l) bcopy(s,d,l) |
163 | # else |
164 | # define memcpy(d,s,l) my_bcopy(s,d,l) |
165 | # endif |
166 | # endif |
167 | #endif /* HAS_MEMCPY */ |
fe14fcc3 |
168 | |
ee0007ab |
169 | #ifdef HAS_MEMSET |
170 | # ifndef STANDARD_C |
171 | # ifndef memset |
172 | extern char *memset(); |
173 | # endif |
174 | # endif |
175 | # define memzero(d,l) memset(d,0,l) |
176 | #else |
177 | # ifndef memzero |
178 | # ifdef HAS_BZERO |
179 | # define memzero(d,l) bzero(d,l) |
180 | # else |
181 | # define memzero(d,l) my_bzero(d,l) |
182 | # endif |
352d5a3a |
183 | # endif |
ee0007ab |
184 | #endif /* HAS_MEMSET */ |
185 | |
186 | #ifdef HAS_MEMCMP |
187 | # ifndef STANDARD_C |
188 | # ifndef memcmp |
189 | extern int memcmp(); |
190 | # endif |
191 | # endif |
192 | #else |
193 | # ifndef memcmp |
194 | # define memcmp(s1,s2,l) my_memcmp(s1,s2,l) |
352d5a3a |
195 | # endif |
ee0007ab |
196 | #endif /* HAS_MEMCMP */ |
8d063cd8 |
197 | |
ee0007ab |
198 | /* we prefer bcmp slightly for comparisons that don't care about ordering */ |
199 | #ifndef HAS_BCMP |
352d5a3a |
200 | # ifndef bcmp |
201 | # define bcmp(s1,s2,l) memcmp(s1,s2,l) |
202 | # endif |
ee0007ab |
203 | #endif /* HAS_BCMP */ |
204 | |
205 | #ifndef HAS_MEMMOVE |
206 | #if defined(HAS_BCOPY) && defined(SAFE_BCOPY) |
207 | #define memmove(d,s,l) bcopy(s,d,l) |
208 | #else |
209 | #if defined(HAS_MEMCPY) && defined(SAFE_MEMCPY) |
210 | #define memmove(d,s,l) memcpy(d,s,l) |
211 | #else |
212 | #define memmove(d,s,l) my_bcopy(s,d,l) |
213 | #endif |
214 | #endif |
d9d8d8de |
215 | #endif |
378cc40b |
216 | |
217 | #ifndef _TYPES_ /* If types.h defines this it's easy. */ |
218 | #ifndef major /* Does everyone's types.h define this? */ |
8d063cd8 |
219 | #include <sys/types.h> |
378cc40b |
220 | #endif |
221 | #endif |
222 | |
ae986130 |
223 | #ifdef I_NETINET_IN |
224 | #include <netinet/in.h> |
225 | #endif |
226 | |
8d063cd8 |
227 | #include <sys/stat.h> |
ee0007ab |
228 | #if defined(uts) || defined(UTekV) |
988174c1 |
229 | #undef S_ISDIR |
230 | #undef S_ISCHR |
231 | #undef S_ISBLK |
232 | #undef S_ISREG |
233 | #undef S_ISFIFO |
234 | #undef S_ISLNK |
235 | #define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR) |
236 | #define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR) |
237 | #define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK) |
238 | #define S_ISREG(P) (((P)&S_IFMT)==S_IFREG) |
239 | #define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO) |
ee0007ab |
240 | #ifdef S_IFLNK |
988174c1 |
241 | #define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK) |
242 | #endif |
ee0007ab |
243 | #endif |
135863df |
244 | |
663a0e37 |
245 | #ifdef I_TIME |
246 | # include <time.h> |
ffed7fef |
247 | #endif |
663a0e37 |
248 | |
fe14fcc3 |
249 | #ifdef I_SYS_TIME |
663a0e37 |
250 | # ifdef SYSTIMEKERNEL |
251 | # define KERNEL |
252 | # endif |
253 | # include <sys/time.h> |
254 | # ifdef SYSTIMEKERNEL |
255 | # undef KERNEL |
256 | # endif |
a687059c |
257 | #endif |
135863df |
258 | |
d9d8d8de |
259 | #ifndef MSDOS |
8d063cd8 |
260 | #include <sys/times.h> |
d9d8d8de |
261 | #endif |
8d063cd8 |
262 | |
fe14fcc3 |
263 | #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR)) |
264 | #undef HAS_STRERROR |
663a0e37 |
265 | #endif |
266 | |
267 | #include <errno.h> |
d9d8d8de |
268 | #ifndef MSDOS |
663a0e37 |
269 | #ifndef errno |
270 | extern int errno; /* ANSI allows errno to be an lvalue expr */ |
271 | #endif |
d9d8d8de |
272 | #endif |
663a0e37 |
273 | |
35c8bce7 |
274 | #ifndef strerror |
fe14fcc3 |
275 | #ifdef HAS_STRERROR |
663a0e37 |
276 | char *strerror(); |
277 | #else |
278 | extern int sys_nerr; |
279 | extern char *sys_errlist[]; |
280 | #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e]) |
281 | #endif |
35c8bce7 |
282 | #endif |
663a0e37 |
283 | |
a687059c |
284 | #ifdef I_SYSIOCTL |
285 | #ifndef _IOCTL_ |
286 | #include <sys/ioctl.h> |
287 | #endif |
288 | #endif |
289 | |
ee0007ab |
290 | #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000) |
fe14fcc3 |
291 | #ifdef HAS_SOCKETPAIR |
292 | #undef HAS_SOCKETPAIR |
a687059c |
293 | #endif |
fe14fcc3 |
294 | #ifdef HAS_NDBM |
295 | #undef HAS_NDBM |
a687059c |
296 | #endif |
297 | #endif |
298 | |
45d8adaa |
299 | #ifdef WANT_DBZ |
300 | #include <dbz.h> |
301 | #define SOME_DBM |
302 | #define dbm_fetch(db,dkey) fetch(dkey) |
303 | #define dbm_delete(db,dkey) fatal("dbz doesn't implement delete") |
304 | #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent) |
305 | #define dbm_close(db) dbmclose() |
306 | #define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch()) |
307 | #define nextkey() (fatal("dbz doesn't implement traversal"),fetch()) |
308 | #define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch()) |
309 | #ifdef HAS_NDBM |
310 | #undef HAS_NDBM |
311 | #endif |
312 | #ifndef HAS_ODBM |
313 | #define HAS_ODBM |
314 | #endif |
315 | #else |
fe14fcc3 |
316 | #ifdef HAS_GDBM |
317 | #ifdef I_GDBM |
318 | #include <gdbm.h> |
319 | #endif |
320 | #define SOME_DBM |
321 | #ifdef HAS_NDBM |
322 | #undef HAS_NDBM |
323 | #endif |
324 | #ifdef HAS_ODBM |
325 | #undef HAS_ODBM |
326 | #endif |
327 | #else |
328 | #ifdef HAS_NDBM |
a687059c |
329 | #include <ndbm.h> |
330 | #define SOME_DBM |
fe14fcc3 |
331 | #ifdef HAS_ODBM |
332 | #undef HAS_ODBM |
ae986130 |
333 | #endif |
a687059c |
334 | #else |
fe14fcc3 |
335 | #ifdef HAS_ODBM |
a687059c |
336 | #ifdef NULL |
337 | #undef NULL /* suppress redefinition message */ |
338 | #endif |
339 | #include <dbm.h> |
340 | #ifdef NULL |
341 | #undef NULL |
342 | #endif |
343 | #define NULL 0 /* silly thing is, we don't even use this */ |
344 | #define SOME_DBM |
345 | #define dbm_fetch(db,dkey) fetch(dkey) |
346 | #define dbm_delete(db,dkey) delete(dkey) |
347 | #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent) |
348 | #define dbm_close(db) dbmclose() |
349 | #define dbm_firstkey(db) firstkey() |
fe14fcc3 |
350 | #endif /* HAS_ODBM */ |
351 | #endif /* HAS_NDBM */ |
352 | #endif /* HAS_GDBM */ |
45d8adaa |
353 | #endif /* WANT_DBZ */ |
a687059c |
354 | #ifdef SOME_DBM |
355 | EXT char *dbmkey; |
356 | EXT int dbmlen; |
357 | #endif |
358 | |
359 | #if INTSIZE == 2 |
360 | #define htoni htons |
361 | #define ntohi ntohs |
362 | #else |
363 | #define htoni htonl |
364 | #define ntohi ntohl |
365 | #endif |
366 | |
35c8bce7 |
367 | #if defined(I_DIRENT) |
663a0e37 |
368 | # include <dirent.h> |
369 | # define DIRENT dirent |
ae986130 |
370 | #else |
fe14fcc3 |
371 | # ifdef I_SYS_NDIR |
79a0689e |
372 | # include <sys/ndir.h> |
663a0e37 |
373 | # define DIRENT direct |
374 | # else |
fe14fcc3 |
375 | # ifdef I_SYS_DIR |
79a0689e |
376 | # ifdef hp9000s500 |
377 | # include <ndir.h> /* may be wrong in the future */ |
378 | # else |
379 | # include <sys/dir.h> |
380 | # endif |
663a0e37 |
381 | # define DIRENT direct |
382 | # endif |
383 | # endif |
a687059c |
384 | #endif |
385 | |
352d5a3a |
386 | #ifdef FPUTS_BOTCH |
387 | /* work around botch in SunOS 4.0.1 and 4.0.2 */ |
388 | # ifndef fputs |
389 | # define fputs(str,fp) fprintf(fp,"%s",str) |
390 | # endif |
391 | #endif |
392 | |
c623bd54 |
393 | /* |
394 | * The following gobbledygook brought to you on behalf of __STDC__. |
395 | * (I could just use #ifndef __STDC__, but this is more bulletproof |
396 | * in the face of half-implementations.) |
397 | */ |
398 | |
399 | #ifndef S_IFMT |
400 | # ifdef _S_IFMT |
401 | # define S_IFMT _S_IFMT |
402 | # else |
403 | # define S_IFMT 0170000 |
404 | # endif |
405 | #endif |
406 | |
407 | #ifndef S_ISDIR |
408 | # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) |
409 | #endif |
410 | |
411 | #ifndef S_ISCHR |
412 | # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) |
413 | #endif |
414 | |
415 | #ifndef S_ISBLK |
fe14fcc3 |
416 | # ifdef S_IFBLK |
417 | # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) |
418 | # else |
419 | # define S_ISBLK(m) (0) |
420 | # endif |
c623bd54 |
421 | #endif |
422 | |
423 | #ifndef S_ISREG |
424 | # define S_ISREG(m) ((m & S_IFMT) == S_IFREG) |
425 | #endif |
426 | |
427 | #ifndef S_ISFIFO |
fe14fcc3 |
428 | # ifdef S_IFIFO |
429 | # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) |
430 | # else |
431 | # define S_ISFIFO(m) (0) |
432 | # endif |
c623bd54 |
433 | #endif |
434 | |
435 | #ifndef S_ISLNK |
436 | # ifdef _S_ISLNK |
437 | # define S_ISLNK(m) _S_ISLNK(m) |
438 | # else |
439 | # ifdef _S_IFLNK |
440 | # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK) |
441 | # else |
442 | # ifdef S_IFLNK |
443 | # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK) |
444 | # else |
445 | # define S_ISLNK(m) (0) |
446 | # endif |
447 | # endif |
448 | # endif |
449 | #endif |
450 | |
451 | #ifndef S_ISSOCK |
452 | # ifdef _S_ISSOCK |
453 | # define S_ISSOCK(m) _S_ISSOCK(m) |
454 | # else |
455 | # ifdef _S_IFSOCK |
456 | # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK) |
457 | # else |
458 | # ifdef S_IFSOCK |
459 | # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK) |
460 | # else |
461 | # define S_ISSOCK(m) (0) |
462 | # endif |
463 | # endif |
464 | # endif |
465 | #endif |
466 | |
467 | #ifndef S_IRUSR |
468 | # ifdef S_IREAD |
469 | # define S_IRUSR S_IREAD |
470 | # define S_IWUSR S_IWRITE |
471 | # define S_IXUSR S_IEXEC |
472 | # else |
473 | # define S_IRUSR 0400 |
474 | # define S_IWUSR 0200 |
475 | # define S_IXUSR 0100 |
476 | # endif |
477 | # define S_IRGRP (S_IRUSR>>3) |
478 | # define S_IWGRP (S_IWUSR>>3) |
479 | # define S_IXGRP (S_IXUSR>>3) |
480 | # define S_IROTH (S_IRUSR>>6) |
481 | # define S_IWOTH (S_IWUSR>>6) |
482 | # define S_IXOTH (S_IXUSR>>6) |
483 | #endif |
484 | |
485 | #ifndef S_ISUID |
486 | # define S_ISUID 04000 |
487 | #endif |
488 | |
489 | #ifndef S_ISGID |
490 | # define S_ISGID 02000 |
491 | #endif |
492 | |
352d5a3a |
493 | #ifdef f_next |
494 | #undef f_next |
495 | #endif |
496 | |
ee0007ab |
497 | #if defined(cray) || defined(gould) || defined(i860) |
45d8adaa |
498 | # define SLOPPYDIVIDE |
499 | #endif |
500 | |
988174c1 |
501 | #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff |
45d8adaa |
502 | # define QUAD |
503 | #endif |
504 | |
505 | #ifdef QUAD |
506 | # ifdef cray |
507 | # define quad int |
508 | # else |
988174c1 |
509 | # if defined(convex) || defined (uts) |
45d8adaa |
510 | # define quad long long |
511 | # else |
512 | # define quad long |
513 | # endif |
514 | # endif |
515 | #endif |
516 | |
ee0007ab |
517 | typedef MEM_SIZE STRLEN; |
450a55e4 |
518 | |
8d063cd8 |
519 | typedef struct arg ARG; |
520 | typedef struct cmd CMD; |
521 | typedef struct formcmd FCMD; |
522 | typedef struct scanpat SPAT; |
8d063cd8 |
523 | typedef struct stio STIO; |
378cc40b |
524 | typedef struct sub SUBR; |
8d063cd8 |
525 | typedef struct string STR; |
526 | typedef struct atbl ARRAY; |
527 | typedef struct htbl HASH; |
378cc40b |
528 | typedef struct regexp REGEXP; |
a687059c |
529 | typedef struct stabptrs STBP; |
530 | typedef struct stab STAB; |
d9d8d8de |
531 | typedef struct callsave CSV; |
8d063cd8 |
532 | |
378cc40b |
533 | #include "handy.h" |
534 | #include "regexp.h" |
8d063cd8 |
535 | #include "str.h" |
378cc40b |
536 | #include "util.h" |
8d063cd8 |
537 | #include "form.h" |
538 | #include "stab.h" |
539 | #include "spat.h" |
540 | #include "arg.h" |
541 | #include "cmd.h" |
542 | #include "array.h" |
543 | #include "hash.h" |
544 | |
450a55e4 |
545 | #if defined(iAPX286) || defined(M_I286) || defined(I80286) |
a687059c |
546 | # define I286 |
547 | #endif |
548 | |
352d5a3a |
549 | #ifndef STANDARD_C |
135863df |
550 | #ifdef CHARSPRINTF |
551 | char *sprintf(); |
552 | #else |
553 | int sprintf(); |
554 | #endif |
a687059c |
555 | #endif |
135863df |
556 | |
8d063cd8 |
557 | EXT char *Yes INIT("1"); |
558 | EXT char *No INIT(""); |
559 | |
a687059c |
560 | /* "gimme" values */ |
561 | |
562 | /* Note: cmd.c assumes that it can use && to produce one of these values! */ |
563 | #define G_SCALAR 0 |
564 | #define G_ARRAY 1 |
565 | |
566 | #ifdef CRIPPLED_CC |
567 | int str_true(); |
568 | #else /* !CRIPPLED_CC */ |
569 | #define str_true(str) (Str = (str), \ |
570 | (Str->str_pok ? \ |
571 | ((*Str->str_ptr > '0' || \ |
572 | Str->str_cur > 1 || \ |
573 | (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \ |
574 | : \ |
575 | (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) )) |
576 | #endif /* CRIPPLED_CC */ |
8d063cd8 |
577 | |
135863df |
578 | #ifdef DEBUGGING |
a687059c |
579 | #define str_peek(str) (Str = (str), \ |
580 | (Str->str_pok ? \ |
581 | Str->str_ptr : \ |
582 | (Str->str_nok ? \ |
583 | (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \ |
584 | (char*)tokenbuf) : \ |
585 | "" ))) |
135863df |
586 | #endif |
587 | |
a687059c |
588 | #ifdef CRIPPLED_CC |
589 | char *str_get(); |
590 | #else |
591 | #ifdef TAINT |
592 | #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \ |
593 | (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) |
594 | #else |
8d063cd8 |
595 | #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) |
a687059c |
596 | #endif /* TAINT */ |
597 | #endif /* CRIPPLED_CC */ |
598 | |
599 | #ifdef CRIPPLED_CC |
600 | double str_gnum(); |
601 | #else /* !CRIPPLED_CC */ |
602 | #ifdef TAINT |
603 | #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \ |
604 | (Str->str_nok ? Str->str_u.str_nval : str_2num(Str))) |
605 | #else /* !TAINT */ |
606 | #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str))) |
607 | #endif /* TAINT*/ |
608 | #endif /* CRIPPLED_CC */ |
8d063cd8 |
609 | EXT STR *Str; |
610 | |
611 | #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) |
612 | |
ee0007ab |
613 | #ifndef DOSISH |
a687059c |
614 | #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len) |
450a55e4 |
615 | #define Str_Grow str_grow |
616 | #else |
617 | /* extra parentheses intentionally NOT placed around "len"! */ |
618 | #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \ |
619 | str_grow(str,(unsigned long)len) |
620 | #define Str_Grow(str,len) str_grow(str,(unsigned long)(len)) |
ee0007ab |
621 | #endif /* DOSISH */ |
a687059c |
622 | |
623 | #ifndef BYTEORDER |
ffed7fef |
624 | #define BYTEORDER 0x1234 |
a687059c |
625 | #endif |
626 | |
fe14fcc3 |
627 | #if defined(htonl) && !defined(HAS_HTONL) |
628 | #define HAS_HTONL |
ae986130 |
629 | #endif |
fe14fcc3 |
630 | #if defined(htons) && !defined(HAS_HTONS) |
631 | #define HAS_HTONS |
ae986130 |
632 | #endif |
fe14fcc3 |
633 | #if defined(ntohl) && !defined(HAS_NTOHL) |
634 | #define HAS_NTOHL |
ae986130 |
635 | #endif |
fe14fcc3 |
636 | #if defined(ntohs) && !defined(HAS_NTOHS) |
637 | #define HAS_NTOHS |
ae986130 |
638 | #endif |
fe14fcc3 |
639 | #ifndef HAS_HTONL |
d9d8d8de |
640 | #if (BYTEORDER & 0xffff) != 0x4321 |
fe14fcc3 |
641 | #define HAS_HTONS |
642 | #define HAS_HTONL |
643 | #define HAS_NTOHS |
644 | #define HAS_NTOHL |
a687059c |
645 | #define MYSWAP |
646 | #define htons my_swap |
647 | #define htonl my_htonl |
648 | #define ntohs my_swap |
649 | #define ntohl my_ntohl |
650 | #endif |
651 | #else |
d9d8d8de |
652 | #if (BYTEORDER & 0xffff) == 0x4321 |
fe14fcc3 |
653 | #undef HAS_HTONS |
654 | #undef HAS_HTONL |
655 | #undef HAS_NTOHS |
656 | #undef HAS_NTOHL |
a687059c |
657 | #endif |
658 | #endif |
659 | |
988174c1 |
660 | /* |
661 | * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'. |
662 | * -DWS |
663 | */ |
664 | #if BYTEORDER != 0x1234 |
665 | # define HAS_VTOHL |
666 | # define HAS_VTOHS |
667 | # define HAS_HTOVL |
668 | # define HAS_HTOVS |
669 | # if BYTEORDER == 0x4321 |
670 | # define vtohl(x) ((((x)&0xFF)<<24) \ |
671 | +(((x)>>24)&0xFF) \ |
672 | +(((x)&0x0000FF00)<<8) \ |
673 | +(((x)&0x00FF0000)>>8) ) |
674 | # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF)) |
675 | # define htovl(x) vtohl(x) |
676 | # define htovs(x) vtohs(x) |
677 | # endif |
678 | /* otherwise default to functions in util.c */ |
679 | #endif |
680 | |
0f85fab0 |
681 | #ifdef CASTNEGFLOAT |
682 | #define U_S(what) ((unsigned short)(what)) |
683 | #define U_I(what) ((unsigned int)(what)) |
684 | #define U_L(what) ((unsigned long)(what)) |
685 | #else |
686 | unsigned long castulong(); |
687 | #define U_S(what) ((unsigned int)castulong(what)) |
688 | #define U_I(what) ((unsigned int)castulong(what)) |
689 | #define U_L(what) (castulong(what)) |
690 | #endif |
691 | |
8d063cd8 |
692 | CMD *add_label(); |
693 | CMD *block_head(); |
694 | CMD *append_line(); |
695 | CMD *make_acmd(); |
696 | CMD *make_ccmd(); |
a687059c |
697 | CMD *make_icmd(); |
8d063cd8 |
698 | CMD *invert(); |
699 | CMD *addcond(); |
700 | CMD *addloop(); |
701 | CMD *wopt(); |
378cc40b |
702 | CMD *over(); |
8d063cd8 |
703 | |
8d063cd8 |
704 | STAB *stabent(); |
378cc40b |
705 | STAB *genstab(); |
8d063cd8 |
706 | |
378cc40b |
707 | ARG *stab2arg(); |
8d063cd8 |
708 | ARG *op_new(); |
709 | ARG *make_op(); |
8d063cd8 |
710 | ARG *make_match(); |
711 | ARG *make_split(); |
a687059c |
712 | ARG *rcatmaybe(); |
378cc40b |
713 | ARG *listish(); |
a687059c |
714 | ARG *maybelistish(); |
378cc40b |
715 | ARG *localize(); |
a687059c |
716 | ARG *fixeval(); |
717 | ARG *jmaybe(); |
378cc40b |
718 | ARG *l(); |
a687059c |
719 | ARG *fixl(); |
378cc40b |
720 | ARG *mod_match(); |
721 | ARG *make_list(); |
722 | ARG *cmd_to_arg(); |
723 | ARG *addflags(); |
724 | ARG *hide_ary(); |
725 | ARG *cval_to_arg(); |
8d063cd8 |
726 | |
8d063cd8 |
727 | STR *str_new(); |
728 | STR *stab_str(); |
a687059c |
729 | |
ee0007ab |
730 | int apply(); |
a687059c |
731 | int do_each(); |
732 | int do_subr(); |
733 | int do_match(); |
734 | int do_unpack(); |
735 | int eval(); /* this evaluates expressions */ |
736 | int do_eval(); /* this evaluates eval operator */ |
737 | int do_assign(); |
378cc40b |
738 | |
739 | SUBR *make_sub(); |
8d063cd8 |
740 | |
741 | FCMD *load_format(); |
742 | |
743 | char *scanpat(); |
744 | char *scansubst(); |
745 | char *scantrans(); |
746 | char *scanstr(); |
fe14fcc3 |
747 | char *scanident(); |
8d063cd8 |
748 | char *str_append_till(); |
749 | char *str_gets(); |
a687059c |
750 | char *str_grow(); |
8d063cd8 |
751 | |
8d063cd8 |
752 | bool do_open(); |
753 | bool do_close(); |
754 | bool do_print(); |
378cc40b |
755 | bool do_aprint(); |
756 | bool do_exec(); |
757 | bool do_aexec(); |
8d063cd8 |
758 | |
759 | int do_subst(); |
378cc40b |
760 | int cando(); |
761 | int ingroup(); |
ee0007ab |
762 | int whichsig(); |
763 | int userinit(); |
764 | #ifdef CRYPTSCRIPT |
765 | void cryptswitch(); |
766 | #endif |
8d063cd8 |
767 | |
378cc40b |
768 | void str_replace(); |
769 | void str_inc(); |
770 | void str_dec(); |
8d063cd8 |
771 | void str_free(); |
ee0007ab |
772 | void cmd_free(); |
773 | void arg_free(); |
774 | void spat_free(); |
775 | void regfree(); |
a687059c |
776 | void stab_clear(); |
ee0007ab |
777 | void do_chop(); |
778 | void do_vop(); |
779 | void do_write(); |
378cc40b |
780 | void do_join(); |
378cc40b |
781 | void do_sprintf(); |
a687059c |
782 | void do_accept(); |
ac58e20f |
783 | void do_pipe(); |
a687059c |
784 | void do_vecset(); |
fe14fcc3 |
785 | void do_unshift(); |
786 | void do_execfree(); |
787 | void magicalize(); |
788 | void magicname(); |
a687059c |
789 | void savelist(); |
790 | void saveitem(); |
791 | void saveint(); |
792 | void savelong(); |
793 | void savesptr(); |
794 | void savehptr(); |
795 | void restorelist(); |
ac58e20f |
796 | void repeatcpy(); |
ee0007ab |
797 | void make_form(); |
798 | void dehoist(); |
799 | void format(); |
800 | void my_unexec(); |
801 | void fatal(); |
802 | void warn(); |
803 | #ifdef DEBUGGING |
804 | void dump_all(); |
805 | void dump_cmd(); |
806 | void dump_arg(); |
807 | void dump_flags(); |
808 | void dump_stab(); |
809 | void dump_spat(); |
810 | #endif |
811 | #ifdef MSTATS |
812 | void mstats(); |
813 | #endif |
814 | |
a687059c |
815 | HASH *savehash(); |
816 | ARRAY *saveary(); |
378cc40b |
817 | |
ac58e20f |
818 | EXT char **origargv; |
819 | EXT int origargc; |
fe14fcc3 |
820 | EXT char **origenviron; |
35c8bce7 |
821 | extern char **environ; |
822 | |
45d8adaa |
823 | EXT long subline INIT(0); |
a687059c |
824 | EXT STR *subname INIT(Nullstr); |
8d063cd8 |
825 | EXT int arybase INIT(0); |
826 | |
827 | struct outrec { |
d9d8d8de |
828 | long o_lines; |
829 | char *o_str; |
830 | int o_len; |
8d063cd8 |
831 | }; |
832 | |
833 | EXT struct outrec outrec; |
834 | EXT struct outrec toprec; |
835 | |
a687059c |
836 | EXT STAB *stdinstab INIT(Nullstab); |
8d063cd8 |
837 | EXT STAB *last_in_stab INIT(Nullstab); |
838 | EXT STAB *defstab INIT(Nullstab); |
839 | EXT STAB *argvstab INIT(Nullstab); |
840 | EXT STAB *envstab INIT(Nullstab); |
841 | EXT STAB *sigstab INIT(Nullstab); |
842 | EXT STAB *defoutstab INIT(Nullstab); |
843 | EXT STAB *curoutstab INIT(Nullstab); |
844 | EXT STAB *argvoutstab INIT(Nullstab); |
378cc40b |
845 | EXT STAB *incstab INIT(Nullstab); |
a687059c |
846 | EXT STAB *leftstab INIT(Nullstab); |
847 | EXT STAB *amperstab INIT(Nullstab); |
848 | EXT STAB *rightstab INIT(Nullstab); |
849 | EXT STAB *DBstab INIT(Nullstab); |
d9d8d8de |
850 | EXT STAB *DBline INIT(Nullstab); |
a687059c |
851 | EXT STAB *DBsub INIT(Nullstab); |
852 | |
853 | EXT HASH *defstash; /* main symbol table */ |
854 | EXT HASH *curstash; /* symbol table for current package */ |
855 | EXT HASH *debstash; /* symbol table for perldb package */ |
856 | |
857 | EXT STR *curstname; /* name of current package */ |
8d063cd8 |
858 | |
859 | EXT STR *freestrroot INIT(Nullstr); |
378cc40b |
860 | EXT STR *lastretstr INIT(Nullstr); |
a687059c |
861 | EXT STR *DBsingle INIT(Nullstr); |
d9d8d8de |
862 | EXT STR *DBtrace INIT(Nullstr); |
863 | EXT STR *DBsignal INIT(Nullstr); |
ee0007ab |
864 | EXT STR *formfeed INIT(Nullstr); |
a687059c |
865 | |
866 | EXT int lastspbase; |
867 | EXT int lastsize; |
8d063cd8 |
868 | |
45d8adaa |
869 | EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx"); |
378cc40b |
870 | EXT char *origfilename; |
ac58e20f |
871 | EXT FILE * VOLATILE rsfp; |
8d063cd8 |
872 | EXT char buf[1024]; |
a687059c |
873 | EXT char *bufptr; |
874 | EXT char *oldbufptr; |
875 | EXT char *oldoldbufptr; |
876 | EXT char *bufend; |
8d063cd8 |
877 | |
878 | EXT STR *linestr INIT(Nullstr); |
879 | |
fe14fcc3 |
880 | EXT char *rs INIT("\n"); |
881 | EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */ |
a687059c |
882 | EXT int rslen INIT(1); |
ee0007ab |
883 | EXT bool rspara INIT(FALSE); |
8d063cd8 |
884 | EXT char *ofs INIT(Nullch); |
a687059c |
885 | EXT int ofslen INIT(0); |
8d063cd8 |
886 | EXT char *ors INIT(Nullch); |
a687059c |
887 | EXT int orslen INIT(0); |
8d063cd8 |
888 | EXT char *ofmt INIT(Nullch); |
889 | EXT char *inplace INIT(Nullch); |
a687059c |
890 | EXT char *nointrp INIT(""); |
8d063cd8 |
891 | |
378cc40b |
892 | EXT bool preprocess INIT(FALSE); |
893 | EXT bool minus_n INIT(FALSE); |
894 | EXT bool minus_p INIT(FALSE); |
fe14fcc3 |
895 | EXT bool minus_l INIT(FALSE); |
378cc40b |
896 | EXT bool minus_a INIT(FALSE); |
897 | EXT bool doswitches INIT(FALSE); |
898 | EXT bool dowarn INIT(FALSE); |
450a55e4 |
899 | EXT bool doextract INIT(FALSE); |
378cc40b |
900 | EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/ |
901 | EXT bool sawampersand INIT(FALSE); /* must save all match strings */ |
902 | EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */ |
a687059c |
903 | EXT bool sawi INIT(FALSE); /* study must assume case insensitive */ |
904 | EXT bool sawvec INIT(FALSE); |
ac58e20f |
905 | EXT bool localizing INIT(FALSE); /* are we processing a local() list? */ |
a687059c |
906 | |
352d5a3a |
907 | #ifndef MAXSYSFD |
908 | # define MAXSYSFD 2 |
909 | #endif |
910 | EXT int maxsysfd INIT(MAXSYSFD); /* top fd to pass to subprocesses */ |
911 | |
ae986130 |
912 | #ifdef CSH |
ee0007ab |
913 | EXT char *cshname INIT(CSH); |
914 | EXT int cshlen INIT(0); |
ae986130 |
915 | #endif /* CSH */ |
a687059c |
916 | |
917 | #ifdef TAINT |
918 | EXT bool tainted INIT(FALSE); /* using variables controlled by $< */ |
ee0007ab |
919 | EXT bool taintanyway INIT(FALSE); /* force taint checks when !set?id */ |
a687059c |
920 | #endif |
378cc40b |
921 | |
ee0007ab |
922 | EXT bool nomemok INIT(FALSE); /* let malloc context handle nomem */ |
923 | |
924 | #ifndef DOSISH |
378cc40b |
925 | #define TMPPATH "/tmp/perl-eXXXXXX" |
450a55e4 |
926 | #else |
57ebbfd0 |
927 | #define TMPPATH "plXXXXXX" |
450a55e4 |
928 | #endif /* MSDOS */ |
378cc40b |
929 | EXT char *e_tmpname; |
930 | EXT FILE *e_fp INIT(Nullfp); |
931 | |
8d063cd8 |
932 | EXT char tokenbuf[256]; |
a687059c |
933 | EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */ |
ac58e20f |
934 | EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */ |
a687059c |
935 | EXT int multiline INIT(0); /* $*--do strings hold >1 line? */ |
936 | EXT int forkprocess; /* so do_open |- can return proc# */ |
937 | EXT int do_undump INIT(0); /* -u or dump seen? */ |
938 | EXT int error_count INIT(0); /* how many errors so far, max 10 */ |
939 | EXT int multi_start INIT(0); /* 1st line of multi-line string */ |
940 | EXT int multi_end INIT(0); /* last line of multi-line string */ |
941 | EXT int multi_open INIT(0); /* delimiter of said string */ |
942 | EXT int multi_close INIT(0); /* delimiter of said string */ |
8d063cd8 |
943 | |
944 | FILE *popen(); |
945 | /* char *str_get(); */ |
946 | STR *interp(); |
947 | void free_arg(); |
948 | STIO *stio_new(); |
1462b684 |
949 | void hoistmust(); |
45d8adaa |
950 | void scanconst(); |
8d063cd8 |
951 | |
952 | EXT struct stat statbuf; |
a687059c |
953 | EXT struct stat statcache; |
ee0007ab |
954 | EXT STAB *statstab INIT(Nullstab); |
955 | EXT STR *statname; |
d9d8d8de |
956 | #ifndef MSDOS |
8d063cd8 |
957 | EXT struct tms timesbuf; |
d9d8d8de |
958 | #endif |
378cc40b |
959 | EXT int uid; |
960 | EXT int euid; |
a687059c |
961 | EXT int gid; |
962 | EXT int egid; |
378cc40b |
963 | UIDTYPE getuid(); |
964 | UIDTYPE geteuid(); |
965 | GIDTYPE getgid(); |
966 | GIDTYPE getegid(); |
967 | EXT int unsafe; |
8d063cd8 |
968 | |
969 | #ifdef DEBUGGING |
ac58e20f |
970 | EXT VOLATILE int debug INIT(0); |
8d063cd8 |
971 | EXT int dlevel INIT(0); |
a687059c |
972 | EXT int dlmax INIT(128); |
973 | EXT char *debname; |
974 | EXT char *debdelim; |
d96024cf |
975 | #define YYDEBUG 1 |
8d063cd8 |
976 | #endif |
a687059c |
977 | EXT int perldb INIT(0); |
fe14fcc3 |
978 | #define YYMAXDEPTH 300 |
8d063cd8 |
979 | |
378cc40b |
980 | EXT line_t cmdline INIT(NOLINE); |
981 | |
a687059c |
982 | EXT STR str_undef; |
8d063cd8 |
983 | EXT STR str_no; |
984 | EXT STR str_yes; |
985 | |
986 | /* runtime control stuff */ |
987 | |
988 | EXT struct loop { |
a687059c |
989 | char *loop_label; /* what the loop was called, if anything */ |
990 | int loop_sp; /* stack pointer to copy stuff down to */ |
8d063cd8 |
991 | jmp_buf loop_env; |
a687059c |
992 | } *loop_stack; |
8d063cd8 |
993 | |
994 | EXT int loop_ptr INIT(-1); |
a687059c |
995 | EXT int loop_max INIT(128); |
8d063cd8 |
996 | |
997 | EXT jmp_buf top_env; |
998 | |
ac58e20f |
999 | EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */ |
8d063cd8 |
1000 | |
450a55e4 |
1001 | struct ufuncs { |
1002 | int (*uf_val)(); |
1003 | int (*uf_set)(); |
1004 | int uf_index; |
1005 | }; |
1006 | |
a687059c |
1007 | EXT ARRAY *stack; /* THE STACK */ |
1008 | |
ac58e20f |
1009 | EXT ARRAY * VOLATILE savestack; /* to save non-local values on */ |
378cc40b |
1010 | |
1011 | EXT ARRAY *tosave; /* strings to save on recursive subroutine */ |
1012 | |
a687059c |
1013 | EXT ARRAY *lineary; /* lines of script for debugger */ |
d9d8d8de |
1014 | EXT ARRAY *dbargs; /* args to call listed by caller function */ |
a687059c |
1015 | |
d9d8d8de |
1016 | EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */ |
1017 | EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */ |
a687059c |
1018 | |
ac58e20f |
1019 | EXT int *di; /* for tmp use in debuggers */ |
1020 | EXT char *dc; |
1021 | EXT short *ds; |
1022 | |
fe14fcc3 |
1023 | /* Fix these up for __STDC__ */ |
ee0007ab |
1024 | EXT time_t basetime INIT(0); |
fe14fcc3 |
1025 | char *mktemp(); |
352d5a3a |
1026 | #ifndef STANDARD_C |
fe14fcc3 |
1027 | /* All of these are in stdlib.h or time.h for ANSI C */ |
8d063cd8 |
1028 | double atof(); |
a687059c |
1029 | long time(); |
8d063cd8 |
1030 | struct tm *gmtime(), *localtime(); |
378cc40b |
1031 | char *index(), *rindex(); |
1032 | char *strcpy(), *strcat(); |
352d5a3a |
1033 | #endif /* ! STANDARD_C */ |
8d063cd8 |
1034 | |
8d063cd8 |
1035 | #ifdef EUNICE |
378cc40b |
1036 | #define UNLINK unlnk |
1037 | int unlnk(); |
8d063cd8 |
1038 | #else |
1039 | #define UNLINK unlink |
1040 | #endif |
a687059c |
1041 | |
fe14fcc3 |
1042 | #ifndef HAS_SETREUID |
1043 | #ifdef HAS_SETRESUID |
a687059c |
1044 | #define setreuid(r,e) setresuid(r,e,-1) |
fe14fcc3 |
1045 | #define HAS_SETREUID |
a687059c |
1046 | #endif |
1047 | #endif |
fe14fcc3 |
1048 | #ifndef HAS_SETREGID |
1049 | #ifdef HAS_SETRESGID |
a687059c |
1050 | #define setregid(r,e) setresgid(r,e,-1) |
fe14fcc3 |
1051 | #define HAS_SETREGID |
a687059c |
1052 | #endif |
1053 | #endif |
ee0007ab |
1054 | |
1055 | #define SCAN_DEF 0 |
1056 | #define SCAN_TR 1 |
1057 | #define SCAN_REPL 2 |