This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Okay, here's your official unofficial closure leak patch
[perl5.git] / perl.h
1 /*    perl.h
2  *
3  *    Copyright (c) 1987-1994, Larry Wall
4  *
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.
7  *
8  */
9 #ifndef H_PERL
10 #define H_PERL 1
11 #define OVERLOAD
12
13 #include "embed.h"
14
15 #define VOIDUSED 1
16 #include "config.h"
17
18 #ifndef BYTEORDER
19 #   define BYTEORDER 0x1234
20 #endif
21
22 /* Overall memory policy? */
23 #ifndef CONSERVATIVE
24 #   define LIBERAL 1
25 #endif
26
27 /*
28  * The following contortions are brought to you on behalf of all the
29  * standards, semi-standards, de facto standards, not-so-de-facto standards
30  * of the world, as well as all the other botches anyone ever thought of.
31  * The basic theory is that if we work hard enough here, the rest of the
32  * code can be a lot prettier.  Well, so much for theory.  Sorry, Henry...
33  */
34
35 #ifdef MYMALLOC
36 #   ifdef HIDEMYMALLOC
37 #       define malloc Mymalloc
38 #       define realloc Myremalloc
39 #       define free Myfree
40 #   endif
41 #   define safemalloc malloc
42 #   define saferealloc realloc
43 #   define safefree free
44 #endif
45
46 /* work around some libPW problems */
47 #ifdef DOINIT
48 EXT char Error[1];
49 #endif
50
51 /* define this once if either system, instead of cluttering up the src */
52 #if defined(MSDOS) || defined(atarist)
53 #define DOSISH 1
54 #endif
55
56 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
57 # define STANDARD_C 1
58 #endif
59
60 #if defined(HASVOLATILE) || defined(STANDARD_C)
61 #   ifdef __cplusplus
62 #       define VOL              // to temporarily suppress warnings
63 #   else
64 #       define VOL volatile
65 #   endif
66 #else
67 #   define VOL
68 #endif
69
70 #define TAINT_IF(c)     (tainted |= (c))
71 #define TAINT_NOT       (tainted = 0)
72 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
73 #define TAINT_ENV()     if (tainting) taint_env()
74
75 #ifdef HAS_GETPGRP2
76 #   ifndef HAS_GETPGRP
77 #       define HAS_GETPGRP
78 #   endif
79 #endif
80
81 #ifdef HAS_SETPGRP2
82 #   ifndef HAS_SETPGRP
83 #       define HAS_SETPGRP
84 #   endif
85 #endif
86
87 #include <stdio.h>
88 #ifdef USE_NEXT_CTYPE 
89 #include <appkit/NXCType.h>
90 #else
91 #include <ctype.h>
92 #endif
93
94 #ifdef METHOD   /* Defined by OSF/1 v3.0 by ctype.h */
95 #undef METHOD
96 #endif
97
98 #include <setjmp.h>
99
100 #ifdef I_SYS_PARAM
101 #   ifdef PARAM_NEEDS_TYPES
102 #       include <sys/types.h>
103 #   endif
104 #   include <sys/param.h>
105 #endif
106
107
108 /* Use all the "standard" definitions? */
109 #if defined(STANDARD_C) && defined(I_STDLIB)
110 #   include <stdlib.h>
111 #endif /* STANDARD_C */
112
113 #define MEM_SIZE Size_t
114
115 #if defined(I_STRING) || defined(__cplusplus)
116 #   include <string.h>
117 #else
118 #   include <strings.h>
119 #endif
120
121 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
122 #define strchr index
123 #define strrchr rindex
124 #endif
125
126 #if defined(mips) && defined(ultrix) && !defined(__STDC__)
127 #   undef HAS_MEMCMP
128 #endif
129
130 #ifdef HAS_MEMCPY
131 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
132 #    ifndef memcpy
133         extern char * memcpy _((char*, char*, int));
134 #    endif
135 #  endif
136 #else
137 #   ifndef memcpy
138 #       ifdef HAS_BCOPY
139 #           define memcpy(d,s,l) bcopy(s,d,l)
140 #       else
141 #           define memcpy(d,s,l) my_bcopy(s,d,l)
142 #       endif
143 #   endif
144 #endif /* HAS_MEMCPY */
145
146 #ifdef HAS_MEMSET
147 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
148 #    ifndef memset
149         extern char *memset _((char*, int, int));
150 #    endif
151 #  endif
152 #  define memzero(d,l) memset(d,0,l)
153 #else
154 #   ifndef memzero
155 #       ifdef HAS_BZERO
156 #           define memzero(d,l) bzero(d,l)
157 #       else
158 #           define memzero(d,l) my_bzero(d,l)
159 #       endif
160 #   endif
161 #endif /* HAS_MEMSET */
162
163 #ifdef HAS_MEMCMP
164 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
165 #    ifndef memcmp
166         extern int memcmp _((char*, char*, int));
167 #    endif
168 #  endif
169 #else
170 #   ifndef memcmp
171 #       define memcmp   my_memcmp
172 #   endif
173 #endif /* HAS_MEMCMP */
174
175 /* we prefer bcmp slightly for comparisons that don't care about ordering */
176 #ifndef HAS_BCMP
177 #   ifndef bcmp
178 #       define bcmp(s1,s2,l) memcmp(s1,s2,l)
179 #   endif
180 #endif /* HAS_BCMP */
181
182 #if !defined(HAS_MEMMOVE) && !defined(memmove)
183 #   if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
184 #       define memmove(d,s,l) bcopy(s,d,l)
185 #   else
186 #       if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
187 #           define memmove(d,s,l) memcpy(d,s,l)
188 #       else
189 #           define memmove(d,s,l) my_bcopy(s,d,l)
190 #       endif
191 #   endif
192 #endif
193
194 #ifndef _TYPES_         /* If types.h defines this it's easy. */
195 #   ifndef major                /* Does everyone's types.h define this? */
196 #       include <sys/types.h>
197 #   endif
198 #endif
199
200 #ifdef I_NETINET_IN
201 #   include <netinet/in.h>
202 #endif
203
204 #ifdef I_SYS_STAT
205 #include <sys/stat.h>
206 #endif
207
208 /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
209    like UTekV) are broken, sometimes giving false positives.  Undefine
210    them here and let the code below set them to proper values.
211
212    The ghs macro stands for GreenHills Software C-1.8.5 which
213    is the C compiler for sysV88 and the various derivatives.
214    This header file bug is corrected in gcc-2.5.8 and later versions.
215    --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94.  */
216
217 #if defined(uts) || (defined(m88k) && defined(ghs))
218 #   undef S_ISDIR
219 #   undef S_ISCHR
220 #   undef S_ISBLK
221 #   undef S_ISREG
222 #   undef S_ISFIFO
223 #   undef S_ISLNK
224 #endif
225
226 #ifdef I_TIME
227 #   include <time.h>
228 #endif
229
230 #ifdef I_SYS_TIME
231 #   ifdef I_SYS_TIME_KERNEL
232 #       define KERNEL
233 #   endif
234 #   include <sys/time.h>
235 #   ifdef I_SYS_TIME_KERNEL
236 #       undef KERNEL
237 #   endif
238 #endif
239
240 #ifndef MSDOS
241 #  if defined(HAS_TIMES) && defined(I_SYS_TIMES)
242 #    include <sys/times.h>
243 #  endif
244 #endif
245
246 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
247 #   undef HAS_STRERROR
248 #endif
249
250 #ifndef HAS_MKFIFO
251 #  ifndef mkfifo
252 #    define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
253 #  endif
254 #endif /* !HAS_MKFIFO */
255
256 #include <errno.h>
257 #ifdef HAS_SOCKET
258 #   ifdef I_NET_ERRNO
259 #     include <net/errno.h>
260 #   endif
261 #endif
262 #ifndef VMS
263 #   define FIXSTATUS(sts)  (U_L((sts) & 0xffff))
264 #   define SHIFTSTATUS(sts) ((sts) >> 8)
265 #   define SETERRNO(errcode,vmserrcode) errno = (errcode)
266 #else
267 #   define FIXSTATUS(sts)  (U_L(sts))
268 #   define SHIFTSTATUS(sts) (sts)
269 #   define SETERRNO(errcode,vmserrcode) {set_errno(errcode); set_vaxc_errno(vmserrcode);}
270 #endif
271
272 #ifndef MSDOS
273 #   ifndef errno
274         extern int errno;     /* ANSI allows errno to be an lvalue expr */
275 #   endif
276 #endif
277
278 #ifdef HAS_STRERROR
279 #       ifdef VMS
280         char *strerror _((int,...));
281 #       else
282         char *strerror _((int));
283 #       endif
284 #       ifndef Strerror
285 #           define Strerror strerror
286 #       endif
287 #else
288 #    ifdef HAS_SYS_ERRLIST
289         extern int sys_nerr;
290         extern char *sys_errlist[];
291 #       ifndef Strerror
292 #           define Strerror(e) \
293                 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
294 #       endif
295 #   endif
296 #endif
297
298 #ifdef I_SYS_IOCTL
299 #   ifndef _IOCTL_
300 #       include <sys/ioctl.h>
301 #   endif
302 #endif
303
304 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
305 #   ifdef HAS_SOCKETPAIR
306 #       undef HAS_SOCKETPAIR
307 #   endif
308 #   ifdef I_NDBM
309 #       undef I_NDBM
310 #   endif
311 #endif
312
313 #if INTSIZE == 2
314 #   define htoni htons
315 #   define ntohi ntohs
316 #else
317 #   define htoni htonl
318 #   define ntohi ntohl
319 #endif
320
321 /* Configure already sets Direntry_t */
322 #if defined(I_DIRENT)
323 #   include <dirent.h>
324 #   if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
325 #       include <sys/dir.h>
326 #   endif
327 #else
328 #   ifdef I_SYS_NDIR
329 #       include <sys/ndir.h>
330 #   else
331 #       ifdef I_SYS_DIR
332 #           ifdef hp9000s500
333 #               include <ndir.h>        /* may be wrong in the future */
334 #           else
335 #               include <sys/dir.h>
336 #           endif
337 #       endif
338 #   endif
339 #endif 
340
341 #ifdef FPUTS_BOTCH
342 /* work around botch in SunOS 4.0.1 and 4.0.2 */
343 #   ifndef fputs
344 #       define fputs(sv,fp) fprintf(fp,"%s",sv)
345 #   endif
346 #endif
347
348 /*
349  * The following gobbledygook brought to you on behalf of __STDC__.
350  * (I could just use #ifndef __STDC__, but this is more bulletproof
351  * in the face of half-implementations.)
352  */
353
354 #ifndef S_IFMT
355 #   ifdef _S_IFMT
356 #       define S_IFMT _S_IFMT
357 #   else
358 #       define S_IFMT 0170000
359 #   endif
360 #endif
361
362 #ifndef S_ISDIR
363 #   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
364 #endif
365
366 #ifndef S_ISCHR
367 #   define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
368 #endif
369
370 #ifndef S_ISBLK
371 #   ifdef S_IFBLK
372 #       define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
373 #   else
374 #       define S_ISBLK(m) (0)
375 #   endif
376 #endif
377
378 #ifndef S_ISREG
379 #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
380 #endif
381
382 #ifndef S_ISFIFO
383 #   ifdef S_IFIFO
384 #       define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
385 #   else
386 #       define S_ISFIFO(m) (0)
387 #   endif
388 #endif
389
390 #ifndef S_ISLNK
391 #   ifdef _S_ISLNK
392 #       define S_ISLNK(m) _S_ISLNK(m)
393 #   else
394 #       ifdef _S_IFLNK
395 #           define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
396 #       else
397 #           ifdef S_IFLNK
398 #               define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
399 #           else
400 #               define S_ISLNK(m) (0)
401 #           endif
402 #       endif
403 #   endif
404 #endif
405
406 #ifndef S_ISSOCK
407 #   ifdef _S_ISSOCK
408 #       define S_ISSOCK(m) _S_ISSOCK(m)
409 #   else
410 #       ifdef _S_IFSOCK
411 #           define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
412 #       else
413 #           ifdef S_IFSOCK
414 #               define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
415 #           else
416 #               define S_ISSOCK(m) (0)
417 #           endif
418 #       endif
419 #   endif
420 #endif
421
422 #ifndef S_IRUSR
423 #   ifdef S_IREAD
424 #       define S_IRUSR S_IREAD
425 #       define S_IWUSR S_IWRITE
426 #       define S_IXUSR S_IEXEC
427 #   else
428 #       define S_IRUSR 0400
429 #       define S_IWUSR 0200
430 #       define S_IXUSR 0100
431 #   endif
432 #   define S_IRGRP (S_IRUSR>>3)
433 #   define S_IWGRP (S_IWUSR>>3)
434 #   define S_IXGRP (S_IXUSR>>3)
435 #   define S_IROTH (S_IRUSR>>6)
436 #   define S_IWOTH (S_IWUSR>>6)
437 #   define S_IXOTH (S_IXUSR>>6)
438 #endif
439
440 #ifndef S_ISUID
441 #   define S_ISUID 04000
442 #endif
443
444 #ifndef S_ISGID
445 #   define S_ISGID 02000
446 #endif
447
448 #ifdef ff_next
449 #   undef ff_next
450 #endif
451
452 #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
453 #   define SLOPPYDIVIDE
454 #endif
455
456 #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
457 #   define HAS_QUAD
458 #endif
459
460 #ifdef UV
461 #undef UV
462 #endif
463
464 #ifdef HAS_QUAD
465 #   ifdef cray
466 #       define Quad_t int
467 #   else
468 #       if defined(convex) || defined (uts)
469 #           define Quad_t long long
470 #       else
471 #           define Quad_t long
472 #       endif
473 #   endif
474     typedef Quad_t IV;
475     typedef unsigned Quad_t UV;
476 #else
477     typedef long IV;
478     typedef unsigned long UV;
479 #endif
480
481 typedef MEM_SIZE STRLEN;
482
483 typedef struct op OP;
484 typedef struct cop COP;
485 typedef struct unop UNOP;
486 typedef struct binop BINOP;
487 typedef struct listop LISTOP;
488 typedef struct logop LOGOP;
489 typedef struct condop CONDOP;
490 typedef struct pmop PMOP;
491 typedef struct svop SVOP;
492 typedef struct gvop GVOP;
493 typedef struct pvop PVOP;
494 typedef struct cvop CVOP;
495 typedef struct loop LOOP;
496
497 typedef struct Outrec Outrec;
498 typedef struct interpreter PerlInterpreter;
499 typedef struct ff FF;
500 typedef struct sv SV;
501 typedef struct av AV;
502 typedef struct hv HV;
503 typedef struct cv CV;
504 typedef struct regexp REGEXP;
505 typedef struct gp GP;
506 typedef struct sv GV;
507 typedef struct io IO;
508 typedef struct context CONTEXT;
509 typedef struct block BLOCK;
510
511 typedef struct magic MAGIC;
512 typedef struct xrv XRV;
513 typedef struct xpv XPV;
514 typedef struct xpviv XPVIV;
515 typedef struct xpvnv XPVNV;
516 typedef struct xpvmg XPVMG;
517 typedef struct xpvlv XPVLV;
518 typedef struct xpvav XPVAV;
519 typedef struct xpvhv XPVHV;
520 typedef struct xpvgv XPVGV;
521 typedef struct xpvcv XPVCV;
522 typedef struct xpvbm XPVBM;
523 typedef struct xpvfm XPVFM;
524 typedef struct xpvio XPVIO;
525 typedef struct mgvtbl MGVTBL;
526 typedef union any ANY;
527
528 typedef int (*cryptswitch_t) _((void));
529
530 #include "handy.h"
531
532 #ifdef DOSISH
533 #   include "dosish.h"
534 #else
535 # if defined(VMS)
536 #   include "vmsish.h"
537 # else
538 #   include "unixish.h"
539 # endif
540 #endif
541
542 #ifndef HAS_PAUSE
543 #define pause() sleep((32767<<16)+32767)
544 #endif
545
546 #ifndef IOCPARM_LEN
547 #   ifdef IOCPARM_MASK
548         /* on BSDish systes we're safe */
549 #       define IOCPARM_LEN(x)  (((x) >> 16) & IOCPARM_MASK)
550 #   else
551         /* otherwise guess at what's safe */
552 #       define IOCPARM_LEN(x)   256
553 #   endif
554 #endif
555
556 union any {
557     void*       any_ptr;
558     I32         any_i32;
559     IV          any_iv;
560     long        any_long;
561     void        (*any_dptr) _((void*));
562 };
563
564 #include "regexp.h"
565 #include "sv.h"
566 #include "util.h"
567 #include "form.h"
568 #include "gv.h"
569 #include "cv.h"
570 #include "opcode.h"
571 #include "op.h"
572 #include "cop.h"
573 #include "av.h"
574 #include "hv.h"
575 #include "mg.h"
576 #include "scope.h"
577
578 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
579 #   define I286
580 #endif
581
582 #if defined(htonl) && !defined(HAS_HTONL)
583 #define HAS_HTONL
584 #endif
585 #if defined(htons) && !defined(HAS_HTONS)
586 #define HAS_HTONS
587 #endif
588 #if defined(ntohl) && !defined(HAS_NTOHL)
589 #define HAS_NTOHL
590 #endif
591 #if defined(ntohs) && !defined(HAS_NTOHS)
592 #define HAS_NTOHS
593 #endif
594 #ifndef HAS_HTONL
595 #if (BYTEORDER & 0xffff) != 0x4321
596 #define HAS_HTONS
597 #define HAS_HTONL
598 #define HAS_NTOHS
599 #define HAS_NTOHL
600 #define MYSWAP
601 #define htons my_swap
602 #define htonl my_htonl
603 #define ntohs my_swap
604 #define ntohl my_ntohl
605 #endif
606 #else
607 #if (BYTEORDER & 0xffff) == 0x4321
608 #undef HAS_HTONS
609 #undef HAS_HTONL
610 #undef HAS_NTOHS
611 #undef HAS_NTOHL
612 #endif
613 #endif
614
615 /*
616  * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
617  * -DWS
618  */
619 #if BYTEORDER != 0x1234
620 # define HAS_VTOHL
621 # define HAS_VTOHS
622 # define HAS_HTOVL
623 # define HAS_HTOVS
624 # if BYTEORDER == 0x4321
625 #  define vtohl(x)      ((((x)&0xFF)<<24)       \
626                         +(((x)>>24)&0xFF)       \
627                         +(((x)&0x0000FF00)<<8)  \
628                         +(((x)&0x00FF0000)>>8)  )
629 #  define vtohs(x)      ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
630 #  define htovl(x)      vtohl(x)
631 #  define htovs(x)      vtohs(x)
632 # endif
633         /* otherwise default to functions in util.c */
634 #endif
635
636 #ifdef CASTNEGFLOAT
637 #define U_S(what) ((U16)(what))
638 #define U_I(what) ((unsigned int)(what))
639 #define U_L(what) ((U32)(what))
640 #else
641 U32 cast_ulong _((double));
642 #define U_S(what) ((U16)cast_ulong(what))
643 #define U_I(what) ((unsigned int)cast_ulong(what))
644 #define U_L(what) (cast_ulong(what))
645 #endif
646
647 #ifdef CASTI32
648 #define I_32(what) ((I32)(what))
649 #define I_V(what) ((IV)(what))
650 #else
651 I32 cast_i32 _((double));
652 #define I_32(what) (cast_i32(what))
653 IV cast_iv _((double));
654 #define I_V(what) (cast_iv(what))
655 #endif
656
657 struct Outrec {
658     I32         o_lines;
659     char        *o_str;
660     U32         o_len;
661 };
662
663 #ifndef MAXSYSFD
664 #   define MAXSYSFD 2
665 #endif
666
667 #ifdef DOSISH
668 #define TMPPATH "plXXXXXX"
669 #else
670 #ifdef VMS
671 #define TMPPATH "sys$scratch:perl-eXXXXXX"
672 #else
673 #define TMPPATH "/tmp/perl-eXXXXXX"
674 #endif
675 #endif
676
677 #ifndef __cplusplus
678 Uid_t getuid _((void));
679 Uid_t geteuid _((void));
680 Gid_t getgid _((void));
681 Gid_t getegid _((void));
682 #endif
683
684 #ifdef DEBUGGING
685 #define YYDEBUG 1
686 #define DEB(a)                          a
687 #define DEBUG(a)   if (debug)           a
688 #define DEBUG_p(a) if (debug & 1)       a
689 #define DEBUG_s(a) if (debug & 2)       a
690 #define DEBUG_l(a) if (debug & 4)       a
691 #define DEBUG_t(a) if (debug & 8)       a
692 #define DEBUG_o(a) if (debug & 16)      a
693 #define DEBUG_c(a) if (debug & 32)      a
694 #define DEBUG_P(a) if (debug & 64)      a
695 #define DEBUG_m(a) if (debug & 128)     a
696 #define DEBUG_f(a) if (debug & 256)     a
697 #define DEBUG_r(a) if (debug & 512)     a
698 #define DEBUG_x(a) if (debug & 1024)    a
699 #define DEBUG_u(a) if (debug & 2048)    a
700 #define DEBUG_L(a) if (debug & 4096)    a
701 #define DEBUG_H(a) if (debug & 8192)    a
702 #define DEBUG_X(a) if (debug & 16384)   a
703 #define DEBUG_D(a) if (debug & 32768)   a
704 #else
705 #define DEB(a)
706 #define DEBUG(a)
707 #define DEBUG_p(a)
708 #define DEBUG_s(a)
709 #define DEBUG_l(a)
710 #define DEBUG_t(a)
711 #define DEBUG_o(a)
712 #define DEBUG_c(a)
713 #define DEBUG_P(a)
714 #define DEBUG_m(a)
715 #define DEBUG_f(a)
716 #define DEBUG_r(a)
717 #define DEBUG_x(a)
718 #define DEBUG_u(a)
719 #define DEBUG_L(a)
720 #define DEBUG_H(a)
721 #define DEBUG_X(a)
722 #define DEBUG_D(a)
723 #endif
724 #define YYMAXDEPTH 300
725
726 #define assert(what)    DEB( {                                          \
727         if (!(what)) {                                                  \
728             croak("Assertion failed: file \"%s\", line %d",             \
729                 __FILE__, __LINE__);                                    \
730             exit(1);                                                    \
731         }})
732
733 struct ufuncs {
734     I32 (*uf_val)_((IV, SV*));
735     I32 (*uf_set)_((IV, SV*));
736     IV uf_index;
737 };
738
739 /* Fix these up for __STDC__ */
740 #ifndef __cplusplus
741 char *mktemp _((char*));
742 double atof _((const char*));
743 #endif
744
745 #ifndef STANDARD_C
746 /* All of these are in stdlib.h or time.h for ANSI C */
747 Time_t time();
748 struct tm *gmtime(), *localtime();
749 char *strchr(), *strrchr();
750 char *strcpy(), *strcat();
751 #endif /* ! STANDARD_C */
752
753
754 #ifdef I_MATH
755 #    include <math.h>
756 #else
757 #   ifdef __cplusplus
758         extern "C" {
759 #   endif
760             double exp _((double));
761             double fmod _((double,double));
762             double log _((double));
763             double sqrt _((double));
764             double modf _((double,double*));
765             double sin _((double));
766             double cos _((double));
767             double atan2 _((double,double));
768             double pow _((double,double));
769 #   ifdef __cplusplus
770         };
771 #   endif
772 #endif
773
774 #ifndef HAS_FMOD
775 #   ifdef HAS_DREM
776 #       define fmod(x,y) drem((x),(y))
777 #   else
778 #       define USE_MY_FMOD
779 #       define fmod(x,y) my_fmod(x,y)
780 #   endif
781 #endif
782
783 #ifndef __cplusplus
784 char *crypt _((const char*, const char*));
785 char *getenv _((const char*));
786 Off_t lseek _((int,Off_t,int));
787 char *getlogin _((void));
788 #endif
789
790 #ifdef EUNICE
791 #define UNLINK unlnk
792 I32 unlnk _((char*));
793 #else
794 #define UNLINK unlink
795 #endif
796
797 #ifndef HAS_SETREUID
798 #  ifdef HAS_SETRESUID
799 #    define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
800 #    define HAS_SETREUID
801 #  endif
802 #endif
803 #ifndef HAS_SETREGID
804 #  ifdef HAS_SETRESGID
805 #    define setregid(r,e) setresgid(r,e,(Gid_t)-1)
806 #    define HAS_SETREGID
807 #  endif
808 #endif
809
810 #define SCAN_DEF 0
811 #define SCAN_TR 1
812 #define SCAN_REPL 2
813
814 #ifdef DEBUGGING
815 # ifndef register 
816 #  define register
817 # endif
818 # define PAD_SV(po) pad_sv(po)
819 #else
820 # define PAD_SV(po) curpad[po]
821 #endif
822
823 /****************/
824 /* Truly global */
825 /****************/
826
827 /* global state */
828 EXT PerlInterpreter *   curinterp;      /* currently running interpreter */
829 #ifndef VMS  /* VMS doesn't use environ array */
830 extern char **  environ;        /* environment variables supplied via exec */
831 #endif
832 EXT int         uid;            /* current real user id */
833 EXT int         euid;           /* current effective user id */
834 EXT int         gid;            /* current real group id */
835 EXT int         egid;           /* current effective group id */
836 EXT bool        nomemok;        /* let malloc context handle nomem */
837 EXT U32         an;             /* malloc sequence number */
838 EXT U32         cop_seqmax;     /* statement sequence number */
839 EXT U32         op_seqmax;      /* op sequence number */
840 EXT U32         evalseq;        /* eval sequence number */
841 EXT U32         sub_generation; /* inc to force methods to be looked up again */
842 EXT char **     origenviron;
843 EXT U32         origalen;
844 EXT U32 *       profiledata;
845
846 EXT XPV*        xiv_arenaroot;  /* list of allocated xiv areas */
847 EXT IV **       xiv_root;       /* free xiv list--shared by interpreters */
848 EXT double *    xnv_root;       /* free xnv list--shared by interpreters */
849 EXT XRV *       xrv_root;       /* free xrv list--shared by interpreters */
850 EXT XPV *       xpv_root;       /* free xpv list--shared by interpreters */
851
852 /* Stack for currently executing thread--context switch must handle this.     */
853 EXT SV **       stack_base;     /* stack->array_ary */
854 EXT SV **       stack_sp;       /* stack pointer now */
855 EXT SV **       stack_max;      /* stack->array_ary + stack->array_max */
856
857 /* likewise for these */
858
859 EXT OP *        op;             /* current op--oughta be in a global register */
860
861 EXT I32 *       scopestack;     /* blocks we've entered */
862 EXT I32         scopestack_ix;
863 EXT I32         scopestack_max;
864
865 EXT ANY*        savestack;      /* to save non-local values on */
866 EXT I32         savestack_ix;
867 EXT I32         savestack_max;
868
869 EXT OP **       retstack;       /* returns we've pushed */
870 EXT I32         retstack_ix;
871 EXT I32         retstack_max;
872
873 EXT I32 *       markstack;      /* stackmarks we're remembering */
874 EXT I32 *       markstack_ptr;  /* stackmarks we're remembering */
875 EXT I32 *       markstack_max;  /* stackmarks we're remembering */
876
877 EXT SV **       curpad;
878
879 /* temp space */
880 EXT SV *        Sv;
881 EXT XPV *       Xpv;
882 EXT char        buf[1024];
883 EXT char        tokenbuf[256];
884 EXT struct stat statbuf;
885 #ifdef HAS_TIMES
886 EXT struct tms  timesbuf;
887 #endif
888 EXT STRLEN na;          /* for use in SvPV when length is Not Applicable */
889
890 /* for tmp use in stupid debuggers */
891 EXT int *       di;
892 EXT short *     ds;
893 EXT char *      dc;
894
895 /* handy constants */
896 EXT char *      Yes INIT("1");
897 EXT char *      No INIT("");
898 EXT char *      hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
899 EXT char *      patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
900 EXT char *      vert INIT("|");
901
902 EXT char        warn_uninit[]
903   INIT("Use of uninitialized value");
904 EXT char        warn_nosemi[]
905   INIT("Semicolon seems to be missing");
906 EXT char        warn_reserved[]
907   INIT("Unquoted string \"%s\" may clash with future reserved word");
908 EXT char        warn_nl[]
909   INIT("Unsuccessful %s on filename containing newline");
910 EXT char        no_wrongref[]
911   INIT("Can't use %s ref as %s ref");
912 EXT char        no_symref[]
913   INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
914 EXT char        no_usym[]
915   INIT("Can't use an undefined value as %s reference");
916 EXT char        no_aelem[]
917   INIT("Modification of non-creatable array value attempted, subscript %d");
918 EXT char        no_helem[]
919   INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
920 EXT char        no_modify[]
921   INIT("Modification of a read-only value attempted");
922 EXT char        no_mem[]
923   INIT("Out of memory!\n");
924 EXT char        no_security[]
925   INIT("Insecure dependency in %s%s");
926 EXT char        no_sock_func[]
927   INIT("Unsupported socket function \"%s\" called");
928 EXT char        no_dir_func[]
929   INIT("Unsupported directory function \"%s\" called");
930 EXT char        no_func[]
931   INIT("The %s function is unimplemented");
932 EXT char        no_myglob[]
933   INIT("\"my\" variable %s can't be in a package");
934
935 EXT SV          sv_undef;
936 EXT SV          sv_no;
937 EXT SV          sv_yes;
938 #ifdef CSH
939     EXT char *  cshname INIT(CSH);
940     EXT I32     cshlen;
941 #endif
942
943 #ifdef DOINIT
944 EXT char *sig_name[] = {
945     SIG_NAME,0
946 };
947 #else
948 EXT char *sig_name[];
949 #endif
950
951 #ifdef DOINIT
952 EXT unsigned char fold[] = {    /* fast case folding table */
953         0,      1,      2,      3,      4,      5,      6,      7,
954         8,      9,      10,     11,     12,     13,     14,     15,
955         16,     17,     18,     19,     20,     21,     22,     23,
956         24,     25,     26,     27,     28,     29,     30,     31,
957         32,     33,     34,     35,     36,     37,     38,     39,
958         40,     41,     42,     43,     44,     45,     46,     47,
959         48,     49,     50,     51,     52,     53,     54,     55,
960         56,     57,     58,     59,     60,     61,     62,     63,
961         64,     'a',    'b',    'c',    'd',    'e',    'f',    'g',
962         'h',    'i',    'j',    'k',    'l',    'm',    'n',    'o',
963         'p',    'q',    'r',    's',    't',    'u',    'v',    'w',
964         'x',    'y',    'z',    91,     92,     93,     94,     95,
965         96,     'A',    'B',    'C',    'D',    'E',    'F',    'G',
966         'H',    'I',    'J',    'K',    'L',    'M',    'N',    'O',
967         'P',    'Q',    'R',    'S',    'T',    'U',    'V',    'W',
968         'X',    'Y',    'Z',    123,    124,    125,    126,    127,
969         128,    129,    130,    131,    132,    133,    134,    135,
970         136,    137,    138,    139,    140,    141,    142,    143,
971         144,    145,    146,    147,    148,    149,    150,    151,
972         152,    153,    154,    155,    156,    157,    158,    159,
973         160,    161,    162,    163,    164,    165,    166,    167,
974         168,    169,    170,    171,    172,    173,    174,    175,
975         176,    177,    178,    179,    180,    181,    182,    183,
976         184,    185,    186,    187,    188,    189,    190,    191,
977         192,    193,    194,    195,    196,    197,    198,    199,
978         200,    201,    202,    203,    204,    205,    206,    207,
979         208,    209,    210,    211,    212,    213,    214,    215,
980         216,    217,    218,    219,    220,    221,    222,    223,    
981         224,    225,    226,    227,    228,    229,    230,    231,
982         232,    233,    234,    235,    236,    237,    238,    239,
983         240,    241,    242,    243,    244,    245,    246,    247,
984         248,    249,    250,    251,    252,    253,    254,    255
985 };
986 #else
987 EXT unsigned char fold[];
988 #endif
989
990 #ifdef DOINIT
991 EXT unsigned char freq[] = {    /* letter frequencies for mixed English/C */
992         1,      2,      84,     151,    154,    155,    156,    157,
993         165,    246,    250,    3,      158,    7,      18,     29,
994         40,     51,     62,     73,     85,     96,     107,    118,
995         129,    140,    147,    148,    149,    150,    152,    153,
996         255,    182,    224,    205,    174,    176,    180,    217,
997         233,    232,    236,    187,    235,    228,    234,    226,
998         222,    219,    211,    195,    188,    193,    185,    184,
999         191,    183,    201,    229,    181,    220,    194,    162,
1000         163,    208,    186,    202,    200,    218,    198,    179,
1001         178,    214,    166,    170,    207,    199,    209,    206,
1002         204,    160,    212,    216,    215,    192,    175,    173,
1003         243,    172,    161,    190,    203,    189,    164,    230,
1004         167,    248,    227,    244,    242,    255,    241,    231,
1005         240,    253,    169,    210,    245,    237,    249,    247,
1006         239,    168,    252,    251,    254,    238,    223,    221,
1007         213,    225,    177,    197,    171,    196,    159,    4,
1008         5,      6,      8,      9,      10,     11,     12,     13,
1009         14,     15,     16,     17,     19,     20,     21,     22,
1010         23,     24,     25,     26,     27,     28,     30,     31,
1011         32,     33,     34,     35,     36,     37,     38,     39,
1012         41,     42,     43,     44,     45,     46,     47,     48,
1013         49,     50,     52,     53,     54,     55,     56,     57,
1014         58,     59,     60,     61,     63,     64,     65,     66,
1015         67,     68,     69,     70,     71,     72,     74,     75,
1016         76,     77,     78,     79,     80,     81,     82,     83,
1017         86,     87,     88,     89,     90,     91,     92,     93,
1018         94,     95,     97,     98,     99,     100,    101,    102,
1019         103,    104,    105,    106,    108,    109,    110,    111,
1020         112,    113,    114,    115,    116,    117,    119,    120,
1021         121,    122,    123,    124,    125,    126,    127,    128,
1022         130,    131,    132,    133,    134,    135,    136,    137,
1023         138,    139,    141,    142,    143,    144,    145,    146
1024 };
1025 #else
1026 EXT unsigned char freq[];
1027 #endif
1028
1029 #ifdef DEBUGGING
1030 #ifdef DOINIT
1031 EXT char* block_type[] = {
1032         "NULL",
1033         "SUB",
1034         "EVAL",
1035         "LOOP",
1036         "SUBST",
1037         "BLOCK",
1038 };
1039 #else
1040 EXT char* block_type[];
1041 #endif
1042 #endif
1043
1044 /*****************************************************************************/
1045 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
1046 /*****************************************************************************/
1047 /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
1048
1049 #include "perly.h"
1050
1051 typedef enum {
1052     XOPERATOR,
1053     XTERM,
1054     XREF,
1055     XSTATE,
1056     XBLOCK,
1057     XTERMBLOCK
1058 } expectation;
1059
1060 EXT U32         lex_state;      /* next token is determined */
1061 EXT U32         lex_defer;      /* state after determined token */
1062 EXT expectation lex_expect;     /* expect after determined token */
1063 EXT I32         lex_brackets;   /* bracket count */
1064 EXT I32         lex_formbrack;  /* bracket count at outer format level */
1065 EXT I32         lex_fakebrack;  /* outer bracket is mere delimiter */
1066 EXT I32         lex_casemods;   /* casemod count */
1067 EXT I32         lex_dojoin;     /* doing an array interpolation */
1068 EXT I32         lex_starts;     /* how many interps done on level */
1069 EXT SV *        lex_stuff;      /* runtime pattern from m// or s/// */
1070 EXT SV *        lex_repl;       /* runtime replacement from s/// */
1071 EXT OP *        lex_op;         /* extra info to pass back on op */
1072 EXT OP *        lex_inpat;      /* in pattern $) and $| are special */
1073 EXT I32         lex_inwhat;     /* what kind of quoting are we in */
1074 EXT char *      lex_brackstack; /* what kind of brackets to pop */
1075 EXT char *      lex_casestack;  /* what kind of case mods in effect */
1076
1077 /* What we know when we're in LEX_KNOWNEXT state. */
1078 EXT YYSTYPE     nextval[5];     /* value of next token, if any */
1079 EXT I32         nexttype[5];    /* type of next token */
1080 EXT I32         nexttoke;
1081
1082 EXT FILE * VOL  rsfp INIT(Nullfp);
1083 EXT SV *        linestr;
1084 EXT char *      bufptr;
1085 EXT char *      oldbufptr;
1086 EXT char *      oldoldbufptr;
1087 EXT char *      bufend;
1088 EXT expectation expect INIT(XSTATE);    /* how to interpret ambiguous tokens */
1089 EXT char *      autoboot_preamble INIT(Nullch);
1090 EXT cryptswitch_t cryptswitch_fp;
1091
1092 EXT I32         multi_start;    /* 1st line of multi-line string */
1093 EXT I32         multi_end;      /* last line of multi-line string */
1094 EXT I32         multi_open;     /* delimiter of said string */
1095 EXT I32         multi_close;    /* delimiter of said string */
1096
1097 EXT GV *        scrgv;
1098 EXT I32         error_count;    /* how many errors so far, max 10 */
1099 EXT I32         subline;        /* line this subroutine began on */
1100 EXT SV *        subname;        /* name of current subroutine */
1101
1102 EXT CV *        compcv;         /* currently compiling subroutine */
1103 EXT AV *        comppad;        /* storage for lexically scoped temporaries */
1104 EXT AV *        comppad_name;   /* variable names for "my" variables */
1105 EXT I32         comppad_name_fill;/* last "introduced" variable offset */
1106 EXT I32         min_intro_pending;/* start of vars to introduce */
1107 EXT I32         max_intro_pending;/* end of vars to introduce */
1108 EXT I32         padix;          /* max used index in current "register" pad */
1109 EXT I32         padix_floor;    /* how low may inner block reset padix */
1110 EXT I32         pad_reset_pending; /* reset pad on next attempted alloc */
1111 EXT COP         compiling;
1112
1113 EXT I32         thisexpr;       /* name id for nothing_in_common() */
1114 EXT char *      last_uni;       /* position of last named-unary operator */
1115 EXT char *      last_lop;       /* position of last list operator */
1116 EXT OPCODE      last_lop_op;    /* last list operator */
1117 EXT bool        in_my;          /* we're compiling a "my" declaration */
1118 #ifdef FCRYPT
1119 EXT I32         cryptseen;      /* has fast crypt() been initialized? */
1120 #endif
1121
1122 EXT U32         hints;          /* various compilation flags */
1123
1124                                 /* Note: the lowest 8 bits are reserved for
1125                                    stuffing into op->op_private */
1126 #define HINT_INTEGER            0x00000001
1127 #define HINT_STRICT_REFS        0x00000002
1128
1129 #define HINT_BLOCK_SCOPE        0x00000100
1130 #define HINT_STRICT_SUBS        0x00000200
1131 #define HINT_STRICT_VARS        0x00000400
1132
1133 /**************************************************************************/
1134 /* This regexp stuff is global since it always happens within 1 expr eval */
1135 /**************************************************************************/
1136
1137 EXT char *      regprecomp;     /* uncompiled string. */
1138 EXT char *      regparse;       /* Input-scan pointer. */
1139 EXT char *      regxend;        /* End of input for compile */
1140 EXT I32         regnpar;        /* () count. */
1141 EXT char *      regcode;        /* Code-emit pointer; &regdummy = don't. */
1142 EXT I32         regsize;        /* Code size. */
1143 EXT I32         regnaughty;     /* How bad is this pattern? */
1144 EXT I32         regsawback;     /* Did we see \1, ...? */
1145
1146 EXT char *      reginput;       /* String-input pointer. */
1147 EXT char *      regbol;         /* Beginning of input, for ^ check. */
1148 EXT char *      regeol;         /* End of input, for $ check. */
1149 EXT char **     regstartp;      /* Pointer to startp array. */
1150 EXT char **     regendp;        /* Ditto for endp. */
1151 EXT U32 *       reglastparen;   /* Similarly for lastparen. */
1152 EXT char *      regtill;        /* How far we are required to go. */
1153 EXT U16         regflags;       /* are we folding, multilining? */
1154 EXT char        regprev;        /* char before regbol, \n if none */
1155
1156 /***********************************************/
1157 /* Global only to current interpreter instance */
1158 /***********************************************/
1159
1160 #ifdef MULTIPLICITY
1161 #define IEXT
1162 #define IINIT(x)
1163 struct interpreter {
1164 #else
1165 #define IEXT EXT
1166 #define IINIT(x) INIT(x)
1167 #endif
1168
1169 /* pseudo environmental stuff */
1170 IEXT int        Iorigargc;
1171 IEXT char **    Iorigargv;
1172 IEXT GV *       Ienvgv;
1173 IEXT GV *       Isiggv;
1174 IEXT GV *       Iincgv;
1175 IEXT char *     Iorigfilename;
1176 IEXT SV *       Idiehook;
1177 IEXT SV *       Iwarnhook;
1178 IEXT SV *       Iparsehook;
1179
1180 /* switches */
1181 IEXT char *     Icddir;
1182 IEXT bool       Iminus_c;
1183 IEXT char       Ipatchlevel[6];
1184 IEXT char *     Inrs IINIT("\n");
1185 IEXT U32        Inrschar IINIT('\n');   /* final char of rs, or 0777 if none */
1186 IEXT I32        Inrslen IINIT(1);
1187 IEXT char *     Isplitstr IINIT(" ");
1188 IEXT bool       Ipreprocess;
1189 IEXT bool       Iminus_n;
1190 IEXT bool       Iminus_p;
1191 IEXT bool       Iminus_l;
1192 IEXT bool       Iminus_a;
1193 IEXT bool       Iminus_F;
1194 IEXT bool       Idoswitches;
1195 IEXT bool       Idowarn;
1196 IEXT bool       Idoextract;
1197 IEXT bool       Isawampersand;  /* must save all match strings */
1198 IEXT bool       Isawstudy;      /* do fbm_instr on all strings */
1199 IEXT bool       Isawi;          /* study must assume case insensitive */
1200 IEXT bool       Isawvec;
1201 IEXT bool       Iunsafe;
1202 IEXT bool       Ido_undump;             /* -u or dump seen? */
1203 IEXT char *     Iinplace;
1204 IEXT char *     Ie_tmpname;
1205 IEXT FILE *     Ie_fp;
1206 IEXT VOL U32    Idebug;
1207 IEXT U32        Iperldb;
1208         /* This value may be raised by extensions for testing purposes */
1209 IEXT int        Iperl_destruct_level;   /* 0=none, 1=full, 2=full with checks */
1210
1211 /* magical thingies */
1212 IEXT Time_t     Ibasetime;              /* $^T */
1213 IEXT SV *       Iformfeed;              /* $^L */
1214 IEXT char *     Ichopset IINIT(" \n-"); /* $: */
1215 IEXT char *     Irs IINIT("\n");        /* $/ */
1216 IEXT U32        Irschar IINIT('\n');    /* final char of rs, or 0777 if none */
1217 IEXT STRLEN     Irslen IINIT(1);
1218 IEXT bool       Irspara;
1219 IEXT char *     Iofs;                   /* $, */
1220 IEXT STRLEN     Iofslen;
1221 IEXT char *     Iors;                   /* $\ */
1222 IEXT STRLEN     Iorslen;
1223 IEXT char *     Iofmt;                  /* $# */
1224 IEXT I32        Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1225 IEXT int        Imultiline;       /* $*--do strings hold >1 line? */
1226 IEXT U32        Istatusvalue;   /* $? */
1227
1228 IEXT struct stat Istatcache;            /* _ */
1229 IEXT GV *       Istatgv;
1230 IEXT SV *       Istatname IINIT(Nullsv);
1231
1232 /* shortcuts to various I/O objects */
1233 IEXT GV *       Istdingv;
1234 IEXT GV *       Ilast_in_gv;
1235 IEXT GV *       Idefgv;
1236 IEXT GV *       Iargvgv;
1237 IEXT GV *       Idefoutgv;
1238 IEXT GV *       Iargvoutgv;
1239
1240 /* shortcuts to regexp stuff */
1241 IEXT GV *       Ileftgv;
1242 IEXT GV *       Iampergv;
1243 IEXT GV *       Irightgv;
1244 IEXT PMOP *     Icurpm;         /* what to do \ interps from */
1245 IEXT I32 *      Iscreamfirst;
1246 IEXT I32 *      Iscreamnext;
1247 IEXT I32        Imaxscream IINIT(-1);
1248 IEXT SV *       Ilastscream;
1249
1250 /* shortcuts to debugging objects */
1251 IEXT GV *       IDBgv;
1252 IEXT GV *       IDBline;
1253 IEXT GV *       IDBsub;
1254 IEXT SV *       IDBsingle;
1255 IEXT SV *       IDBtrace;
1256 IEXT SV *       IDBsignal;
1257 IEXT AV *       Ilineary;       /* lines of script for debugger */
1258 IEXT AV *       Idbargs;        /* args to call listed by caller function */
1259
1260 /* symbol tables */
1261 IEXT HV *       Idefstash;      /* main symbol table */
1262 IEXT HV *       Icurstash;      /* symbol table for current package */
1263 IEXT HV *       Idebstash;      /* symbol table for perldb package */
1264 IEXT SV *       Icurstname;     /* name of current package */
1265 IEXT AV *       Ibeginav;       /* names of BEGIN subroutines */
1266 IEXT AV *       Iendav;         /* names of END subroutines */
1267 IEXT AV *       Ipad;           /* storage for lexically scoped temporaries */
1268 IEXT AV *       Ipadname;       /* variable names for "my" variables */
1269
1270 /* memory management */
1271 IEXT SV **      Itmps_stack;
1272 IEXT I32        Itmps_ix IINIT(-1);
1273 IEXT I32        Itmps_floor IINIT(-1);
1274 IEXT I32        Itmps_max;
1275 IEXT I32        Isv_count;      /* how many SV* are currently allocated */
1276 IEXT I32        Isv_objcount;   /* how many objects are currently allocated */
1277 IEXT SV*        Isv_root;       /* storage for SVs belonging to interp */
1278 IEXT SV*        Isv_arenaroot;  /* list of areas for garbage collection */
1279
1280 /* funky return mechanisms */
1281 IEXT I32        Ilastspbase;
1282 IEXT I32        Ilastsize;
1283 IEXT int        Iforkprocess;   /* so do_open |- can return proc# */
1284
1285 /* subprocess state */
1286 IEXT AV *       Ifdpid;         /* keep fd-to-pid mappings for my_popen */
1287 IEXT HV *       Ipidstatus;     /* keep pid-to-status mappings for waitpid */
1288
1289 /* internal state */
1290 IEXT VOL int    Iin_eval;       /* trap "fatal" errors? */
1291 IEXT OP *       Irestartop;     /* Are we propagating an error from croak? */
1292 IEXT int        Idelaymagic;    /* ($<,$>) = ... */
1293 IEXT bool       Idirty;         /* In the middle of tearing things down? */
1294 IEXT U8         Ilocalizing;    /* are we processing a local() list? */
1295 IEXT bool       Itainted;       /* using variables controlled by $< */
1296 IEXT bool       Itainting;      /* doing taint checks */
1297
1298 /* trace state */
1299 IEXT I32        Idlevel;
1300 IEXT I32        Idlmax IINIT(128);
1301 IEXT char *     Idebname;
1302 IEXT char *     Idebdelim;
1303
1304 /* current interpreter roots */
1305 IEXT CV *       Imain_cv;
1306 IEXT OP *       Imain_root;
1307 IEXT OP *       Imain_start;
1308 IEXT OP *       Ieval_root;
1309 IEXT OP *       Ieval_start;
1310
1311 /* runtime control stuff */
1312 IEXT COP * VOL  Icurcop IINIT(&compiling);
1313 IEXT line_t     Icopline IINIT(NOLINE);
1314 IEXT CONTEXT *  Icxstack;
1315 IEXT I32        Icxstack_ix IINIT(-1);
1316 IEXT I32        Icxstack_max IINIT(128);
1317 IEXT jmp_buf    Itop_env;
1318 IEXT I32        Irunlevel;
1319
1320 /* stack stuff */
1321 IEXT AV *       Istack;         /* THE STACK */
1322 IEXT AV *       Imainstack;     /* the stack when nothing funny is happening */
1323 IEXT SV **      Imystack_base;  /* stack->array_ary */
1324 IEXT SV **      Imystack_sp;    /* stack pointer now */
1325 IEXT SV **      Imystack_max;   /* stack->array_ary + stack->array_max */
1326
1327 /* format accumulators */
1328 IEXT SV *       Iformtarget;
1329 IEXT SV *       Ibodytarget;
1330 IEXT SV *       Itoptarget;
1331
1332 /* statics moved here for shared library purposes */
1333 IEXT SV         Istrchop;       /* return value from chop */
1334 IEXT int        Ifilemode;      /* so nextargv() can preserve mode */
1335 IEXT int        Ilastfd;        /* what to preserve mode on */
1336 IEXT char *     Ioldname;       /* what to preserve mode on */
1337 IEXT char **    IArgv;          /* stuff to free from do_aexec, vfork safe */
1338 IEXT char *     ICmd;           /* stuff to free from do_aexec, vfork safe */
1339 IEXT OP *       Isortcop;       /* user defined sort routine */
1340 IEXT HV *       Isortstash;     /* which is in some package or other */
1341 IEXT GV *       Ifirstgv;       /* $a */
1342 IEXT GV *       Isecondgv;      /* $b */
1343 IEXT AV *       Isortstack;     /* temp stack during pp_sort() */
1344 IEXT AV *       Isignalstack;   /* temp stack during sighandler() */
1345 IEXT SV *       Imystrk;        /* temp key string for do_each() */
1346 IEXT I32        Idumplvl;       /* indentation level on syntax tree dump */
1347 IEXT PMOP *     Ioldlastpm;     /* for saving regexp context during debugger */
1348 IEXT I32        Igensym;        /* next symbol for getsym() to define */
1349 IEXT bool       Ipreambled;
1350 IEXT int        Ilaststatval IINIT(-1);
1351 IEXT I32        Ilaststype IINIT(OP_STAT);
1352
1353 #undef IEXT
1354 #undef IINIT
1355
1356 #ifdef MULTIPLICITY
1357 };
1358 #else
1359 struct interpreter {
1360     char broiled;
1361 };
1362 #endif
1363
1364 #include "pp.h"
1365
1366 #ifdef __cplusplus
1367 extern "C" {
1368 #endif
1369
1370 #ifdef __cplusplus
1371 #  ifndef I_STDARG
1372 #    define I_STDARG 1
1373 #  endif
1374 #endif
1375
1376 #ifdef I_STDARG
1377 #  include <stdarg.h>
1378 #else
1379 #  ifdef I_VARARGS
1380 #    include <varargs.h>
1381 #  endif
1382 #endif
1383
1384 #include "proto.h"
1385
1386 #ifdef EMBED
1387 #define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
1388 #define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
1389 #else
1390 #define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
1391 #define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
1392 #endif
1393
1394 #ifdef __cplusplus
1395 };
1396 #endif
1397
1398 /* The following must follow proto.h */
1399
1400 #ifdef DOINIT
1401 MGVTBL vtbl_sv =        {magic_get,
1402                                 magic_set,
1403                                         magic_len,
1404                                                 0,      0};
1405 MGVTBL vtbl_env =       {0,     0,      0,      0,      0};
1406 MGVTBL vtbl_envelem =   {0,     magic_setenv,
1407                                         0,      magic_clearenv,
1408                                                         0};
1409 MGVTBL vtbl_sig =       {0,     0,               0, 0, 0};
1410 MGVTBL vtbl_sigelem =   {0,     magic_setsig,
1411                                         0,      0,      0};
1412 MGVTBL vtbl_pack =      {0,     0,      0,      magic_wipepack,
1413                                                         0};
1414 MGVTBL vtbl_packelem =  {magic_getpack,
1415                                 magic_setpack,
1416                                         0,      magic_clearpack,
1417                                                         0};
1418 MGVTBL vtbl_dbline =    {0,     magic_setdbline,
1419                                         0,      0,      0};
1420 MGVTBL vtbl_isa =       {0,     magic_setisa,
1421                                         0,      0,      0};
1422 MGVTBL vtbl_isaelem =   {0,     magic_setisa,
1423                                         0,      0,      0};
1424 MGVTBL vtbl_arylen =    {magic_getarylen,
1425                                 magic_setarylen,
1426                                         0,      0,      0};
1427 MGVTBL vtbl_glob =      {magic_getglob,
1428                                 magic_setglob,
1429                                         0,      0,      0};
1430 MGVTBL vtbl_mglob =     {0,     magic_setmglob,
1431                                         0,      0,      0};
1432 MGVTBL vtbl_taint =     {magic_gettaint,magic_settaint,
1433                                         0,      0,      0};
1434 MGVTBL vtbl_substr =    {0,     magic_setsubstr,
1435                                         0,      0,      0};
1436 MGVTBL vtbl_vec =       {0,     magic_setvec,
1437                                         0,      0,      0};
1438 MGVTBL vtbl_pos =       {magic_getpos,
1439                                 magic_setpos,
1440                                         0,      0,      0};
1441 MGVTBL vtbl_bm =        {0,     magic_setbm,
1442                                         0,      0,      0};
1443 MGVTBL vtbl_uvar =      {magic_getuvar,
1444                                 magic_setuvar,
1445                                         0,      0,      0};
1446
1447 #ifdef OVERLOAD
1448 MGVTBL vtbl_amagic =       {0,     magic_setamagic,
1449                                         0,      0,      magic_setamagic};
1450 MGVTBL vtbl_amagicelem =   {0,     magic_setamagic,
1451                                         0,      0,      magic_setamagic};
1452 #endif /* OVERLOAD */
1453
1454 #else
1455 EXT MGVTBL vtbl_sv;
1456 EXT MGVTBL vtbl_env;
1457 EXT MGVTBL vtbl_envelem;
1458 EXT MGVTBL vtbl_sig;
1459 EXT MGVTBL vtbl_sigelem;
1460 EXT MGVTBL vtbl_pack;
1461 EXT MGVTBL vtbl_packelem;
1462 EXT MGVTBL vtbl_dbline;
1463 EXT MGVTBL vtbl_isa;
1464 EXT MGVTBL vtbl_isaelem;
1465 EXT MGVTBL vtbl_arylen;
1466 EXT MGVTBL vtbl_glob;
1467 EXT MGVTBL vtbl_mglob;
1468 EXT MGVTBL vtbl_taint;
1469 EXT MGVTBL vtbl_substr;
1470 EXT MGVTBL vtbl_vec;
1471 EXT MGVTBL vtbl_pos;
1472 EXT MGVTBL vtbl_bm;
1473 EXT MGVTBL vtbl_uvar;
1474
1475 #ifdef OVERLOAD
1476 EXT MGVTBL vtbl_amagic;
1477 EXT MGVTBL vtbl_amagicelem;
1478 #endif /* OVERLOAD */
1479
1480 #endif
1481
1482 #ifdef OVERLOAD
1483 EXT long amagic_generation;
1484
1485 #define NofAMmeth 29
1486 #ifdef DOINIT
1487 EXT char * AMG_names[NofAMmeth][2] = {
1488   {"fallback","abs"},
1489   {"bool", "nomethod"},
1490   {"\"\"", "0+"},
1491   {"+","+="},
1492   {"-","-="},
1493   {"*", "*="},
1494   {"/", "/="},
1495   {"%", "%="},
1496   {"**", "**="},
1497   {"<<", "<<="},
1498   {">>", ">>="},
1499   {"&", "&="},
1500   {"|", "|="},
1501   {"^", "^="},
1502   {"<", "<="},
1503   {">", ">="},
1504   {"==", "!="},
1505   {"<=>", "cmp"},
1506   {"lt", "le"},
1507   {"gt", "ge"},
1508   {"eq", "ne"},
1509   {"!", "~"},
1510   {"++", "--"},
1511   {"atan2", "cos"},
1512   {"sin", "exp"},
1513   {"log", "sqrt"},
1514   {"x","x="},
1515   {".",".="},
1516   {"=","neg"}
1517 };
1518 #else
1519 EXT char * AMG_names[NofAMmeth][2];
1520 #endif /* def INITAMAGIC */
1521
1522 struct  am_table        {
1523   long was_ok_sub;
1524   long was_ok_am;
1525   CV* table[NofAMmeth*2];
1526   long fallback;
1527 };
1528 typedef struct am_table AMT;
1529
1530 #define AMGfallNEVER    1
1531 #define AMGfallNO       2
1532 #define AMGfallYES      3
1533
1534 enum {
1535   fallback_amg, abs_amg,
1536   bool__amg,    nomethod_amg,
1537   string_amg,   numer_amg,
1538   add_amg,      add_ass_amg,
1539   subtr_amg,    subtr_ass_amg,
1540   mult_amg,     mult_ass_amg,
1541   div_amg,      div_ass_amg,
1542   mod_amg,      mod_ass_amg,
1543   pow_amg,      pow_ass_amg,
1544   lshift_amg,   lshift_ass_amg,
1545   rshift_amg,   rshift_ass_amg,
1546   band_amg,     band_ass_amg,
1547   bor_amg,      bor_ass_amg,
1548   bxor_amg,     bxor_ass_amg,
1549   lt_amg,       le_amg,
1550   gt_amg,       ge_amg,
1551   eq_amg,       ne_amg,
1552   ncmp_amg,     scmp_amg,
1553   slt_amg,      sle_amg,
1554   sgt_amg,      sge_amg,
1555   seq_amg,      sne_amg,
1556   not_amg,      compl_amg,
1557   inc_amg,      dec_amg,
1558   atan2_amg,    cos_amg,
1559   sin_amg,      exp_amg,
1560   log_amg,      sqrt_amg,
1561   repeat_amg,   repeat_ass_amg,
1562   concat_amg,   concat_ass_amg,
1563   copy_amg,     neg_amg
1564 };
1565 #endif /* OVERLOAD */
1566
1567 #endif /* Include guard */