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