3 * Copyright (c) 1987-1994, Larry Wall
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.
19 # define BYTEORDER 0x1234
22 /* Overall memory policy? */
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...
37 # define malloc Mymalloc
38 # define realloc Myremalloc
41 # define safemalloc malloc
42 # define saferealloc realloc
43 # define safefree free
46 /* work around some libPW problems */
51 /* define this once if either system, instead of cluttering up the src */
52 #if defined(MSDOS) || defined(atarist)
56 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
60 #if defined(HASVOLATILE) || defined(STANDARD_C)
62 # define VOL // to temporarily suppress warnings
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()
93 #include <appkit/NXCType.h>
98 #ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */
105 # ifdef PARAM_NEEDS_TYPES
106 # include <sys/types.h>
108 # include <sys/param.h>
112 /* Use all the "standard" definitions? */
113 #if defined(STANDARD_C) && defined(I_STDLIB)
115 #endif /* STANDARD_C */
117 #define MEM_SIZE Size_t
119 #if defined(I_STRING) || defined(__cplusplus)
122 # include <strings.h>
125 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
127 #define strrchr rindex
130 #if defined(mips) && defined(ultrix) && !defined(__STDC__)
135 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
137 extern char * memcpy _((char*, char*, int));
143 # define memcpy(d,s,l) bcopy(s,d,l)
145 # define memcpy(d,s,l) my_bcopy(s,d,l)
148 #endif /* HAS_MEMCPY */
151 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
153 extern char *memset _((char*, int, int));
156 # define memzero(d,l) memset(d,0,l)
160 # define memzero(d,l) bzero(d,l)
162 # define memzero(d,l) my_bzero(d,l)
165 #endif /* HAS_MEMSET */
168 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
170 extern int memcmp _((char*, char*, int));
175 # define memcmp(s1,s2,l) my_memcmp(s1,s2,l)
177 #endif /* HAS_MEMCMP */
179 /* we prefer bcmp slightly for comparisons that don't care about ordering */
182 # define bcmp(s1,s2,l) memcmp(s1,s2,l)
184 #endif /* HAS_BCMP */
186 #if !defined(HAS_MEMMOVE) && !defined(memmove)
187 # if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
188 # define memmove(d,s,l) bcopy(s,d,l)
190 # if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
191 # define memmove(d,s,l) memcpy(d,s,l)
193 # define memmove(d,s,l) my_bcopy(s,d,l)
198 #ifndef _TYPES_ /* If types.h defines this it's easy. */
199 # ifndef major /* Does everyone's types.h define this? */
200 # include <sys/types.h>
205 # include <netinet/in.h>
208 #include <sys/stat.h>
210 /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
211 like UTekV) are broken, sometimes giving false positives. Undefine
212 them here and let the code below set them to proper values.
214 The ghs macro stands for GreenHills Software C-1.8.5 which
215 is the C compiler for sysV88 and the various derivatives.
216 This header file bug is corrected in gcc-2.5.8 and later versions.
217 --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */
219 #if defined(uts) || (defined(m88k) && defined(ghs))
233 # ifdef I_SYS_TIME_KERNEL
236 # include <sys/time.h>
237 # ifdef I_SYS_TIME_KERNEL
243 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
244 # include <sys/times.h>
248 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
254 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
256 #endif /* !HAS_MKFIFO */
261 # include <net/errno.h>
267 extern int errno; /* ANSI allows errno to be an lvalue expr */
273 char *strerror _((int,...));
275 char *strerror _((int));
278 # define Strerror strerror
281 # ifdef HAS_SYS_ERRLIST
283 extern char *sys_errlist[];
285 # define Strerror(e) \
286 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
293 # include <sys/ioctl.h>
297 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
298 # ifdef HAS_SOCKETPAIR
299 # undef HAS_SOCKETPAIR
314 /* Configure already sets Direntry_t */
315 #if defined(I_DIRENT)
317 # if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
318 # include <sys/dir.h>
322 # include <sys/ndir.h>
326 # include <ndir.h> /* may be wrong in the future */
328 # include <sys/dir.h>
335 /* work around botch in SunOS 4.0.1 and 4.0.2 */
337 # define fputs(sv,fp) fprintf(fp,"%s",sv)
342 * The following gobbledygook brought to you on behalf of __STDC__.
343 * (I could just use #ifndef __STDC__, but this is more bulletproof
344 * in the face of half-implementations.)
349 # define S_IFMT _S_IFMT
351 # define S_IFMT 0170000
356 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
360 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
365 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
367 # define S_ISBLK(m) (0)
372 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
377 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
379 # define S_ISFIFO(m) (0)
385 # define S_ISLNK(m) _S_ISLNK(m)
388 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
391 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
393 # define S_ISLNK(m) (0)
401 # define S_ISSOCK(m) _S_ISSOCK(m)
404 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
407 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
409 # define S_ISSOCK(m) (0)
417 # define S_IRUSR S_IREAD
418 # define S_IWUSR S_IWRITE
419 # define S_IXUSR S_IEXEC
421 # define S_IRUSR 0400
422 # define S_IWUSR 0200
423 # define S_IXUSR 0100
425 # define S_IRGRP (S_IRUSR>>3)
426 # define S_IWGRP (S_IWUSR>>3)
427 # define S_IXGRP (S_IXUSR>>3)
428 # define S_IROTH (S_IRUSR>>6)
429 # define S_IWOTH (S_IWUSR>>6)
430 # define S_IXOTH (S_IXUSR>>6)
434 # define S_ISUID 04000
438 # define S_ISGID 02000
445 #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
446 # define SLOPPYDIVIDE
449 #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
457 # if defined(convex) || defined (uts)
458 # define quad long long
466 # define VOIDRET void
477 # include "unixish.h"
482 #define pause() sleep((32767<<16)+32767)
487 /* on BSDish systes we're safe */
488 # define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
490 /* otherwise guess at what's safe */
491 # define IOCPARM_LEN(x) 256
495 typedef MEM_SIZE STRLEN;
497 typedef struct op OP;
498 typedef struct cop COP;
499 typedef struct unop UNOP;
500 typedef struct binop BINOP;
501 typedef struct listop LISTOP;
502 typedef struct logop LOGOP;
503 typedef struct condop CONDOP;
504 typedef struct pmop PMOP;
505 typedef struct svop SVOP;
506 typedef struct gvop GVOP;
507 typedef struct pvop PVOP;
508 typedef struct cvop CVOP;
509 typedef struct loop LOOP;
511 typedef struct Outrec Outrec;
512 typedef struct lstring Lstring;
513 typedef struct interpreter PerlInterpreter;
514 typedef struct ff FF;
515 typedef struct sv SV;
516 typedef struct av AV;
517 typedef struct hv HV;
518 typedef struct cv CV;
519 typedef struct regexp REGEXP;
520 typedef struct gp GP;
521 typedef struct sv GV;
522 typedef struct io IO;
523 typedef struct context CONTEXT;
524 typedef struct block BLOCK;
526 typedef struct magic MAGIC;
527 typedef struct xrv XRV;
528 typedef struct xpv XPV;
529 typedef struct xpviv XPVIV;
530 typedef struct xpvnv XPVNV;
531 typedef struct xpvmg XPVMG;
532 typedef struct xpvlv XPVLV;
533 typedef struct xpvav XPVAV;
534 typedef struct xpvhv XPVHV;
535 typedef struct xpvgv XPVGV;
536 typedef struct xpvcv XPVCV;
537 typedef struct xpvbm XPVBM;
538 typedef struct xpvfm XPVFM;
539 typedef struct xpvio XPVIO;
540 typedef struct mgvtbl MGVTBL;
541 typedef union any ANY;
543 typedef FILE * (*cryptswitch_t) _((FILE *rfp));
558 void (*any_dptr) _((void*));
575 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
581 char *sprintf _((char *, const char *, ...));
583 int sprintf _((char *, const char *, ...));
587 #if defined(htonl) && !defined(HAS_HTONL)
590 #if defined(htons) && !defined(HAS_HTONS)
593 #if defined(ntohl) && !defined(HAS_NTOHL)
596 #if defined(ntohs) && !defined(HAS_NTOHS)
600 #if (BYTEORDER & 0xffff) != 0x4321
606 #define htons my_swap
607 #define htonl my_htonl
608 #define ntohs my_swap
609 #define ntohl my_ntohl
612 #if (BYTEORDER & 0xffff) == 0x4321
621 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
624 #if BYTEORDER != 0x1234
629 # if BYTEORDER == 0x4321
630 # define vtohl(x) ((((x)&0xFF)<<24) \
632 +(((x)&0x0000FF00)<<8) \
633 +(((x)&0x00FF0000)>>8) )
634 # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
635 # define htovl(x) vtohl(x)
636 # define htovs(x) vtohs(x)
638 /* otherwise default to functions in util.c */
642 #define U_S(what) ((U16)(what))
643 #define U_I(what) ((unsigned int)(what))
644 #define U_L(what) ((U32)(what))
646 U32 cast_ulong _((double));
647 #define U_S(what) ((U16)cast_ulong(what))
648 #define U_I(what) ((unsigned int)cast_ulong(what))
649 #define U_L(what) (cast_ulong(what))
653 #define I_32(what) ((I32)(what))
654 #define I_V(what) ((IV)(what))
656 I32 cast_i32 _((double));
657 #define I_32(what) (cast_i32(what))
658 IV cast_iv _((double));
659 #define I_V(what) (cast_iv(what))
673 #define TMPPATH "plXXXXXX"
676 #define TMPPATH "/sys$scratch/perl-eXXXXXX"
678 #define TMPPATH "/tmp/perl-eXXXXXX"
683 Uid_t getuid _((void));
684 Uid_t geteuid _((void));
685 Gid_t getgid _((void));
686 Gid_t getegid _((void));
692 #define DEBUG(a) if (debug) a
693 #define DEBUG_p(a) if (debug & 1) a
694 #define DEBUG_s(a) if (debug & 2) a
695 #define DEBUG_l(a) if (debug & 4) a
696 #define DEBUG_t(a) if (debug & 8) a
697 #define DEBUG_o(a) if (debug & 16) a
698 #define DEBUG_c(a) if (debug & 32) a
699 #define DEBUG_P(a) if (debug & 64) a
700 #define DEBUG_m(a) if (debug & 128) a
701 #define DEBUG_f(a) if (debug & 256) a
702 #define DEBUG_r(a) if (debug & 512) a
703 #define DEBUG_x(a) if (debug & 1024) a
704 #define DEBUG_u(a) if (debug & 2048) a
705 #define DEBUG_L(a) if (debug & 4096) a
706 #define DEBUG_H(a) if (debug & 8192) a
707 #define DEBUG_X(a) if (debug & 16384) a
708 #define DEBUG_D(a) if (debug & 32768) a
729 #define YYMAXDEPTH 300
731 #define assert(what) DEB( { \
733 croak("Assertion failed: file \"%s\", line %d", \
734 __FILE__, __LINE__); \
739 I32 (*uf_val)_((IV, SV*));
740 I32 (*uf_set)_((IV, SV*));
744 /* Fix these up for __STDC__ */
746 char *mktemp _((char*));
747 double atof _((const char*));
751 /* All of these are in stdlib.h or time.h for ANSI C */
753 struct tm *gmtime(), *localtime();
754 char *strchr(), *strrchr();
755 char *strcpy(), *strcat();
756 #endif /* ! STANDARD_C */
765 double exp _((double));
766 double fmod _((double,double));
767 double log _((double));
768 double sqrt _((double));
769 double modf _((double,double*));
770 double sin _((double));
771 double cos _((double));
772 double atan2 _((double,double));
773 double pow _((double,double));
779 #if !defined(HAS_FMOD) && defined(HAS_DREM)
780 #define fmod(x,y) drem((x),(y))
784 char *crypt _((const char*, const char*));
785 char *getenv _((const char*));
786 Off_t lseek _((int,Off_t,int));
787 char *getlogin _((void));
792 I32 unlnk _((char*));
794 #define UNLINK unlink
798 # ifdef HAS_SETRESUID
799 # define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
800 # define HAS_SETREUID
804 # ifdef HAS_SETRESGID
805 # define setregid(r,e) setresgid(r,e,(Gid_t)-1)
806 # define HAS_SETREGID
818 # define PAD_SV(po) pad_sv(po)
820 # define PAD_SV(po) curpad[po]
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 */
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;
844 EXT U32 * profiledata;
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 */
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 */
857 /* likewise for these */
859 EXT OP * op; /* current op--oughta be in a global register */
861 EXT I32 * scopestack; /* blocks we've entered */
862 EXT I32 scopestack_ix;
863 EXT I32 scopestack_max;
865 EXT ANY* savestack; /* to save non-local values on */
866 EXT I32 savestack_ix;
867 EXT I32 savestack_max;
869 EXT OP ** retstack; /* returns we've pushed */
871 EXT I32 retstack_max;
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 */
883 EXT char tokenbuf[256];
884 EXT struct stat statbuf;
886 EXT struct tms timesbuf;
888 EXT STRLEN na; /* for use in SvPV when length is Not Applicable */
890 /* for tmp use in stupid debuggers */
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("|");
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");
909 INIT("Unsuccessful %s on filename containing newline");
910 EXT char no_wrongref[]
911 INIT("Can't use %s ref as %s ref");
913 INIT("Can't use a string as %s ref while \"strict refs\" in use");
915 INIT("Can't use an undefined value as %s reference");
917 INIT("Modification of non-creatable array value attempted, subscript %d");
919 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
921 INIT("Modification of a read-only value attempted");
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");
931 INIT("The %s function is unimplemented");
937 EXT char * cshname INIT(CSH);
942 EXT char *sig_name[] = {
946 EXT char *sig_name[];
950 EXT unsigned char fold[] = { /* fast case folding table */
951 0, 1, 2, 3, 4, 5, 6, 7,
952 8, 9, 10, 11, 12, 13, 14, 15,
953 16, 17, 18, 19, 20, 21, 22, 23,
954 24, 25, 26, 27, 28, 29, 30, 31,
955 32, 33, 34, 35, 36, 37, 38, 39,
956 40, 41, 42, 43, 44, 45, 46, 47,
957 48, 49, 50, 51, 52, 53, 54, 55,
958 56, 57, 58, 59, 60, 61, 62, 63,
959 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
960 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
961 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
962 'x', 'y', 'z', 91, 92, 93, 94, 95,
963 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
964 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
965 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
966 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
967 128, 129, 130, 131, 132, 133, 134, 135,
968 136, 137, 138, 139, 140, 141, 142, 143,
969 144, 145, 146, 147, 148, 149, 150, 151,
970 152, 153, 154, 155, 156, 157, 158, 159,
971 160, 161, 162, 163, 164, 165, 166, 167,
972 168, 169, 170, 171, 172, 173, 174, 175,
973 176, 177, 178, 179, 180, 181, 182, 183,
974 184, 185, 186, 187, 188, 189, 190, 191,
975 192, 193, 194, 195, 196, 197, 198, 199,
976 200, 201, 202, 203, 204, 205, 206, 207,
977 208, 209, 210, 211, 212, 213, 214, 215,
978 216, 217, 218, 219, 220, 221, 222, 223,
979 224, 225, 226, 227, 228, 229, 230, 231,
980 232, 233, 234, 235, 236, 237, 238, 239,
981 240, 241, 242, 243, 244, 245, 246, 247,
982 248, 249, 250, 251, 252, 253, 254, 255
985 EXT unsigned char fold[];
989 EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */
990 1, 2, 84, 151, 154, 155, 156, 157,
991 165, 246, 250, 3, 158, 7, 18, 29,
992 40, 51, 62, 73, 85, 96, 107, 118,
993 129, 140, 147, 148, 149, 150, 152, 153,
994 255, 182, 224, 205, 174, 176, 180, 217,
995 233, 232, 236, 187, 235, 228, 234, 226,
996 222, 219, 211, 195, 188, 193, 185, 184,
997 191, 183, 201, 229, 181, 220, 194, 162,
998 163, 208, 186, 202, 200, 218, 198, 179,
999 178, 214, 166, 170, 207, 199, 209, 206,
1000 204, 160, 212, 216, 215, 192, 175, 173,
1001 243, 172, 161, 190, 203, 189, 164, 230,
1002 167, 248, 227, 244, 242, 255, 241, 231,
1003 240, 253, 169, 210, 245, 237, 249, 247,
1004 239, 168, 252, 251, 254, 238, 223, 221,
1005 213, 225, 177, 197, 171, 196, 159, 4,
1006 5, 6, 8, 9, 10, 11, 12, 13,
1007 14, 15, 16, 17, 19, 20, 21, 22,
1008 23, 24, 25, 26, 27, 28, 30, 31,
1009 32, 33, 34, 35, 36, 37, 38, 39,
1010 41, 42, 43, 44, 45, 46, 47, 48,
1011 49, 50, 52, 53, 54, 55, 56, 57,
1012 58, 59, 60, 61, 63, 64, 65, 66,
1013 67, 68, 69, 70, 71, 72, 74, 75,
1014 76, 77, 78, 79, 80, 81, 82, 83,
1015 86, 87, 88, 89, 90, 91, 92, 93,
1016 94, 95, 97, 98, 99, 100, 101, 102,
1017 103, 104, 105, 106, 108, 109, 110, 111,
1018 112, 113, 114, 115, 116, 117, 119, 120,
1019 121, 122, 123, 124, 125, 126, 127, 128,
1020 130, 131, 132, 133, 134, 135, 136, 137,
1021 138, 139, 141, 142, 143, 144, 145, 146
1024 EXT unsigned char freq[];
1029 EXT char* block_type[] = {
1038 EXT char* block_type[];
1042 /*****************************************************************************/
1043 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
1044 /*****************************************************************************/
1045 /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
1058 EXT U32 lex_state; /* next token is determined */
1059 EXT U32 lex_defer; /* state after determined token */
1060 EXT expectation lex_expect; /* expect after determined token */
1061 EXT I32 lex_brackets; /* bracket count */
1062 EXT I32 lex_formbrack; /* bracket count at outer format level */
1063 EXT I32 lex_fakebrack; /* outer bracket is mere delimiter */
1064 EXT I32 lex_casemods; /* casemod count */
1065 EXT I32 lex_dojoin; /* doing an array interpolation */
1066 EXT I32 lex_starts; /* how many interps done on level */
1067 EXT SV * lex_stuff; /* runtime pattern from m// or s/// */
1068 EXT SV * lex_repl; /* runtime replacement from s/// */
1069 EXT OP * lex_op; /* extra info to pass back on op */
1070 EXT OP * lex_inpat; /* in pattern $) and $| are special */
1071 EXT I32 lex_inwhat; /* what kind of quoting are we in */
1072 EXT char * lex_brackstack; /* what kind of brackets to pop */
1073 EXT char * lex_casestack; /* what kind of case mods in effect */
1075 /* What we know when we're in LEX_KNOWNEXT state. */
1076 EXT YYSTYPE nextval[5]; /* value of next token, if any */
1077 EXT I32 nexttype[5]; /* type of next token */
1080 EXT FILE * VOL rsfp INIT(Nullfp);
1083 EXT char * oldbufptr;
1084 EXT char * oldoldbufptr;
1086 EXT expectation expect INIT(XSTATE); /* how to interpret ambiguous tokens */
1087 EXT char * autoboot_preamble INIT(Nullch);
1089 EXT I32 multi_start; /* 1st line of multi-line string */
1090 EXT I32 multi_end; /* last line of multi-line string */
1091 EXT I32 multi_open; /* delimiter of said string */
1092 EXT I32 multi_close; /* delimiter of said string */
1095 EXT I32 error_count; /* how many errors so far, max 10 */
1096 EXT I32 subline; /* line this subroutine began on */
1097 EXT SV * subname; /* name of current subroutine */
1099 EXT AV * comppad; /* storage for lexically scoped temporaries */
1100 EXT AV * comppad_name; /* variable names for "my" variables */
1101 EXT I32 comppad_name_fill;/* last "introduced" variable offset */
1102 EXT I32 min_intro_pending;/* start of vars to introduce */
1103 EXT I32 max_intro_pending;/* end of vars to introduce */
1104 EXT I32 padix; /* max used index in current "register" pad */
1105 EXT I32 padix_floor; /* how low may inner block reset padix */
1106 EXT bool pad_reset_pending; /* reset pad on next attempted alloc */
1109 EXT I32 thisexpr; /* name id for nothing_in_common() */
1110 EXT char * last_uni; /* position of last named-unary operator */
1111 EXT char * last_lop; /* position of last list operator */
1112 EXT OPCODE last_lop_op; /* last list operator */
1113 EXT bool in_my; /* we're compiling a "my" declaration */
1115 EXT I32 cryptseen; /* has fast crypt() been initialized? */
1118 EXT U32 hints; /* various compilation flags */
1120 /* Note: the lowest 8 bits are reserved for
1121 stuffing into op->op_private */
1122 #define HINT_INTEGER 0x00000001
1123 #define HINT_STRICT_REFS 0x00000002
1125 #define HINT_BLOCK_SCOPE 0x00000100
1126 #define HINT_STRICT_SUBS 0x00000200
1127 #define HINT_STRICT_VARS 0x00000400
1129 /**************************************************************************/
1130 /* This regexp stuff is global since it always happens within 1 expr eval */
1131 /**************************************************************************/
1133 EXT char * regprecomp; /* uncompiled string. */
1134 EXT char * regparse; /* Input-scan pointer. */
1135 EXT char * regxend; /* End of input for compile */
1136 EXT I32 regnpar; /* () count. */
1137 EXT char * regcode; /* Code-emit pointer; ®dummy = don't. */
1138 EXT I32 regsize; /* Code size. */
1139 EXT I32 regnaughty; /* How bad is this pattern? */
1140 EXT I32 regsawback; /* Did we see \1, ...? */
1142 EXT char * reginput; /* String-input pointer. */
1143 EXT char * regbol; /* Beginning of input, for ^ check. */
1144 EXT char * regeol; /* End of input, for $ check. */
1145 EXT char ** regstartp; /* Pointer to startp array. */
1146 EXT char ** regendp; /* Ditto for endp. */
1147 EXT U32 * reglastparen; /* Similarly for lastparen. */
1148 EXT char * regtill; /* How far we are required to go. */
1149 EXT U16 regflags; /* are we folding, multilining? */
1150 EXT char regprev; /* char before regbol, \n if none */
1152 /***********************************************/
1153 /* Global only to current interpreter instance */
1154 /***********************************************/
1159 struct interpreter {
1162 #define IINIT(x) INIT(x)
1165 /* pseudo environmental stuff */
1167 IEXT char ** Iorigargv;
1171 IEXT char * Iorigfilename;
1176 IEXT char Ipatchlevel[6];
1177 IEXT char * Inrs IINIT("\n");
1178 IEXT U32 Inrschar IINIT('\n'); /* final char of rs, or 0777 if none */
1179 IEXT I32 Inrslen IINIT(1);
1180 IEXT char * Isplitstr IINIT(" ");
1181 IEXT bool Ipreprocess;
1187 IEXT bool Idoswitches;
1189 IEXT bool Idoextract;
1190 IEXT bool Isawampersand; /* must save all match strings */
1191 IEXT bool Isawstudy; /* do fbm_instr on all strings */
1192 IEXT bool Isawi; /* study must assume case insensitive */
1195 IEXT bool Ido_undump; /* -u or dump seen? */
1196 IEXT char * Iinplace;
1197 IEXT char * Ie_tmpname;
1199 IEXT VOL U32 Idebug;
1202 /* magical thingies */
1203 IEXT Time_t Ibasetime; /* $^T */
1204 IEXT SV * Iformfeed; /* $^L */
1205 IEXT char * Ichopset IINIT(" \n-"); /* $: */
1206 IEXT char * Irs IINIT("\n"); /* $/ */
1207 IEXT U32 Irschar IINIT('\n'); /* final char of rs, or 0777 if none */
1208 IEXT STRLEN Irslen IINIT(1);
1210 IEXT char * Iofs; /* $, */
1211 IEXT STRLEN Iofslen;
1212 IEXT char * Iors; /* $\ */
1213 IEXT STRLEN Iorslen;
1214 IEXT char * Iofmt; /* $# */
1215 IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1216 IEXT int Imultiline; /* $*--do strings hold >1 line? */
1217 IEXT U16 Istatusvalue; /* $? */
1219 IEXT struct stat Istatcache; /* _ */
1221 IEXT SV * Istatname IINIT(Nullsv);
1223 /* shortcuts to various I/O objects */
1225 IEXT GV * Ilast_in_gv;
1228 IEXT GV * Idefoutgv;
1229 IEXT GV * Iargvoutgv;
1231 /* shortcuts to regexp stuff */
1235 IEXT PMOP * Icurpm; /* what to do \ interps from */
1236 IEXT I32 * Iscreamfirst;
1237 IEXT I32 * Iscreamnext;
1238 IEXT I32 Imaxscream IINIT(-1);
1239 IEXT SV * Ilastscream;
1241 /* shortcuts to debugging objects */
1245 IEXT SV * IDBsingle;
1247 IEXT SV * IDBsignal;
1248 IEXT AV * Ilineary; /* lines of script for debugger */
1249 IEXT AV * Idbargs; /* args to call listed by caller function */
1252 IEXT HV * Idefstash; /* main symbol table */
1253 IEXT HV * Icurstash; /* symbol table for current package */
1254 IEXT HV * Idebstash; /* symbol table for perldb package */
1255 IEXT SV * Icurstname; /* name of current package */
1256 IEXT AV * Ibeginav; /* names of BEGIN subroutines */
1257 IEXT AV * Iendav; /* names of END subroutines */
1258 IEXT AV * Ipad; /* storage for lexically scoped temporaries */
1259 IEXT AV * Ipadname; /* variable names for "my" variables */
1261 /* memory management */
1262 IEXT SV ** Itmps_stack;
1263 IEXT I32 Itmps_ix IINIT(-1);
1264 IEXT I32 Itmps_floor IINIT(-1);
1266 IEXT I32 Isv_count; /* how many SV* are currently allocated */
1267 IEXT I32 Isv_objcount; /* how many objects are currently allocated */
1268 IEXT SV* Isv_root; /* storage for SVs belonging to interp */
1269 IEXT SV* Isv_arenaroot; /* list of areas for garbage collection */
1271 /* funky return mechanisms */
1272 IEXT I32 Ilastspbase;
1274 IEXT int Iforkprocess; /* so do_open |- can return proc# */
1276 /* subprocess state */
1277 IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */
1278 IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */
1280 /* internal state */
1281 IEXT VOL int Iin_eval; /* trap "fatal" errors? */
1282 IEXT OP * Irestartop; /* Are we propagating an error from croak? */
1283 IEXT int Idelaymagic; /* ($<,$>) = ... */
1284 IEXT bool Idirty; /* In the middle of tearing things down? */
1285 IEXT bool Ilocalizing; /* are we processing a local() list? */
1286 IEXT bool Itainted; /* using variables controlled by $< */
1287 IEXT bool Itainting; /* doing taint checks */
1291 IEXT I32 Idlmax IINIT(128);
1292 IEXT char * Idebname;
1293 IEXT char * Idebdelim;
1295 /* current interpreter roots */
1296 IEXT OP * Imain_root;
1297 IEXT OP * Imain_start;
1298 IEXT OP * Ieval_root;
1299 IEXT OP * Ieval_start;
1301 /* runtime control stuff */
1302 IEXT COP * VOL Icurcop IINIT(&compiling);
1303 IEXT line_t Icopline IINIT(NOLINE);
1304 IEXT CONTEXT * Icxstack;
1305 IEXT I32 Icxstack_ix IINIT(-1);
1306 IEXT I32 Icxstack_max IINIT(128);
1307 IEXT jmp_buf Itop_env;
1311 IEXT AV * Istack; /* THE STACK */
1312 IEXT AV * Imainstack; /* the stack when nothing funny is happening */
1313 IEXT SV ** Imystack_base; /* stack->array_ary */
1314 IEXT SV ** Imystack_sp; /* stack pointer now */
1315 IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */
1317 /* format accumulators */
1318 IEXT SV * Iformtarget;
1319 IEXT SV * Ibodytarget;
1320 IEXT SV * Itoptarget;
1322 /* statics moved here for shared library purposes */
1323 IEXT SV Istrchop; /* return value from chop */
1324 IEXT int Ifilemode; /* so nextargv() can preserve mode */
1325 IEXT int Ilastfd; /* what to preserve mode on */
1326 IEXT char * Ioldname; /* what to preserve mode on */
1327 IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */
1328 IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */
1329 IEXT OP * Isortcop; /* user defined sort routine */
1330 IEXT HV * Isortstash; /* which is in some package or other */
1331 IEXT GV * Ifirstgv; /* $a */
1332 IEXT GV * Isecondgv; /* $b */
1333 IEXT AV * Isortstack; /* temp stack during pp_sort() */
1334 IEXT AV * Isignalstack; /* temp stack during sighandler() */
1335 IEXT SV * Imystrk; /* temp key string for do_each() */
1336 IEXT I32 Idumplvl; /* indentation level on syntax tree dump */
1337 IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */
1338 IEXT I32 Igensym; /* next symbol for getsym() to define */
1339 IEXT bool Ipreambled;
1340 IEXT int Ilaststatval IINIT(-1);
1341 IEXT I32 Ilaststype IINIT(OP_STAT);
1349 struct interpreter {
1367 # include <stdarg.h>
1370 # include <varargs.h>
1377 #define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
1378 #define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
1380 #define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
1381 #define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
1388 /* The following must follow proto.h */
1391 MGVTBL vtbl_sv = {magic_get,
1395 MGVTBL vtbl_env = {0, 0, 0, 0, 0};
1396 MGVTBL vtbl_envelem = {0, magic_setenv,
1399 MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
1400 MGVTBL vtbl_sigelem = {0, magic_setsig,
1402 MGVTBL vtbl_pack = {0, 0, 0, magic_wipepack,
1404 MGVTBL vtbl_packelem = {magic_getpack,
1408 MGVTBL vtbl_dbline = {0, magic_setdbline,
1410 MGVTBL vtbl_isa = {0, magic_setisa,
1412 MGVTBL vtbl_isaelem = {0, magic_setisa,
1414 MGVTBL vtbl_arylen = {magic_getarylen,
1417 MGVTBL vtbl_glob = {magic_getglob,
1420 MGVTBL vtbl_mglob = {0, magic_setmglob,
1422 MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
1424 MGVTBL vtbl_substr = {0, magic_setsubstr,
1426 MGVTBL vtbl_vec = {0, magic_setvec,
1428 MGVTBL vtbl_pos = {magic_getpos,
1431 MGVTBL vtbl_bm = {0, magic_setbm,
1433 MGVTBL vtbl_uvar = {magic_getuvar,
1438 MGVTBL vtbl_amagic = {0, magic_setamagic,
1440 MGVTBL vtbl_amagicelem = {0, magic_setamagic,
1442 #endif /* OVERLOAD */
1446 EXT MGVTBL vtbl_env;
1447 EXT MGVTBL vtbl_envelem;
1448 EXT MGVTBL vtbl_sig;
1449 EXT MGVTBL vtbl_sigelem;
1450 EXT MGVTBL vtbl_pack;
1451 EXT MGVTBL vtbl_packelem;
1452 EXT MGVTBL vtbl_dbline;
1453 EXT MGVTBL vtbl_isa;
1454 EXT MGVTBL vtbl_isaelem;
1455 EXT MGVTBL vtbl_arylen;
1456 EXT MGVTBL vtbl_glob;
1457 EXT MGVTBL vtbl_mglob;
1458 EXT MGVTBL vtbl_taint;
1459 EXT MGVTBL vtbl_substr;
1460 EXT MGVTBL vtbl_vec;
1461 EXT MGVTBL vtbl_pos;
1463 EXT MGVTBL vtbl_uvar;
1466 EXT MGVTBL vtbl_amagic;
1467 EXT MGVTBL vtbl_amagicelem;
1468 #endif /* OVERLOAD */
1473 EXT long amagic_generation;
1475 #define NofAMmeth 27
1477 EXT char * AMG_names[NofAMmeth][2] = {
1479 {"bool", "nomethod"},
1507 EXT char * AMG_names[NofAMmeth][2];
1508 #endif /* def INITAMAGIC */
1513 CV* table[NofAMmeth*2];
1516 typedef struct am_table AMT;
1518 #define AMGfallNEVER 1
1520 #define AMGfallYES 3
1523 fallback_amg, abs_amg,
1524 bool__amg, nomethod_amg,
1525 string_amg, numer_amg,
1526 add_amg, add_ass_amg,
1527 subtr_amg, subtr_ass_amg,
1528 mult_amg, mult_ass_amg,
1529 div_amg, div_ass_amg,
1530 mod_amg, mod_ass_amg,
1531 pow_amg, pow_ass_amg,
1532 lshift_amg, lshift_ass_amg,
1533 rshift_amg, rshift_ass_amg,
1548 repeat_amg, repeat_ass_amg,
1549 concat_amg, concat_ass_amg
1551 #endif /* OVERLOAD */
1553 #endif /* Include guard */