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