This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 4.0 patch 27: patch #20, continued
[perl5.git] / perl.h
... / ...
CommitLineData
1/* $RCSfile: perl.h,v $$Revision: 4.0.1.5 $$Date: 91/11/11 16:41:07 $
2 *
3 * Copyright (c) 1991, Larry Wall
4 *
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.
7 *
8 * $Log: perl.h,v $
9 * Revision 4.0.1.5 91/11/11 16:41:07 lwall
10 * patch19: uts wrongly defines S_ISDIR() et al
11 * patch19: too many preprocessors can't expand a macro right in #if
12 * patch19: added little-endian pack/unpack options
13 *
14 * Revision 4.0.1.4 91/11/05 18:06:10 lwall
15 * patch11: various portability fixes
16 * patch11: added support for dbz
17 * patch11: added some support for 64-bit integers
18 * patch11: hex() didn't understand leading 0x
19 *
20 * Revision 4.0.1.3 91/06/10 01:25:10 lwall
21 * patch10: certain pattern optimizations were botched
22 *
23 * Revision 4.0.1.2 91/06/07 11:28:33 lwall
24 * patch4: new copyright notice
25 * patch4: made some allowances for "semi-standard" C
26 * patch4: many, many itty-bitty portability fixes
27 *
28 * Revision 4.0.1.1 91/04/11 17:49:51 lwall
29 * patch1: hopefully straightened out some of the Xenix mess
30 *
31 * Revision 4.0 91/03/20 01:37:56 lwall
32 * 4.0 baseline.
33 *
34 */
35
36#define VOIDWANT 1
37#include "config.h"
38
39#ifdef MYMALLOC
40# ifdef HIDEMYMALLOC
41# define malloc Mymalloc
42# define realloc Myremalloc
43# define free Myfree
44# endif
45# define safemalloc malloc
46# define saferealloc realloc
47# define safefree free
48#endif
49
50/* work around some libPW problems */
51#define fatal Myfatal
52#ifdef DOINIT
53char Error[1];
54#endif
55
56#ifdef MSDOS
57/* This stuff now in the MS-DOS config.h file. */
58#else /* !MSDOS */
59
60/*
61 * The following symbols are defined if your operating system supports
62 * functions by that name. All Unixes I know of support them, thus they
63 * are not checked by the configuration script, but are directly defined
64 * here.
65 */
66#define HAS_ALARM
67#define HAS_CHOWN
68#define HAS_CHROOT
69#define HAS_FORK
70#define HAS_GETLOGIN
71#define HAS_GETPPID
72#define HAS_KILL
73#define HAS_LINK
74#define HAS_PIPE
75#define HAS_WAIT
76#define HAS_UMASK
77/*
78 * The following symbols are defined if your operating system supports
79 * password and group functions in general. All Unix systems do.
80 */
81#define HAS_GROUP
82#define HAS_PASSWD
83
84#endif /* !MSDOS */
85
86#if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
87# define STANDARD_C 1
88#endif
89
90#if defined(HASVOLATILE) || defined(STANDARD_C)
91#define VOLATILE volatile
92#else
93#define VOLATILE
94#endif
95
96#ifdef IAMSUID
97# ifndef TAINT
98# define TAINT
99# endif
100#endif
101
102#ifndef HAS_VFORK
103# define vfork fork
104#endif
105
106#ifdef HAS_GETPGRP2
107# ifndef HAS_GETPGRP
108# define HAS_GETPGRP
109# endif
110# define getpgrp getpgrp2
111#endif
112
113#ifdef HAS_SETPGRP2
114# ifndef HAS_SETPGRP
115# define HAS_SETPGRP
116# endif
117# define setpgrp setpgrp2
118#endif
119
120#include <stdio.h>
121#include <ctype.h>
122#include <setjmp.h>
123#ifndef MSDOS
124#ifdef PARAM_NEEDS_TYPES
125#include <sys/types.h>
126#endif
127#include <sys/param.h>
128#endif
129#ifdef STANDARD_C
130/* Use all the "standard" definitions */
131#include <stdlib.h>
132#include <string.h>
133#endif /* STANDARD_C */
134
135#if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234
136#undef HAS_MEMCMP
137#endif
138
139#ifdef HAS_MEMCPY
140
141# ifndef STANDARD_C
142# ifndef memcpy
143extern char * memcpy(), *memset();
144extern int memcmp();
145# endif /* ndef memcpy */
146# endif /* ndef STANDARD_C */
147
148# ifndef bcopy
149# define bcopy(s1,s2,l) memcpy(s2,s1,l)
150# endif
151# ifndef bzero
152# define bzero(s,l) memset(s,0,l)
153# endif
154#endif /* HAS_MEMCPY */
155
156#ifndef HAS_BCMP /* prefer bcmp slightly 'cuz it doesn't order */
157# ifndef bcmp
158# define bcmp(s1,s2,l) memcmp(s1,s2,l)
159# endif
160#endif
161
162#ifndef _TYPES_ /* If types.h defines this it's easy. */
163#ifndef major /* Does everyone's types.h define this? */
164#include <sys/types.h>
165#endif
166#endif
167
168#ifdef I_NETINET_IN
169#include <netinet/in.h>
170#endif
171
172#include <sys/stat.h>
173#ifdef uts
174#undef S_ISDIR
175#undef S_ISCHR
176#undef S_ISBLK
177#undef S_ISREG
178#undef S_ISFIFO
179#undef S_ISLNK
180#define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
181#define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
182#define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
183#define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
184#define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
185#define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
186#endif
187
188#ifdef I_TIME
189# include <time.h>
190#endif
191
192#ifdef I_SYS_TIME
193# ifdef SYSTIMEKERNEL
194# define KERNEL
195# endif
196# include <sys/time.h>
197# ifdef SYSTIMEKERNEL
198# undef KERNEL
199# endif
200#endif
201
202#ifndef MSDOS
203#include <sys/times.h>
204#endif
205
206#if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
207#undef HAS_STRERROR
208#endif
209
210#include <errno.h>
211#ifndef MSDOS
212#ifndef errno
213extern int errno; /* ANSI allows errno to be an lvalue expr */
214#endif
215#endif
216
217#ifndef strerror
218#ifdef HAS_STRERROR
219char *strerror();
220#else
221extern int sys_nerr;
222extern char *sys_errlist[];
223#define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
224#endif
225#endif
226
227#ifdef I_SYSIOCTL
228#ifndef _IOCTL_
229#include <sys/ioctl.h>
230#endif
231#endif
232
233#if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
234#ifdef HAS_SOCKETPAIR
235#undef HAS_SOCKETPAIR
236#endif
237#ifdef HAS_NDBM
238#undef HAS_NDBM
239#endif
240#endif
241
242#ifdef WANT_DBZ
243#include <dbz.h>
244#define SOME_DBM
245#define dbm_fetch(db,dkey) fetch(dkey)
246#define dbm_delete(db,dkey) fatal("dbz doesn't implement delete")
247#define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
248#define dbm_close(db) dbmclose()
249#define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch())
250#define nextkey() (fatal("dbz doesn't implement traversal"),fetch())
251#define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch())
252#ifdef HAS_NDBM
253#undef HAS_NDBM
254#endif
255#ifndef HAS_ODBM
256#define HAS_ODBM
257#endif
258#else
259#ifdef HAS_GDBM
260#ifdef I_GDBM
261#include <gdbm.h>
262#endif
263#define SOME_DBM
264#ifdef HAS_NDBM
265#undef HAS_NDBM
266#endif
267#ifdef HAS_ODBM
268#undef HAS_ODBM
269#endif
270#else
271#ifdef HAS_NDBM
272#include <ndbm.h>
273#define SOME_DBM
274#ifdef HAS_ODBM
275#undef HAS_ODBM
276#endif
277#else
278#ifdef HAS_ODBM
279#ifdef NULL
280#undef NULL /* suppress redefinition message */
281#endif
282#include <dbm.h>
283#ifdef NULL
284#undef NULL
285#endif
286#define NULL 0 /* silly thing is, we don't even use this */
287#define SOME_DBM
288#define dbm_fetch(db,dkey) fetch(dkey)
289#define dbm_delete(db,dkey) delete(dkey)
290#define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
291#define dbm_close(db) dbmclose()
292#define dbm_firstkey(db) firstkey()
293#endif /* HAS_ODBM */
294#endif /* HAS_NDBM */
295#endif /* HAS_GDBM */
296#endif /* WANT_DBZ */
297#ifdef SOME_DBM
298EXT char *dbmkey;
299EXT int dbmlen;
300#endif
301
302#if INTSIZE == 2
303#define htoni htons
304#define ntohi ntohs
305#else
306#define htoni htonl
307#define ntohi ntohl
308#endif
309
310#if defined(I_DIRENT)
311# include <dirent.h>
312# define DIRENT dirent
313#else
314# ifdef I_SYS_NDIR
315# include <sys/ndir.h>
316# define DIRENT direct
317# else
318# ifdef I_SYS_DIR
319# ifdef hp9000s500
320# include <ndir.h> /* may be wrong in the future */
321# else
322# include <sys/dir.h>
323# endif
324# define DIRENT direct
325# endif
326# endif
327#endif
328
329#ifdef FPUTS_BOTCH
330/* work around botch in SunOS 4.0.1 and 4.0.2 */
331# ifndef fputs
332# define fputs(str,fp) fprintf(fp,"%s",str)
333# endif
334#endif
335
336/*
337 * The following gobbledygook brought to you on behalf of __STDC__.
338 * (I could just use #ifndef __STDC__, but this is more bulletproof
339 * in the face of half-implementations.)
340 */
341
342#ifndef S_IFMT
343# ifdef _S_IFMT
344# define S_IFMT _S_IFMT
345# else
346# define S_IFMT 0170000
347# endif
348#endif
349
350#ifndef S_ISDIR
351# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
352#endif
353
354#ifndef S_ISCHR
355# define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
356#endif
357
358#ifndef S_ISBLK
359# ifdef S_IFBLK
360# define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
361# else
362# define S_ISBLK(m) (0)
363# endif
364#endif
365
366#ifndef S_ISREG
367# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
368#endif
369
370#ifndef S_ISFIFO
371# ifdef S_IFIFO
372# define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
373# else
374# define S_ISFIFO(m) (0)
375# endif
376#endif
377
378#ifndef S_ISLNK
379# ifdef _S_ISLNK
380# define S_ISLNK(m) _S_ISLNK(m)
381# else
382# ifdef _S_IFLNK
383# define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
384# else
385# ifdef S_IFLNK
386# define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
387# else
388# define S_ISLNK(m) (0)
389# endif
390# endif
391# endif
392#endif
393
394#ifndef S_ISSOCK
395# ifdef _S_ISSOCK
396# define S_ISSOCK(m) _S_ISSOCK(m)
397# else
398# ifdef _S_IFSOCK
399# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
400# else
401# ifdef S_IFSOCK
402# define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
403# else
404# define S_ISSOCK(m) (0)
405# endif
406# endif
407# endif
408#endif
409
410#ifndef S_IRUSR
411# ifdef S_IREAD
412# define S_IRUSR S_IREAD
413# define S_IWUSR S_IWRITE
414# define S_IXUSR S_IEXEC
415# else
416# define S_IRUSR 0400
417# define S_IWUSR 0200
418# define S_IXUSR 0100
419# endif
420# define S_IRGRP (S_IRUSR>>3)
421# define S_IWGRP (S_IWUSR>>3)
422# define S_IXGRP (S_IXUSR>>3)
423# define S_IROTH (S_IRUSR>>6)
424# define S_IWOTH (S_IWUSR>>6)
425# define S_IXOTH (S_IXUSR>>6)
426#endif
427
428#ifndef S_ISUID
429# define S_ISUID 04000
430#endif
431
432#ifndef S_ISGID
433# define S_ISGID 02000
434#endif
435
436#ifdef f_next
437#undef f_next
438#endif
439
440#if defined(cray) || defined(gould)
441# define SLOPPYDIVIDE
442#endif
443
444#if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
445# define QUAD
446#endif
447
448#ifdef QUAD
449# ifdef cray
450# define quad int
451# else
452# if defined(convex) || defined (uts)
453# define quad long long
454# else
455# define quad long
456# endif
457# endif
458#endif
459
460typedef unsigned int STRLEN;
461
462typedef struct arg ARG;
463typedef struct cmd CMD;
464typedef struct formcmd FCMD;
465typedef struct scanpat SPAT;
466typedef struct stio STIO;
467typedef struct sub SUBR;
468typedef struct string STR;
469typedef struct atbl ARRAY;
470typedef struct htbl HASH;
471typedef struct regexp REGEXP;
472typedef struct stabptrs STBP;
473typedef struct stab STAB;
474typedef struct callsave CSV;
475
476#include "handy.h"
477#include "regexp.h"
478#include "str.h"
479#include "util.h"
480#include "form.h"
481#include "stab.h"
482#include "spat.h"
483#include "arg.h"
484#include "cmd.h"
485#include "array.h"
486#include "hash.h"
487
488#if defined(iAPX286) || defined(M_I286) || defined(I80286)
489# define I286
490#endif
491
492#ifndef STANDARD_C
493#ifdef CHARSPRINTF
494 char *sprintf();
495#else
496 int sprintf();
497#endif
498#endif
499
500EXT char *Yes INIT("1");
501EXT char *No INIT("");
502
503/* "gimme" values */
504
505/* Note: cmd.c assumes that it can use && to produce one of these values! */
506#define G_SCALAR 0
507#define G_ARRAY 1
508
509#ifdef CRIPPLED_CC
510int str_true();
511#else /* !CRIPPLED_CC */
512#define str_true(str) (Str = (str), \
513 (Str->str_pok ? \
514 ((*Str->str_ptr > '0' || \
515 Str->str_cur > 1 || \
516 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
517 : \
518 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
519#endif /* CRIPPLED_CC */
520
521#ifdef DEBUGGING
522#define str_peek(str) (Str = (str), \
523 (Str->str_pok ? \
524 Str->str_ptr : \
525 (Str->str_nok ? \
526 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
527 (char*)tokenbuf) : \
528 "" )))
529#endif
530
531#ifdef CRIPPLED_CC
532char *str_get();
533#else
534#ifdef TAINT
535#define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
536 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
537#else
538#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
539#endif /* TAINT */
540#endif /* CRIPPLED_CC */
541
542#ifdef CRIPPLED_CC
543double str_gnum();
544#else /* !CRIPPLED_CC */
545#ifdef TAINT
546#define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
547 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
548#else /* !TAINT */
549#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
550#endif /* TAINT*/
551#endif /* CRIPPLED_CC */
552EXT STR *Str;
553
554#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
555
556#ifndef MSDOS
557#define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
558#define Str_Grow str_grow
559#else
560/* extra parentheses intentionally NOT placed around "len"! */
561#define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
562 str_grow(str,(unsigned long)len)
563#define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
564#endif /* MSDOS */
565
566#ifndef BYTEORDER
567#define BYTEORDER 0x1234
568#endif
569
570#if defined(htonl) && !defined(HAS_HTONL)
571#define HAS_HTONL
572#endif
573#if defined(htons) && !defined(HAS_HTONS)
574#define HAS_HTONS
575#endif
576#if defined(ntohl) && !defined(HAS_NTOHL)
577#define HAS_NTOHL
578#endif
579#if defined(ntohs) && !defined(HAS_NTOHS)
580#define HAS_NTOHS
581#endif
582#ifndef HAS_HTONL
583#if (BYTEORDER & 0xffff) != 0x4321
584#define HAS_HTONS
585#define HAS_HTONL
586#define HAS_NTOHS
587#define HAS_NTOHL
588#define MYSWAP
589#define htons my_swap
590#define htonl my_htonl
591#define ntohs my_swap
592#define ntohl my_ntohl
593#endif
594#else
595#if (BYTEORDER & 0xffff) == 0x4321
596#undef HAS_HTONS
597#undef HAS_HTONL
598#undef HAS_NTOHS
599#undef HAS_NTOHL
600#endif
601#endif
602
603/*
604 * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
605 * -DWS
606 */
607#if BYTEORDER != 0x1234
608# define HAS_VTOHL
609# define HAS_VTOHS
610# define HAS_HTOVL
611# define HAS_HTOVS
612# if BYTEORDER == 0x4321
613# define vtohl(x) ((((x)&0xFF)<<24) \
614 +(((x)>>24)&0xFF) \
615 +(((x)&0x0000FF00)<<8) \
616 +(((x)&0x00FF0000)>>8) )
617# define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
618# define htovl(x) vtohl(x)
619# define htovs(x) vtohs(x)
620# endif
621 /* otherwise default to functions in util.c */
622#endif
623
624#ifdef CASTNEGFLOAT
625#define U_S(what) ((unsigned short)(what))
626#define U_I(what) ((unsigned int)(what))
627#define U_L(what) ((unsigned long)(what))
628#else
629unsigned long castulong();
630#define U_S(what) ((unsigned int)castulong(what))
631#define U_I(what) ((unsigned int)castulong(what))
632#define U_L(what) (castulong(what))
633#endif
634
635CMD *add_label();
636CMD *block_head();
637CMD *append_line();
638CMD *make_acmd();
639CMD *make_ccmd();
640CMD *make_icmd();
641CMD *invert();
642CMD *addcond();
643CMD *addloop();
644CMD *wopt();
645CMD *over();
646
647STAB *stabent();
648STAB *genstab();
649
650ARG *stab2arg();
651ARG *op_new();
652ARG *make_op();
653ARG *make_match();
654ARG *make_split();
655ARG *rcatmaybe();
656ARG *listish();
657ARG *maybelistish();
658ARG *localize();
659ARG *fixeval();
660ARG *jmaybe();
661ARG *l();
662ARG *fixl();
663ARG *mod_match();
664ARG *make_list();
665ARG *cmd_to_arg();
666ARG *addflags();
667ARG *hide_ary();
668ARG *cval_to_arg();
669
670STR *str_new();
671STR *stab_str();
672
673int do_each();
674int do_subr();
675int do_match();
676int do_unpack();
677int eval(); /* this evaluates expressions */
678int do_eval(); /* this evaluates eval operator */
679int do_assign();
680
681SUBR *make_sub();
682
683FCMD *load_format();
684
685char *scanpat();
686char *scansubst();
687char *scantrans();
688char *scanstr();
689char *scanident();
690char *str_append_till();
691char *str_gets();
692char *str_grow();
693
694bool do_open();
695bool do_close();
696bool do_print();
697bool do_aprint();
698bool do_exec();
699bool do_aexec();
700
701int do_subst();
702int cando();
703int ingroup();
704
705void str_replace();
706void str_inc();
707void str_dec();
708void str_free();
709void stab_clear();
710void do_join();
711void do_sprintf();
712void do_accept();
713void do_pipe();
714void do_vecset();
715void do_unshift();
716void do_execfree();
717void magicalize();
718void magicname();
719void savelist();
720void saveitem();
721void saveint();
722void savelong();
723void savesptr();
724void savehptr();
725void restorelist();
726void repeatcpy();
727HASH *savehash();
728ARRAY *saveary();
729
730EXT char **origargv;
731EXT int origargc;
732EXT char **origenviron;
733extern char **environ;
734
735EXT long subline INIT(0);
736EXT STR *subname INIT(Nullstr);
737EXT int arybase INIT(0);
738
739struct outrec {
740 long o_lines;
741 char *o_str;
742 int o_len;
743};
744
745EXT struct outrec outrec;
746EXT struct outrec toprec;
747
748EXT STAB *stdinstab INIT(Nullstab);
749EXT STAB *last_in_stab INIT(Nullstab);
750EXT STAB *defstab INIT(Nullstab);
751EXT STAB *argvstab INIT(Nullstab);
752EXT STAB *envstab INIT(Nullstab);
753EXT STAB *sigstab INIT(Nullstab);
754EXT STAB *defoutstab INIT(Nullstab);
755EXT STAB *curoutstab INIT(Nullstab);
756EXT STAB *argvoutstab INIT(Nullstab);
757EXT STAB *incstab INIT(Nullstab);
758EXT STAB *leftstab INIT(Nullstab);
759EXT STAB *amperstab INIT(Nullstab);
760EXT STAB *rightstab INIT(Nullstab);
761EXT STAB *DBstab INIT(Nullstab);
762EXT STAB *DBline INIT(Nullstab);
763EXT STAB *DBsub INIT(Nullstab);
764
765EXT HASH *defstash; /* main symbol table */
766EXT HASH *curstash; /* symbol table for current package */
767EXT HASH *debstash; /* symbol table for perldb package */
768
769EXT STR *curstname; /* name of current package */
770
771EXT STR *freestrroot INIT(Nullstr);
772EXT STR *lastretstr INIT(Nullstr);
773EXT STR *DBsingle INIT(Nullstr);
774EXT STR *DBtrace INIT(Nullstr);
775EXT STR *DBsignal INIT(Nullstr);
776
777EXT int lastspbase;
778EXT int lastsize;
779
780EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
781EXT char *origfilename;
782EXT FILE * VOLATILE rsfp;
783EXT char buf[1024];
784EXT char *bufptr;
785EXT char *oldbufptr;
786EXT char *oldoldbufptr;
787EXT char *bufend;
788
789EXT STR *linestr INIT(Nullstr);
790
791EXT char *rs INIT("\n");
792EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */
793EXT int rslen INIT(1);
794EXT char *ofs INIT(Nullch);
795EXT int ofslen INIT(0);
796EXT char *ors INIT(Nullch);
797EXT int orslen INIT(0);
798EXT char *ofmt INIT(Nullch);
799EXT char *inplace INIT(Nullch);
800EXT char *nointrp INIT("");
801
802EXT bool preprocess INIT(FALSE);
803EXT bool minus_n INIT(FALSE);
804EXT bool minus_p INIT(FALSE);
805EXT bool minus_l INIT(FALSE);
806EXT bool minus_a INIT(FALSE);
807EXT bool doswitches INIT(FALSE);
808EXT bool dowarn INIT(FALSE);
809EXT bool doextract INIT(FALSE);
810EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
811EXT bool sawampersand INIT(FALSE); /* must save all match strings */
812EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
813EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
814EXT bool sawvec INIT(FALSE);
815EXT bool localizing INIT(FALSE); /* are we processing a local() list? */
816
817#ifndef MAXSYSFD
818# define MAXSYSFD 2
819#endif
820EXT int maxsysfd INIT(MAXSYSFD); /* top fd to pass to subprocesses */
821
822#ifdef CSH
823char *cshname INIT(CSH);
824int cshlen INIT(0);
825#endif /* CSH */
826
827#ifdef TAINT
828EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
829#endif
830
831#ifndef MSDOS
832#define TMPPATH "/tmp/perl-eXXXXXX"
833#else
834#define TMPPATH "plXXXXXX"
835#endif /* MSDOS */
836EXT char *e_tmpname;
837EXT FILE *e_fp INIT(Nullfp);
838
839EXT char tokenbuf[256];
840EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
841EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */
842EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
843EXT int forkprocess; /* so do_open |- can return proc# */
844EXT int do_undump INIT(0); /* -u or dump seen? */
845EXT int error_count INIT(0); /* how many errors so far, max 10 */
846EXT int multi_start INIT(0); /* 1st line of multi-line string */
847EXT int multi_end INIT(0); /* last line of multi-line string */
848EXT int multi_open INIT(0); /* delimiter of said string */
849EXT int multi_close INIT(0); /* delimiter of said string */
850
851FILE *popen();
852/* char *str_get(); */
853STR *interp();
854void free_arg();
855STIO *stio_new();
856void hoistmust();
857void scanconst();
858
859EXT struct stat statbuf;
860EXT struct stat statcache;
861STAB *statstab INIT(Nullstab);
862STR *statname;
863#ifndef MSDOS
864EXT struct tms timesbuf;
865#endif
866EXT int uid;
867EXT int euid;
868EXT int gid;
869EXT int egid;
870UIDTYPE getuid();
871UIDTYPE geteuid();
872GIDTYPE getgid();
873GIDTYPE getegid();
874EXT int unsafe;
875
876#ifdef DEBUGGING
877EXT VOLATILE int debug INIT(0);
878EXT int dlevel INIT(0);
879EXT int dlmax INIT(128);
880EXT char *debname;
881EXT char *debdelim;
882#define YYDEBUG 1
883#endif
884EXT int perldb INIT(0);
885#define YYMAXDEPTH 300
886
887EXT line_t cmdline INIT(NOLINE);
888
889EXT STR str_undef;
890EXT STR str_no;
891EXT STR str_yes;
892
893/* runtime control stuff */
894
895EXT struct loop {
896 char *loop_label; /* what the loop was called, if anything */
897 int loop_sp; /* stack pointer to copy stuff down to */
898 jmp_buf loop_env;
899} *loop_stack;
900
901EXT int loop_ptr INIT(-1);
902EXT int loop_max INIT(128);
903
904EXT jmp_buf top_env;
905
906EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
907
908struct ufuncs {
909 int (*uf_val)();
910 int (*uf_set)();
911 int uf_index;
912};
913
914EXT ARRAY *stack; /* THE STACK */
915
916EXT ARRAY * VOLATILE savestack; /* to save non-local values on */
917
918EXT ARRAY *tosave; /* strings to save on recursive subroutine */
919
920EXT ARRAY *lineary; /* lines of script for debugger */
921EXT ARRAY *dbargs; /* args to call listed by caller function */
922
923EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */
924EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */
925
926EXT int *di; /* for tmp use in debuggers */
927EXT char *dc;
928EXT short *ds;
929
930/* Fix these up for __STDC__ */
931EXT long basetime INIT(0);
932char *mktemp();
933#ifndef STANDARD_C
934/* All of these are in stdlib.h or time.h for ANSI C */
935double atof();
936long time();
937struct tm *gmtime(), *localtime();
938char *index(), *rindex();
939char *strcpy(), *strcat();
940#endif /* ! STANDARD_C */
941
942#ifdef EUNICE
943#define UNLINK unlnk
944int unlnk();
945#else
946#define UNLINK unlink
947#endif
948
949#ifndef HAS_SETREUID
950#ifdef HAS_SETRESUID
951#define setreuid(r,e) setresuid(r,e,-1)
952#define HAS_SETREUID
953#endif
954#endif
955#ifndef HAS_SETREGID
956#ifdef HAS_SETRESGID
957#define setregid(r,e) setresgid(r,e,-1)
958#define HAS_SETREGID
959#endif
960#endif