perl 4.0 patch 19: (combined patch)
[p5sagit/p5-mst-13.2.git] / perl.h
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
53 char 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
143 extern char * memcpy(), *memset();
144 extern 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
213 extern int errno;     /* ANSI allows errno to be an lvalue expr */
214 #endif
215 #endif
216
217 #ifndef strerror
218 #ifdef HAS_STRERROR
219 char *strerror();
220 #else
221 extern int sys_nerr;
222 extern 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
298 EXT char *dbmkey;
299 EXT 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
460 typedef unsigned int STRLEN;
461
462 typedef struct arg ARG;
463 typedef struct cmd CMD;
464 typedef struct formcmd FCMD;
465 typedef struct scanpat SPAT;
466 typedef struct stio STIO;
467 typedef struct sub SUBR;
468 typedef struct string STR;
469 typedef struct atbl ARRAY;
470 typedef struct htbl HASH;
471 typedef struct regexp REGEXP;
472 typedef struct stabptrs STBP;
473 typedef struct stab STAB;
474 typedef 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
500 EXT char *Yes INIT("1");
501 EXT 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
510 int 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
532 char *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
543 double 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 */
552 EXT 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
629 unsigned 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
635 CMD *add_label();
636 CMD *block_head();
637 CMD *append_line();
638 CMD *make_acmd();
639 CMD *make_ccmd();
640 CMD *make_icmd();
641 CMD *invert();
642 CMD *addcond();
643 CMD *addloop();
644 CMD *wopt();
645 CMD *over();
646
647 STAB *stabent();
648 STAB *genstab();
649
650 ARG *stab2arg();
651 ARG *op_new();
652 ARG *make_op();
653 ARG *make_match();
654 ARG *make_split();
655 ARG *rcatmaybe();
656 ARG *listish();
657 ARG *maybelistish();
658 ARG *localize();
659 ARG *fixeval();
660 ARG *jmaybe();
661 ARG *l();
662 ARG *fixl();
663 ARG *mod_match();
664 ARG *make_list();
665 ARG *cmd_to_arg();
666 ARG *addflags();
667 ARG *hide_ary();
668 ARG *cval_to_arg();
669
670 STR *str_new();
671 STR *stab_str();
672
673 int do_each();
674 int do_subr();
675 int do_match();
676 int do_unpack();
677 int eval();             /* this evaluates expressions */
678 int do_eval();          /* this evaluates eval operator */
679 int do_assign();
680
681 SUBR *make_sub();
682
683 FCMD *load_format();
684
685 char *scanpat();
686 char *scansubst();
687 char *scantrans();
688 char *scanstr();
689 char *scanident();
690 char *str_append_till();
691 char *str_gets();
692 char *str_grow();
693
694 bool do_open();
695 bool do_close();
696 bool do_print();
697 bool do_aprint();
698 bool do_exec();
699 bool do_aexec();
700
701 int do_subst();
702 int cando();
703 int ingroup();
704
705 void str_replace();
706 void str_inc();
707 void str_dec();
708 void str_free();
709 void stab_clear();
710 void do_join();
711 void do_sprintf();
712 void do_accept();
713 void do_pipe();
714 void do_vecset();
715 void do_unshift();
716 void do_execfree();
717 void magicalize();
718 void magicname();
719 void savelist();
720 void saveitem();
721 void saveint();
722 void savelong();
723 void savesptr();
724 void savehptr();
725 void restorelist();
726 void repeatcpy();
727 HASH *savehash();
728 ARRAY *saveary();
729
730 EXT char **origargv;
731 EXT int origargc;
732 EXT char **origenviron;
733 extern char **environ;
734
735 EXT long subline INIT(0);
736 EXT STR *subname INIT(Nullstr);
737 EXT int arybase INIT(0);
738
739 struct outrec {
740     long        o_lines;
741     char        *o_str;
742     int         o_len;
743 };
744
745 EXT struct outrec outrec;
746 EXT struct outrec toprec;
747
748 EXT STAB *stdinstab INIT(Nullstab);
749 EXT STAB *last_in_stab INIT(Nullstab);
750 EXT STAB *defstab INIT(Nullstab);
751 EXT STAB *argvstab INIT(Nullstab);
752 EXT STAB *envstab INIT(Nullstab);
753 EXT STAB *sigstab INIT(Nullstab);
754 EXT STAB *defoutstab INIT(Nullstab);
755 EXT STAB *curoutstab INIT(Nullstab);
756 EXT STAB *argvoutstab INIT(Nullstab);
757 EXT STAB *incstab INIT(Nullstab);
758 EXT STAB *leftstab INIT(Nullstab);
759 EXT STAB *amperstab INIT(Nullstab);
760 EXT STAB *rightstab INIT(Nullstab);
761 EXT STAB *DBstab INIT(Nullstab);
762 EXT STAB *DBline INIT(Nullstab);
763 EXT STAB *DBsub INIT(Nullstab);
764
765 EXT HASH *defstash;             /* main symbol table */
766 EXT HASH *curstash;             /* symbol table for current package */
767 EXT HASH *debstash;             /* symbol table for perldb package */
768
769 EXT STR *curstname;             /* name of current package */
770
771 EXT STR *freestrroot INIT(Nullstr);
772 EXT STR *lastretstr INIT(Nullstr);
773 EXT STR *DBsingle INIT(Nullstr);
774 EXT STR *DBtrace INIT(Nullstr);
775 EXT STR *DBsignal INIT(Nullstr);
776
777 EXT int lastspbase;
778 EXT int lastsize;
779
780 EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
781 EXT char *origfilename;
782 EXT FILE * VOLATILE rsfp;
783 EXT char buf[1024];
784 EXT char *bufptr;
785 EXT char *oldbufptr;
786 EXT char *oldoldbufptr;
787 EXT char *bufend;
788
789 EXT STR *linestr INIT(Nullstr);
790
791 EXT char *rs INIT("\n");
792 EXT int rschar INIT('\n');      /* final char of rs, or 0777 if none */
793 EXT int rslen INIT(1);
794 EXT char *ofs INIT(Nullch);
795 EXT int ofslen INIT(0);
796 EXT char *ors INIT(Nullch);
797 EXT int orslen INIT(0);
798 EXT char *ofmt INIT(Nullch);
799 EXT char *inplace INIT(Nullch);
800 EXT char *nointrp INIT("");
801
802 EXT bool preprocess INIT(FALSE);
803 EXT bool minus_n INIT(FALSE);
804 EXT bool minus_p INIT(FALSE);
805 EXT bool minus_l INIT(FALSE);
806 EXT bool minus_a INIT(FALSE);
807 EXT bool doswitches INIT(FALSE);
808 EXT bool dowarn INIT(FALSE);
809 EXT bool doextract INIT(FALSE);
810 EXT bool allstabs INIT(FALSE);  /* init all customary symbols in symbol table?*/
811 EXT bool sawampersand INIT(FALSE);      /* must save all match strings */
812 EXT bool sawstudy INIT(FALSE);          /* do fbminstr on all strings */
813 EXT bool sawi INIT(FALSE);              /* study must assume case insensitive */
814 EXT bool sawvec INIT(FALSE);
815 EXT bool localizing INIT(FALSE);        /* are we processing a local() list? */
816
817 #ifndef MAXSYSFD
818 #   define MAXSYSFD 2
819 #endif
820 EXT int maxsysfd INIT(MAXSYSFD);        /* top fd to pass to subprocesses */
821
822 #ifdef CSH
823 char *cshname INIT(CSH);
824 int cshlen INIT(0);
825 #endif /* CSH */
826
827 #ifdef TAINT
828 EXT 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 */
836 EXT char *e_tmpname;
837 EXT FILE *e_fp INIT(Nullfp);
838
839 EXT char tokenbuf[256];
840 EXT int expectterm INIT(TRUE);          /* how to interpret ambiguous tokens */
841 EXT VOLATILE int in_eval INIT(FALSE);   /* trap fatal errors? */
842 EXT int multiline INIT(0);              /* $*--do strings hold >1 line? */
843 EXT int forkprocess;                    /* so do_open |- can return proc# */
844 EXT int do_undump INIT(0);              /* -u or dump seen? */
845 EXT int error_count INIT(0);            /* how many errors so far, max 10 */
846 EXT int multi_start INIT(0);            /* 1st line of multi-line string */
847 EXT int multi_end INIT(0);              /* last line of multi-line string */
848 EXT int multi_open INIT(0);             /* delimiter of said string */
849 EXT int multi_close INIT(0);            /* delimiter of said string */
850
851 FILE *popen();
852 /* char *str_get(); */
853 STR *interp();
854 void free_arg();
855 STIO *stio_new();
856 void hoistmust();
857 void scanconst();
858
859 EXT struct stat statbuf;
860 EXT struct stat statcache;
861 STAB *statstab INIT(Nullstab);
862 STR *statname;
863 #ifndef MSDOS
864 EXT struct tms timesbuf;
865 #endif
866 EXT int uid;
867 EXT int euid;
868 EXT int gid;
869 EXT int egid;
870 UIDTYPE getuid();
871 UIDTYPE geteuid();
872 GIDTYPE getgid();
873 GIDTYPE getegid();
874 EXT int unsafe;
875
876 #ifdef DEBUGGING
877 EXT VOLATILE int debug INIT(0);
878 EXT int dlevel INIT(0);
879 EXT int dlmax INIT(128);
880 EXT char *debname;
881 EXT char *debdelim;
882 #define YYDEBUG 1
883 #endif
884 EXT int perldb INIT(0);
885 #define YYMAXDEPTH 300
886
887 EXT line_t cmdline INIT(NOLINE);
888
889 EXT STR str_undef;
890 EXT STR str_no;
891 EXT STR str_yes;
892
893 /* runtime control stuff */
894
895 EXT 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
901 EXT int loop_ptr INIT(-1);
902 EXT int loop_max INIT(128);
903
904 EXT jmp_buf top_env;
905
906 EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
907
908 struct ufuncs {
909     int (*uf_val)();
910     int (*uf_set)();
911     int uf_index;
912 };
913
914 EXT ARRAY *stack;               /* THE STACK */
915
916 EXT ARRAY * VOLATILE savestack;         /* to save non-local values on */
917
918 EXT ARRAY *tosave;              /* strings to save on recursive subroutine */
919
920 EXT ARRAY *lineary;             /* lines of script for debugger */
921 EXT ARRAY *dbargs;              /* args to call listed by caller function */
922
923 EXT ARRAY *fdpid;               /* keep fd-to-pid mappings for mypopen */
924 EXT HASH *pidstatus;            /* keep pid-to-status mappings for waitpid */
925
926 EXT int *di;                    /* for tmp use in debuggers */
927 EXT char *dc;
928 EXT short *ds;
929
930 /* Fix these up for __STDC__ */
931 EXT long basetime INIT(0);
932 char *mktemp();
933 #ifndef STANDARD_C
934 /* All of these are in stdlib.h or time.h for ANSI C */
935 double atof();
936 long time();
937 struct tm *gmtime(), *localtime();
938 char *index(), *rindex();
939 char *strcpy(), *strcat();
940 #endif /* ! STANDARD_C */
941
942 #ifdef EUNICE
943 #define UNLINK unlnk
944 int 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