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