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.
14 * STMT_START { statements; } STMT_END;
15 * can be used as a single statement, as in
16 * if (x) STMT_START { ... } STMT_END; else ...
18 * Trying to select a version that gives no warnings...
20 #if !(defined(STMT_START) && defined(STMT_END))
21 # if defined(__GNUC__) && !defined(__STRICT_ANSI__)
22 # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
25 /* Now which other defined()s do we need here ??? */
26 # if (VOIDFLAGS) && (defined(sun) || defined(__sun__))
27 # define STMT_START if (1)
28 # define STMT_END else (void)0
30 # define STMT_START do
31 # define STMT_END while (0)
42 # define BYTEORDER 0x1234
45 /* Overall memory policy? */
51 * The following contortions are brought to you on behalf of all the
52 * standards, semi-standards, de facto standards, not-so-de-facto standards
53 * of the world, as well as all the other botches anyone ever thought of.
54 * The basic theory is that if we work hard enough here, the rest of the
55 * code can be a lot prettier. Well, so much for theory. Sorry, Henry...
58 /* define this once if either system, instead of cluttering up the src */
59 #if defined(MSDOS) || defined(atarist)
63 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
67 #if defined(HASVOLATILE) || defined(STANDARD_C)
69 # define VOL // to temporarily suppress warnings
77 #define TAINT_IF(c) (tainted |= (c))
78 #define TAINT_NOT (tainted = 0)
79 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
80 #define TAINT_ENV() if (tainting) taint_env()
84 # define BSD_GETPGRP(pid) getpgrp((pid))
87 # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
91 # define BSD_GETPGRP(pid) getpgrp2((pid))
97 # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
105 #ifdef USE_NEXT_CTYPE
106 #include <appkit/NXCType.h>
115 #ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */
122 # ifdef PARAM_NEEDS_TYPES
123 # include <sys/types.h>
125 # include <sys/param.h>
129 /* Use all the "standard" definitions? */
130 #if defined(STANDARD_C) && defined(I_STDLIB)
132 #endif /* STANDARD_C */
134 /* Maybe this comes after <stdlib.h> so we don't try to change
135 the standard library prototypes?. We'll use our own in
136 proto.h instead. I guess. The patch had no explanation.
140 # define malloc Mymalloc
141 # define realloc Myremalloc
144 # define safemalloc malloc
145 # define saferealloc realloc
146 # define safefree free
149 #define MEM_SIZE Size_t
151 #if defined(I_STRING) || defined(__cplusplus)
154 # include <strings.h>
157 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
159 #define strrchr rindex
162 #if defined(mips) && defined(ultrix) && !defined(__STDC__)
171 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
173 extern char * memcpy _((char*, char*, int));
179 # define memcpy(d,s,l) bcopy(s,d,l)
181 # define memcpy(d,s,l) my_bcopy(s,d,l)
184 #endif /* HAS_MEMCPY */
187 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
189 extern char *memset _((char*, int, int));
192 # define memzero(d,l) memset(d,0,l)
196 # define memzero(d,l) bzero(d,l)
198 # define memzero(d,l) my_bzero(d,l)
201 #endif /* HAS_MEMSET */
204 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
206 extern int memcmp _((char*, char*, int));
211 # define memcmp my_memcmp
213 #endif /* HAS_MEMCMP */
215 /* XXX we prefer bcmp slightly for comparisons that don't care about ordering */
218 # define bcmp(s1,s2,l) memcmp(s1,s2,l)
220 #endif /* HAS_BCMP */
222 #if !defined(HAS_MEMMOVE) && !defined(memmove)
223 # if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
224 # define memmove(d,s,l) bcopy(s,d,l)
226 # if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
227 # define memmove(d,s,l) memcpy(d,s,l)
229 # define memmove(d,s,l) my_bcopy(s,d,l)
234 #ifndef _TYPES_ /* If types.h defines this it's easy. */
235 # ifndef major /* Does everyone's types.h define this? */
236 # include <sys/types.h>
241 # include <netinet/in.h>
245 #include <sys/stat.h>
248 /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
249 like UTekV) are broken, sometimes giving false positives. Undefine
250 them here and let the code below set them to proper values.
252 The ghs macro stands for GreenHills Software C-1.8.5 which
253 is the C compiler for sysV88 and the various derivatives.
254 This header file bug is corrected in gcc-2.5.8 and later versions.
255 --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */
257 #if defined(uts) || (defined(m88k) && defined(ghs))
271 # ifdef I_SYS_TIME_KERNEL
274 # include <sys/time.h>
275 # ifdef I_SYS_TIME_KERNEL
281 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
282 # include <sys/times.h>
286 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
292 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
294 #endif /* !HAS_MKFIFO */
299 # include <net/errno.h>
303 # define FIXSTATUS(sts) (U_L((sts) & 0xffff))
304 # define SHIFTSTATUS(sts) ((sts) >> 8)
305 # define SETERRNO(errcode,vmserrcode) errno = (errcode)
307 # define FIXSTATUS(sts) (U_L(sts))
308 # define SHIFTSTATUS(sts) (sts)
309 # define SETERRNO(errcode,vmserrcode) STMT_START {set_errno(errcode); set_vaxc_errno(vmserrcode);} STMT_END
314 extern int errno; /* ANSI allows errno to be an lvalue expr */
320 char *strerror _((int,...));
322 char *strerror _((int));
325 # define Strerror strerror
328 # ifdef HAS_SYS_ERRLIST
330 extern char *sys_errlist[];
332 # define Strerror(e) \
333 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
340 # include <sys/ioctl.h>
344 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
345 # ifdef HAS_SOCKETPAIR
346 # undef HAS_SOCKETPAIR
361 /* Configure already sets Direntry_t */
362 #if defined(I_DIRENT)
364 # if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
365 # include <sys/dir.h>
369 # include <sys/ndir.h>
373 # include <ndir.h> /* may be wrong in the future */
375 # include <sys/dir.h>
382 /* work around botch in SunOS 4.0.1 and 4.0.2 */
384 # define fputs(sv,fp) fprintf(fp,"%s",sv)
389 * The following gobbledygook brought to you on behalf of __STDC__.
390 * (I could just use #ifndef __STDC__, but this is more bulletproof
391 * in the face of half-implementations.)
396 # define S_IFMT _S_IFMT
398 # define S_IFMT 0170000
403 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
407 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
412 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
414 # define S_ISBLK(m) (0)
419 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
424 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
426 # define S_ISFIFO(m) (0)
432 # define S_ISLNK(m) _S_ISLNK(m)
435 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
438 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
440 # define S_ISLNK(m) (0)
448 # define S_ISSOCK(m) _S_ISSOCK(m)
451 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
454 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
456 # define S_ISSOCK(m) (0)
464 # define S_IRUSR S_IREAD
465 # define S_IWUSR S_IWRITE
466 # define S_IXUSR S_IEXEC
468 # define S_IRUSR 0400
469 # define S_IWUSR 0200
470 # define S_IXUSR 0100
472 # define S_IRGRP (S_IRUSR>>3)
473 # define S_IWGRP (S_IWUSR>>3)
474 # define S_IXGRP (S_IXUSR>>3)
475 # define S_IROTH (S_IRUSR>>6)
476 # define S_IWOTH (S_IWUSR>>6)
477 # define S_IXOTH (S_IXUSR>>6)
481 # define S_ISUID 04000
485 # define S_ISGID 02000
492 #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
493 # define SLOPPYDIVIDE
496 #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
508 # if defined(convex) || defined (uts)
509 # define Quad_t long long
515 typedef unsigned Quad_t UV;
518 typedef unsigned long UV;
521 typedef MEM_SIZE STRLEN;
523 typedef struct op OP;
524 typedef struct cop COP;
525 typedef struct unop UNOP;
526 typedef struct binop BINOP;
527 typedef struct listop LISTOP;
528 typedef struct logop LOGOP;
529 typedef struct condop CONDOP;
530 typedef struct pmop PMOP;
531 typedef struct svop SVOP;
532 typedef struct gvop GVOP;
533 typedef struct pvop PVOP;
534 typedef struct loop LOOP;
536 typedef struct Outrec Outrec;
537 typedef struct interpreter PerlInterpreter;
538 typedef struct ff FF;
539 typedef struct sv SV;
540 typedef struct av AV;
541 typedef struct hv HV;
542 typedef struct cv CV;
543 typedef struct regexp REGEXP;
544 typedef struct gp GP;
545 typedef struct sv GV;
546 typedef struct io IO;
547 typedef struct context CONTEXT;
548 typedef struct block BLOCK;
550 typedef struct magic MAGIC;
551 typedef struct xrv XRV;
552 typedef struct xpv XPV;
553 typedef struct xpviv XPVIV;
554 typedef struct xpvnv XPVNV;
555 typedef struct xpvmg XPVMG;
556 typedef struct xpvlv XPVLV;
557 typedef struct xpvav XPVAV;
558 typedef struct xpvhv XPVHV;
559 typedef struct xpvgv XPVGV;
560 typedef struct xpvcv XPVCV;
561 typedef struct xpvbm XPVBM;
562 typedef struct xpvfm XPVFM;
563 typedef struct xpvio XPVIO;
564 typedef struct mgvtbl MGVTBL;
565 typedef union any ANY;
569 typedef I32 (*filter_t) _((int, SV *, int));
570 #define FILTER_READ(idx, sv, len) filter_read(idx, sv, len)
571 #define FILTER_DATA(idx) (AvARRAY(rsfp_filters)[idx])
572 #define FILTER_ISREADER(idx) (idx >= AvFILL(rsfp_filters))
584 # include "unixish.h"
589 #define pause() sleep((32767<<16)+32767)
594 /* on BSDish systes we're safe */
595 # define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
597 /* otherwise guess at what's safe */
598 # define IOCPARM_LEN(x) 256
607 void (*any_dptr) _((void*));
624 /* work around some libPW problems */
629 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
633 #if defined(htonl) && !defined(HAS_HTONL)
636 #if defined(htons) && !defined(HAS_HTONS)
639 #if defined(ntohl) && !defined(HAS_NTOHL)
642 #if defined(ntohs) && !defined(HAS_NTOHS)
646 #if (BYTEORDER & 0xffff) != 0x4321
652 #define htons my_swap
653 #define htonl my_htonl
654 #define ntohs my_swap
655 #define ntohl my_ntohl
658 #if (BYTEORDER & 0xffff) == 0x4321
667 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
670 #if BYTEORDER != 0x1234
675 # if BYTEORDER == 0x4321
676 # define vtohl(x) ((((x)&0xFF)<<24) \
678 +(((x)&0x0000FF00)<<8) \
679 +(((x)&0x00FF0000)>>8) )
680 # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
681 # define htovl(x) vtohl(x)
682 # define htovs(x) vtohs(x)
684 /* otherwise default to functions in util.c */
688 #define U_S(what) ((U16)(what))
689 #define U_I(what) ((unsigned int)(what))
690 #define U_L(what) ((U32)(what))
692 U32 cast_ulong _((double));
693 #define U_S(what) ((U16)cast_ulong((double)(what)))
694 #define U_I(what) ((unsigned int)cast_ulong((double)(what)))
695 #define U_L(what) (cast_ulong((double)(what)))
699 #define I_32(what) ((I32)(what))
700 #define I_V(what) ((IV)(what))
701 #define U_V(what) ((UV)(what))
703 I32 cast_i32 _((double));
704 #define I_32(what) (cast_i32((double)(what)))
705 IV cast_iv _((double));
706 #define I_V(what) (cast_iv((double)(what)))
707 UV cast_uv _((double));
708 #define U_V(what) (cast_uv((double)(what)))
722 # define TMPPATH "/tmp/perl-eXXXXXX"
726 Uid_t getuid _((void));
727 Uid_t geteuid _((void));
728 Gid_t getgid _((void));
729 Gid_t getegid _((void));
735 #define DEBUG(a) if (debug) a
736 #define DEBUG_p(a) if (debug & 1) a
737 #define DEBUG_s(a) if (debug & 2) a
738 #define DEBUG_l(a) if (debug & 4) a
739 #define DEBUG_t(a) if (debug & 8) a
740 #define DEBUG_o(a) if (debug & 16) a
741 #define DEBUG_c(a) if (debug & 32) a
742 #define DEBUG_P(a) if (debug & 64) a
743 #define DEBUG_m(a) if (debug & 128) a
744 #define DEBUG_f(a) if (debug & 256) a
745 #define DEBUG_r(a) if (debug & 512) a
746 #define DEBUG_x(a) if (debug & 1024) a
747 #define DEBUG_u(a) if (debug & 2048) a
748 #define DEBUG_L(a) if (debug & 4096) a
749 #define DEBUG_H(a) if (debug & 8192) a
750 #define DEBUG_X(a) if (debug & 16384) a
751 #define DEBUG_D(a) if (debug & 32768) a
772 #define YYMAXDEPTH 300
774 #define assert(what) DEB( { \
776 croak("Assertion failed: file \"%s\", line %d", \
777 __FILE__, __LINE__); \
782 I32 (*uf_val)_((IV, SV*));
783 I32 (*uf_set)_((IV, SV*));
787 /* Fix these up for __STDC__ */
789 char *mktemp _((char*));
790 double atof _((const char*));
794 /* All of these are in stdlib.h or time.h for ANSI C */
796 struct tm *gmtime(), *localtime();
797 char *strchr(), *strrchr();
798 char *strcpy(), *strcat();
799 #endif /* ! STANDARD_C */
808 double exp _((double));
809 double log _((double));
810 double sqrt _((double));
811 double modf _((double,double*));
812 double sin _((double));
813 double cos _((double));
814 double atan2 _((double,double));
815 double pow _((double,double));
822 char *crypt _((const char*, const char*));
823 char *getenv _((const char*));
824 Off_t lseek _((int,Off_t,int));
825 char *getlogin _((void));
828 #ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */
830 I32 unlnk _((char*));
832 #define UNLINK unlink
836 # ifdef HAS_SETRESUID
837 # define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
838 # define HAS_SETREUID
842 # ifdef HAS_SETRESGID
843 # define setregid(r,e) setresgid(r,e,(Gid_t)-1)
844 # define HAS_SETREGID
857 # define DEBUGGING_MSTATS
859 # define PAD_SV(po) pad_sv(po)
861 # define PAD_SV(po) curpad[po]
869 EXT PerlInterpreter * curinterp; /* currently running interpreter */
870 #ifndef VMS /* VMS doesn't use environ array */
871 extern char ** environ; /* environment variables supplied via exec */
873 EXT int uid; /* current real user id */
874 EXT int euid; /* current effective user id */
875 EXT int gid; /* current real group id */
876 EXT int egid; /* current effective group id */
877 EXT bool nomemok; /* let malloc context handle nomem */
878 EXT U32 an; /* malloc sequence number */
879 EXT U32 cop_seqmax; /* statement sequence number */
880 EXT U16 op_seqmax; /* op sequence number */
881 EXT U32 evalseq; /* eval sequence number */
882 EXT U32 sub_generation; /* inc to force methods to be looked up again */
883 EXT char ** origenviron;
885 EXT U32 * profiledata;
886 EXT int maxo INIT(MAXO);/* Number of ops */
887 EXT char * osname; /* operating system */
889 EXT XPV* xiv_arenaroot; /* list of allocated xiv areas */
890 EXT IV ** xiv_root; /* free xiv list--shared by interpreters */
891 EXT double * xnv_root; /* free xnv list--shared by interpreters */
892 EXT XRV * xrv_root; /* free xrv list--shared by interpreters */
893 EXT XPV * xpv_root; /* free xpv list--shared by interpreters */
894 EXT HE * he_root; /* free he list--shared by interpreters */
895 EXT char * nice_chunk; /* a nice chunk of memory to reuse */
896 EXT U32 nice_chunk_size;/* how nice the chunk of memory is */
898 /* Stack for currently executing thread--context switch must handle this. */
899 EXT SV ** stack_base; /* stack->array_ary */
900 EXT SV ** stack_sp; /* stack pointer now */
901 EXT SV ** stack_max; /* stack->array_ary + stack->array_max */
903 /* likewise for these */
905 EXT OP * op; /* current op--oughta be in a global register */
907 EXT I32 * scopestack; /* blocks we've entered */
908 EXT I32 scopestack_ix;
909 EXT I32 scopestack_max;
911 EXT ANY* savestack; /* to save non-local values on */
912 EXT I32 savestack_ix;
913 EXT I32 savestack_max;
915 EXT OP ** retstack; /* returns we've pushed */
917 EXT I32 retstack_max;
919 EXT I32 * markstack; /* stackmarks we're remembering */
920 EXT I32 * markstack_ptr; /* stackmarks we're remembering */
921 EXT I32 * markstack_max; /* stackmarks we're remembering */
928 EXT char buf[2048]; /* should be longer than PATH_MAX */
929 EXT char tokenbuf[256];
930 EXT struct stat statbuf;
932 EXT struct tms timesbuf;
934 EXT STRLEN na; /* for use in SvPV when length is Not Applicable */
936 /* for tmp use in stupid debuggers */
941 /* handy constants */
942 EXT char * Yes INIT("1");
943 EXT char * No INIT("");
944 EXT char * hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
945 EXT char * patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
946 EXT char * vert INIT("|");
948 EXT char warn_uninit[]
949 INIT("Use of uninitialized value");
950 EXT char warn_nosemi[]
951 INIT("Semicolon seems to be missing");
952 EXT char warn_reserved[]
953 INIT("Unquoted string \"%s\" may clash with future reserved word");
955 INIT("Unsuccessful %s on filename containing newline");
956 EXT char no_wrongref[]
957 INIT("Can't use %s ref as %s ref");
959 INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
961 INIT("Can't use an undefined value as %s reference");
963 INIT("Modification of non-creatable array value attempted, subscript %d");
965 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
967 INIT("Modification of a read-only value attempted");
969 INIT("Out of memory!\n");
970 EXT char no_security[]
971 INIT("Insecure dependency in %s%s");
972 EXT char no_sock_func[]
973 INIT("Unsupported socket function \"%s\" called");
974 EXT char no_dir_func[]
975 INIT("Unsupported directory function \"%s\" called");
977 INIT("The %s function is unimplemented");
979 INIT("\"my\" variable %s can't be in a package");
985 EXT char * cshname INIT(CSH);
990 EXT char *sig_name[] = { SIG_NAME };
991 EXT int sig_num[] = { SIG_NUM };
993 EXT char *sig_name[];
998 EXT unsigned char fold[] = { /* fast case folding table */
999 0, 1, 2, 3, 4, 5, 6, 7,
1000 8, 9, 10, 11, 12, 13, 14, 15,
1001 16, 17, 18, 19, 20, 21, 22, 23,
1002 24, 25, 26, 27, 28, 29, 30, 31,
1003 32, 33, 34, 35, 36, 37, 38, 39,
1004 40, 41, 42, 43, 44, 45, 46, 47,
1005 48, 49, 50, 51, 52, 53, 54, 55,
1006 56, 57, 58, 59, 60, 61, 62, 63,
1007 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
1008 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
1009 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
1010 'x', 'y', 'z', 91, 92, 93, 94, 95,
1011 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
1012 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
1013 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
1014 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
1015 128, 129, 130, 131, 132, 133, 134, 135,
1016 136, 137, 138, 139, 140, 141, 142, 143,
1017 144, 145, 146, 147, 148, 149, 150, 151,
1018 152, 153, 154, 155, 156, 157, 158, 159,
1019 160, 161, 162, 163, 164, 165, 166, 167,
1020 168, 169, 170, 171, 172, 173, 174, 175,
1021 176, 177, 178, 179, 180, 181, 182, 183,
1022 184, 185, 186, 187, 188, 189, 190, 191,
1023 192, 193, 194, 195, 196, 197, 198, 199,
1024 200, 201, 202, 203, 204, 205, 206, 207,
1025 208, 209, 210, 211, 212, 213, 214, 215,
1026 216, 217, 218, 219, 220, 221, 222, 223,
1027 224, 225, 226, 227, 228, 229, 230, 231,
1028 232, 233, 234, 235, 236, 237, 238, 239,
1029 240, 241, 242, 243, 244, 245, 246, 247,
1030 248, 249, 250, 251, 252, 253, 254, 255
1033 EXT unsigned char fold[];
1037 EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */
1038 1, 2, 84, 151, 154, 155, 156, 157,
1039 165, 246, 250, 3, 158, 7, 18, 29,
1040 40, 51, 62, 73, 85, 96, 107, 118,
1041 129, 140, 147, 148, 149, 150, 152, 153,
1042 255, 182, 224, 205, 174, 176, 180, 217,
1043 233, 232, 236, 187, 235, 228, 234, 226,
1044 222, 219, 211, 195, 188, 193, 185, 184,
1045 191, 183, 201, 229, 181, 220, 194, 162,
1046 163, 208, 186, 202, 200, 218, 198, 179,
1047 178, 214, 166, 170, 207, 199, 209, 206,
1048 204, 160, 212, 216, 215, 192, 175, 173,
1049 243, 172, 161, 190, 203, 189, 164, 230,
1050 167, 248, 227, 244, 242, 255, 241, 231,
1051 240, 253, 169, 210, 245, 237, 249, 247,
1052 239, 168, 252, 251, 254, 238, 223, 221,
1053 213, 225, 177, 197, 171, 196, 159, 4,
1054 5, 6, 8, 9, 10, 11, 12, 13,
1055 14, 15, 16, 17, 19, 20, 21, 22,
1056 23, 24, 25, 26, 27, 28, 30, 31,
1057 32, 33, 34, 35, 36, 37, 38, 39,
1058 41, 42, 43, 44, 45, 46, 47, 48,
1059 49, 50, 52, 53, 54, 55, 56, 57,
1060 58, 59, 60, 61, 63, 64, 65, 66,
1061 67, 68, 69, 70, 71, 72, 74, 75,
1062 76, 77, 78, 79, 80, 81, 82, 83,
1063 86, 87, 88, 89, 90, 91, 92, 93,
1064 94, 95, 97, 98, 99, 100, 101, 102,
1065 103, 104, 105, 106, 108, 109, 110, 111,
1066 112, 113, 114, 115, 116, 117, 119, 120,
1067 121, 122, 123, 124, 125, 126, 127, 128,
1068 130, 131, 132, 133, 134, 135, 136, 137,
1069 138, 139, 141, 142, 143, 144, 145, 146
1072 EXT unsigned char freq[];
1077 EXT char* block_type[] = {
1086 EXT char* block_type[];
1090 /*****************************************************************************/
1091 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
1092 /*****************************************************************************/
1093 /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
1106 EXT U32 lex_state; /* next token is determined */
1107 EXT U32 lex_defer; /* state after determined token */
1108 EXT expectation lex_expect; /* expect after determined token */
1109 EXT I32 lex_brackets; /* bracket count */
1110 EXT I32 lex_formbrack; /* bracket count at outer format level */
1111 EXT I32 lex_fakebrack; /* outer bracket is mere delimiter */
1112 EXT I32 lex_casemods; /* casemod count */
1113 EXT I32 lex_dojoin; /* doing an array interpolation */
1114 EXT I32 lex_starts; /* how many interps done on level */
1115 EXT SV * lex_stuff; /* runtime pattern from m// or s/// */
1116 EXT SV * lex_repl; /* runtime replacement from s/// */
1117 EXT OP * lex_op; /* extra info to pass back on op */
1118 EXT OP * lex_inpat; /* in pattern $) and $| are special */
1119 EXT I32 lex_inwhat; /* what kind of quoting are we in */
1120 EXT char * lex_brackstack; /* what kind of brackets to pop */
1121 EXT char * lex_casestack; /* what kind of case mods in effect */
1123 /* What we know when we're in LEX_KNOWNEXT state. */
1124 EXT YYSTYPE nextval[5]; /* value of next token, if any */
1125 EXT I32 nexttype[5]; /* type of next token */
1128 EXT FILE * VOL rsfp INIT(Nullfp);
1131 EXT char * oldbufptr;
1132 EXT char * oldoldbufptr;
1134 EXT expectation expect INIT(XSTATE); /* how to interpret ambiguous tokens */
1135 EXT AV * rsfp_filters;
1137 EXT I32 multi_start; /* 1st line of multi-line string */
1138 EXT I32 multi_end; /* last line of multi-line string */
1139 EXT I32 multi_open; /* delimiter of said string */
1140 EXT I32 multi_close; /* delimiter of said string */
1143 EXT I32 error_count; /* how many errors so far, max 10 */
1144 EXT I32 subline; /* line this subroutine began on */
1145 EXT SV * subname; /* name of current subroutine */
1147 EXT CV * compcv; /* currently compiling subroutine */
1148 EXT AV * comppad; /* storage for lexically scoped temporaries */
1149 EXT AV * comppad_name; /* variable names for "my" variables */
1150 EXT I32 comppad_name_fill;/* last "introduced" variable offset */
1151 EXT I32 min_intro_pending;/* start of vars to introduce */
1152 EXT I32 max_intro_pending;/* end of vars to introduce */
1153 EXT I32 padix; /* max used index in current "register" pad */
1154 EXT I32 padix_floor; /* how low may inner block reset padix */
1155 EXT I32 pad_reset_pending; /* reset pad on next attempted alloc */
1158 EXT I32 thisexpr; /* name id for nothing_in_common() */
1159 EXT char * last_uni; /* position of last named-unary operator */
1160 EXT char * last_lop; /* position of last list operator */
1161 EXT OPCODE last_lop_op; /* last list operator */
1162 EXT bool in_my; /* we're compiling a "my" declaration */
1164 EXT I32 cryptseen; /* has fast crypt() been initialized? */
1167 EXT U32 hints; /* various compilation flags */
1169 /* Note: the lowest 8 bits are reserved for
1170 stuffing into op->op_private */
1171 #define HINT_INTEGER 0x00000001
1172 #define HINT_STRICT_REFS 0x00000002
1174 #define HINT_BLOCK_SCOPE 0x00000100
1175 #define HINT_STRICT_SUBS 0x00000200
1176 #define HINT_STRICT_VARS 0x00000400
1178 /**************************************************************************/
1179 /* This regexp stuff is global since it always happens within 1 expr eval */
1180 /**************************************************************************/
1182 EXT char * regprecomp; /* uncompiled string. */
1183 EXT char * regparse; /* Input-scan pointer. */
1184 EXT char * regxend; /* End of input for compile */
1185 EXT I32 regnpar; /* () count. */
1186 EXT char * regcode; /* Code-emit pointer; ®dummy = don't. */
1187 EXT I32 regsize; /* Code size. */
1188 EXT I32 regnaughty; /* How bad is this pattern? */
1189 EXT I32 regsawback; /* Did we see \1, ...? */
1191 EXT char * reginput; /* String-input pointer. */
1192 EXT char * regbol; /* Beginning of input, for ^ check. */
1193 EXT char * regeol; /* End of input, for $ check. */
1194 EXT char ** regstartp; /* Pointer to startp array. */
1195 EXT char ** regendp; /* Ditto for endp. */
1196 EXT U32 * reglastparen; /* Similarly for lastparen. */
1197 EXT char * regtill; /* How far we are required to go. */
1198 EXT U16 regflags; /* are we folding, multilining? */
1199 EXT char regprev; /* char before regbol, \n if none */
1201 /***********************************************/
1202 /* Global only to current interpreter instance */
1203 /***********************************************/
1208 struct interpreter {
1211 #define IINIT(x) INIT(x)
1214 /* pseudo environmental stuff */
1216 IEXT char ** Iorigargv;
1220 IEXT char * Iorigfilename;
1222 IEXT SV * Iwarnhook;
1223 IEXT SV * Iparsehook;
1225 /* Various states of an input record separator SV (rs, nrs) */
1226 #define RsSNARF(sv) (! SvOK(sv))
1227 #define RsSIMPLE(sv) (SvOK(sv) && SvCUR(sv))
1228 #define RsPARA(sv) (SvOK(sv) && ! SvCUR(sv))
1233 IEXT char Ipatchlevel[10];
1234 IEXT char ** Ilocalpatches;
1236 IEXT char * Isplitstr IINIT(" ");
1237 IEXT bool Ipreprocess;
1243 IEXT bool Idoswitches;
1245 IEXT bool Idoextract;
1246 IEXT bool Isawampersand; /* must save all match strings */
1247 IEXT bool Isawstudy; /* do fbm_instr on all strings */
1248 IEXT bool Isawi; /* study must assume case insensitive */
1251 IEXT bool Ido_undump; /* -u or dump seen? */
1252 IEXT char * Iinplace;
1253 IEXT char * Ie_tmpname;
1255 IEXT VOL U32 Idebug;
1257 /* This value may be raised by extensions for testing purposes */
1258 IEXT int Iperl_destruct_level; /* 0=none, 1=full, 2=full with checks */
1260 /* magical thingies */
1261 IEXT Time_t Ibasetime; /* $^T */
1262 IEXT SV * Iformfeed; /* $^L */
1263 IEXT char * Ichopset IINIT(" \n-"); /* $: */
1264 IEXT SV * Irs; /* $/ */
1265 IEXT char * Iofs; /* $, */
1266 IEXT STRLEN Iofslen;
1267 IEXT char * Iors; /* $\ */
1268 IEXT STRLEN Iorslen;
1269 IEXT char * Iofmt; /* $# */
1270 IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1271 IEXT int Imultiline; /* $*--do strings hold >1 line? */
1272 IEXT U32 Istatusvalue; /* $? */
1274 IEXT struct stat Istatcache; /* _ */
1276 IEXT SV * Istatname IINIT(Nullsv);
1278 /* shortcuts to various I/O objects */
1280 IEXT GV * Ilast_in_gv;
1283 IEXT GV * Idefoutgv;
1284 IEXT GV * Iargvoutgv;
1286 /* shortcuts to regexp stuff */
1290 IEXT PMOP * Icurpm; /* what to do \ interps from */
1291 IEXT I32 * Iscreamfirst;
1292 IEXT I32 * Iscreamnext;
1293 IEXT I32 Imaxscream IINIT(-1);
1294 IEXT SV * Ilastscream;
1296 /* shortcuts to misc objects */
1299 /* shortcuts to debugging objects */
1303 IEXT SV * IDBsingle;
1305 IEXT SV * IDBsignal;
1306 IEXT AV * Ilineary; /* lines of script for debugger */
1307 IEXT AV * Idbargs; /* args to call listed by caller function */
1310 IEXT HV * Idefstash; /* main symbol table */
1311 IEXT HV * Icurstash; /* symbol table for current package */
1312 IEXT HV * Idebstash; /* symbol table for perldb package */
1313 IEXT SV * Icurstname; /* name of current package */
1314 IEXT AV * Ibeginav; /* names of BEGIN subroutines */
1315 IEXT AV * Iendav; /* names of END subroutines */
1316 IEXT AV * Ipad; /* storage for lexically scoped temporaries */
1317 IEXT AV * Ipadname; /* variable names for "my" variables */
1319 /* memory management */
1320 IEXT SV ** Itmps_stack;
1321 IEXT I32 Itmps_ix IINIT(-1);
1322 IEXT I32 Itmps_floor IINIT(-1);
1324 IEXT I32 Isv_count; /* how many SV* are currently allocated */
1325 IEXT I32 Isv_objcount; /* how many objects are currently allocated */
1326 IEXT SV* Isv_root; /* storage for SVs belonging to interp */
1327 IEXT SV* Isv_arenaroot; /* list of areas for garbage collection */
1329 /* funky return mechanisms */
1330 IEXT I32 Ilastspbase;
1332 IEXT int Iforkprocess; /* so do_open |- can return proc# */
1334 /* subprocess state */
1335 IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */
1336 IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */
1338 /* internal state */
1339 IEXT VOL int Iin_eval; /* trap "fatal" errors? */
1340 IEXT OP * Irestartop; /* Are we propagating an error from croak? */
1341 IEXT int Idelaymagic; /* ($<,$>) = ... */
1342 IEXT bool Idirty; /* In the middle of tearing things down? */
1343 IEXT U8 Ilocalizing; /* are we processing a local() list? */
1344 IEXT bool Itainted; /* using variables controlled by $< */
1345 IEXT bool Itainting; /* doing taint checks */
1346 IEXT char * Iop_mask IINIT(NULL); /* masked operations for safe evals */
1350 IEXT I32 Idlmax IINIT(128);
1351 IEXT char * Idebname;
1352 IEXT char * Idebdelim;
1354 /* current interpreter roots */
1356 IEXT OP * Imain_root;
1357 IEXT OP * Imain_start;
1358 IEXT OP * Ieval_root;
1359 IEXT OP * Ieval_start;
1361 /* runtime control stuff */
1362 IEXT COP * VOL Icurcop IINIT(&compiling);
1363 IEXT line_t Icopline IINIT(NOLINE);
1364 IEXT CONTEXT * Icxstack;
1365 IEXT I32 Icxstack_ix IINIT(-1);
1366 IEXT I32 Icxstack_max IINIT(128);
1367 IEXT Sigjmp_buf Itop_env;
1371 IEXT AV * Istack; /* THE STACK */
1372 IEXT AV * Imainstack; /* the stack when nothing funny is happening */
1373 IEXT SV ** Imystack_base; /* stack->array_ary */
1374 IEXT SV ** Imystack_sp; /* stack pointer now */
1375 IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */
1377 /* format accumulators */
1378 IEXT SV * Iformtarget;
1379 IEXT SV * Ibodytarget;
1380 IEXT SV * Itoptarget;
1382 /* statics moved here for shared library purposes */
1383 IEXT SV Istrchop; /* return value from chop */
1384 IEXT int Ifilemode; /* so nextargv() can preserve mode */
1385 IEXT int Ilastfd; /* what to preserve mode on */
1386 IEXT char * Ioldname; /* what to preserve mode on */
1387 IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */
1388 IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */
1389 IEXT OP * Isortcop; /* user defined sort routine */
1390 IEXT HV * Isortstash; /* which is in some package or other */
1391 IEXT GV * Ifirstgv; /* $a */
1392 IEXT GV * Isecondgv; /* $b */
1393 IEXT AV * Isortstack; /* temp stack during pp_sort() */
1394 IEXT AV * Isignalstack; /* temp stack during sighandler() */
1395 IEXT SV * Imystrk; /* temp key string for do_each() */
1396 IEXT I32 Idumplvl; /* indentation level on syntax tree dump */
1397 IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */
1398 IEXT I32 Igensym; /* next symbol for getsym() to define */
1399 IEXT bool Ipreambled;
1400 IEXT AV * Ipreambleav;
1401 IEXT int Ilaststatval IINIT(-1);
1402 IEXT I32 Ilaststype IINIT(OP_STAT);
1410 struct interpreter {
1428 # include <stdarg.h>
1431 # include <varargs.h>
1438 #define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
1439 #define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
1441 #define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
1442 #define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
1449 /* The following must follow proto.h */
1452 EXT MGVTBL vtbl_sv = {magic_get,
1456 EXT MGVTBL vtbl_env = {0, 0, 0, 0, 0};
1457 EXT MGVTBL vtbl_envelem = {0, magic_setenv,
1460 EXT MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
1461 EXT MGVTBL vtbl_sigelem = {0, magic_setsig,
1463 EXT MGVTBL vtbl_pack = {0, 0, 0, magic_wipepack,
1465 EXT MGVTBL vtbl_packelem = {magic_getpack,
1469 EXT MGVTBL vtbl_dbline = {0, magic_setdbline,
1471 EXT MGVTBL vtbl_isa = {0, magic_setisa,
1473 EXT MGVTBL vtbl_isaelem = {0, magic_setisa,
1475 EXT MGVTBL vtbl_arylen = {magic_getarylen,
1478 EXT MGVTBL vtbl_glob = {magic_getglob,
1481 EXT MGVTBL vtbl_mglob = {0, magic_setmglob,
1483 EXT MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
1485 EXT MGVTBL vtbl_substr = {0, magic_setsubstr,
1487 EXT MGVTBL vtbl_vec = {0, magic_setvec,
1489 EXT MGVTBL vtbl_pos = {magic_getpos,
1492 EXT MGVTBL vtbl_bm = {0, magic_setbm,
1494 EXT MGVTBL vtbl_uvar = {magic_getuvar,
1499 EXT MGVTBL vtbl_amagic = {0, magic_setamagic,
1500 0, 0, magic_setamagic};
1501 EXT MGVTBL vtbl_amagicelem = {0, magic_setamagic,
1502 0, 0, magic_setamagic};
1503 #endif /* OVERLOAD */
1507 EXT MGVTBL vtbl_env;
1508 EXT MGVTBL vtbl_envelem;
1509 EXT MGVTBL vtbl_sig;
1510 EXT MGVTBL vtbl_sigelem;
1511 EXT MGVTBL vtbl_pack;
1512 EXT MGVTBL vtbl_packelem;
1513 EXT MGVTBL vtbl_dbline;
1514 EXT MGVTBL vtbl_isa;
1515 EXT MGVTBL vtbl_isaelem;
1516 EXT MGVTBL vtbl_arylen;
1517 EXT MGVTBL vtbl_glob;
1518 EXT MGVTBL vtbl_mglob;
1519 EXT MGVTBL vtbl_taint;
1520 EXT MGVTBL vtbl_substr;
1521 EXT MGVTBL vtbl_vec;
1522 EXT MGVTBL vtbl_pos;
1524 EXT MGVTBL vtbl_uvar;
1527 EXT MGVTBL vtbl_amagic;
1528 EXT MGVTBL vtbl_amagicelem;
1529 #endif /* OVERLOAD */
1534 EXT long amagic_generation;
1536 #define NofAMmeth 29
1538 EXT char * AMG_names[NofAMmeth][2] = {
1540 {"bool", "nomethod"},
1570 EXT char * AMG_names[NofAMmeth][2];
1571 #endif /* def INITAMAGIC */
1576 CV* table[NofAMmeth*2];
1579 typedef struct am_table AMT;
1581 #define AMGfallNEVER 1
1583 #define AMGfallYES 3
1586 fallback_amg, abs_amg,
1587 bool__amg, nomethod_amg,
1588 string_amg, numer_amg,
1589 add_amg, add_ass_amg,
1590 subtr_amg, subtr_ass_amg,
1591 mult_amg, mult_ass_amg,
1592 div_amg, div_ass_amg,
1593 mod_amg, mod_ass_amg,
1594 pow_amg, pow_ass_amg,
1595 lshift_amg, lshift_ass_amg,
1596 rshift_amg, rshift_ass_amg,
1597 band_amg, band_ass_amg,
1598 bor_amg, bor_ass_amg,
1599 bxor_amg, bxor_ass_amg,
1612 repeat_amg, repeat_ass_amg,
1613 concat_amg, concat_ass_amg,
1616 #endif /* OVERLOAD */
1618 #endif /* Include guard */