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 */
86 /* define this once if either system, instead of cluttering up the src */
87 #if defined(MSDOS) || defined(atarist)
91 #if defined(__STDC__) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
95 #if defined(STANDARD_C)
101 #if defined(HASVOLATILE) || defined(STANDARD_C)
103 # define VOL // to temporarily suppress warnings
105 # define VOL volatile
111 #define TAINT_IF(c) (tainted |= (c))
112 #define TAINT_NOT (tainted = 0)
113 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
114 #define TAINT_ENV() if (tainting) taint_env()
124 # define getpgrp getpgrp2
131 # define setpgrp setpgrp2
139 # ifdef PARAM_NEEDS_TYPES
140 # include <sys/types.h>
142 # include <sys/param.h>
146 /* Use all the "standard" definitions? */
150 # define MEM_SIZE size_t
152 typedef unsigned int MEM_SIZE;
153 #endif /* STANDARD_C */
155 #if defined(HAS_MEMCMP) && defined(mips) && defined(ultrix)
162 extern char * memcpy P((char*, char*, int));
168 # define memcpy(d,s,l) bcopy(s,d,l)
170 # define memcpy(d,s,l) my_bcopy(s,d,l)
173 #endif /* HAS_MEMCPY */
178 extern char *memset P((char*, int, int));
181 # define memzero(d,l) memset(d,0,l)
185 # define memzero(d,l) bzero(d,l)
187 # define memzero(d,l) my_bzero(d,l)
190 #endif /* HAS_MEMSET */
195 extern int memcmp P((char*, char*, int));
200 # define memcmp(s1,s2,l) my_memcmp(s1,s2,l)
202 #endif /* HAS_MEMCMP */
204 /* we prefer bcmp slightly for comparisons that don't care about ordering */
207 # define bcmp(s1,s2,l) memcmp(s1,s2,l)
209 #endif /* HAS_BCMP */
212 # if defined(HAS_BCOPY) && defined(SAFE_BCOPY)
213 # define memmove(d,s,l) bcopy(s,d,l)
215 # if defined(HAS_MEMCPY) && defined(SAFE_MEMCPY)
216 # define memmove(d,s,l) memcpy(d,s,l)
218 # define memmove(d,s,l) my_bcopy(s,d,l)
223 #ifndef _TYPES_ /* If types.h defines this it's easy. */
224 # ifndef major /* Does everyone's types.h define this? */
225 # include <sys/types.h>
230 # include <netinet/in.h>
233 #include <sys/stat.h>
235 #if defined(uts) || defined(UTekV)
242 # define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
243 # define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
244 # define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
245 # define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
246 # define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
248 # define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
257 # ifdef SYSTIMEKERNEL
260 # include <sys/time.h>
261 # ifdef SYSTIMEKERNEL
267 #include <sys/times.h>
270 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
277 # include <net/errno.h>
283 extern int errno; /* ANSI allows errno to be an lvalue expr */
289 char *strerror P((int));
292 extern char *sys_errlist[];
293 # define strerror(e) \
294 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
300 # include <sys/ioctl.h>
304 #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
305 # ifdef HAS_SOCKETPAIR
306 # undef HAS_SOCKETPAIR
321 #if defined(I_DIRENT)
323 # define DIRENT dirent
326 # include <sys/ndir.h>
327 # define DIRENT direct
331 # include <ndir.h> /* may be wrong in the future */
333 # include <sys/dir.h>
335 # define DIRENT direct
341 /* work around botch in SunOS 4.0.1 and 4.0.2 */
343 # define fputs(sv,fp) fprintf(fp,"%s",sv)
348 * The following gobbledygook brought to you on behalf of __STDC__.
349 * (I could just use #ifndef __STDC__, but this is more bulletproof
350 * in the face of half-implementations.)
355 # define S_IFMT _S_IFMT
357 # define S_IFMT 0170000
362 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
366 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
371 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
373 # define S_ISBLK(m) (0)
378 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
383 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
385 # define S_ISFIFO(m) (0)
391 # define S_ISLNK(m) _S_ISLNK(m)
394 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
397 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
399 # define S_ISLNK(m) (0)
407 # define S_ISSOCK(m) _S_ISSOCK(m)
410 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
413 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
415 # define S_ISSOCK(m) (0)
423 # define S_IRUSR S_IREAD
424 # define S_IWUSR S_IWRITE
425 # define S_IXUSR S_IEXEC
427 # define S_IRUSR 0400
428 # define S_IWUSR 0200
429 # define S_IXUSR 0100
431 # define S_IRGRP (S_IRUSR>>3)
432 # define S_IWGRP (S_IWUSR>>3)
433 # define S_IXGRP (S_IXUSR>>3)
434 # define S_IROTH (S_IRUSR>>6)
435 # define S_IWOTH (S_IWUSR>>6)
436 # define S_IXOTH (S_IXUSR>>6)
440 # define S_ISUID 04000
444 # define S_ISGID 02000
451 #if defined(cray) || defined(gould) || defined(i860)
452 # define SLOPPYDIVIDE
455 #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
463 # if defined(convex) || defined (uts)
464 # define quad long long
472 # define VOIDRET void
480 # include "unixish.h"
484 #define pause() sleep((32767<<16)+32767)
489 /* on BSDish systes we're safe */
490 # define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
492 /* otherwise guess at what's safe */
493 # define IOCPARM_LEN(x) 256
497 typedef MEM_SIZE STRLEN;
499 typedef struct op OP;
500 typedef struct cop COP;
501 typedef struct unop UNOP;
502 typedef struct binop BINOP;
503 typedef struct listop LISTOP;
504 typedef struct logop LOGOP;
505 typedef struct condop CONDOP;
506 typedef struct pmop PMOP;
507 typedef struct svop SVOP;
508 typedef struct gvop GVOP;
509 typedef struct pvop PVOP;
510 typedef struct cvop CVOP;
511 typedef struct loop LOOP;
513 typedef struct Outrec Outrec;
514 typedef struct lstring Lstring;
515 typedef struct interpreter PerlInterpreter;
516 typedef struct ff FF;
517 typedef struct io IO;
518 typedef struct sv SV;
519 typedef struct av AV;
520 typedef struct hv HV;
521 typedef struct cv CV;
522 typedef struct regexp REGEXP;
523 typedef struct gp GP;
524 typedef struct sv GV;
525 typedef struct context CONTEXT;
526 typedef struct block BLOCK;
528 typedef struct magic MAGIC;
529 typedef struct xrv XRV;
530 typedef struct xpv XPV;
531 typedef struct xpviv XPVIV;
532 typedef struct xpvnv XPVNV;
533 typedef struct xpvmg XPVMG;
534 typedef struct xpvlv XPVLV;
535 typedef struct xpvav XPVAV;
536 typedef struct xpvhv XPVHV;
537 typedef struct xpvgv XPVGV;
538 typedef struct xpvcv XPVCV;
539 typedef struct xpvbm XPVBM;
540 typedef struct xpvfm XPVFM;
541 typedef struct mgvtbl MGVTBL;
542 typedef union any ANY;
564 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
570 char *sprintf P((char *, ...));
572 int sprintf P((char *, ...));
576 #if defined(htonl) && !defined(HAS_HTONL)
579 #if defined(htons) && !defined(HAS_HTONS)
582 #if defined(ntohl) && !defined(HAS_NTOHL)
585 #if defined(ntohs) && !defined(HAS_NTOHS)
589 #if (BYTEORDER & 0xffff) != 0x4321
595 #define htons my_swap
596 #define htonl my_htonl
597 #define ntohs my_swap
598 #define ntohl my_ntohl
601 #if (BYTEORDER & 0xffff) == 0x4321
610 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
613 #if BYTEORDER != 0x1234
618 # if BYTEORDER == 0x4321
619 # define vtohl(x) ((((x)&0xFF)<<24) \
621 +(((x)&0x0000FF00)<<8) \
622 +(((x)&0x00FF0000)>>8) )
623 # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
624 # define htovl(x) vtohl(x)
625 # define htovs(x) vtohs(x)
627 /* otherwise default to functions in util.c */
631 #define U_S(what) ((U16)(what))
632 #define U_I(what) ((unsigned int)(what))
633 #define U_L(what) ((U32)(what))
635 U32 cast_ulong P((double));
636 #define U_S(what) ((U16)cast_ulong(what))
637 #define U_I(what) ((unsigned int)cast_ulong(what))
638 #define U_L(what) (cast_ulong(what))
642 #define I_32(what) ((I32)(what))
644 I32 cast_i32 P((double));
645 #define I_32(what) (cast_i32(what))
659 #define TMPPATH "/tmp/perl-eXXXXXX"
661 #define TMPPATH "plXXXXXX"
665 UIDTYPE getuid P(());
666 UIDTYPE geteuid P(());
667 GIDTYPE getgid P(());
668 GIDTYPE getegid P(());
674 #define DEBUG(a) if (debug) a
675 #define DEBUG_p(a) if (debug & 1) a
676 #define DEBUG_s(a) if (debug & 2) a
677 #define DEBUG_l(a) if (debug & 4) a
678 #define DEBUG_t(a) if (debug & 8) a
679 #define DEBUG_o(a) if (debug & 16) a
680 #define DEBUG_c(a) if (debug & 32) a
681 #define DEBUG_P(a) if (debug & 64) a
682 #define DEBUG_m(a) if (debug & 128) a
683 #define DEBUG_f(a) if (debug & 256) a
684 #define DEBUG_r(a) if (debug & 512) a
685 #define DEBUG_x(a) if (debug & 1024) a
686 #define DEBUG_u(a) if (debug & 2048) a
687 #define DEBUG_L(a) if (debug & 4096) a
688 #define DEBUG_H(a) if (debug & 8192) a
689 #define DEBUG_X(a) if (debug & 16384) a
709 #define YYMAXDEPTH 300
711 #define assert(what) DEB( { \
713 croak("Assertion failed: file \"%s\", line %d", \
714 __FILE__, __LINE__); \
719 I32 (*uf_val)P((I32, SV*));
720 I32 (*uf_set)P((I32, SV*));
724 /* Fix these up for __STDC__ */
725 char *mktemp P((char*));
726 double atof P((const char*));
729 /* All of these are in stdlib.h or time.h for ANSI C */
731 struct tm *gmtime(), *localtime();
732 char *strchr(), *strrchr();
733 char *strcpy(), *strcat();
734 #endif /* ! STANDARD_C */
743 double exp P((double));
744 double log P((double));
745 double sqrt P((double));
746 double modf P((double,int*));
747 double sin P((double));
748 double cos P((double));
749 double atan2 P((double,double));
750 double pow P((double,double));
757 char *crypt P((const char*, const char*));
758 char *getenv P((const char*));
759 long lseek P((int,int,int));
760 char *getlogin P((void));
764 int unlnk P((char*));
766 #define UNLINK unlink
771 #define setreuid(r,e) setresuid(r,e,-1)
777 #define setregid(r,e) setresgid(r,e,-1)
787 #define PAD_SV(po) pad_sv(po)
789 #define PAD_SV(po) curpad[po]
797 EXT PerlInterpreter *curinterp; /* currently running interpreter */
798 extern char ** environ; /* environment variables supplied via exec */
799 EXT int uid; /* current real user id */
800 EXT int euid; /* current effective user id */
801 EXT int gid; /* current real group id */
802 EXT int egid; /* current effective group id */
803 EXT bool nomemok; /* let malloc context handle nomem */
804 EXT U32 an; /* malloc sequence number */
805 EXT U32 cop_seqmax; /* statement sequence number */
806 EXT U32 op_seqmax; /* op sequence number */
807 EXT U32 sub_generation; /* inc to force methods to be looked up again */
808 EXT char ** origenviron;
811 /* Stack for currently executing thread--context switch must handle this. */
812 EXT SV ** stack_base; /* stack->array_ary */
813 EXT SV ** stack_sp; /* stack pointer now */
814 EXT SV ** stack_max; /* stack->array_ary + stack->array_max */
816 /* likewise for these */
818 EXT OP * op; /* current op--oughta be in a global register */
820 EXT I32 * scopestack; /* blocks we've entered */
821 EXT I32 scopestack_ix;
822 EXT I32 scopestack_max;
824 EXT ANY* savestack; /* to save non-local values on */
825 EXT I32 savestack_ix;
826 EXT I32 savestack_max;
828 EXT OP ** retstack; /* returns we've pushed */
830 EXT I32 retstack_max;
832 EXT I32 * markstack; /* stackmarks we're remembering */
833 EXT I32 * markstack_ptr; /* stackmarks we're remembering */
834 EXT I32 * markstack_max; /* stackmarks we're remembering */
842 EXT char tokenbuf[256];
843 EXT struct stat statbuf;
845 EXT struct tms timesbuf;
847 EXT STRLEN na; /* for use in SvPV when length is Not Applicable */
849 /* for tmp use in stupid debuggers */
854 /* handy constants */
855 EXT char * Yes INIT("1");
856 EXT char * No INIT("");
857 EXT char * hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
858 EXT char * patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
859 EXT char * vert INIT("|");
861 EXT char warn_nosemi[]
862 INIT("Semicolon seems to be missing");
863 EXT char warn_reserved[]
864 INIT("Unquoted string \"%s\" may clash with future reserved word");
866 INIT("Unsuccessful %s on filename containing newline");
868 INIT("Can't use an undefined value to create a symbol");
870 INIT("Modification of non-creatable array value attempted, subscript %d");
872 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
874 INIT("Modification of a read-only value attempted");
876 INIT("Out of memory!\n");
877 EXT char no_security[]
878 INIT("Insecure dependency in %s%s");
879 EXT char no_sock_func[]
880 INIT("Unsupported socket function \"%s\" called");
881 EXT char no_dir_func[]
882 INIT("Unsupported directory function \"%s\" called");
884 INIT("The %s function is unimplemented");
890 EXT char * cshname INIT(CSH);
895 EXT char *sig_name[] = {
899 EXT char *sig_name[];
903 EXT unsigned char fold[] = { /* fast case folding table */
904 0, 1, 2, 3, 4, 5, 6, 7,
905 8, 9, 10, 11, 12, 13, 14, 15,
906 16, 17, 18, 19, 20, 21, 22, 23,
907 24, 25, 26, 27, 28, 29, 30, 31,
908 32, 33, 34, 35, 36, 37, 38, 39,
909 40, 41, 42, 43, 44, 45, 46, 47,
910 48, 49, 50, 51, 52, 53, 54, 55,
911 56, 57, 58, 59, 60, 61, 62, 63,
912 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
913 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
914 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
915 'x', 'y', 'z', 91, 92, 93, 94, 95,
916 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
917 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
918 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
919 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
920 128, 129, 130, 131, 132, 133, 134, 135,
921 136, 137, 138, 139, 140, 141, 142, 143,
922 144, 145, 146, 147, 148, 149, 150, 151,
923 152, 153, 154, 155, 156, 157, 158, 159,
924 160, 161, 162, 163, 164, 165, 166, 167,
925 168, 169, 170, 171, 172, 173, 174, 175,
926 176, 177, 178, 179, 180, 181, 182, 183,
927 184, 185, 186, 187, 188, 189, 190, 191,
928 192, 193, 194, 195, 196, 197, 198, 199,
929 200, 201, 202, 203, 204, 205, 206, 207,
930 208, 209, 210, 211, 212, 213, 214, 215,
931 216, 217, 218, 219, 220, 221, 222, 223,
932 224, 225, 226, 227, 228, 229, 230, 231,
933 232, 233, 234, 235, 236, 237, 238, 239,
934 240, 241, 242, 243, 244, 245, 246, 247,
935 248, 249, 250, 251, 252, 253, 254, 255
938 EXT unsigned char fold[];
942 EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */
943 1, 2, 84, 151, 154, 155, 156, 157,
944 165, 246, 250, 3, 158, 7, 18, 29,
945 40, 51, 62, 73, 85, 96, 107, 118,
946 129, 140, 147, 148, 149, 150, 152, 153,
947 255, 182, 224, 205, 174, 176, 180, 217,
948 233, 232, 236, 187, 235, 228, 234, 226,
949 222, 219, 211, 195, 188, 193, 185, 184,
950 191, 183, 201, 229, 181, 220, 194, 162,
951 163, 208, 186, 202, 200, 218, 198, 179,
952 178, 214, 166, 170, 207, 199, 209, 206,
953 204, 160, 212, 216, 215, 192, 175, 173,
954 243, 172, 161, 190, 203, 189, 164, 230,
955 167, 248, 227, 244, 242, 255, 241, 231,
956 240, 253, 169, 210, 245, 237, 249, 247,
957 239, 168, 252, 251, 254, 238, 223, 221,
958 213, 225, 177, 197, 171, 196, 159, 4,
959 5, 6, 8, 9, 10, 11, 12, 13,
960 14, 15, 16, 17, 19, 20, 21, 22,
961 23, 24, 25, 26, 27, 28, 30, 31,
962 32, 33, 34, 35, 36, 37, 38, 39,
963 41, 42, 43, 44, 45, 46, 47, 48,
964 49, 50, 52, 53, 54, 55, 56, 57,
965 58, 59, 60, 61, 63, 64, 65, 66,
966 67, 68, 69, 70, 71, 72, 74, 75,
967 76, 77, 78, 79, 80, 81, 82, 83,
968 86, 87, 88, 89, 90, 91, 92, 93,
969 94, 95, 97, 98, 99, 100, 101, 102,
970 103, 104, 105, 106, 108, 109, 110, 111,
971 112, 113, 114, 115, 116, 117, 119, 120,
972 121, 122, 123, 124, 125, 126, 127, 128,
973 130, 131, 132, 133, 134, 135, 136, 137,
974 138, 139, 141, 142, 143, 144, 145, 146
977 EXT unsigned char freq[];
980 /*****************************************************************************/
981 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
982 /*****************************************************************************/
991 EXT FILE * VOL rsfp INIT(Nullfp);
994 EXT char * oldbufptr;
995 EXT char * oldoldbufptr;
997 EXT expectation expect INIT(XBLOCK); /* how to interpret ambiguous tokens */
999 EXT I32 multi_start; /* 1st line of multi-line string */
1000 EXT I32 multi_end; /* last line of multi-line string */
1001 EXT I32 multi_open; /* delimiter of said string */
1002 EXT I32 multi_close; /* delimiter of said string */
1005 EXT I32 error_count; /* how many errors so far, max 10 */
1006 EXT I32 subline; /* line this subroutine began on */
1007 EXT SV * subname; /* name of current subroutine */
1009 EXT AV * comppad; /* storage for lexically scoped temporaries */
1010 EXT AV * comppadname; /* variable names for "my" variables */
1011 EXT I32 comppadnamefill;/* last "introduced" variable offset */
1012 EXT I32 padix; /* max used index in current "register" pad */
1015 EXT SV * evstr; /* op_fold_const() temp string cache */
1016 EXT I32 thisexpr; /* name id for nothing_in_common() */
1017 EXT char * last_uni; /* position of last named-unary operator */
1018 EXT char * last_lop; /* position of last list operator */
1019 EXT bool in_format; /* we're compiling a run_format */
1020 EXT bool in_my; /* we're compiling a "my" declaration */
1021 EXT I32 needblockscope INIT(TRUE); /* block overhead needed? */
1023 EXT I32 cryptseen; /* has fast crypt() been initialized? */
1026 /**************************************************************************/
1027 /* This regexp stuff is global since it always happens within 1 expr eval */
1028 /**************************************************************************/
1030 EXT char * regprecomp; /* uncompiled string. */
1031 EXT char * regparse; /* Input-scan pointer. */
1032 EXT char * regxend; /* End of input for compile */
1033 EXT I32 regnpar; /* () count. */
1034 EXT char * regcode; /* Code-emit pointer; ®dummy = don't. */
1035 EXT I32 regsize; /* Code size. */
1036 EXT I32 regfold; /* are we folding? */
1037 EXT I32 regsawbracket; /* Did we do {d,d} trick? */
1038 EXT I32 regsawback; /* Did we see \1, ...? */
1040 EXT char * reginput; /* String-input pointer. */
1041 EXT char regprev; /* char before regbol, \n if none */
1042 EXT char * regbol; /* Beginning of input, for ^ check. */
1043 EXT char * regeol; /* End of input, for $ check. */
1044 EXT char ** regstartp; /* Pointer to startp array. */
1045 EXT char ** regendp; /* Ditto for endp. */
1046 EXT char * reglastparen; /* Similarly for lastparen. */
1047 EXT char * regtill; /* How far we are required to go. */
1048 EXT I32 regmyp_size;
1049 EXT char ** regmystartp;
1050 EXT char ** regmyendp;
1052 /***********************************************/
1053 /* Global only to current interpreter instance */
1054 /***********************************************/
1059 struct interpreter {
1062 #define IINIT(x) INIT(x)
1065 /* pseudo environmental stuff */
1067 IEXT char ** Iorigargv;
1071 IEXT char * Iorigfilename;
1076 IEXT char Ipatchlevel[6];
1077 IEXT char * Inrs IINIT("\n");
1078 IEXT U32 Inrschar IINIT('\n'); /* final char of rs, or 0777 if none */
1079 IEXT I32 Inrslen IINIT(1);
1080 IEXT bool Ipreprocess;
1085 IEXT bool Idoswitches;
1087 IEXT bool Idoextract;
1088 IEXT bool Isawampersand; /* must save all match strings */
1089 IEXT bool Isawstudy; /* do fbm_instr on all strings */
1090 IEXT bool Isawi; /* study must assume case insensitive */
1093 IEXT bool Ido_undump; /* -u or dump seen? */
1094 IEXT char * Iinplace;
1095 IEXT char * Ie_tmpname;
1097 IEXT VOL U32 Idebug;
1100 /* magical thingies */
1101 IEXT time_t Ibasetime; /* $^T */
1102 IEXT I32 Iarybase; /* $[ */
1103 IEXT SV * Iformfeed; /* $^L */
1104 IEXT char * Ichopset IINIT(" \n-"); /* $: */
1105 IEXT char * Irs IINIT("\n"); /* $/ */
1106 IEXT U32 Irschar IINIT('\n'); /* final char of rs, or 0777 if none */
1107 IEXT I32 Irslen IINIT(1);
1109 IEXT char * Iofs; /* $, */
1111 IEXT char * Iors; /* $\ */
1113 IEXT char * Iofmt; /* $# */
1114 IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1115 IEXT int Imultiline; /* $*--do strings hold >1 line? */
1116 IEXT U16 Istatusvalue; /* $? */
1118 IEXT struct stat Istatcache; /* _ */
1120 IEXT SV * Istatname IINIT(Nullsv);
1122 /* shortcuts to various I/O objects */
1124 IEXT GV * Ilast_in_gv;
1127 IEXT GV * Idefoutgv;
1128 IEXT GV * Icuroutgv;
1129 IEXT GV * Iargvoutgv;
1131 /* shortcuts to regexp stuff */
1135 IEXT PMOP * Icurpm; /* what to do \ interps from */
1136 IEXT I32 * Iscreamfirst;
1137 IEXT I32 * Iscreamnext;
1138 IEXT I32 Imaxscream IINIT(-1);
1139 IEXT SV * Ilastscream;
1141 /* shortcuts to debugging objects */
1145 IEXT SV * IDBsingle;
1147 IEXT SV * IDBsignal;
1148 IEXT AV * Ilineary; /* lines of script for debugger */
1149 IEXT AV * Idbargs; /* args to call listed by caller function */
1152 IEXT HV * Idefstash; /* main symbol table */
1153 IEXT HV * Icurstash; /* symbol table for current package */
1154 IEXT HV * Idebstash; /* symbol table for perldb package */
1155 IEXT SV * Icurstname; /* name of current package */
1156 IEXT AV * Ibeginav; /* names of BEGIN subroutines */
1157 IEXT AV * Iendav; /* names of END subroutines */
1158 IEXT AV * Ipad; /* storage for lexically scoped temporaries */
1159 IEXT AV * Ipadname; /* variable names for "my" variables */
1161 /* memory management */
1162 IEXT SV * Ifreestrroot;
1163 IEXT SV ** Itmps_stack;
1164 IEXT I32 Itmps_ix IINIT(-1);
1165 IEXT I32 Itmps_floor IINIT(-1);
1166 IEXT I32 Itmps_max IINIT(-1);
1168 /* funky return mechanisms */
1169 IEXT I32 Ilastspbase;
1171 IEXT int Iforkprocess; /* so do_open |- can return proc# */
1173 /* subprocess state */
1174 IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */
1175 IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */
1177 /* internal state */
1178 IEXT VOL int Iin_eval; /* trap "fatal" errors? */
1179 IEXT OP * Irestartop; /* Are we propagating an error from croak? */
1180 IEXT int Idelaymagic; /* ($<,$>) = ... */
1181 IEXT bool Idirty; /* clean before rerunning */
1182 IEXT bool Ilocalizing; /* are we processing a local() list? */
1183 IEXT bool Itainted; /* using variables controlled by $< */
1184 IEXT bool Itainting; /* doing taint checks */
1188 IEXT I32 Idlmax IINIT(128);
1189 IEXT char * Idebname;
1190 IEXT char * Idebdelim;
1192 /* current interpreter roots */
1193 IEXT OP * Imain_root;
1194 IEXT OP * Imain_start;
1195 IEXT OP * Ieval_root;
1196 IEXT OP * Ieval_start;
1198 /* runtime control stuff */
1199 IEXT COP * VOL Icurcop IINIT(&compiling);
1200 IEXT line_t Icopline IINIT(NOLINE);
1201 IEXT CONTEXT * Icxstack;
1202 IEXT I32 Icxstack_ix IINIT(-1);
1203 IEXT I32 Icxstack_max IINIT(128);
1204 IEXT jmp_buf Itop_env;
1207 IEXT AV * Istack; /* THE STACK */
1208 IEXT AV * Imainstack; /* the stack when nothing funny is happening */
1209 IEXT SV ** Imystack_base; /* stack->array_ary */
1210 IEXT SV ** Imystack_sp; /* stack pointer now */
1211 IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */
1213 /* format accumulators */
1214 IEXT SV * Iformtarget;
1215 IEXT SV * Ibodytarget;
1216 IEXT SV * Itoptarget;
1218 /* statics moved here for shared library purposes */
1219 IEXT SV Istrchop; /* return value from chop */
1220 IEXT int Ifilemode; /* so nextargv() can preserve mode */
1221 IEXT int Ilastfd; /* what to preserve mode on */
1222 IEXT char * Ioldname; /* what to preserve mode on */
1223 IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */
1224 IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */
1225 IEXT OP * Isortcop; /* user defined sort routine */
1226 IEXT HV * Isortstash; /* which is in some package or other */
1227 IEXT GV * Ifirstgv; /* $a */
1228 IEXT GV * Isecondgv; /* $b */
1229 IEXT AV * Isortstack; /* temp stack during pp_sort() */
1230 IEXT AV * Isignalstack; /* temp stack during sighandler() */
1231 IEXT SV * Imystrk; /* temp key string for do_each() */
1232 IEXT I32 Idumplvl; /* indentation level on syntax tree dump */
1233 IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */
1234 IEXT I32 Igensym; /* next symbol for getsym() to define */
1235 IEXT bool Ipreambled;
1236 IEXT int Ilaststatval IINIT(-1);
1237 IEXT I32 Ilaststype IINIT(OP_STAT);
1245 struct interpreter {
1262 /* The following must follow proto.h */
1265 MGVTBL vtbl_sv = {magic_get,
1269 MGVTBL vtbl_env = {0, 0, 0, 0, 0};
1270 MGVTBL vtbl_envelem = {0, magic_setenv,
1272 MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
1273 MGVTBL vtbl_sigelem = {0, magic_setsig,
1275 MGVTBL vtbl_pack = {0, 0,
1277 MGVTBL vtbl_packelem = {magic_getpack,
1281 MGVTBL vtbl_dbline = {0, magic_setdbline,
1283 MGVTBL vtbl_isa = {0, magic_setisa,
1285 MGVTBL vtbl_isaelem = {0, magic_setisa,
1287 MGVTBL vtbl_arylen = {magic_getarylen,
1290 MGVTBL vtbl_glob = {magic_getglob,
1293 MGVTBL vtbl_mglob = {0, magic_setmglob,
1295 MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
1297 MGVTBL vtbl_substr = {0, magic_setsubstr,
1299 MGVTBL vtbl_vec = {0, magic_setvec,
1301 MGVTBL vtbl_bm = {0, magic_setbm,
1303 MGVTBL vtbl_uvar = {magic_getuvar,
1308 EXT MGVTBL vtbl_env;
1309 EXT MGVTBL vtbl_envelem;
1310 EXT MGVTBL vtbl_sig;
1311 EXT MGVTBL vtbl_sigelem;
1312 EXT MGVTBL vtbl_pack;
1313 EXT MGVTBL vtbl_packelem;
1314 EXT MGVTBL vtbl_dbline;
1315 EXT MGVTBL vtbl_isa;
1316 EXT MGVTBL vtbl_isaelem;
1317 EXT MGVTBL vtbl_arylen;
1318 EXT MGVTBL vtbl_glob;
1319 EXT MGVTBL vtbl_mglob;
1320 EXT MGVTBL vtbl_taint;
1321 EXT MGVTBL vtbl_substr;
1322 EXT MGVTBL vtbl_vec;
1324 EXT MGVTBL vtbl_uvar;