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)
46 # define BYTEORDER 0x1234
49 /* Overall memory policy? */
55 * The following contortions are brought to you on behalf of all the
56 * standards, semi-standards, de facto standards, not-so-de-facto standards
57 * of the world, as well as all the other botches anyone ever thought of.
58 * The basic theory is that if we work hard enough here, the rest of the
59 * code can be a lot prettier. Well, so much for theory. Sorry, Henry...
62 /* define this once if either system, instead of cluttering up the src */
63 #if defined(MSDOS) || defined(atarist)
67 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
71 #if defined(HASVOLATILE) || defined(STANDARD_C)
73 # define VOL // to temporarily suppress warnings
81 #define TAINT_IF(c) (tainted |= (c))
82 #define TAINT_NOT (tainted = 0)
83 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
84 #define TAINT_ENV() if (tainting) taint_env()
88 # define BSD_GETPGRP(pid) getpgrp((pid))
91 # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
95 # define BSD_GETPGRP(pid) getpgrp2((pid))
101 # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
109 #ifdef USE_NEXT_CTYPE
110 #include <appkit/NXCType.h>
119 #ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */
126 # ifdef PARAM_NEEDS_TYPES
127 # include <sys/types.h>
129 # include <sys/param.h>
133 /* Use all the "standard" definitions? */
134 #if defined(STANDARD_C) && defined(I_STDLIB)
136 #endif /* STANDARD_C */
138 /* Maybe this comes after <stdlib.h> so we don't try to change
139 the standard library prototypes?. We'll use our own in
140 proto.h instead. I guess. The patch had no explanation.
144 # define malloc Mymalloc
145 # define realloc Myremalloc
148 # define safemalloc malloc
149 # define saferealloc realloc
150 # define safefree free
153 #define MEM_SIZE Size_t
155 #if defined(I_STRING) || defined(__cplusplus)
158 # include <strings.h>
161 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
163 #define strrchr rindex
166 #if defined(mips) && defined(ultrix) && !defined(__STDC__)
175 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
177 extern char * memcpy _((char*, char*, int));
183 # define memcpy(d,s,l) bcopy(s,d,l)
185 # define memcpy(d,s,l) my_bcopy(s,d,l)
188 #endif /* HAS_MEMCPY */
191 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
193 extern char *memset _((char*, int, int));
196 # define memzero(d,l) memset(d,0,l)
200 # define memzero(d,l) bzero(d,l)
202 # define memzero(d,l) my_bzero(d,l)
205 #endif /* HAS_MEMSET */
208 # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
210 extern int memcmp _((char*, char*, int));
215 # define memcmp my_memcmp
217 #endif /* HAS_MEMCMP */
219 /* XXX we prefer bcmp slightly for comparisons that don't care about ordering */
222 # define bcmp(s1,s2,l) memcmp(s1,s2,l)
224 #endif /* HAS_BCMP */
226 #if !defined(HAS_MEMMOVE) && !defined(memmove)
227 # if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
228 # define memmove(d,s,l) bcopy(s,d,l)
230 # if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
231 # define memmove(d,s,l) memcpy(d,s,l)
233 # define memmove(d,s,l) my_bcopy(s,d,l)
238 #ifndef _TYPES_ /* If types.h defines this it's easy. */
239 # ifndef major /* Does everyone's types.h define this? */
240 # include <sys/types.h>
245 # include <netinet/in.h>
249 #include <sys/stat.h>
252 /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
253 like UTekV) are broken, sometimes giving false positives. Undefine
254 them here and let the code below set them to proper values.
256 The ghs macro stands for GreenHills Software C-1.8.5 which
257 is the C compiler for sysV88 and the various derivatives.
258 This header file bug is corrected in gcc-2.5.8 and later versions.
259 --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */
261 #if defined(uts) || (defined(m88k) && defined(ghs))
275 # ifdef I_SYS_TIME_KERNEL
278 # include <sys/time.h>
279 # ifdef I_SYS_TIME_KERNEL
285 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
286 # include <sys/times.h>
290 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
296 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
298 #endif /* !HAS_MKFIFO */
303 # include <net/errno.h>
307 # define FIXSTATUS(sts) (U_L((sts) & 0xffff))
308 # define SHIFTSTATUS(sts) ((sts) >> 8)
309 # define SETERRNO(errcode,vmserrcode) errno = (errcode)
311 # define FIXSTATUS(sts) (U_L(sts))
312 # define SHIFTSTATUS(sts) (sts)
313 # define SETERRNO(errcode,vmserrcode) STMT_START {set_errno(errcode); set_vaxc_errno(vmserrcode);} STMT_END
318 extern int errno; /* ANSI allows errno to be an lvalue expr */
324 char *strerror _((int,...));
326 char *strerror _((int));
329 # define Strerror strerror
332 # ifdef HAS_SYS_ERRLIST
334 extern char *sys_errlist[];
336 # define Strerror(e) \
337 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
344 # include <sys/ioctl.h>
348 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
349 # ifdef HAS_SOCKETPAIR
350 # undef HAS_SOCKETPAIR
365 /* Configure already sets Direntry_t */
366 #if defined(I_DIRENT)
368 # if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
369 # include <sys/dir.h>
373 # include <sys/ndir.h>
377 # include <ndir.h> /* may be wrong in the future */
379 # include <sys/dir.h>
386 /* work around botch in SunOS 4.0.1 and 4.0.2 */
388 # define fputs(sv,fp) fprintf(fp,"%s",sv)
393 * The following gobbledygook brought to you on behalf of __STDC__.
394 * (I could just use #ifndef __STDC__, but this is more bulletproof
395 * in the face of half-implementations.)
400 # define S_IFMT _S_IFMT
402 # define S_IFMT 0170000
407 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
411 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
416 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
418 # define S_ISBLK(m) (0)
423 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
428 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
430 # define S_ISFIFO(m) (0)
436 # define S_ISLNK(m) _S_ISLNK(m)
439 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
442 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
444 # define S_ISLNK(m) (0)
452 # define S_ISSOCK(m) _S_ISSOCK(m)
455 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
458 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
460 # define S_ISSOCK(m) (0)
468 # define S_IRUSR S_IREAD
469 # define S_IWUSR S_IWRITE
470 # define S_IXUSR S_IEXEC
472 # define S_IRUSR 0400
473 # define S_IWUSR 0200
474 # define S_IXUSR 0100
476 # define S_IRGRP (S_IRUSR>>3)
477 # define S_IWGRP (S_IWUSR>>3)
478 # define S_IXGRP (S_IXUSR>>3)
479 # define S_IROTH (S_IRUSR>>6)
480 # define S_IWOTH (S_IWUSR>>6)
481 # define S_IXOTH (S_IXUSR>>6)
485 # define S_ISUID 04000
489 # define S_ISGID 02000
496 #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
497 # define SLOPPYDIVIDE
500 #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
512 # if defined(convex) || defined (uts)
513 # define Quad_t long long
519 typedef unsigned Quad_t UV;
522 typedef unsigned long UV;
525 typedef MEM_SIZE STRLEN;
527 typedef struct op OP;
528 typedef struct cop COP;
529 typedef struct unop UNOP;
530 typedef struct binop BINOP;
531 typedef struct listop LISTOP;
532 typedef struct logop LOGOP;
533 typedef struct condop CONDOP;
534 typedef struct pmop PMOP;
535 typedef struct svop SVOP;
536 typedef struct gvop GVOP;
537 typedef struct pvop PVOP;
538 typedef struct loop LOOP;
540 typedef struct Outrec Outrec;
541 typedef struct interpreter PerlInterpreter;
542 typedef struct ff FF;
543 typedef struct sv SV;
544 typedef struct av AV;
545 typedef struct hv HV;
546 typedef struct cv CV;
547 typedef struct regexp REGEXP;
548 typedef struct gp GP;
549 typedef struct sv GV;
550 typedef struct io IO;
551 typedef struct context CONTEXT;
552 typedef struct block BLOCK;
554 typedef struct magic MAGIC;
555 typedef struct xrv XRV;
556 typedef struct xpv XPV;
557 typedef struct xpviv XPVIV;
558 typedef struct xpvnv XPVNV;
559 typedef struct xpvmg XPVMG;
560 typedef struct xpvlv XPVLV;
561 typedef struct xpvav XPVAV;
562 typedef struct xpvhv XPVHV;
563 typedef struct xpvgv XPVGV;
564 typedef struct xpvcv XPVCV;
565 typedef struct xpvbm XPVBM;
566 typedef struct xpvfm XPVFM;
567 typedef struct xpvio XPVIO;
568 typedef struct mgvtbl MGVTBL;
569 typedef union any ANY;
573 typedef I32 (*filter_t) _((int, SV *, int));
574 #define FILTER_READ(idx, sv, len) filter_read(idx, sv, len)
575 #define FILTER_DATA(idx) (AvARRAY(rsfp_filters)[idx])
576 #define FILTER_ISREADER(idx) (idx >= AvFILL(rsfp_filters))
588 # include "unixish.h"
593 #define pause() sleep((32767<<16)+32767)
598 /* on BSDish systes we're safe */
599 # define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
601 /* otherwise guess at what's safe */
602 # define IOCPARM_LEN(x) 256
611 void (*any_dptr) _((void*));
615 #define ARGSproto struct thread *
617 #define ARGSproto void
618 #endif /* USE_THREADS */
634 /* work around some libPW problems */
639 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
643 #if defined(htonl) && !defined(HAS_HTONL)
646 #if defined(htons) && !defined(HAS_HTONS)
649 #if defined(ntohl) && !defined(HAS_NTOHL)
652 #if defined(ntohs) && !defined(HAS_NTOHS)
656 #if (BYTEORDER & 0xffff) != 0x4321
662 #define htons my_swap
663 #define htonl my_htonl
664 #define ntohs my_swap
665 #define ntohl my_ntohl
668 #if (BYTEORDER & 0xffff) == 0x4321
677 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
680 #if BYTEORDER != 0x1234
685 # if BYTEORDER == 0x4321
686 # define vtohl(x) ((((x)&0xFF)<<24) \
688 +(((x)&0x0000FF00)<<8) \
689 +(((x)&0x00FF0000)>>8) )
690 # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
691 # define htovl(x) vtohl(x)
692 # define htovs(x) vtohs(x)
694 /* otherwise default to functions in util.c */
698 #define U_S(what) ((U16)(what))
699 #define U_I(what) ((unsigned int)(what))
700 #define U_L(what) ((U32)(what))
702 U32 cast_ulong _((double));
703 #define U_S(what) ((U16)cast_ulong((double)(what)))
704 #define U_I(what) ((unsigned int)cast_ulong((double)(what)))
705 #define U_L(what) (cast_ulong((double)(what)))
709 #define I_32(what) ((I32)(what))
710 #define I_V(what) ((IV)(what))
711 #define U_V(what) ((UV)(what))
713 I32 cast_i32 _((double));
714 #define I_32(what) (cast_i32((double)(what)))
715 IV cast_iv _((double));
716 #define I_V(what) (cast_iv((double)(what)))
717 UV cast_uv _((double));
718 #define U_V(what) (cast_uv((double)(what)))
732 # define TMPPATH "/tmp/perl-eXXXXXX"
736 Uid_t getuid _((void));
737 Uid_t geteuid _((void));
738 Gid_t getgid _((void));
739 Gid_t getegid _((void));
745 #define DEBUG(a) if (debug) a
746 #define DEBUG_p(a) if (debug & 1) a
747 #define DEBUG_s(a) if (debug & 2) a
748 #define DEBUG_l(a) if (debug & 4) a
749 #define DEBUG_t(a) if (debug & 8) a
750 #define DEBUG_o(a) if (debug & 16) a
751 #define DEBUG_c(a) if (debug & 32) a
752 #define DEBUG_P(a) if (debug & 64) a
753 #define DEBUG_m(a) if (debug & 128) a
754 #define DEBUG_f(a) if (debug & 256) a
755 #define DEBUG_r(a) if (debug & 512) a
756 #define DEBUG_x(a) if (debug & 1024) a
757 #define DEBUG_u(a) if (debug & 2048) a
758 #define DEBUG_L(a) if (debug & 4096) a
759 #define DEBUG_H(a) if (debug & 8192) a
760 #define DEBUG_X(a) if (debug & 16384) a
761 #define DEBUG_D(a) if (debug & 32768) a
782 #define YYMAXDEPTH 300
784 #define assert(what) DEB( { \
786 croak("Assertion failed: file \"%s\", line %d", \
787 __FILE__, __LINE__); \
792 I32 (*uf_val)_((IV, SV*));
793 I32 (*uf_set)_((IV, SV*));
797 /* Fix these up for __STDC__ */
799 char *mktemp _((char*));
800 double atof _((const char*));
804 /* All of these are in stdlib.h or time.h for ANSI C */
806 struct tm *gmtime(), *localtime();
807 char *strchr(), *strrchr();
808 char *strcpy(), *strcat();
809 #endif /* ! STANDARD_C */
818 double exp _((double));
819 double log _((double));
820 double sqrt _((double));
821 double modf _((double,double*));
822 double sin _((double));
823 double cos _((double));
824 double atan2 _((double,double));
825 double pow _((double,double));
832 char *crypt _((const char*, const char*));
833 char *getenv _((const char*));
834 Off_t lseek _((int,Off_t,int));
835 char *getlogin _((void));
838 #ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */
840 I32 unlnk _((char*));
842 #define UNLINK unlink
846 # ifdef HAS_SETRESUID
847 # define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
848 # define HAS_SETREUID
852 # ifdef HAS_SETRESGID
853 # define setregid(r,e) setresgid(r,e,(Gid_t)-1)
854 # define HAS_SETREGID
867 # define DEBUGGING_MSTATS
869 # define PAD_SV(po) pad_sv(po)
871 # define PAD_SV(po) curpad[po]
879 EXT PerlInterpreter * curinterp; /* currently running interpreter */
881 EXT pthread_key_t thr_key; /* For per-thread struct thread ptr */
882 EXT pthread_mutex_t sv_mutex; /* Mutex for allocating SVs in sv.c */
883 EXT pthread_mutex_t malloc_mutex; /* Mutex for malloc */
884 EXT pthread_mutex_t eval_mutex; /* Mutex for doeval */
885 EXT pthread_cond_t eval_cond; /* Condition variable for doeval */
886 EXT struct thread * eval_owner; /* Owner thread for doeval */
887 EXT int nthreads; /* Number of threads currently */
888 EXT pthread_mutex_t nthreads_mutex; /* Mutex for nthreads */
889 EXT pthread_cond_t nthreads_cond; /* Condition variable for nthreads */
890 #endif /* USE_THREADS */
892 #ifndef VMS /* VMS doesn't use environ array */
893 extern char ** environ; /* environment variables supplied via exec */
895 EXT int uid; /* current real user id */
896 EXT int euid; /* current effective user id */
897 EXT int gid; /* current real group id */
898 EXT int egid; /* current effective group id */
899 EXT bool nomemok; /* let malloc context handle nomem */
900 EXT U32 an; /* malloc sequence number */
901 EXT U32 cop_seqmax; /* statement sequence number */
902 EXT U16 op_seqmax; /* op sequence number */
903 EXT U32 evalseq; /* eval sequence number */
904 EXT U32 sub_generation; /* inc to force methods to be looked up again */
905 EXT char ** origenviron;
907 EXT U32 * profiledata;
908 EXT int maxo INIT(MAXO);/* Number of ops */
909 EXT char * osname; /* operating system */
911 EXT XPV* xiv_arenaroot; /* list of allocated xiv areas */
912 EXT IV ** xiv_root; /* free xiv list--shared by interpreters */
913 EXT double * xnv_root; /* free xnv list--shared by interpreters */
914 EXT XRV * xrv_root; /* free xrv list--shared by interpreters */
915 EXT XPV * xpv_root; /* free xpv list--shared by interpreters */
916 EXT HE * he_root; /* free he list--shared by interpreters */
917 EXT char * nice_chunk; /* a nice chunk of memory to reuse */
918 EXT U32 nice_chunk_size;/* how nice the chunk of memory is */
920 /* Stack for currently executing thread--context switch must handle this. */
921 EXT SV ** stack_base; /* stack->array_ary */
922 EXT SV ** stack_sp; /* stack pointer now */
923 EXT SV ** stack_max; /* stack->array_ary + stack->array_max */
925 /* likewise for these */
927 EXT OP * op; /* current op--oughta be in a global register */
929 EXT I32 * scopestack; /* blocks we've entered */
930 EXT I32 scopestack_ix;
931 EXT I32 scopestack_max;
933 EXT ANY* savestack; /* to save non-local values on */
934 EXT I32 savestack_ix;
935 EXT I32 savestack_max;
937 EXT OP ** retstack; /* returns we've pushed */
939 EXT I32 retstack_max;
941 EXT I32 * markstack; /* stackmarks we're remembering */
942 EXT I32 * markstack_ptr; /* stackmarks we're remembering */
943 EXT I32 * markstack_max; /* stackmarks we're remembering */
950 EXT char buf[2048]; /* should be longer than PATH_MAX */
951 EXT char tokenbuf[256];
952 EXT struct stat statbuf;
954 EXT struct tms timesbuf;
956 EXT STRLEN na; /* for use in SvPV when length is Not Applicable */
958 /* for tmp use in stupid debuggers */
963 /* handy constants */
964 EXT char * Yes INIT("1");
965 EXT char * No INIT("");
966 EXT char * hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
967 EXT char * patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
968 EXT char * vert INIT("|");
970 EXT char warn_uninit[]
971 INIT("Use of uninitialized value");
972 EXT char warn_nosemi[]
973 INIT("Semicolon seems to be missing");
974 EXT char warn_reserved[]
975 INIT("Unquoted string \"%s\" may clash with future reserved word");
977 INIT("Unsuccessful %s on filename containing newline");
978 EXT char no_wrongref[]
979 INIT("Can't use %s ref as %s ref");
981 INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
983 INIT("Can't use an undefined value as %s reference");
985 INIT("Modification of non-creatable array value attempted, subscript %d");
987 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
989 INIT("Modification of a read-only value attempted");
991 INIT("Out of memory!\n");
992 EXT char no_security[]
993 INIT("Insecure dependency in %s%s");
994 EXT char no_sock_func[]
995 INIT("Unsupported socket function \"%s\" called");
996 EXT char no_dir_func[]
997 INIT("Unsupported directory function \"%s\" called");
999 INIT("The %s function is unimplemented");
1000 EXT char no_myglob[]
1001 INIT("\"my\" variable %s can't be in a package");
1007 EXT char * cshname INIT(CSH);
1012 EXT char *sig_name[] = { SIG_NAME };
1013 EXT int sig_num[] = { SIG_NUM };
1015 EXT char *sig_name[];
1020 EXT unsigned char fold[] = { /* fast case folding table */
1021 0, 1, 2, 3, 4, 5, 6, 7,
1022 8, 9, 10, 11, 12, 13, 14, 15,
1023 16, 17, 18, 19, 20, 21, 22, 23,
1024 24, 25, 26, 27, 28, 29, 30, 31,
1025 32, 33, 34, 35, 36, 37, 38, 39,
1026 40, 41, 42, 43, 44, 45, 46, 47,
1027 48, 49, 50, 51, 52, 53, 54, 55,
1028 56, 57, 58, 59, 60, 61, 62, 63,
1029 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
1030 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
1031 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
1032 'x', 'y', 'z', 91, 92, 93, 94, 95,
1033 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
1034 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
1035 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
1036 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
1037 128, 129, 130, 131, 132, 133, 134, 135,
1038 136, 137, 138, 139, 140, 141, 142, 143,
1039 144, 145, 146, 147, 148, 149, 150, 151,
1040 152, 153, 154, 155, 156, 157, 158, 159,
1041 160, 161, 162, 163, 164, 165, 166, 167,
1042 168, 169, 170, 171, 172, 173, 174, 175,
1043 176, 177, 178, 179, 180, 181, 182, 183,
1044 184, 185, 186, 187, 188, 189, 190, 191,
1045 192, 193, 194, 195, 196, 197, 198, 199,
1046 200, 201, 202, 203, 204, 205, 206, 207,
1047 208, 209, 210, 211, 212, 213, 214, 215,
1048 216, 217, 218, 219, 220, 221, 222, 223,
1049 224, 225, 226, 227, 228, 229, 230, 231,
1050 232, 233, 234, 235, 236, 237, 238, 239,
1051 240, 241, 242, 243, 244, 245, 246, 247,
1052 248, 249, 250, 251, 252, 253, 254, 255
1055 EXT unsigned char fold[];
1059 EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */
1060 1, 2, 84, 151, 154, 155, 156, 157,
1061 165, 246, 250, 3, 158, 7, 18, 29,
1062 40, 51, 62, 73, 85, 96, 107, 118,
1063 129, 140, 147, 148, 149, 150, 152, 153,
1064 255, 182, 224, 205, 174, 176, 180, 217,
1065 233, 232, 236, 187, 235, 228, 234, 226,
1066 222, 219, 211, 195, 188, 193, 185, 184,
1067 191, 183, 201, 229, 181, 220, 194, 162,
1068 163, 208, 186, 202, 200, 218, 198, 179,
1069 178, 214, 166, 170, 207, 199, 209, 206,
1070 204, 160, 212, 216, 215, 192, 175, 173,
1071 243, 172, 161, 190, 203, 189, 164, 230,
1072 167, 248, 227, 244, 242, 255, 241, 231,
1073 240, 253, 169, 210, 245, 237, 249, 247,
1074 239, 168, 252, 251, 254, 238, 223, 221,
1075 213, 225, 177, 197, 171, 196, 159, 4,
1076 5, 6, 8, 9, 10, 11, 12, 13,
1077 14, 15, 16, 17, 19, 20, 21, 22,
1078 23, 24, 25, 26, 27, 28, 30, 31,
1079 32, 33, 34, 35, 36, 37, 38, 39,
1080 41, 42, 43, 44, 45, 46, 47, 48,
1081 49, 50, 52, 53, 54, 55, 56, 57,
1082 58, 59, 60, 61, 63, 64, 65, 66,
1083 67, 68, 69, 70, 71, 72, 74, 75,
1084 76, 77, 78, 79, 80, 81, 82, 83,
1085 86, 87, 88, 89, 90, 91, 92, 93,
1086 94, 95, 97, 98, 99, 100, 101, 102,
1087 103, 104, 105, 106, 108, 109, 110, 111,
1088 112, 113, 114, 115, 116, 117, 119, 120,
1089 121, 122, 123, 124, 125, 126, 127, 128,
1090 130, 131, 132, 133, 134, 135, 136, 137,
1091 138, 139, 141, 142, 143, 144, 145, 146
1094 EXT unsigned char freq[];
1099 EXT char* block_type[] = {
1108 EXT char* block_type[];
1112 /*****************************************************************************/
1113 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
1114 /*****************************************************************************/
1115 /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
1128 EXT U32 lex_state; /* next token is determined */
1129 EXT U32 lex_defer; /* state after determined token */
1130 EXT expectation lex_expect; /* expect after determined token */
1131 EXT I32 lex_brackets; /* bracket count */
1132 EXT I32 lex_formbrack; /* bracket count at outer format level */
1133 EXT I32 lex_fakebrack; /* outer bracket is mere delimiter */
1134 EXT I32 lex_casemods; /* casemod count */
1135 EXT I32 lex_dojoin; /* doing an array interpolation */
1136 EXT I32 lex_starts; /* how many interps done on level */
1137 EXT SV * lex_stuff; /* runtime pattern from m// or s/// */
1138 EXT SV * lex_repl; /* runtime replacement from s/// */
1139 EXT OP * lex_op; /* extra info to pass back on op */
1140 EXT OP * lex_inpat; /* in pattern $) and $| are special */
1141 EXT I32 lex_inwhat; /* what kind of quoting are we in */
1142 EXT char * lex_brackstack; /* what kind of brackets to pop */
1143 EXT char * lex_casestack; /* what kind of case mods in effect */
1145 /* What we know when we're in LEX_KNOWNEXT state. */
1146 EXT YYSTYPE nextval[5]; /* value of next token, if any */
1147 EXT I32 nexttype[5]; /* type of next token */
1150 EXT FILE * VOL rsfp INIT(Nullfp);
1153 EXT char * oldbufptr;
1154 EXT char * oldoldbufptr;
1156 EXT expectation expect INIT(XSTATE); /* how to interpret ambiguous tokens */
1157 EXT AV * rsfp_filters;
1159 EXT I32 multi_start; /* 1st line of multi-line string */
1160 EXT I32 multi_end; /* last line of multi-line string */
1161 EXT I32 multi_open; /* delimiter of said string */
1162 EXT I32 multi_close; /* delimiter of said string */
1165 EXT I32 error_count; /* how many errors so far, max 10 */
1166 EXT I32 subline; /* line this subroutine began on */
1167 EXT SV * subname; /* name of current subroutine */
1169 EXT CV * compcv; /* currently compiling subroutine */
1170 EXT AV * comppad; /* storage for lexically scoped temporaries */
1171 EXT AV * comppad_name; /* variable names for "my" variables */
1172 EXT I32 comppad_name_fill;/* last "introduced" variable offset */
1173 EXT I32 min_intro_pending;/* start of vars to introduce */
1174 EXT I32 max_intro_pending;/* end of vars to introduce */
1175 EXT I32 padix; /* max used index in current "register" pad */
1176 EXT I32 padix_floor; /* how low may inner block reset padix */
1177 EXT I32 pad_reset_pending; /* reset pad on next attempted alloc */
1180 EXT I32 thisexpr; /* name id for nothing_in_common() */
1181 EXT char * last_uni; /* position of last named-unary operator */
1182 EXT char * last_lop; /* position of last list operator */
1183 EXT OPCODE last_lop_op; /* last list operator */
1184 EXT bool in_my; /* we're compiling a "my" declaration */
1186 EXT I32 cryptseen; /* has fast crypt() been initialized? */
1189 EXT U32 hints; /* various compilation flags */
1191 /* Note: the lowest 8 bits are reserved for
1192 stuffing into op->op_private */
1193 #define HINT_INTEGER 0x00000001
1194 #define HINT_STRICT_REFS 0x00000002
1196 #define HINT_BLOCK_SCOPE 0x00000100
1197 #define HINT_STRICT_SUBS 0x00000200
1198 #define HINT_STRICT_VARS 0x00000400
1200 /**************************************************************************/
1201 /* This regexp stuff is global since it always happens within 1 expr eval */
1202 /**************************************************************************/
1204 EXT char * regprecomp; /* uncompiled string. */
1205 EXT char * regparse; /* Input-scan pointer. */
1206 EXT char * regxend; /* End of input for compile */
1207 EXT I32 regnpar; /* () count. */
1208 EXT char * regcode; /* Code-emit pointer; ®dummy = don't. */
1209 EXT I32 regsize; /* Code size. */
1210 EXT I32 regnaughty; /* How bad is this pattern? */
1211 EXT I32 regsawback; /* Did we see \1, ...? */
1213 EXT char * reginput; /* String-input pointer. */
1214 EXT char * regbol; /* Beginning of input, for ^ check. */
1215 EXT char * regeol; /* End of input, for $ check. */
1216 EXT char ** regstartp; /* Pointer to startp array. */
1217 EXT char ** regendp; /* Ditto for endp. */
1218 EXT U32 * reglastparen; /* Similarly for lastparen. */
1219 EXT char * regtill; /* How far we are required to go. */
1220 EXT U16 regflags; /* are we folding, multilining? */
1221 EXT char regprev; /* char before regbol, \n if none */
1223 /***********************************************/
1224 /* Global only to current interpreter instance */
1225 /***********************************************/
1230 struct interpreter {
1233 #define IINIT(x) INIT(x)
1236 /* pseudo environmental stuff */
1238 IEXT char ** Iorigargv;
1242 IEXT char * Iorigfilename;
1244 IEXT SV * Iwarnhook;
1245 IEXT SV * Iparsehook;
1247 /* Various states of an input record separator SV (rs, nrs) */
1248 #define RsSNARF(sv) (! SvOK(sv))
1249 #define RsSIMPLE(sv) (SvOK(sv) && SvCUR(sv))
1250 #define RsPARA(sv) (SvOK(sv) && ! SvCUR(sv))
1255 IEXT char Ipatchlevel[10];
1256 IEXT char ** Ilocalpatches;
1258 IEXT char * Isplitstr IINIT(" ");
1259 IEXT bool Ipreprocess;
1265 IEXT bool Idoswitches;
1267 IEXT bool Idoextract;
1268 IEXT bool Isawampersand; /* must save all match strings */
1269 IEXT bool Isawstudy; /* do fbm_instr on all strings */
1270 IEXT bool Isawi; /* study must assume case insensitive */
1273 IEXT bool Ido_undump; /* -u or dump seen? */
1274 IEXT char * Iinplace;
1275 IEXT char * Ie_tmpname;
1277 IEXT VOL U32 Idebug;
1279 /* This value may be raised by extensions for testing purposes */
1280 IEXT int Iperl_destruct_level; /* 0=none, 1=full, 2=full with checks */
1282 /* magical thingies */
1283 IEXT Time_t Ibasetime; /* $^T */
1284 IEXT SV * Iformfeed; /* $^L */
1285 IEXT char * Ichopset IINIT(" \n-"); /* $: */
1286 IEXT SV * Irs; /* $/ */
1287 IEXT char * Iofs; /* $, */
1288 IEXT STRLEN Iofslen;
1289 IEXT char * Iors; /* $\ */
1290 IEXT STRLEN Iorslen;
1291 IEXT char * Iofmt; /* $# */
1292 IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1293 IEXT int Imultiline; /* $*--do strings hold >1 line? */
1294 IEXT U32 Istatusvalue; /* $? */
1296 IEXT struct stat Istatcache; /* _ */
1298 IEXT SV * Istatname IINIT(Nullsv);
1300 /* shortcuts to various I/O objects */
1302 IEXT GV * Ilast_in_gv;
1305 IEXT GV * Idefoutgv;
1306 IEXT GV * Iargvoutgv;
1308 /* shortcuts to regexp stuff */
1312 IEXT PMOP * Icurpm; /* what to do \ interps from */
1313 IEXT I32 * Iscreamfirst;
1314 IEXT I32 * Iscreamnext;
1315 IEXT I32 Imaxscream IINIT(-1);
1316 IEXT SV * Ilastscream;
1318 /* shortcuts to misc objects */
1321 /* shortcuts to debugging objects */
1325 IEXT SV * IDBsingle;
1327 IEXT SV * IDBsignal;
1328 IEXT AV * Ilineary; /* lines of script for debugger */
1329 IEXT AV * Idbargs; /* args to call listed by caller function */
1332 IEXT HV * Idefstash; /* main symbol table */
1333 IEXT HV * Icurstash; /* symbol table for current package */
1334 IEXT HV * Idebstash; /* symbol table for perldb package */
1335 IEXT SV * Icurstname; /* name of current package */
1336 IEXT AV * Ibeginav; /* names of BEGIN subroutines */
1337 IEXT AV * Iendav; /* names of END subroutines */
1338 IEXT AV * Ipad; /* storage for lexically scoped temporaries */
1339 IEXT AV * Ipadname; /* variable names for "my" variables */
1341 /* memory management */
1342 IEXT SV ** Itmps_stack;
1343 IEXT I32 Itmps_ix IINIT(-1);
1344 IEXT I32 Itmps_floor IINIT(-1);
1346 IEXT I32 Isv_count; /* how many SV* are currently allocated */
1347 IEXT I32 Isv_objcount; /* how many objects are currently allocated */
1348 IEXT SV* Isv_root; /* storage for SVs belonging to interp */
1349 IEXT SV* Isv_arenaroot; /* list of areas for garbage collection */
1351 /* funky return mechanisms */
1352 IEXT I32 Ilastspbase;
1354 IEXT int Iforkprocess; /* so do_open |- can return proc# */
1356 /* subprocess state */
1357 IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */
1358 IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */
1360 /* internal state */
1361 IEXT VOL int Iin_eval; /* trap "fatal" errors? */
1362 IEXT OP * Irestartop; /* Are we propagating an error from croak? */
1363 IEXT int Idelaymagic; /* ($<,$>) = ... */
1364 IEXT bool Idirty; /* In the middle of tearing things down? */
1365 IEXT U8 Ilocalizing; /* are we processing a local() list? */
1366 IEXT bool Itainted; /* using variables controlled by $< */
1367 IEXT bool Itainting; /* doing taint checks */
1368 IEXT char * Iop_mask IINIT(NULL); /* masked operations for safe evals */
1372 IEXT I32 Idlmax IINIT(128);
1373 IEXT char * Idebname;
1374 IEXT char * Idebdelim;
1376 /* current interpreter roots */
1378 IEXT OP * Imain_root;
1379 IEXT OP * Imain_start;
1380 IEXT OP * Ieval_root;
1381 IEXT OP * Ieval_start;
1383 /* runtime control stuff */
1384 IEXT COP * VOL Icurcop IINIT(&compiling);
1385 IEXT line_t Icopline IINIT(NOLINE);
1386 IEXT CONTEXT * Icxstack;
1387 IEXT I32 Icxstack_ix IINIT(-1);
1388 IEXT I32 Icxstack_max IINIT(128);
1389 IEXT Sigjmp_buf Itop_env;
1393 IEXT AV * Istack; /* THE STACK */
1394 IEXT AV * Imainstack; /* the stack when nothing funny is happening */
1395 IEXT SV ** Imystack_base; /* stack->array_ary */
1396 IEXT SV ** Imystack_sp; /* stack pointer now */
1397 IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */
1399 /* format accumulators */
1400 IEXT SV * Iformtarget;
1401 IEXT SV * Ibodytarget;
1402 IEXT SV * Itoptarget;
1404 /* statics moved here for shared library purposes */
1405 IEXT SV Istrchop; /* return value from chop */
1406 IEXT int Ifilemode; /* so nextargv() can preserve mode */
1407 IEXT int Ilastfd; /* what to preserve mode on */
1408 IEXT char * Ioldname; /* what to preserve mode on */
1409 IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */
1410 IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */
1411 IEXT OP * Isortcop; /* user defined sort routine */
1412 IEXT HV * Isortstash; /* which is in some package or other */
1413 IEXT GV * Ifirstgv; /* $a */
1414 IEXT GV * Isecondgv; /* $b */
1415 IEXT AV * Isortstack; /* temp stack during pp_sort() */
1416 IEXT AV * Isignalstack; /* temp stack during sighandler() */
1417 IEXT SV * Imystrk; /* temp key string for do_each() */
1418 IEXT I32 Idumplvl; /* indentation level on syntax tree dump */
1419 IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */
1420 IEXT I32 Igensym; /* next symbol for getsym() to define */
1421 IEXT bool Ipreambled;
1422 IEXT AV * Ipreambleav;
1423 IEXT int Ilaststatval IINIT(-1);
1424 IEXT I32 Ilaststype IINIT(OP_STAT);
1432 struct interpreter {
1451 # include <stdarg.h>
1454 # include <varargs.h>
1461 #define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
1462 #define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
1464 #define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
1465 #define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
1472 /* The following must follow proto.h */
1475 EXT MGVTBL vtbl_sv = {magic_get,
1479 EXT MGVTBL vtbl_env = {0, 0, 0, 0, 0};
1480 EXT MGVTBL vtbl_envelem = {0, magic_setenv,
1483 EXT MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
1484 EXT MGVTBL vtbl_sigelem = {0, magic_setsig,
1486 EXT MGVTBL vtbl_pack = {0, 0, 0, magic_wipepack,
1488 EXT MGVTBL vtbl_packelem = {magic_getpack,
1492 EXT MGVTBL vtbl_dbline = {0, magic_setdbline,
1494 EXT MGVTBL vtbl_isa = {0, magic_setisa,
1496 EXT MGVTBL vtbl_isaelem = {0, magic_setisa,
1498 EXT MGVTBL vtbl_arylen = {magic_getarylen,
1501 EXT MGVTBL vtbl_glob = {magic_getglob,
1504 EXT MGVTBL vtbl_mglob = {0, magic_setmglob,
1506 EXT MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
1508 EXT MGVTBL vtbl_substr = {0, magic_setsubstr,
1510 EXT MGVTBL vtbl_vec = {0, magic_setvec,
1512 EXT MGVTBL vtbl_pos = {magic_getpos,
1515 EXT MGVTBL vtbl_bm = {0, magic_setbm,
1517 EXT MGVTBL vtbl_uvar = {magic_getuvar,
1522 EXT MGVTBL vtbl_amagic = {0, magic_setamagic,
1523 0, 0, magic_setamagic};
1524 EXT MGVTBL vtbl_amagicelem = {0, magic_setamagic,
1525 0, 0, magic_setamagic};
1526 #endif /* OVERLOAD */
1530 EXT MGVTBL vtbl_env;
1531 EXT MGVTBL vtbl_envelem;
1532 EXT MGVTBL vtbl_sig;
1533 EXT MGVTBL vtbl_sigelem;
1534 EXT MGVTBL vtbl_pack;
1535 EXT MGVTBL vtbl_packelem;
1536 EXT MGVTBL vtbl_dbline;
1537 EXT MGVTBL vtbl_isa;
1538 EXT MGVTBL vtbl_isaelem;
1539 EXT MGVTBL vtbl_arylen;
1540 EXT MGVTBL vtbl_glob;
1541 EXT MGVTBL vtbl_mglob;
1542 EXT MGVTBL vtbl_taint;
1543 EXT MGVTBL vtbl_substr;
1544 EXT MGVTBL vtbl_vec;
1545 EXT MGVTBL vtbl_pos;
1547 EXT MGVTBL vtbl_uvar;
1550 EXT MGVTBL vtbl_amagic;
1551 EXT MGVTBL vtbl_amagicelem;
1552 #endif /* OVERLOAD */
1557 EXT long amagic_generation;
1559 #define NofAMmeth 29
1561 EXT char * AMG_names[NofAMmeth][2] = {
1563 {"bool", "nomethod"},
1593 EXT char * AMG_names[NofAMmeth][2];
1594 #endif /* def INITAMAGIC */
1599 CV* table[NofAMmeth*2];
1602 typedef struct am_table AMT;
1604 #define AMGfallNEVER 1
1606 #define AMGfallYES 3
1609 fallback_amg, abs_amg,
1610 bool__amg, nomethod_amg,
1611 string_amg, numer_amg,
1612 add_amg, add_ass_amg,
1613 subtr_amg, subtr_ass_amg,
1614 mult_amg, mult_ass_amg,
1615 div_amg, div_ass_amg,
1616 mod_amg, mod_ass_amg,
1617 pow_amg, pow_ass_amg,
1618 lshift_amg, lshift_ass_amg,
1619 rshift_amg, rshift_ass_amg,
1620 band_amg, band_ass_amg,
1621 bor_amg, bor_ass_amg,
1622 bxor_amg, bxor_ass_amg,
1635 repeat_amg, repeat_ass_amg,
1636 concat_amg, concat_ass_amg,
1639 #endif /* OVERLOAD */
1641 #endif /* Include guard */