1 /* $RCSfile: perl.h,v $$Revision: 4.1 $$Date: 92/08/07 18:25:56 $
3 * Copyright (c) 1991, 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.
9 * Revision 4.1 92/08/07 18:25:56 lwall
11 * Revision 4.0.1.6 92/06/08 14:55:10 lwall
12 * patch20: added Atari ST portability
13 * patch20: bcopy() and memcpy() now tested for overlap safety
14 * patch20: Perl now distinguishes overlapped copies from non-overlapped
15 * patch20: removed implicit int declarations on functions
17 * Revision 4.0.1.5 91/11/11 16:41:07 lwall
18 * patch19: uts wrongly defines S_ISDIR() et al
19 * patch19: too many preprocessors can't expand a macro right in #if
20 * patch19: added little-endian pack/unpack options
22 * Revision 4.0.1.4 91/11/05 18:06:10 lwall
23 * patch11: various portability fixes
24 * patch11: added support for dbz
25 * patch11: added some support for 64-bit integers
26 * patch11: hex() didn't understand leading 0x
28 * Revision 4.0.1.3 91/06/10 01:25:10 lwall
29 * patch10: certain pattern optimizations were botched
31 * Revision 4.0.1.2 91/06/07 11:28:33 lwall
32 * patch4: new copyright notice
33 * patch4: made some allowances for "semi-standard" C
34 * patch4: many, many itty-bitty portability fixes
36 * Revision 4.0.1.1 91/04/11 17:49:51 lwall
37 * patch1: hopefully straightened out some of the Xenix mess
39 * Revision 4.0 91/03/20 01:37:56 lwall
48 #include "config_c++.h"
54 # define BYTEORDER 0x1234
57 /* Overall memory policy? */
63 * The following contortions are brought to you on behalf of all the
64 * standards, semi-standards, de facto standards, not-so-de-facto standards
65 * of the world, as well as all the other botches anyone ever thought of.
66 * The basic theory is that if we work hard enough here, the rest of the
67 * code can be a lot prettier. Well, so much for theory. Sorry, Henry...
72 # define malloc Mymalloc
73 # define realloc Myremalloc
76 # define safemalloc malloc
77 # define saferealloc realloc
78 # define safefree free
81 /* work around some libPW problems */
87 /* define this once if either system, instead of cluttering up the src */
88 #if defined(MSDOS) || defined(atarist)
92 #if defined(__STDC__) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
96 #if defined(STANDARD_C)
102 #if defined(HASVOLATILE) || defined(STANDARD_C)
104 # define VOL // to temporarily suppress warnings
106 # define VOL volatile
118 # define TAINT_IF(c) (tainted |= (c))
119 # define TAINT_NOT (tainted = 0)
120 # define TAINT_PROPER(s) taint_proper(no_security, s)
121 # define TAINT_ENV() taint_env()
125 # define TAINT_PROPER(s)
137 # define getpgrp getpgrp2
144 # define setpgrp setpgrp2
152 # ifdef PARAM_NEEDS_TYPES
153 # include <sys/types.h>
155 # include <sys/param.h>
159 /* Use all the "standard" definitions? */
163 # define MEM_SIZE size_t
165 typedef unsigned int MEM_SIZE;
166 #endif /* STANDARD_C */
168 #if defined(HAS_MEMCMP) && defined(mips) && defined(ultrix)
175 extern char * memcpy P((char*, char*, int));
181 # define memcpy(d,s,l) bcopy(s,d,l)
183 # define memcpy(d,s,l) my_bcopy(s,d,l)
186 #endif /* HAS_MEMCPY */
191 extern char *memset P((char*, int, int));
194 # define memzero(d,l) memset(d,0,l)
198 # define memzero(d,l) bzero(d,l)
200 # define memzero(d,l) my_bzero(d,l)
203 #endif /* HAS_MEMSET */
208 extern int memcmp P((char*, char*, int));
213 # define memcmp(s1,s2,l) my_memcmp(s1,s2,l)
215 #endif /* HAS_MEMCMP */
217 /* we prefer bcmp slightly for comparisons that don't care about ordering */
220 # define bcmp(s1,s2,l) memcmp(s1,s2,l)
222 #endif /* HAS_BCMP */
225 # if defined(HAS_BCOPY) && defined(SAFE_BCOPY)
226 # define memmove(d,s,l) bcopy(s,d,l)
228 # if defined(HAS_MEMCPY) && defined(SAFE_MEMCPY)
229 # define memmove(d,s,l) memcpy(d,s,l)
231 # define memmove(d,s,l) my_bcopy(s,d,l)
236 #ifndef _TYPES_ /* If types.h defines this it's easy. */
237 # ifndef major /* Does everyone's types.h define this? */
238 # include <sys/types.h>
243 # include <netinet/in.h>
246 #include <sys/stat.h>
248 #if defined(uts) || defined(UTekV)
255 # define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
256 # define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
257 # define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
258 # define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
259 # define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
261 # define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
270 # ifdef SYSTIMEKERNEL
273 # include <sys/time.h>
274 # ifdef SYSTIMEKERNEL
280 #include <sys/times.h>
283 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
290 extern int errno; /* ANSI allows errno to be an lvalue expr */
296 char *strerror P((int));
299 extern char *sys_errlist[];
300 # define strerror(e) \
301 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
307 # include <sys/ioctl.h>
311 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
312 # ifdef HAS_SOCKETPAIR
313 # undef HAS_SOCKETPAIR
323 # define dbm_fetch(db,dkey) fetch(dkey)
324 # define dbm_delete(db,dkey) fatal("dbz doesn't implement delete")
325 # define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
326 # define dbm_close(db) dbmclose()
327 # define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch())
328 # define nextkey() (fatal("dbz doesn't implement traversal"),fetch())
329 # define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch())
358 # undef NULL /* suppress redefinition message */
364 # define NULL 0 /* silly thing is, we don't even use this... */
366 # define dbm_fetch(db,dkey) fetch(dkey)
367 # define dbm_delete(db,dkey) delete(dkey)
368 # define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
369 # define dbm_close(db) dbmclose()
370 # define dbm_firstkey(db) firstkey()
371 # endif /* HAS_ODBM */
372 # endif /* HAS_NDBM */
373 # endif /* HAS_GDBM */
374 #endif /* WANT_DBZ */
384 #if defined(I_DIRENT)
386 # define DIRENT dirent
389 # include <sys/ndir.h>
390 # define DIRENT direct
394 # include <ndir.h> /* may be wrong in the future */
396 # include <sys/dir.h>
398 # define DIRENT direct
404 /* work around botch in SunOS 4.0.1 and 4.0.2 */
406 # define fputs(sv,fp) fprintf(fp,"%s",sv)
411 * The following gobbledygook brought to you on behalf of __STDC__.
412 * (I could just use #ifndef __STDC__, but this is more bulletproof
413 * in the face of half-implementations.)
418 # define S_IFMT _S_IFMT
420 # define S_IFMT 0170000
425 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
429 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
434 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
436 # define S_ISBLK(m) (0)
441 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
446 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
448 # define S_ISFIFO(m) (0)
454 # define S_ISLNK(m) _S_ISLNK(m)
457 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
460 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
462 # define S_ISLNK(m) (0)
470 # define S_ISSOCK(m) _S_ISSOCK(m)
473 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
476 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
478 # define S_ISSOCK(m) (0)
486 # define S_IRUSR S_IREAD
487 # define S_IWUSR S_IWRITE
488 # define S_IXUSR S_IEXEC
490 # define S_IRUSR 0400
491 # define S_IWUSR 0200
492 # define S_IXUSR 0100
494 # define S_IRGRP (S_IRUSR>>3)
495 # define S_IWGRP (S_IWUSR>>3)
496 # define S_IXGRP (S_IXUSR>>3)
497 # define S_IROTH (S_IRUSR>>6)
498 # define S_IWOTH (S_IWUSR>>6)
499 # define S_IXOTH (S_IXUSR>>6)
503 # define S_ISUID 04000
507 # define S_ISGID 02000
514 #if defined(cray) || defined(gould) || defined(i860)
515 # define SLOPPYDIVIDE
518 #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
526 # if defined(convex) || defined (uts)
527 # define quad long long
535 # define VOIDRET void
543 # include "unixish.h"
547 #define pause() sleep((32767<<16)+32767)
552 /* on BSDish systes we're safe */
553 # define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
555 /* otherwise guess at what's safe */
556 # define IOCPARM_LEN(x) 256
560 typedef MEM_SIZE STRLEN;
562 typedef struct op OP;
563 typedef struct cop COP;
564 typedef struct unop UNOP;
565 typedef struct binop BINOP;
566 typedef struct listop LISTOP;
567 typedef struct logop LOGOP;
568 typedef struct condop CONDOP;
569 typedef struct pmop PMOP;
570 typedef struct svop SVOP;
571 typedef struct gvop GVOP;
572 typedef struct pvop PVOP;
573 typedef struct cvop CVOP;
574 typedef struct loop LOOP;
576 typedef struct Outrec Outrec;
577 typedef struct lstring Lstring;
578 typedef struct interpreter PerlInterpreter;
579 typedef struct ff FF;
580 typedef struct io IO;
581 typedef struct sv SV;
582 typedef struct av AV;
583 typedef struct hv HV;
584 typedef struct cv CV;
585 typedef struct regexp REGEXP;
586 typedef struct gp GP;
587 typedef struct sv GV;
588 typedef struct context CONTEXT;
589 typedef struct block BLOCK;
591 typedef struct magic MAGIC;
592 typedef struct xpv XPV;
593 typedef struct xpviv XPVIV;
594 typedef struct xpvnv XPVNV;
595 typedef struct xpvmg XPVMG;
596 typedef struct xpvlv XPVLV;
597 typedef struct xpvav XPVAV;
598 typedef struct xpvhv XPVHV;
599 typedef struct xpvgv XPVGV;
600 typedef struct xpvcv XPVCV;
601 typedef struct xpvbm XPVBM;
602 typedef struct xpvfm XPVFM;
603 typedef struct mgvtbl MGVTBL;
604 typedef union any ANY;
626 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
632 char *sprintf P((char *, ...));
634 int sprintf P((char *, ...));
638 #if defined(htonl) && !defined(HAS_HTONL)
641 #if defined(htons) && !defined(HAS_HTONS)
644 #if defined(ntohl) && !defined(HAS_NTOHL)
647 #if defined(ntohs) && !defined(HAS_NTOHS)
651 #if (BYTEORDER & 0xffff) != 0x4321
657 #define htons my_swap
658 #define htonl my_htonl
659 #define ntohs my_swap
660 #define ntohl my_ntohl
663 #if (BYTEORDER & 0xffff) == 0x4321
672 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
675 #if BYTEORDER != 0x1234
680 # if BYTEORDER == 0x4321
681 # define vtohl(x) ((((x)&0xFF)<<24) \
683 +(((x)&0x0000FF00)<<8) \
684 +(((x)&0x00FF0000)>>8) )
685 # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
686 # define htovl(x) vtohl(x)
687 # define htovs(x) vtohs(x)
689 /* otherwise default to functions in util.c */
693 #define U_S(what) ((U16)(what))
694 #define U_I(what) ((unsigned int)(what))
695 #define U_L(what) ((U32)(what))
697 U32 cast_ulong P((double));
698 #define U_S(what) ((U16)cast_ulong(what))
699 #define U_I(what) ((unsigned int)cast_ulong(what))
700 #define U_L(what) (cast_ulong(what))
714 #define TMPPATH "/tmp/perl-eXXXXXX"
716 #define TMPPATH "plXXXXXX"
720 UIDTYPE getuid P(());
721 UIDTYPE geteuid P(());
722 GIDTYPE getgid P(());
723 GIDTYPE getegid P(());
729 #define DEBUG(a) if (debug) a
730 #define DEBUG_p(a) if (debug & 1) a
731 #define DEBUG_s(a) if (debug & 2) a
732 #define DEBUG_l(a) if (debug & 4) a
733 #define DEBUG_t(a) if (debug & 8) a
734 #define DEBUG_o(a) if (debug & 16) a
735 #define DEBUG_c(a) if (debug & 32) a
736 #define DEBUG_P(a) if (debug & 64) a
737 #define DEBUG_m(a) if (debug & 128) a
738 #define DEBUG_f(a) if (debug & 256) a
739 #define DEBUG_r(a) if (debug & 512) a
740 #define DEBUG_x(a) if (debug & 1024) a
741 #define DEBUG_u(a) if (debug & 2048) a
742 #define DEBUG_L(a) if (debug & 4096) a
743 #define DEBUG_H(a) if (debug & 8192) a
744 #define DEBUG_X(a) if (debug & 16384) a
764 #define YYMAXDEPTH 300
766 #define assert(what) DEB( { \
768 fatal("Assertion failed: file \"%s\", line %d", \
769 __FILE__, __LINE__); \
774 I32 (*uf_val)P((I32, SV*));
775 I32 (*uf_set)P((I32, SV*));
779 /* Fix these up for __STDC__ */
780 char *mktemp P((char*));
781 double atof P((const char*));
784 /* All of these are in stdlib.h or time.h for ANSI C */
786 struct tm *gmtime(), *localtime();
787 char *strchr(), *strrchr();
788 char *strcpy(), *strcat();
789 #endif /* ! STANDARD_C */
798 double exp P((double));
799 double log P((double));
800 double sqrt P((double));
801 double modf P((double,int*));
802 double sin P((double));
803 double cos P((double));
804 double atan2 P((double,double));
805 double pow P((double,double));
812 char *crypt P((const char*, const char*));
813 char *getenv P((const char*));
814 long lseek P((int,int,int));
815 char *getlogin P((void));
819 int unlnk P((char*));
821 #define UNLINK unlink
826 #define setreuid(r,e) setresuid(r,e,-1)
832 #define setregid(r,e) setresgid(r,e,-1)
842 #define PAD_SV(po) pad_sv(po)
844 #define PAD_SV(po) curpad[po]
852 EXT PerlInterpreter *curinterp; /* currently running interpreter */
853 extern char ** environ; /* environment variables supplied via exec */
854 EXT int uid; /* current real user id */
855 EXT int euid; /* current effective user id */
856 EXT int gid; /* current real group id */
857 EXT int egid; /* current effective group id */
858 EXT bool nomemok; /* let malloc context handle nomem */
859 EXT U32 an; /* malloc sequence number */
860 EXT U32 cop_seq; /* statement sequence number */
861 EXT U32 op_seq; /* op sequence number */
862 EXT char ** origenviron;
865 /* Stack for currently executing thread--context switch must handle this. */
866 EXT SV ** stack_base; /* stack->array_ary */
867 EXT SV ** stack_sp; /* stack pointer now */
868 EXT SV ** stack_max; /* stack->array_ary + stack->array_max */
870 /* likewise for these */
872 EXT OP * op; /* current op--oughta be in a global register */
874 EXT I32 * scopestack; /* blocks we've entered */
875 EXT I32 scopestack_ix;
876 EXT I32 scopestack_max;
878 EXT ANY* savestack; /* to save non-local values on */
879 EXT I32 savestack_ix;
880 EXT I32 savestack_max;
882 EXT OP ** retstack; /* returns we've pushed */
884 EXT I32 retstack_max;
886 EXT I32 * markstack; /* stackmarks we're remembering */
887 EXT I32 * markstack_ptr; /* stackmarks we're remembering */
888 EXT I32 * markstack_max; /* stackmarks we're remembering */
896 EXT char tokenbuf[256];
897 EXT struct stat statbuf;
899 EXT struct tms timesbuf;
902 /* for tmp use in stupid debuggers */
907 /* handy constants */
908 EXT char * Yes INIT("1");
909 EXT char * No INIT("");
910 EXT char * hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
911 EXT char * patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
912 EXT char * vert INIT("|");
915 INIT("Unsuccessful %s on filename containing newline");
917 INIT("Can't use an undefined value to create a symbol");
919 INIT("Modification of non-creatable array value attempted, subscript %d");
921 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
923 INIT("Modification of a read-only value attempted");
925 INIT("Out of memory!\n");
926 EXT char no_security[]
927 INIT("Insecure dependency in %s");
928 EXT char no_sock_func[]
929 INIT("Unsupported socket function \"%s\" called");
930 EXT char no_dir_func[]
931 INIT("Unsupported directory function \"%s\" called");
933 INIT("The %s function is unimplemented");
939 EXT char * cshname INIT(CSH);
944 EXT char *sig_name[] = {
948 EXT char *sig_name[];
952 EXT char coeff[] = { /* hash function coefficients */
953 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
954 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
955 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
956 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
957 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
958 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
959 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
960 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1};
966 EXT unsigned char fold[] = { /* fast case folding table */
967 0, 1, 2, 3, 4, 5, 6, 7,
968 8, 9, 10, 11, 12, 13, 14, 15,
969 16, 17, 18, 19, 20, 21, 22, 23,
970 24, 25, 26, 27, 28, 29, 30, 31,
971 32, 33, 34, 35, 36, 37, 38, 39,
972 40, 41, 42, 43, 44, 45, 46, 47,
973 48, 49, 50, 51, 52, 53, 54, 55,
974 56, 57, 58, 59, 60, 61, 62, 63,
975 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
976 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
977 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
978 'x', 'y', 'z', 91, 92, 93, 94, 95,
979 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
980 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
981 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
982 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
983 128, 129, 130, 131, 132, 133, 134, 135,
984 136, 137, 138, 139, 140, 141, 142, 143,
985 144, 145, 146, 147, 148, 149, 150, 151,
986 152, 153, 154, 155, 156, 157, 158, 159,
987 160, 161, 162, 163, 164, 165, 166, 167,
988 168, 169, 170, 171, 172, 173, 174, 175,
989 176, 177, 178, 179, 180, 181, 182, 183,
990 184, 185, 186, 187, 188, 189, 190, 191,
991 192, 193, 194, 195, 196, 197, 198, 199,
992 200, 201, 202, 203, 204, 205, 206, 207,
993 208, 209, 210, 211, 212, 213, 214, 215,
994 216, 217, 218, 219, 220, 221, 222, 223,
995 224, 225, 226, 227, 228, 229, 230, 231,
996 232, 233, 234, 235, 236, 237, 238, 239,
997 240, 241, 242, 243, 244, 245, 246, 247,
998 248, 249, 250, 251, 252, 253, 254, 255
1001 EXT unsigned char fold[];
1005 EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */
1006 1, 2, 84, 151, 154, 155, 156, 157,
1007 165, 246, 250, 3, 158, 7, 18, 29,
1008 40, 51, 62, 73, 85, 96, 107, 118,
1009 129, 140, 147, 148, 149, 150, 152, 153,
1010 255, 182, 224, 205, 174, 176, 180, 217,
1011 233, 232, 236, 187, 235, 228, 234, 226,
1012 222, 219, 211, 195, 188, 193, 185, 184,
1013 191, 183, 201, 229, 181, 220, 194, 162,
1014 163, 208, 186, 202, 200, 218, 198, 179,
1015 178, 214, 166, 170, 207, 199, 209, 206,
1016 204, 160, 212, 216, 215, 192, 175, 173,
1017 243, 172, 161, 190, 203, 189, 164, 230,
1018 167, 248, 227, 244, 242, 255, 241, 231,
1019 240, 253, 169, 210, 245, 237, 249, 247,
1020 239, 168, 252, 251, 254, 238, 223, 221,
1021 213, 225, 177, 197, 171, 196, 159, 4,
1022 5, 6, 8, 9, 10, 11, 12, 13,
1023 14, 15, 16, 17, 19, 20, 21, 22,
1024 23, 24, 25, 26, 27, 28, 30, 31,
1025 32, 33, 34, 35, 36, 37, 38, 39,
1026 41, 42, 43, 44, 45, 46, 47, 48,
1027 49, 50, 52, 53, 54, 55, 56, 57,
1028 58, 59, 60, 61, 63, 64, 65, 66,
1029 67, 68, 69, 70, 71, 72, 74, 75,
1030 76, 77, 78, 79, 80, 81, 82, 83,
1031 86, 87, 88, 89, 90, 91, 92, 93,
1032 94, 95, 97, 98, 99, 100, 101, 102,
1033 103, 104, 105, 106, 108, 109, 110, 111,
1034 112, 113, 114, 115, 116, 117, 119, 120,
1035 121, 122, 123, 124, 125, 126, 127, 128,
1036 130, 131, 132, 133, 134, 135, 136, 137,
1037 138, 139, 141, 142, 143, 144, 145, 146
1040 EXT unsigned char freq[];
1043 /*****************************************************************************/
1044 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
1045 /*****************************************************************************/
1054 EXT FILE * VOL rsfp INIT(Nullfp);
1057 EXT char * oldbufptr;
1058 EXT char * oldoldbufptr;
1060 EXT expectation expect INIT(XBLOCK); /* how to interpret ambiguous tokens */
1062 EXT I32 multi_start; /* 1st line of multi-line string */
1063 EXT I32 multi_end; /* last line of multi-line string */
1064 EXT I32 multi_open; /* delimiter of said string */
1065 EXT I32 multi_close; /* delimiter of said string */
1068 EXT I32 error_count; /* how many errors so far, max 10 */
1069 EXT I32 subline; /* line this subroutine began on */
1070 EXT SV * subname; /* name of current subroutine */
1072 EXT AV * comppad; /* storage for lexically scoped temporaries */
1073 EXT AV * comppadname; /* variable names for "my" variables */
1074 EXT I32 comppadnamefill;/* last "introduced" variable offset */
1075 EXT I32 padix; /* max used index in current "register" pad */
1078 EXT SV * evstr; /* op_fold_const() temp string cache */
1079 EXT I32 thisexpr; /* name id for nothing_in_common() */
1080 EXT char * last_uni; /* position of last named-unary operator */
1081 EXT char * last_lop; /* position of last list operator */
1082 EXT bool in_format; /* we're compiling a run_format */
1083 EXT bool in_my; /* we're compiling a "my" declaration */
1085 EXT I32 cryptseen; /* has fast crypt() been initialized? */
1088 /**************************************************************************/
1089 /* This regexp stuff is global since it always happens within 1 expr eval */
1090 /**************************************************************************/
1092 EXT char * regprecomp; /* uncompiled string. */
1093 EXT char * regparse; /* Input-scan pointer. */
1094 EXT char * regxend; /* End of input for compile */
1095 EXT I32 regnpar; /* () count. */
1096 EXT char * regcode; /* Code-emit pointer; ®dummy = don't. */
1097 EXT I32 regsize; /* Code size. */
1098 EXT I32 regfold; /* are we folding? */
1099 EXT I32 regsawbracket; /* Did we do {d,d} trick? */
1100 EXT I32 regsawback; /* Did we see \1, ...? */
1102 EXT char * reginput; /* String-input pointer. */
1103 EXT char regprev; /* char before regbol, \n if none */
1104 EXT char * regbol; /* Beginning of input, for ^ check. */
1105 EXT char * regeol; /* End of input, for $ check. */
1106 EXT char ** regstartp; /* Pointer to startp array. */
1107 EXT char ** regendp; /* Ditto for endp. */
1108 EXT char * reglastparen; /* Similarly for lastparen. */
1109 EXT char * regtill; /* How far we are required to go. */
1110 EXT I32 regmyp_size;
1111 EXT char ** regmystartp;
1112 EXT char ** regmyendp;
1114 /***********************************************/
1115 /* Global only to current interpreter instance */
1116 /***********************************************/
1121 struct interpreter {
1124 #define IINIT(x) INIT(x)
1127 /* pseudo environmental stuff */
1129 IEXT char ** Iorigargv;
1133 IEXT char * Iorigfilename;
1138 IEXT char Ipatchlevel[6];
1139 IEXT char * Inrs IINIT("\n");
1140 IEXT U32 Inrschar IINIT('\n'); /* final char of rs, or 0777 if none */
1141 IEXT I32 Inrslen IINIT(1);
1142 IEXT bool Ipreprocess;
1147 IEXT bool Idoswitches;
1149 IEXT bool Idoextract;
1150 IEXT bool Iallgvs; /* init all customary symbols in symbol table?*/
1151 IEXT bool Isawampersand; /* must save all match strings */
1152 IEXT bool Isawstudy; /* do fbm_instr on all strings */
1153 IEXT bool Isawi; /* study must assume case insensitive */
1156 IEXT bool Ido_undump; /* -u or dump seen? */
1157 IEXT char * Iinplace;
1158 IEXT char * Ie_tmpname;
1160 IEXT VOL U32 Idebug;
1163 /* magical thingies */
1164 IEXT time_t Ibasetime; /* $^T */
1165 IEXT I32 Iarybase; /* $[ */
1166 IEXT SV * Iformfeed; /* $^L */
1167 IEXT char * Ichopset IINIT(" \n-"); /* $: */
1168 IEXT char * Irs IINIT("\n"); /* $/ */
1169 IEXT U32 Irschar IINIT('\n'); /* final char of rs, or 0777 if none */
1170 IEXT I32 Irslen IINIT(1);
1172 IEXT char * Iofs; /* $, */
1174 IEXT char * Iors; /* $\ */
1176 IEXT char * Iofmt; /* $# */
1177 IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1178 IEXT int Imultiline; /* $*--do strings hold >1 line? */
1179 IEXT U16 Istatusvalue; /* $? */
1181 IEXT struct stat Istatcache; /* _ */
1183 IEXT SV * Istatname IINIT(Nullsv);
1185 /* shortcuts to various I/O objects */
1187 IEXT GV * Ilast_in_gv;
1190 IEXT GV * Idefoutgv;
1191 IEXT GV * Icuroutgv;
1192 IEXT GV * Iargvoutgv;
1194 /* shortcuts to regexp stuff */
1198 IEXT PMOP * Icurpm; /* what to do \ interps from */
1199 IEXT I32 * Iscreamfirst;
1200 IEXT I32 * Iscreamnext;
1201 IEXT I32 Imaxscream IINIT(-1);
1202 IEXT SV * Ilastscream;
1204 /* shortcuts to debugging objects */
1208 IEXT SV * IDBsingle;
1210 IEXT SV * IDBsignal;
1211 IEXT AV * Ilineary; /* lines of script for debugger */
1212 IEXT AV * Idbargs; /* args to call listed by caller function */
1215 IEXT HV * Idefstash; /* main symbol table */
1216 IEXT HV * Icurstash; /* symbol table for current package */
1217 IEXT HV * Idebstash; /* symbol table for perldb package */
1218 IEXT SV * Icurstname; /* name of current package */
1219 IEXT AV * Ibeginav; /* names of BEGIN subroutines */
1220 IEXT AV * Iendav; /* names of END subroutines */
1221 IEXT AV * Ipad; /* storage for lexically scoped temporaries */
1222 IEXT AV * Ipadname; /* variable names for "my" variables */
1224 /* memory management */
1225 IEXT SV * Ifreestrroot;
1226 IEXT SV ** Itmps_stack;
1227 IEXT I32 Itmps_ix IINIT(-1);
1228 IEXT I32 Itmps_floor IINIT(-1);
1229 IEXT I32 Itmps_max IINIT(-1);
1231 /* funky return mechanisms */
1232 IEXT I32 Ilastspbase;
1234 IEXT int Iforkprocess; /* so do_open |- can return proc# */
1236 /* subprocess state */
1237 IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */
1238 IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */
1240 /* internal state */
1241 IEXT VOL int Iin_eval; /* trap fatal errors? */
1242 IEXT OP * Irestartop; /* Are we propagating an error from fatal? */
1243 IEXT int Idelaymagic; /* ($<,$>) = ... */
1244 IEXT bool Idirty; /* clean before rerunning */
1245 IEXT bool Ilocalizing; /* are we processing a local() list? */
1247 IEXT bool Itainted; /* using variables controlled by $< */
1248 IEXT bool Itaintanyway; /* force taint checks when !set?id */
1253 IEXT I32 Idlmax IINIT(128);
1254 IEXT char * Idebname;
1255 IEXT char * Idebdelim;
1257 /* current interpreter roots */
1258 IEXT OP * VOL Imain_root;
1259 IEXT OP * VOL Imain_start;
1260 IEXT OP * VOL Ieval_root;
1261 IEXT OP * VOL Ieval_start;
1263 /* runtime control stuff */
1264 IEXT COP * VOL Icurcop IINIT(&compiling);
1265 IEXT line_t Icopline IINIT(NOLINE);
1266 IEXT CONTEXT * Icxstack;
1267 IEXT I32 Icxstack_ix IINIT(-1);
1268 IEXT I32 Icxstack_max IINIT(128);
1269 IEXT jmp_buf Itop_env;
1272 IEXT AV * Istack; /* THE STACK */
1273 IEXT AV * Imainstack; /* the stack when nothing funny is happening */
1274 IEXT SV ** Imystack_base; /* stack->array_ary */
1275 IEXT SV ** Imystack_sp; /* stack pointer now */
1276 IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */
1278 /* format accumulators */
1279 IEXT SV * formtarget;
1280 IEXT SV * bodytarget;
1281 IEXT SV * toptarget;
1283 /* statics moved here for shared library purposes */
1284 IEXT SV Istrchop; /* return value from chop */
1285 IEXT int Ifilemode; /* so nextargv() can preserve mode */
1286 IEXT int Ilastfd; /* what to preserve mode on */
1287 IEXT char * Ioldname; /* what to preserve mode on */
1288 IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */
1289 IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */
1290 IEXT OP * Isortcop; /* user defined sort routine */
1291 IEXT HV * Isortstash; /* which is in some package or other */
1292 IEXT GV * Ifirstgv; /* $a */
1293 IEXT GV * Isecondgv; /* $b */
1294 IEXT AV * Isortstack; /* temp stack during pp_sort() */
1295 IEXT AV * Isignalstack; /* temp stack during sighandler() */
1296 IEXT SV * Imystrk; /* temp key string for do_each() */
1297 IEXT I32 Idumplvl; /* indentation level on syntax tree dump */
1298 IEXT I32 Idbmrefcnt; /* safety check for old dbm */
1299 IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */
1300 IEXT I32 Igensym; /* next symbol for getsym() to define */
1301 IEXT bool Ipreambled;
1302 IEXT int Ilaststatval IINIT(-1);
1303 IEXT I32 Ilaststype IINIT(OP_STAT);
1311 struct interpreter {
1328 /* The following must follow proto.h */
1331 MGVTBL vtbl_sv = {magic_get, magic_set, magic_len, 0, 0};
1332 MGVTBL vtbl_env = {0, 0, 0, 0, 0};
1333 MGVTBL vtbl_envelem = {0, magic_setenv, 0, 0, 0};
1334 MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
1335 MGVTBL vtbl_sigelem = {0, magic_setsig, 0, 0, 0};
1336 MGVTBL vtbl_dbm = {0, 0, 0, 0, 0};
1337 MGVTBL vtbl_dbmelem = {0, magic_setdbm, 0, 0, 0};
1338 MGVTBL vtbl_dbline = {0, magic_setdbline, 0, 0, 0};
1339 MGVTBL vtbl_arylen = {magic_getarylen,magic_setarylen, 0, 0, 0};
1340 MGVTBL vtbl_glob = {magic_getglob, magic_setglob, 0, 0, 0};
1341 MGVTBL vtbl_mglob = {0, magic_setmglob, 0, 0, 0};
1342 MGVTBL vtbl_substr = {0, magic_setsubstr, 0, 0, 0};
1343 MGVTBL vtbl_vec = {0, magic_setvec, 0, 0, 0};
1344 MGVTBL vtbl_bm = {0, magic_setbm, 0, 0, 0};
1345 MGVTBL vtbl_uvar = {magic_getuvar, magic_setuvar, 0, 0, 0};
1348 EXT MGVTBL vtbl_env;
1349 EXT MGVTBL vtbl_envelem;
1350 EXT MGVTBL vtbl_sig;
1351 EXT MGVTBL vtbl_sigelem;
1352 EXT MGVTBL vtbl_dbm;
1353 EXT MGVTBL vtbl_dbmelem;
1354 EXT MGVTBL vtbl_dbline;
1355 EXT MGVTBL vtbl_arylen;
1356 EXT MGVTBL vtbl_glob;
1357 EXT MGVTBL vtbl_mglob;
1358 EXT MGVTBL vtbl_substr;
1359 EXT MGVTBL vtbl_vec;
1361 EXT MGVTBL vtbl_uvar;