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