This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 9
[perl5.git] / perl.h
CommitLineData
79072805 1/* $RCSfile: perl.h,v $$Revision: 4.1 $$Date: 92/08/07 18:25:56 $
a687059c 2 *
352d5a3a 3 * Copyright (c) 1991, Larry Wall
a687059c 4 *
352d5a3a
LW
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.
8d063cd8
LW
7 *
8 * $Log: perl.h,v $
79072805
LW
9 * Revision 4.1 92/08/07 18:25:56 lwall
10 *
ee0007ab
LW
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
16 *
988174c1
LW
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
21 *
45d8adaa
LW
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
27 *
1462b684
LW
28 * Revision 4.0.1.3 91/06/10 01:25:10 lwall
29 * patch10: certain pattern optimizations were botched
30 *
352d5a3a
LW
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
35 *
35c8bce7
LW
36 * Revision 4.0.1.1 91/04/11 17:49:51 lwall
37 * patch1: hopefully straightened out some of the Xenix mess
38 *
fe14fcc3
LW
39 * Revision 4.0 91/03/20 01:37:56 lwall
40 * 4.0 baseline.
8d063cd8
LW
41 *
42 */
85e6fe83
LW
43#ifndef H_PERL
44#define H_PERL 1
8d063cd8 45
79072805
LW
46#include "embed.h"
47
85e6fe83 48#define VOIDUSED 1
79072805
LW
49#ifdef __cplusplus
50#include "config_c++.h"
51#else
ac58e20f 52#include "config.h"
79072805
LW
53#endif
54
55#ifndef BYTEORDER
56# define BYTEORDER 0x1234
57#endif
58
59/* Overall memory policy? */
60#ifndef CONSERVATIVE
61# define LIBERAL 1
62#endif
63
64/*
65 * The following contortions are brought to you on behalf of all the
66 * standards, semi-standards, de facto standards, not-so-de-facto standards
67 * of the world, as well as all the other botches anyone ever thought of.
68 * The basic theory is that if we work hard enough here, the rest of the
69 * code can be a lot prettier. Well, so much for theory. Sorry, Henry...
70 */
ac58e20f 71
45d8adaa
LW
72#ifdef MYMALLOC
73# ifdef HIDEMYMALLOC
74# define malloc Mymalloc
75# define realloc Myremalloc
76# define free Myfree
77# endif
78# define safemalloc malloc
79# define saferealloc realloc
80# define safefree free
81#endif
82
83/* work around some libPW problems */
45d8adaa
LW
84#ifdef DOINIT
85char Error[1];
86#endif
87
ee0007ab
LW
88/* define this once if either system, instead of cluttering up the src */
89#if defined(MSDOS) || defined(atarist)
90#define DOSISH 1
91#endif
92
79072805 93#if defined(__STDC__) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
352d5a3a
LW
94# define STANDARD_C 1
95#endif
96
79072805
LW
97#if defined(STANDARD_C)
98# define P(args) args
99#else
100# define P(args) ()
101#endif
102
352d5a3a 103#if defined(HASVOLATILE) || defined(STANDARD_C)
79072805
LW
104# ifdef __cplusplus
105# define VOL // to temporarily suppress warnings
106# else
107# define VOL volatile
108# endif
663a0e37 109#else
79072805 110# define VOL
663a0e37
LW
111#endif
112
463ee0b2
LW
113#define TAINT_IF(c) (tainted |= (c))
114#define TAINT_NOT (tainted = 0)
115#define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
116#define TAINT_ENV() if (tainting) taint_env()
a687059c 117
fe14fcc3 118#ifndef HAS_VFORK
03a14243
LW
119# define vfork fork
120#endif
121
fe14fcc3
LW
122#ifdef HAS_GETPGRP2
123# ifndef HAS_GETPGRP
124# define HAS_GETPGRP
663a0e37 125# endif
663a0e37
LW
126#endif
127
fe14fcc3
LW
128#ifdef HAS_SETPGRP2
129# ifndef HAS_SETPGRP
130# define HAS_SETPGRP
663a0e37 131# endif
663a0e37
LW
132#endif
133
fe14fcc3
LW
134#include <stdio.h>
135#include <ctype.h>
136#include <setjmp.h>
79072805 137
fe14fcc3 138#ifndef MSDOS
79072805
LW
139# ifdef PARAM_NEEDS_TYPES
140# include <sys/types.h>
141# endif
142# include <sys/param.h>
352d5a3a 143#endif
79072805
LW
144
145
146/* Use all the "standard" definitions? */
352d5a3a 147#ifdef STANDARD_C
79072805 148# include <stdlib.h>
85e6fe83
LW
149# ifdef I_STRING
150# include <string.h>
151# endif
79072805 152# define MEM_SIZE size_t
ee0007ab 153#else
79072805 154 typedef unsigned int MEM_SIZE;
352d5a3a 155#endif /* STANDARD_C */
03a14243 156
ee0007ab 157#if defined(HAS_MEMCMP) && defined(mips) && defined(ultrix)
79072805 158# undef HAS_MEMCMP
663a0e37 159#endif
fe14fcc3
LW
160
161#ifdef HAS_MEMCPY
85e6fe83 162# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
fe14fcc3 163# ifndef memcpy
85e6fe83 164 extern char * memcpy P((char*, char*, int));
ee0007ab
LW
165# endif
166# endif
167#else
168# ifndef memcpy
169# ifdef HAS_BCOPY
170# define memcpy(d,s,l) bcopy(s,d,l)
171# else
172# define memcpy(d,s,l) my_bcopy(s,d,l)
173# endif
174# endif
175#endif /* HAS_MEMCPY */
fe14fcc3 176
ee0007ab 177#ifdef HAS_MEMSET
85e6fe83 178# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
ee0007ab 179# ifndef memset
79072805 180 extern char *memset P((char*, int, int));
ee0007ab
LW
181# endif
182# endif
183# define memzero(d,l) memset(d,0,l)
184#else
185# ifndef memzero
186# ifdef HAS_BZERO
187# define memzero(d,l) bzero(d,l)
188# else
189# define memzero(d,l) my_bzero(d,l)
190# endif
352d5a3a 191# endif
ee0007ab
LW
192#endif /* HAS_MEMSET */
193
194#ifdef HAS_MEMCMP
85e6fe83 195# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
ee0007ab 196# ifndef memcmp
79072805 197 extern int memcmp P((char*, char*, int));
ee0007ab
LW
198# endif
199# endif
200#else
201# ifndef memcmp
202# define memcmp(s1,s2,l) my_memcmp(s1,s2,l)
352d5a3a 203# endif
ee0007ab 204#endif /* HAS_MEMCMP */
8d063cd8 205
ee0007ab
LW
206/* we prefer bcmp slightly for comparisons that don't care about ordering */
207#ifndef HAS_BCMP
352d5a3a
LW
208# ifndef bcmp
209# define bcmp(s1,s2,l) memcmp(s1,s2,l)
210# endif
ee0007ab
LW
211#endif /* HAS_BCMP */
212
85e6fe83 213#if !defined(HAS_MEMMOVE) && !defined(memmove)
2304df62 214# if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
79072805
LW
215# define memmove(d,s,l) bcopy(s,d,l)
216# else
2304df62 217# if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
79072805
LW
218# define memmove(d,s,l) memcpy(d,s,l)
219# else
220# define memmove(d,s,l) my_bcopy(s,d,l)
221# endif
222# endif
d9d8d8de 223#endif
378cc40b
LW
224
225#ifndef _TYPES_ /* If types.h defines this it's easy. */
79072805
LW
226# ifndef major /* Does everyone's types.h define this? */
227# include <sys/types.h>
228# endif
378cc40b
LW
229#endif
230
ae986130 231#ifdef I_NETINET_IN
79072805 232# include <netinet/in.h>
ae986130
LW
233#endif
234
8d063cd8 235#include <sys/stat.h>
79072805 236
ee0007ab 237#if defined(uts) || defined(UTekV)
79072805
LW
238# undef S_ISDIR
239# undef S_ISCHR
240# undef S_ISBLK
241# undef S_ISREG
242# undef S_ISFIFO
243# undef S_ISLNK
244# define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
245# define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
246# define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
247# define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
248# define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
249# ifdef S_IFLNK
250# define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
251# endif
ee0007ab 252#endif
135863df 253
663a0e37
LW
254#ifdef I_TIME
255# include <time.h>
ffed7fef 256#endif
663a0e37 257
fe14fcc3 258#ifdef I_SYS_TIME
85e6fe83 259# ifdef I_SYS_TIME_KERNEL
663a0e37
LW
260# define KERNEL
261# endif
262# include <sys/time.h>
85e6fe83 263# ifdef I_SYS_TIME_KERNEL
663a0e37
LW
264# undef KERNEL
265# endif
a687059c 266#endif
135863df 267
d9d8d8de 268#ifndef MSDOS
85e6fe83
LW
269# ifdef HAS_TIMES
270# include <sys/times.h>
271# endif
d9d8d8de 272#endif
8d063cd8 273
fe14fcc3 274#if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
79072805 275# undef HAS_STRERROR
663a0e37
LW
276#endif
277
278#include <errno.h>
ed6116ce 279#ifdef HAS_SOCKET
85e6fe83 280# ifdef I_NET_ERRNO
ed6116ce
LW
281# include <net/errno.h>
282# endif
283#endif
284
d9d8d8de 285#ifndef MSDOS
79072805
LW
286# ifndef errno
287 extern int errno; /* ANSI allows errno to be an lvalue expr */
288# endif
d9d8d8de 289#endif
663a0e37 290
2304df62 291#ifdef HAS_STRERROR
79072805 292 char *strerror P((int));
2304df62
AD
293# ifndef Strerror
294# define Strerror strerror
295# endif
296#else
297# ifdef HAS_SYS_ERRLIST
79072805
LW
298 extern int sys_nerr;
299 extern char *sys_errlist[];
2304df62
AD
300# ifndef Strerror
301# define Strerror(e) \
79072805 302 ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
2304df62 303# endif
79072805 304# endif
35c8bce7 305#endif
663a0e37 306
2304df62 307#ifdef I_SYS_IOCTL
79072805
LW
308# ifndef _IOCTL_
309# include <sys/ioctl.h>
310# endif
a687059c
LW
311#endif
312
ee0007ab 313#if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
79072805
LW
314# ifdef HAS_SOCKETPAIR
315# undef HAS_SOCKETPAIR
316# endif
2304df62
AD
317# ifdef I_NDBM
318# undef I_NDBM
79072805 319# endif
a687059c
LW
320#endif
321
a687059c 322#if INTSIZE == 2
79072805
LW
323# define htoni htons
324# define ntohi ntohs
a687059c 325#else
79072805
LW
326# define htoni htonl
327# define ntohi ntohl
a687059c
LW
328#endif
329
35c8bce7 330#if defined(I_DIRENT)
663a0e37
LW
331# include <dirent.h>
332# define DIRENT dirent
ae986130 333#else
fe14fcc3 334# ifdef I_SYS_NDIR
79a0689e 335# include <sys/ndir.h>
663a0e37
LW
336# define DIRENT direct
337# else
fe14fcc3 338# ifdef I_SYS_DIR
79a0689e
LW
339# ifdef hp9000s500
340# include <ndir.h> /* may be wrong in the future */
341# else
342# include <sys/dir.h>
343# endif
663a0e37
LW
344# define DIRENT direct
345# endif
346# endif
a687059c
LW
347#endif
348
352d5a3a
LW
349#ifdef FPUTS_BOTCH
350/* work around botch in SunOS 4.0.1 and 4.0.2 */
351# ifndef fputs
79072805 352# define fputs(sv,fp) fprintf(fp,"%s",sv)
352d5a3a
LW
353# endif
354#endif
355
c623bd54
LW
356/*
357 * The following gobbledygook brought to you on behalf of __STDC__.
358 * (I could just use #ifndef __STDC__, but this is more bulletproof
359 * in the face of half-implementations.)
360 */
361
362#ifndef S_IFMT
363# ifdef _S_IFMT
364# define S_IFMT _S_IFMT
365# else
366# define S_IFMT 0170000
367# endif
368#endif
369
370#ifndef S_ISDIR
371# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
372#endif
373
374#ifndef S_ISCHR
375# define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
376#endif
377
378#ifndef S_ISBLK
fe14fcc3
LW
379# ifdef S_IFBLK
380# define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
381# else
382# define S_ISBLK(m) (0)
383# endif
c623bd54
LW
384#endif
385
386#ifndef S_ISREG
387# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
388#endif
389
390#ifndef S_ISFIFO
fe14fcc3
LW
391# ifdef S_IFIFO
392# define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
393# else
394# define S_ISFIFO(m) (0)
395# endif
c623bd54
LW
396#endif
397
398#ifndef S_ISLNK
399# ifdef _S_ISLNK
400# define S_ISLNK(m) _S_ISLNK(m)
401# else
402# ifdef _S_IFLNK
403# define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
404# else
405# ifdef S_IFLNK
406# define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
407# else
408# define S_ISLNK(m) (0)
409# endif
410# endif
411# endif
412#endif
413
414#ifndef S_ISSOCK
415# ifdef _S_ISSOCK
416# define S_ISSOCK(m) _S_ISSOCK(m)
417# else
418# ifdef _S_IFSOCK
419# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
420# else
421# ifdef S_IFSOCK
422# define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
423# else
424# define S_ISSOCK(m) (0)
425# endif
426# endif
427# endif
428#endif
429
430#ifndef S_IRUSR
431# ifdef S_IREAD
432# define S_IRUSR S_IREAD
433# define S_IWUSR S_IWRITE
434# define S_IXUSR S_IEXEC
435# else
436# define S_IRUSR 0400
437# define S_IWUSR 0200
438# define S_IXUSR 0100
439# endif
440# define S_IRGRP (S_IRUSR>>3)
441# define S_IWGRP (S_IWUSR>>3)
442# define S_IXGRP (S_IXUSR>>3)
443# define S_IROTH (S_IRUSR>>6)
444# define S_IWOTH (S_IWUSR>>6)
445# define S_IXOTH (S_IXUSR>>6)
446#endif
447
448#ifndef S_ISUID
449# define S_ISUID 04000
450#endif
451
452#ifndef S_ISGID
453# define S_ISGID 02000
454#endif
455
79072805
LW
456#ifdef ff_next
457# undef ff_next
352d5a3a
LW
458#endif
459
ee0007ab 460#if defined(cray) || defined(gould) || defined(i860)
45d8adaa
LW
461# define SLOPPYDIVIDE
462#endif
463
988174c1 464#if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
45d8adaa
LW
465# define QUAD
466#endif
467
468#ifdef QUAD
469# ifdef cray
470# define quad int
471# else
988174c1 472# if defined(convex) || defined (uts)
45d8adaa
LW
473# define quad long long
474# else
475# define quad long
476# endif
477# endif
478#endif
479
79072805
LW
480#ifdef VOIDSIG
481# define VOIDRET void
482#else
483# define VOIDRET int
484#endif
485
486#ifdef DOSISH
487# include "dosish.h"
488#else
489# include "unixish.h"
490#endif
491
492#ifndef HAS_PAUSE
493#define pause() sleep((32767<<16)+32767)
494#endif
495
496#ifndef IOCPARM_LEN
497# ifdef IOCPARM_MASK
498 /* on BSDish systes we're safe */
499# define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
500# else
501 /* otherwise guess at what's safe */
502# define IOCPARM_LEN(x) 256
503# endif
504#endif
505
ee0007ab 506typedef MEM_SIZE STRLEN;
450a55e4 507
79072805
LW
508typedef struct op OP;
509typedef struct cop COP;
510typedef struct unop UNOP;
511typedef struct binop BINOP;
512typedef struct listop LISTOP;
513typedef struct logop LOGOP;
514typedef struct condop CONDOP;
515typedef struct pmop PMOP;
516typedef struct svop SVOP;
517typedef struct gvop GVOP;
518typedef struct pvop PVOP;
519typedef struct cvop CVOP;
520typedef struct loop LOOP;
521
522typedef struct Outrec Outrec;
523typedef struct lstring Lstring;
93a17b20 524typedef struct interpreter PerlInterpreter;
79072805 525typedef struct ff FF;
79072805
LW
526typedef struct sv SV;
527typedef struct av AV;
528typedef struct hv HV;
529typedef struct cv CV;
378cc40b 530typedef struct regexp REGEXP;
79072805
LW
531typedef struct gp GP;
532typedef struct sv GV;
8990e307 533typedef struct io IO;
79072805
LW
534typedef struct context CONTEXT;
535typedef struct block BLOCK;
536
537typedef struct magic MAGIC;
ed6116ce 538typedef struct xrv XRV;
79072805
LW
539typedef struct xpv XPV;
540typedef struct xpviv XPVIV;
541typedef struct xpvnv XPVNV;
542typedef struct xpvmg XPVMG;
543typedef struct xpvlv XPVLV;
544typedef struct xpvav XPVAV;
545typedef struct xpvhv XPVHV;
546typedef struct xpvgv XPVGV;
547typedef struct xpvcv XPVCV;
548typedef struct xpvbm XPVBM;
549typedef struct xpvfm XPVFM;
8990e307 550typedef struct xpvio XPVIO;
79072805
LW
551typedef struct mgvtbl MGVTBL;
552typedef union any ANY;
8d063cd8 553
378cc40b 554#include "handy.h"
79072805
LW
555union any {
556 void* any_ptr;
557 I32 any_i32;
85e6fe83 558 long any_long;
79072805
LW
559};
560
378cc40b 561#include "regexp.h"
79072805 562#include "sv.h"
378cc40b 563#include "util.h"
8d063cd8 564#include "form.h"
79072805
LW
565#include "gv.h"
566#include "cv.h"
567#include "opcode.h"
568#include "op.h"
569#include "cop.h"
570#include "av.h"
571#include "hv.h"
572#include "mg.h"
573#include "scope.h"
8d063cd8 574
450a55e4 575#if defined(iAPX286) || defined(M_I286) || defined(I80286)
a687059c
LW
576# define I286
577#endif
578
352d5a3a 579#ifndef STANDARD_C
79072805
LW
580# ifdef CHARSPRINTF
581 char *sprintf P((char *, ...));
582# else
583 int sprintf P((char *, ...));
584# endif
a687059c
LW
585#endif
586
fe14fcc3
LW
587#if defined(htonl) && !defined(HAS_HTONL)
588#define HAS_HTONL
ae986130 589#endif
fe14fcc3
LW
590#if defined(htons) && !defined(HAS_HTONS)
591#define HAS_HTONS
ae986130 592#endif
fe14fcc3
LW
593#if defined(ntohl) && !defined(HAS_NTOHL)
594#define HAS_NTOHL
ae986130 595#endif
fe14fcc3
LW
596#if defined(ntohs) && !defined(HAS_NTOHS)
597#define HAS_NTOHS
ae986130 598#endif
fe14fcc3 599#ifndef HAS_HTONL
d9d8d8de 600#if (BYTEORDER & 0xffff) != 0x4321
fe14fcc3
LW
601#define HAS_HTONS
602#define HAS_HTONL
603#define HAS_NTOHS
604#define HAS_NTOHL
a687059c
LW
605#define MYSWAP
606#define htons my_swap
607#define htonl my_htonl
608#define ntohs my_swap
609#define ntohl my_ntohl
610#endif
611#else
d9d8d8de 612#if (BYTEORDER & 0xffff) == 0x4321
fe14fcc3
LW
613#undef HAS_HTONS
614#undef HAS_HTONL
615#undef HAS_NTOHS
616#undef HAS_NTOHL
a687059c
LW
617#endif
618#endif
619
988174c1
LW
620/*
621 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
622 * -DWS
623 */
624#if BYTEORDER != 0x1234
625# define HAS_VTOHL
626# define HAS_VTOHS
627# define HAS_HTOVL
628# define HAS_HTOVS
629# if BYTEORDER == 0x4321
630# define vtohl(x) ((((x)&0xFF)<<24) \
631 +(((x)>>24)&0xFF) \
632 +(((x)&0x0000FF00)<<8) \
633 +(((x)&0x00FF0000)>>8) )
634# define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
635# define htovl(x) vtohl(x)
636# define htovs(x) vtohs(x)
637# endif
638 /* otherwise default to functions in util.c */
639#endif
640
0f85fab0 641#ifdef CASTNEGFLOAT
79072805 642#define U_S(what) ((U16)(what))
0f85fab0 643#define U_I(what) ((unsigned int)(what))
79072805 644#define U_L(what) ((U32)(what))
0f85fab0 645#else
79072805
LW
646U32 cast_ulong P((double));
647#define U_S(what) ((U16)cast_ulong(what))
648#define U_I(what) ((unsigned int)cast_ulong(what))
649#define U_L(what) (cast_ulong(what))
ee0007ab
LW
650#endif
651
ed6116ce
LW
652#ifdef CASTI32
653#define I_32(what) ((I32)(what))
654#else
655I32 cast_i32 P((double));
656#define I_32(what) (cast_i32(what))
657#endif
658
79072805
LW
659struct Outrec {
660 I32 o_lines;
d9d8d8de 661 char *o_str;
79072805 662 U32 o_len;
8d063cd8
LW
663};
664
352d5a3a
LW
665#ifndef MAXSYSFD
666# define MAXSYSFD 2
667#endif
ee0007ab
LW
668
669#ifndef DOSISH
378cc40b 670#define TMPPATH "/tmp/perl-eXXXXXX"
450a55e4 671#else
57ebbfd0 672#define TMPPATH "plXXXXXX"
450a55e4 673#endif /* MSDOS */
79072805
LW
674
675#ifndef __cplusplus
85e6fe83
LW
676Uid_t getuid P(());
677Uid_t geteuid P(());
678Gid_t getgid P(());
679Gid_t getegid P(());
79072805 680#endif
8d063cd8
LW
681
682#ifdef DEBUGGING
d96024cf 683#define YYDEBUG 1
79072805
LW
684#define DEB(a) a
685#define DEBUG(a) if (debug) a
686#define DEBUG_p(a) if (debug & 1) a
687#define DEBUG_s(a) if (debug & 2) a
688#define DEBUG_l(a) if (debug & 4) a
689#define DEBUG_t(a) if (debug & 8) a
690#define DEBUG_o(a) if (debug & 16) a
691#define DEBUG_c(a) if (debug & 32) a
692#define DEBUG_P(a) if (debug & 64) a
693#define DEBUG_m(a) if (debug & 128) a
694#define DEBUG_f(a) if (debug & 256) a
695#define DEBUG_r(a) if (debug & 512) a
696#define DEBUG_x(a) if (debug & 1024) a
697#define DEBUG_u(a) if (debug & 2048) a
698#define DEBUG_L(a) if (debug & 4096) a
699#define DEBUG_H(a) if (debug & 8192) a
700#define DEBUG_X(a) if (debug & 16384) a
8990e307 701#define DEBUG_D(a) if (debug & 32768) a
79072805
LW
702#else
703#define DEB(a)
704#define DEBUG(a)
705#define DEBUG_p(a)
706#define DEBUG_s(a)
707#define DEBUG_l(a)
708#define DEBUG_t(a)
709#define DEBUG_o(a)
710#define DEBUG_c(a)
711#define DEBUG_P(a)
712#define DEBUG_m(a)
713#define DEBUG_f(a)
714#define DEBUG_r(a)
715#define DEBUG_x(a)
716#define DEBUG_u(a)
717#define DEBUG_L(a)
718#define DEBUG_H(a)
719#define DEBUG_X(a)
8990e307 720#define DEBUG_D(a)
8d063cd8 721#endif
fe14fcc3 722#define YYMAXDEPTH 300
8d063cd8 723
79072805
LW
724#define assert(what) DEB( { \
725 if (!(what)) { \
463ee0b2 726 croak("Assertion failed: file \"%s\", line %d", \
79072805
LW
727 __FILE__, __LINE__); \
728 exit(1); \
729 }})
8d063cd8 730
450a55e4 731struct ufuncs {
79072805
LW
732 I32 (*uf_val)P((I32, SV*));
733 I32 (*uf_set)P((I32, SV*));
734 I32 uf_index;
450a55e4
LW
735};
736
fe14fcc3 737/* Fix these up for __STDC__ */
79072805
LW
738char *mktemp P((char*));
739double atof P((const char*));
740
352d5a3a 741#ifndef STANDARD_C
fe14fcc3 742/* All of these are in stdlib.h or time.h for ANSI C */
85e6fe83 743Time_t time();
8d063cd8 744struct tm *gmtime(), *localtime();
93a17b20 745char *strchr(), *strrchr();
378cc40b 746char *strcpy(), *strcat();
352d5a3a 747#endif /* ! STANDARD_C */
8d063cd8 748
79072805
LW
749
750#ifdef I_MATH
751# include <math.h>
752#else
753# ifdef __cplusplus
754 extern "C" {
755# endif
756 double exp P((double));
757 double log P((double));
758 double sqrt P((double));
2304df62 759 double modf P((double,double*));
79072805
LW
760 double sin P((double));
761 double cos P((double));
762 double atan2 P((double,double));
763 double pow P((double,double));
764# ifdef __cplusplus
765 };
766# endif
767#endif
768
769
770char *crypt P((const char*, const char*));
771char *getenv P((const char*));
85e6fe83 772Off_t lseek P((int,Off_t,int));
79072805
LW
773char *getlogin P((void));
774
8d063cd8 775#ifdef EUNICE
378cc40b 776#define UNLINK unlnk
79072805 777int unlnk P((char*));
8d063cd8
LW
778#else
779#define UNLINK unlink
780#endif
a687059c 781
fe14fcc3 782#ifndef HAS_SETREUID
85e6fe83
LW
783# ifdef HAS_SETRESUID
784# define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
785# define HAS_SETREUID
786# endif
a687059c 787#endif
fe14fcc3 788#ifndef HAS_SETREGID
85e6fe83
LW
789# ifdef HAS_SETRESGID
790# define setregid(r,e) setresgid(r,e,(Gid_t)-1)
791# define HAS_SETREGID
792# endif
a687059c 793#endif
ee0007ab
LW
794
795#define SCAN_DEF 0
796#define SCAN_TR 1
797#define SCAN_REPL 2
79072805
LW
798
799#ifdef DEBUGGING
800#define PAD_SV(po) pad_sv(po)
801#else
802#define PAD_SV(po) curpad[po]
803#endif
804
805/****************/
806/* Truly global */
807/****************/
808
809/* global state */
93a17b20 810EXT PerlInterpreter *curinterp; /* currently running interpreter */
79072805
LW
811extern char ** environ; /* environment variables supplied via exec */
812EXT int uid; /* current real user id */
813EXT int euid; /* current effective user id */
814EXT int gid; /* current real group id */
815EXT int egid; /* current effective group id */
816EXT bool nomemok; /* let malloc context handle nomem */
817EXT U32 an; /* malloc sequence number */
463ee0b2
LW
818EXT U32 cop_seqmax; /* statement sequence number */
819EXT U32 op_seqmax; /* op sequence number */
8990e307 820EXT U32 evalseq; /* eval sequence number */
463ee0b2 821EXT U32 sub_generation; /* inc to force methods to be looked up again */
79072805
LW
822EXT char ** origenviron;
823EXT U32 origalen;
824
85e6fe83 825EXT I32 ** xiv_root; /* free xiv list--shared by interpreters */
8990e307
LW
826EXT double * xnv_root; /* free xnv list--shared by interpreters */
827EXT XRV * xrv_root; /* free xrv list--shared by interpreters */
828EXT XPV * xpv_root; /* free xpv list--shared by interpreters */
829
79072805
LW
830/* Stack for currently executing thread--context switch must handle this. */
831EXT SV ** stack_base; /* stack->array_ary */
832EXT SV ** stack_sp; /* stack pointer now */
833EXT SV ** stack_max; /* stack->array_ary + stack->array_max */
834
835/* likewise for these */
836
837EXT OP * op; /* current op--oughta be in a global register */
838
839EXT I32 * scopestack; /* blocks we've entered */
840EXT I32 scopestack_ix;
841EXT I32 scopestack_max;
842
843EXT ANY* savestack; /* to save non-local values on */
844EXT I32 savestack_ix;
845EXT I32 savestack_max;
846
847EXT OP ** retstack; /* returns we've pushed */
848EXT I32 retstack_ix;
849EXT I32 retstack_max;
850
851EXT I32 * markstack; /* stackmarks we're remembering */
852EXT I32 * markstack_ptr; /* stackmarks we're remembering */
853EXT I32 * markstack_max; /* stackmarks we're remembering */
854
855EXT SV ** curpad;
856
857/* temp space */
858EXT SV * Sv;
859EXT XPV * Xpv;
860EXT char buf[1024];
861EXT char tokenbuf[256];
862EXT struct stat statbuf;
863#ifndef MSDOS
864EXT struct tms timesbuf;
865#endif
463ee0b2 866EXT STRLEN na; /* for use in SvPV when length is Not Applicable */
79072805
LW
867
868/* for tmp use in stupid debuggers */
869EXT int * di;
870EXT short * ds;
871EXT char * dc;
872
873/* handy constants */
874EXT char * Yes INIT("1");
875EXT char * No INIT("");
876EXT char * hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
79072805
LW
877EXT char * patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
878EXT char * vert INIT("|");
879
8990e307
LW
880EXT char warn_uninit[]
881 INIT("Use of uninitialized variable");
463ee0b2
LW
882EXT char warn_nosemi[]
883 INIT("Semicolon seems to be missing");
884EXT char warn_reserved[]
885 INIT("Unquoted string \"%s\" may clash with future reserved word");
886EXT char warn_nl[]
93a17b20 887 INIT("Unsuccessful %s on filename containing newline");
85e6fe83
LW
888EXT char no_hardref[]
889 INIT("Can't use a string as %s ref while \"strict refs\" averred");
93a17b20 890EXT char no_usym[]
8990e307 891 INIT("Can't use an undefined value as %s reference");
93a17b20
LW
892EXT char no_aelem[]
893 INIT("Modification of non-creatable array value attempted, subscript %d");
894EXT char no_helem[]
895 INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
896EXT char no_modify[]
897 INIT("Modification of a read-only value attempted");
898EXT char no_mem[]
899 INIT("Out of memory!\n");
900EXT char no_security[]
463ee0b2 901 INIT("Insecure dependency in %s%s");
93a17b20
LW
902EXT char no_sock_func[]
903 INIT("Unsupported socket function \"%s\" called");
904EXT char no_dir_func[]
905 INIT("Unsupported directory function \"%s\" called");
906EXT char no_func[]
907 INIT("The %s function is unimplemented");
908
79072805
LW
909EXT SV sv_undef;
910EXT SV sv_no;
911EXT SV sv_yes;
912#ifdef CSH
913 EXT char * cshname INIT(CSH);
914 EXT I32 cshlen;
915#endif
916
917#ifdef DOINIT
918EXT char *sig_name[] = {
919 SIG_NAME,0
920};
921#else
922EXT char *sig_name[];
923#endif
924
925#ifdef DOINIT
79072805
LW
926EXT unsigned char fold[] = { /* fast case folding table */
927 0, 1, 2, 3, 4, 5, 6, 7,
928 8, 9, 10, 11, 12, 13, 14, 15,
929 16, 17, 18, 19, 20, 21, 22, 23,
930 24, 25, 26, 27, 28, 29, 30, 31,
931 32, 33, 34, 35, 36, 37, 38, 39,
932 40, 41, 42, 43, 44, 45, 46, 47,
933 48, 49, 50, 51, 52, 53, 54, 55,
934 56, 57, 58, 59, 60, 61, 62, 63,
935 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
936 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
937 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
938 'x', 'y', 'z', 91, 92, 93, 94, 95,
939 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
940 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
941 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
942 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
943 128, 129, 130, 131, 132, 133, 134, 135,
944 136, 137, 138, 139, 140, 141, 142, 143,
945 144, 145, 146, 147, 148, 149, 150, 151,
946 152, 153, 154, 155, 156, 157, 158, 159,
947 160, 161, 162, 163, 164, 165, 166, 167,
948 168, 169, 170, 171, 172, 173, 174, 175,
949 176, 177, 178, 179, 180, 181, 182, 183,
950 184, 185, 186, 187, 188, 189, 190, 191,
951 192, 193, 194, 195, 196, 197, 198, 199,
952 200, 201, 202, 203, 204, 205, 206, 207,
953 208, 209, 210, 211, 212, 213, 214, 215,
954 216, 217, 218, 219, 220, 221, 222, 223,
955 224, 225, 226, 227, 228, 229, 230, 231,
956 232, 233, 234, 235, 236, 237, 238, 239,
957 240, 241, 242, 243, 244, 245, 246, 247,
958 248, 249, 250, 251, 252, 253, 254, 255
959};
960#else
961EXT unsigned char fold[];
962#endif
963
964#ifdef DOINIT
965EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */
966 1, 2, 84, 151, 154, 155, 156, 157,
967 165, 246, 250, 3, 158, 7, 18, 29,
968 40, 51, 62, 73, 85, 96, 107, 118,
969 129, 140, 147, 148, 149, 150, 152, 153,
970 255, 182, 224, 205, 174, 176, 180, 217,
971 233, 232, 236, 187, 235, 228, 234, 226,
972 222, 219, 211, 195, 188, 193, 185, 184,
973 191, 183, 201, 229, 181, 220, 194, 162,
974 163, 208, 186, 202, 200, 218, 198, 179,
975 178, 214, 166, 170, 207, 199, 209, 206,
976 204, 160, 212, 216, 215, 192, 175, 173,
977 243, 172, 161, 190, 203, 189, 164, 230,
978 167, 248, 227, 244, 242, 255, 241, 231,
979 240, 253, 169, 210, 245, 237, 249, 247,
980 239, 168, 252, 251, 254, 238, 223, 221,
981 213, 225, 177, 197, 171, 196, 159, 4,
982 5, 6, 8, 9, 10, 11, 12, 13,
983 14, 15, 16, 17, 19, 20, 21, 22,
984 23, 24, 25, 26, 27, 28, 30, 31,
985 32, 33, 34, 35, 36, 37, 38, 39,
986 41, 42, 43, 44, 45, 46, 47, 48,
987 49, 50, 52, 53, 54, 55, 56, 57,
988 58, 59, 60, 61, 63, 64, 65, 66,
989 67, 68, 69, 70, 71, 72, 74, 75,
990 76, 77, 78, 79, 80, 81, 82, 83,
991 86, 87, 88, 89, 90, 91, 92, 93,
992 94, 95, 97, 98, 99, 100, 101, 102,
993 103, 104, 105, 106, 108, 109, 110, 111,
994 112, 113, 114, 115, 116, 117, 119, 120,
995 121, 122, 123, 124, 125, 126, 127, 128,
996 130, 131, 132, 133, 134, 135, 136, 137,
997 138, 139, 141, 142, 143, 144, 145, 146
998};
999#else
1000EXT unsigned char freq[];
1001#endif
1002
8990e307
LW
1003#ifdef DEBUGGING
1004#ifdef DOINIT
1005EXT char* block_type[] = {
1006 "NULL",
1007 "SUB",
1008 "EVAL",
1009 "LOOP",
1010 "SUBST",
1011 "BLOCK",
1012};
1013#else
1014EXT char* block_type[];
1015#endif
1016#endif
1017
79072805
LW
1018/*****************************************************************************/
1019/* This lexer/parser stuff is currently global since yacc is hard to reenter */
1020/*****************************************************************************/
8990e307 1021/* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
79072805
LW
1022
1023typedef enum {
1024 XOPERATOR,
1025 XTERM,
79072805 1026 XREF,
8990e307 1027 XSTATE,
85e6fe83 1028 XBLOCK
79072805
LW
1029} expectation;
1030
1031EXT FILE * VOL rsfp INIT(Nullfp);
1032EXT SV * linestr;
1033EXT char * bufptr;
1034EXT char * oldbufptr;
1035EXT char * oldoldbufptr;
1036EXT char * bufend;
8990e307 1037EXT expectation expect INIT(XSTATE); /* how to interpret ambiguous tokens */
79072805
LW
1038
1039EXT I32 multi_start; /* 1st line of multi-line string */
1040EXT I32 multi_end; /* last line of multi-line string */
1041EXT I32 multi_open; /* delimiter of said string */
1042EXT I32 multi_close; /* delimiter of said string */
1043
1044EXT GV * scrgv;
1045EXT I32 error_count; /* how many errors so far, max 10 */
1046EXT I32 subline; /* line this subroutine began on */
1047EXT SV * subname; /* name of current subroutine */
1048
93a17b20 1049EXT AV * comppad; /* storage for lexically scoped temporaries */
8990e307
LW
1050EXT AV * comppad_name; /* variable names for "my" variables */
1051EXT I32 comppad_name_fill;/* last "introduced" variable offset */
1052EXT I32 min_intro_pending;/* start of vars to introduce */
1053EXT I32 max_intro_pending;/* end of vars to introduce */
79072805
LW
1054EXT I32 padix; /* max used index in current "register" pad */
1055EXT COP compiling;
1056
1057EXT SV * evstr; /* op_fold_const() temp string cache */
1058EXT I32 thisexpr; /* name id for nothing_in_common() */
1059EXT char * last_uni; /* position of last named-unary operator */
1060EXT char * last_lop; /* position of last list operator */
8990e307 1061EXT OPCODE last_lop_op; /* last list operator */
93a17b20 1062EXT bool in_my; /* we're compiling a "my" declaration */
79072805
LW
1063#ifdef FCRYPT
1064EXT I32 cryptseen; /* has fast crypt() been initialized? */
1065#endif
1066
85e6fe83
LW
1067EXT U32 hints; /* various compilation flags */
1068
1069 /* Note: the lowest 8 bits are reserved for
1070 stuffing into op->op_private */
1071#define HINT_INTEGER 0x00000001
1072#define HINT_STRICT_REFS 0x00000002
1073
1074#define HINT_BLOCK_SCOPE 0x00000100
1075#define HINT_STRICT_SUBS 0x00000200
1076#define HINT_STRICT_VARS 0x00000400
1077
79072805
LW
1078/**************************************************************************/
1079/* This regexp stuff is global since it always happens within 1 expr eval */
1080/**************************************************************************/
1081
1082EXT char * regprecomp; /* uncompiled string. */
1083EXT char * regparse; /* Input-scan pointer. */
1084EXT char * regxend; /* End of input for compile */
1085EXT I32 regnpar; /* () count. */
1086EXT char * regcode; /* Code-emit pointer; &regdummy = don't. */
1087EXT I32 regsize; /* Code size. */
1088EXT I32 regfold; /* are we folding? */
1089EXT I32 regsawbracket; /* Did we do {d,d} trick? */
1090EXT I32 regsawback; /* Did we see \1, ...? */
1091
1092EXT char * reginput; /* String-input pointer. */
1093EXT char regprev; /* char before regbol, \n if none */
1094EXT char * regbol; /* Beginning of input, for ^ check. */
1095EXT char * regeol; /* End of input, for $ check. */
1096EXT char ** regstartp; /* Pointer to startp array. */
1097EXT char ** regendp; /* Ditto for endp. */
1098EXT char * reglastparen; /* Similarly for lastparen. */
1099EXT char * regtill; /* How far we are required to go. */
1100EXT I32 regmyp_size;
1101EXT char ** regmystartp;
1102EXT char ** regmyendp;
1103
1104/***********************************************/
1105/* Global only to current interpreter instance */
1106/***********************************************/
1107
8990e307 1108#ifdef MULTIPLICITY
79072805
LW
1109#define IEXT
1110#define IINIT(x)
1111struct interpreter {
1112#else
1113#define IEXT EXT
1114#define IINIT(x) INIT(x)
1115#endif
1116
1117/* pseudo environmental stuff */
1118IEXT int Iorigargc;
1119IEXT char ** Iorigargv;
1120IEXT GV * Ienvgv;
1121IEXT GV * Isiggv;
1122IEXT GV * Iincgv;
1123IEXT char * Iorigfilename;
1124
1125/* switches */
1126IEXT char * Icddir;
1127IEXT bool Iminus_c;
1128IEXT char Ipatchlevel[6];
1129IEXT char * Inrs IINIT("\n");
1130IEXT U32 Inrschar IINIT('\n'); /* final char of rs, or 0777 if none */
1131IEXT I32 Inrslen IINIT(1);
2304df62 1132IEXT char * Isplitstr IINIT(" ");
79072805
LW
1133IEXT bool Ipreprocess;
1134IEXT bool Iminus_n;
1135IEXT bool Iminus_p;
1136IEXT bool Iminus_l;
1137IEXT bool Iminus_a;
2304df62 1138IEXT bool Iminus_F;
79072805
LW
1139IEXT bool Idoswitches;
1140IEXT bool Idowarn;
1141IEXT bool Idoextract;
79072805
LW
1142IEXT bool Isawampersand; /* must save all match strings */
1143IEXT bool Isawstudy; /* do fbm_instr on all strings */
1144IEXT bool Isawi; /* study must assume case insensitive */
1145IEXT bool Isawvec;
1146IEXT bool Iunsafe;
1147IEXT bool Ido_undump; /* -u or dump seen? */
1148IEXT char * Iinplace;
1149IEXT char * Ie_tmpname;
1150IEXT FILE * Ie_fp;
1151IEXT VOL U32 Idebug;
1152IEXT U32 Iperldb;
1153
1154/* magical thingies */
85e6fe83 1155IEXT Time_t Ibasetime; /* $^T */
79072805
LW
1156IEXT I32 Iarybase; /* $[ */
1157IEXT SV * Iformfeed; /* $^L */
1158IEXT char * Ichopset IINIT(" \n-"); /* $: */
1159IEXT char * Irs IINIT("\n"); /* $/ */
1160IEXT U32 Irschar IINIT('\n'); /* final char of rs, or 0777 if none */
8990e307 1161IEXT STRLEN Irslen IINIT(1);
79072805
LW
1162IEXT bool Irspara;
1163IEXT char * Iofs; /* $, */
8990e307 1164IEXT STRLEN Iofslen;
79072805 1165IEXT char * Iors; /* $\ */
8990e307 1166IEXT STRLEN Iorslen;
79072805
LW
1167IEXT char * Iofmt; /* $# */
1168IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
1169IEXT int Imultiline; /* $*--do strings hold >1 line? */
1170IEXT U16 Istatusvalue; /* $? */
1171
1172IEXT struct stat Istatcache; /* _ */
1173IEXT GV * Istatgv;
1174IEXT SV * Istatname IINIT(Nullsv);
1175
1176/* shortcuts to various I/O objects */
1177IEXT GV * Istdingv;
1178IEXT GV * Ilast_in_gv;
1179IEXT GV * Idefgv;
1180IEXT GV * Iargvgv;
1181IEXT GV * Idefoutgv;
1182IEXT GV * Icuroutgv;
1183IEXT GV * Iargvoutgv;
1184
1185/* shortcuts to regexp stuff */
1186IEXT GV * Ileftgv;
1187IEXT GV * Iampergv;
1188IEXT GV * Irightgv;
1189IEXT PMOP * Icurpm; /* what to do \ interps from */
79072805
LW
1190IEXT I32 * Iscreamfirst;
1191IEXT I32 * Iscreamnext;
1192IEXT I32 Imaxscream IINIT(-1);
1193IEXT SV * Ilastscream;
1194
1195/* shortcuts to debugging objects */
1196IEXT GV * IDBgv;
1197IEXT GV * IDBline;
1198IEXT GV * IDBsub;
1199IEXT SV * IDBsingle;
1200IEXT SV * IDBtrace;
1201IEXT SV * IDBsignal;
1202IEXT AV * Ilineary; /* lines of script for debugger */
1203IEXT AV * Idbargs; /* args to call listed by caller function */
1204
1205/* symbol tables */
1206IEXT HV * Idefstash; /* main symbol table */
1207IEXT HV * Icurstash; /* symbol table for current package */
1208IEXT HV * Idebstash; /* symbol table for perldb package */
1209IEXT SV * Icurstname; /* name of current package */
93a17b20
LW
1210IEXT AV * Ibeginav; /* names of BEGIN subroutines */
1211IEXT AV * Iendav; /* names of END subroutines */
1212IEXT AV * Ipad; /* storage for lexically scoped temporaries */
1213IEXT AV * Ipadname; /* variable names for "my" variables */
79072805
LW
1214
1215/* memory management */
79072805
LW
1216IEXT SV ** Itmps_stack;
1217IEXT I32 Itmps_ix IINIT(-1);
1218IEXT I32 Itmps_floor IINIT(-1);
8990e307
LW
1219IEXT I32 Itmps_max;
1220IEXT I32 Isv_count; /* how many SV* are currently allocated */
1221IEXT I32 Isv_rvcount; /* how many RV* are currently allocated */
1222IEXT SV* Isv_root; /* storage for SVs belonging to interp */
1223IEXT SV* Isv_arenaroot; /* list of areas for garbage collection */
79072805
LW
1224
1225/* funky return mechanisms */
1226IEXT I32 Ilastspbase;
1227IEXT I32 Ilastsize;
1228IEXT int Iforkprocess; /* so do_open |- can return proc# */
1229
1230/* subprocess state */
1231IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */
1232IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */
1233
1234/* internal state */
463ee0b2
LW
1235IEXT VOL int Iin_eval; /* trap "fatal" errors? */
1236IEXT OP * Irestartop; /* Are we propagating an error from croak? */
79072805 1237IEXT int Idelaymagic; /* ($<,$>) = ... */
2304df62 1238IEXT bool Idirty; /* In the middle of tearing things down? */
79072805 1239IEXT bool Ilocalizing; /* are we processing a local() list? */
79072805 1240IEXT bool Itainted; /* using variables controlled by $< */
463ee0b2 1241IEXT bool Itainting; /* doing taint checks */
79072805
LW
1242
1243/* trace state */
1244IEXT I32 Idlevel;
1245IEXT I32 Idlmax IINIT(128);
1246IEXT char * Idebname;
1247IEXT char * Idebdelim;
1248
1249/* current interpreter roots */
463ee0b2
LW
1250IEXT OP * Imain_root;
1251IEXT OP * Imain_start;
1252IEXT OP * Ieval_root;
1253IEXT OP * Ieval_start;
79072805
LW
1254
1255/* runtime control stuff */
1256IEXT COP * VOL Icurcop IINIT(&compiling);
1257IEXT line_t Icopline IINIT(NOLINE);
1258IEXT CONTEXT * Icxstack;
1259IEXT I32 Icxstack_ix IINIT(-1);
1260IEXT I32 Icxstack_max IINIT(128);
1261IEXT jmp_buf Itop_env;
1262
1263/* stack stuff */
1264IEXT AV * Istack; /* THE STACK */
1265IEXT AV * Imainstack; /* the stack when nothing funny is happening */
1266IEXT SV ** Imystack_base; /* stack->array_ary */
1267IEXT SV ** Imystack_sp; /* stack pointer now */
1268IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */
1269
1270/* format accumulators */
463ee0b2
LW
1271IEXT SV * Iformtarget;
1272IEXT SV * Ibodytarget;
1273IEXT SV * Itoptarget;
79072805
LW
1274
1275/* statics moved here for shared library purposes */
93a17b20 1276IEXT SV Istrchop; /* return value from chop */
79072805
LW
1277IEXT int Ifilemode; /* so nextargv() can preserve mode */
1278IEXT int Ilastfd; /* what to preserve mode on */
1279IEXT char * Ioldname; /* what to preserve mode on */
1280IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */
1281IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */
1282IEXT OP * Isortcop; /* user defined sort routine */
1283IEXT HV * Isortstash; /* which is in some package or other */
1284IEXT GV * Ifirstgv; /* $a */
1285IEXT GV * Isecondgv; /* $b */
1286IEXT AV * Isortstack; /* temp stack during pp_sort() */
1287IEXT AV * Isignalstack; /* temp stack during sighandler() */
1288IEXT SV * Imystrk; /* temp key string for do_each() */
1289IEXT I32 Idumplvl; /* indentation level on syntax tree dump */
79072805
LW
1290IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */
1291IEXT I32 Igensym; /* next symbol for getsym() to define */
1292IEXT bool Ipreambled;
1293IEXT int Ilaststatval IINIT(-1);
1294IEXT I32 Ilaststype IINIT(OP_STAT);
1295
1296#undef IEXT
1297#undef IINIT
1298
8990e307 1299#ifdef MULTIPLICITY
79072805
LW
1300};
1301#else
1302struct interpreter {
1303 char broiled;
1304};
1305#endif
1306
1307#include "pp.h"
1308
1309#ifdef __cplusplus
1310extern "C" {
1311#endif
1312
2304df62
AD
1313#ifdef STANDARD_C
1314# include <stdarg.h>
1315#else
1316# ifdef I_VARARGS
1317# include <varargs.h>
1318# endif
1319#endif
1320
79072805
LW
1321#include "proto.h"
1322
1323#ifdef __cplusplus
1324};
1325#endif
1326
93a17b20 1327/* The following must follow proto.h */
79072805
LW
1328
1329#ifdef DOINIT
463ee0b2
LW
1330MGVTBL vtbl_sv = {magic_get,
1331 magic_set,
1332 magic_len,
1333 0, 0};
1334MGVTBL vtbl_env = {0, 0, 0, 0, 0};
1335MGVTBL vtbl_envelem = {0, magic_setenv,
85e6fe83
LW
1336 0, magic_clearenv,
1337 0};
463ee0b2
LW
1338MGVTBL vtbl_sig = {0, 0, 0, 0, 0};
1339MGVTBL vtbl_sigelem = {0, magic_setsig,
1340 0, 0, 0};
1341MGVTBL vtbl_pack = {0, 0,
1342 0, 0, 0};
1343MGVTBL vtbl_packelem = {magic_getpack,
1344 magic_setpack,
1345 0, magic_clearpack,
1346 0};
1347MGVTBL vtbl_dbline = {0, magic_setdbline,
1348 0, 0, 0};
1349MGVTBL vtbl_isa = {0, magic_setisa,
1350 0, 0, 0};
1351MGVTBL vtbl_isaelem = {0, magic_setisa,
1352 0, 0, 0};
1353MGVTBL vtbl_arylen = {magic_getarylen,
1354 magic_setarylen,
1355 0, 0, 0};
1356MGVTBL vtbl_glob = {magic_getglob,
1357 magic_setglob,
1358 0, 0, 0};
1359MGVTBL vtbl_mglob = {0, magic_setmglob,
1360 0, 0, 0};
1361MGVTBL vtbl_taint = {magic_gettaint,magic_settaint,
1362 0, 0, 0};
1363MGVTBL vtbl_substr = {0, magic_setsubstr,
1364 0, 0, 0};
1365MGVTBL vtbl_vec = {0, magic_setvec,
1366 0, 0, 0};
1367MGVTBL vtbl_bm = {0, magic_setbm,
1368 0, 0, 0};
1369MGVTBL vtbl_uvar = {magic_getuvar,
1370 magic_setuvar,
1371 0, 0, 0};
79072805
LW
1372#else
1373EXT MGVTBL vtbl_sv;
1374EXT MGVTBL vtbl_env;
1375EXT MGVTBL vtbl_envelem;
1376EXT MGVTBL vtbl_sig;
1377EXT MGVTBL vtbl_sigelem;
463ee0b2
LW
1378EXT MGVTBL vtbl_pack;
1379EXT MGVTBL vtbl_packelem;
79072805 1380EXT MGVTBL vtbl_dbline;
463ee0b2
LW
1381EXT MGVTBL vtbl_isa;
1382EXT MGVTBL vtbl_isaelem;
79072805
LW
1383EXT MGVTBL vtbl_arylen;
1384EXT MGVTBL vtbl_glob;
93a17b20 1385EXT MGVTBL vtbl_mglob;
463ee0b2 1386EXT MGVTBL vtbl_taint;
79072805
LW
1387EXT MGVTBL vtbl_substr;
1388EXT MGVTBL vtbl_vec;
1389EXT MGVTBL vtbl_bm;
1390EXT MGVTBL vtbl_uvar;
1391#endif
85e6fe83
LW
1392
1393#endif /* Include guard */