perl 4.0 patch 15: patch #11, continued
[p5sagit/p5-mst-13.2.git] / perl.h
1 /* $RCSfile: perl.h,v $$Revision: 4.0.1.4 $$Date: 91/11/05 18:06:10 $
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.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  * 
15  * Revision 4.0.1.3  91/06/10  01:25:10  lwall
16  * patch10: certain pattern optimizations were botched
17  * 
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  * 
23  * Revision 4.0.1.1  91/04/11  17:49:51  lwall
24  * patch1: hopefully straightened out some of the Xenix mess
25  * 
26  * Revision 4.0  91/03/20  01:37:56  lwall
27  * 4.0 baseline.
28  * 
29  */
30
31 #define VOIDWANT 1
32 #include "config.h"
33
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
48 char Error[1];
49 #endif
50
51 #ifdef MSDOS
52 /* This stuff now in the MS-DOS config.h file. */
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  */
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
72 /*
73  * The following symbols are defined if your operating system supports
74  * password and group functions in general.  All Unix systems do.
75  */
76 #define HAS_GROUP
77 #define HAS_PASSWD
78
79 #endif /* !MSDOS */
80
81 #if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
82 # define STANDARD_C 1
83 #endif
84
85 #if defined(HASVOLATILE) || defined(STANDARD_C)
86 #define VOLATILE volatile
87 #else
88 #define VOLATILE
89 #endif
90
91 #ifdef IAMSUID
92 #   ifndef TAINT
93 #       define TAINT
94 #   endif
95 #endif
96
97 #ifndef HAS_VFORK
98 #   define vfork fork
99 #endif
100
101 #ifdef HAS_GETPGRP2
102 #   ifndef HAS_GETPGRP
103 #       define HAS_GETPGRP
104 #   endif
105 #   define getpgrp getpgrp2
106 #endif
107
108 #ifdef HAS_SETPGRP2
109 #   ifndef HAS_SETPGRP
110 #       define HAS_SETPGRP
111 #   endif
112 #   define setpgrp setpgrp2
113 #endif
114
115 #include <stdio.h>
116 #include <ctype.h>
117 #include <setjmp.h>
118 #ifndef MSDOS
119 #ifdef PARAM_NEEDS_TYPES
120 #include <sys/types.h>
121 #endif
122 #include <sys/param.h>
123 #endif
124 #ifdef STANDARD_C
125 /* Use all the "standard" definitions */
126 #include <stdlib.h>
127 #include <string.h>
128 #endif /* STANDARD_C */
129
130 #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234
131 #undef HAS_MEMCMP
132 #endif
133
134 #ifdef HAS_MEMCPY
135
136 #  ifndef STANDARD_C
137 #    ifndef memcpy
138 extern char * memcpy(), *memset();
139 extern int memcmp();
140 #    endif /* ndef memcpy */
141 #  endif /* ndef STANDARD_C */
142
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
149 #endif /* HAS_MEMCPY */
150
151 #ifndef HAS_BCMP                /* prefer bcmp slightly 'cuz it doesn't order */
152 #   ifndef bcmp
153 #       define bcmp(s1,s2,l) memcmp(s1,s2,l)
154 #   endif
155 #endif
156
157 #ifndef _TYPES_         /* If types.h defines this it's easy. */
158 #ifndef major           /* Does everyone's types.h define this? */
159 #include <sys/types.h>
160 #endif
161 #endif
162
163 #ifdef I_NETINET_IN
164 #include <netinet/in.h>
165 #endif
166
167 #include <sys/stat.h>
168
169 #ifdef I_TIME
170 #   include <time.h>
171 #endif
172
173 #ifdef I_SYS_TIME
174 #   ifdef SYSTIMEKERNEL
175 #       define KERNEL
176 #   endif
177 #   include <sys/time.h>
178 #   ifdef SYSTIMEKERNEL
179 #       undef KERNEL
180 #   endif
181 #endif
182
183 #ifndef MSDOS
184 #include <sys/times.h>
185 #endif
186
187 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
188 #undef HAS_STRERROR
189 #endif
190
191 #include <errno.h>
192 #ifndef MSDOS
193 #ifndef errno
194 extern int errno;     /* ANSI allows errno to be an lvalue expr */
195 #endif
196 #endif
197
198 #ifndef strerror
199 #ifdef HAS_STRERROR
200 char *strerror();
201 #else
202 extern int sys_nerr;
203 extern char *sys_errlist[];
204 #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
205 #endif
206 #endif
207
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 */
215 #ifdef HAS_SOCKETPAIR
216 #undef HAS_SOCKETPAIR
217 #endif
218 #ifdef HAS_NDBM
219 #undef HAS_NDBM
220 #endif
221 #endif
222
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
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
253 #include <ndbm.h>
254 #define SOME_DBM
255 #ifdef HAS_ODBM
256 #undef HAS_ODBM
257 #endif
258 #else
259 #ifdef HAS_ODBM
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()
274 #endif /* HAS_ODBM */
275 #endif /* HAS_NDBM */
276 #endif /* HAS_GDBM */
277 #endif /* WANT_DBZ */
278 #ifdef SOME_DBM
279 EXT char *dbmkey;
280 EXT 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
291 #if defined(I_DIRENT)
292 #   include <dirent.h>
293 #   define DIRENT dirent
294 #else
295 #   ifdef I_SYS_NDIR
296 #       include <sys/ndir.h>
297 #       define DIRENT direct
298 #   else
299 #       ifdef I_SYS_DIR
300 #           ifdef hp9000s500
301 #               include <ndir.h>        /* may be wrong in the future */
302 #           else
303 #               include <sys/dir.h>
304 #           endif
305 #           define DIRENT direct
306 #       endif
307 #   endif
308 #endif
309
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
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
340 #   ifdef S_IFBLK
341 #       define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
342 #   else
343 #       define S_ISBLK(m) (0)
344 #   endif
345 #endif
346
347 #if S_ISBLK(060000) == 060000
348         XXX Your sys/stat.h appears to be buggy.  Please fix it.
349 #endif
350
351 #ifndef S_ISREG
352 #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
353 #endif
354
355 #ifndef S_ISFIFO
356 #   ifdef S_IFIFO
357 #       define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
358 #   else
359 #       define S_ISFIFO(m) (0)
360 #   endif
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
421 #ifdef f_next
422 #undef f_next
423 #endif
424
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
445 typedef unsigned int STRLEN;
446
447 typedef struct arg ARG;
448 typedef struct cmd CMD;
449 typedef struct formcmd FCMD;
450 typedef struct scanpat SPAT;
451 typedef struct stio STIO;
452 typedef struct sub SUBR;
453 typedef struct string STR;
454 typedef struct atbl ARRAY;
455 typedef struct htbl HASH;
456 typedef struct regexp REGEXP;
457 typedef struct stabptrs STBP;
458 typedef struct stab STAB;
459 typedef struct callsave CSV;
460
461 #include "handy.h"
462 #include "regexp.h"
463 #include "str.h"
464 #include "util.h"
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
473 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
474 #   define I286
475 #endif
476
477 #ifndef STANDARD_C
478 #ifdef CHARSPRINTF
479     char *sprintf();
480 #else
481     int sprintf();
482 #endif
483 #endif
484
485 EXT char *Yes INIT("1");
486 EXT char *No INIT("");
487
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
495 int 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 */
505
506 #ifdef DEBUGGING
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                 "" )))
514 #endif
515
516 #ifdef CRIPPLED_CC
517 char *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
523 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
524 #endif /* TAINT */
525 #endif /* CRIPPLED_CC */
526
527 #ifdef CRIPPLED_CC
528 double 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 */
537 EXT STR *Str;
538
539 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
540
541 #ifndef MSDOS
542 #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
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 */
550
551 #ifndef BYTEORDER
552 #define BYTEORDER 0x1234
553 #endif
554
555 #if defined(htonl) && !defined(HAS_HTONL)
556 #define HAS_HTONL
557 #endif
558 #if defined(htons) && !defined(HAS_HTONS)
559 #define HAS_HTONS
560 #endif
561 #if defined(ntohl) && !defined(HAS_NTOHL)
562 #define HAS_NTOHL
563 #endif
564 #if defined(ntohs) && !defined(HAS_NTOHS)
565 #define HAS_NTOHS
566 #endif
567 #ifndef HAS_HTONL
568 #if (BYTEORDER & 0xffff) != 0x4321
569 #define HAS_HTONS
570 #define HAS_HTONL
571 #define HAS_NTOHS
572 #define HAS_NTOHL
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
580 #if (BYTEORDER & 0xffff) == 0x4321
581 #undef HAS_HTONS
582 #undef HAS_HTONL
583 #undef HAS_NTOHS
584 #undef HAS_NTOHL
585 #endif
586 #endif
587
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
593 unsigned 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
599 CMD *add_label();
600 CMD *block_head();
601 CMD *append_line();
602 CMD *make_acmd();
603 CMD *make_ccmd();
604 CMD *make_icmd();
605 CMD *invert();
606 CMD *addcond();
607 CMD *addloop();
608 CMD *wopt();
609 CMD *over();
610
611 STAB *stabent();
612 STAB *genstab();
613
614 ARG *stab2arg();
615 ARG *op_new();
616 ARG *make_op();
617 ARG *make_match();
618 ARG *make_split();
619 ARG *rcatmaybe();
620 ARG *listish();
621 ARG *maybelistish();
622 ARG *localize();
623 ARG *fixeval();
624 ARG *jmaybe();
625 ARG *l();
626 ARG *fixl();
627 ARG *mod_match();
628 ARG *make_list();
629 ARG *cmd_to_arg();
630 ARG *addflags();
631 ARG *hide_ary();
632 ARG *cval_to_arg();
633
634 STR *str_new();
635 STR *stab_str();
636
637 int do_each();
638 int do_subr();
639 int do_match();
640 int do_unpack();
641 int eval();             /* this evaluates expressions */
642 int do_eval();          /* this evaluates eval operator */
643 int do_assign();
644
645 SUBR *make_sub();
646
647 FCMD *load_format();
648
649 char *scanpat();
650 char *scansubst();
651 char *scantrans();
652 char *scanstr();
653 char *scanident();
654 char *str_append_till();
655 char *str_gets();
656 char *str_grow();
657
658 bool do_open();
659 bool do_close();
660 bool do_print();
661 bool do_aprint();
662 bool do_exec();
663 bool do_aexec();
664
665 int do_subst();
666 int cando();
667 int ingroup();
668
669 void str_replace();
670 void str_inc();
671 void str_dec();
672 void str_free();
673 void stab_clear();
674 void do_join();
675 void do_sprintf();
676 void do_accept();
677 void do_pipe();
678 void do_vecset();
679 void do_unshift();
680 void do_execfree();
681 void magicalize();
682 void magicname();
683 void savelist();
684 void saveitem();
685 void saveint();
686 void savelong();
687 void savesptr();
688 void savehptr();
689 void restorelist();
690 void repeatcpy();
691 HASH *savehash();
692 ARRAY *saveary();
693
694 EXT char **origargv;
695 EXT int origargc;
696 EXT char **origenviron;
697 extern char **environ;
698
699 EXT long subline INIT(0);
700 EXT STR *subname INIT(Nullstr);
701 EXT int arybase INIT(0);
702
703 struct outrec {
704     long        o_lines;
705     char        *o_str;
706     int         o_len;
707 };
708
709 EXT struct outrec outrec;
710 EXT struct outrec toprec;
711
712 EXT STAB *stdinstab INIT(Nullstab);
713 EXT STAB *last_in_stab INIT(Nullstab);
714 EXT STAB *defstab INIT(Nullstab);
715 EXT STAB *argvstab INIT(Nullstab);
716 EXT STAB *envstab INIT(Nullstab);
717 EXT STAB *sigstab INIT(Nullstab);
718 EXT STAB *defoutstab INIT(Nullstab);
719 EXT STAB *curoutstab INIT(Nullstab);
720 EXT STAB *argvoutstab INIT(Nullstab);
721 EXT STAB *incstab INIT(Nullstab);
722 EXT STAB *leftstab INIT(Nullstab);
723 EXT STAB *amperstab INIT(Nullstab);
724 EXT STAB *rightstab INIT(Nullstab);
725 EXT STAB *DBstab INIT(Nullstab);
726 EXT STAB *DBline INIT(Nullstab);
727 EXT STAB *DBsub INIT(Nullstab);
728
729 EXT HASH *defstash;             /* main symbol table */
730 EXT HASH *curstash;             /* symbol table for current package */
731 EXT HASH *debstash;             /* symbol table for perldb package */
732
733 EXT STR *curstname;             /* name of current package */
734
735 EXT STR *freestrroot INIT(Nullstr);
736 EXT STR *lastretstr INIT(Nullstr);
737 EXT STR *DBsingle INIT(Nullstr);
738 EXT STR *DBtrace INIT(Nullstr);
739 EXT STR *DBsignal INIT(Nullstr);
740
741 EXT int lastspbase;
742 EXT int lastsize;
743
744 EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
745 EXT char *origfilename;
746 EXT FILE * VOLATILE rsfp;
747 EXT char buf[1024];
748 EXT char *bufptr;
749 EXT char *oldbufptr;
750 EXT char *oldoldbufptr;
751 EXT char *bufend;
752
753 EXT STR *linestr INIT(Nullstr);
754
755 EXT char *rs INIT("\n");
756 EXT int rschar INIT('\n');      /* final char of rs, or 0777 if none */
757 EXT int rslen INIT(1);
758 EXT char *ofs INIT(Nullch);
759 EXT int ofslen INIT(0);
760 EXT char *ors INIT(Nullch);
761 EXT int orslen INIT(0);
762 EXT char *ofmt INIT(Nullch);
763 EXT char *inplace INIT(Nullch);
764 EXT char *nointrp INIT("");
765
766 EXT bool preprocess INIT(FALSE);
767 EXT bool minus_n INIT(FALSE);
768 EXT bool minus_p INIT(FALSE);
769 EXT bool minus_l INIT(FALSE);
770 EXT bool minus_a INIT(FALSE);
771 EXT bool doswitches INIT(FALSE);
772 EXT bool dowarn INIT(FALSE);
773 EXT bool doextract INIT(FALSE);
774 EXT bool allstabs INIT(FALSE);  /* init all customary symbols in symbol table?*/
775 EXT bool sawampersand INIT(FALSE);      /* must save all match strings */
776 EXT bool sawstudy INIT(FALSE);          /* do fbminstr on all strings */
777 EXT bool sawi INIT(FALSE);              /* study must assume case insensitive */
778 EXT bool sawvec INIT(FALSE);
779 EXT bool localizing INIT(FALSE);        /* are we processing a local() list? */
780
781 #ifndef MAXSYSFD
782 #   define MAXSYSFD 2
783 #endif
784 EXT int maxsysfd INIT(MAXSYSFD);        /* top fd to pass to subprocesses */
785
786 #ifdef CSH
787 char *cshname INIT(CSH);
788 int cshlen INIT(0);
789 #endif /* CSH */
790
791 #ifdef TAINT
792 EXT bool tainted INIT(FALSE);           /* using variables controlled by $< */
793 #endif
794
795 #ifndef MSDOS
796 #define TMPPATH "/tmp/perl-eXXXXXX"
797 #else
798 #define TMPPATH "plXXXXXX"
799 #endif /* MSDOS */
800 EXT char *e_tmpname;
801 EXT FILE *e_fp INIT(Nullfp);
802
803 EXT char tokenbuf[256];
804 EXT int expectterm INIT(TRUE);          /* how to interpret ambiguous tokens */
805 EXT VOLATILE int in_eval INIT(FALSE);   /* trap fatal errors? */
806 EXT int multiline INIT(0);              /* $*--do strings hold >1 line? */
807 EXT int forkprocess;                    /* so do_open |- can return proc# */
808 EXT int do_undump INIT(0);              /* -u or dump seen? */
809 EXT int error_count INIT(0);            /* how many errors so far, max 10 */
810 EXT int multi_start INIT(0);            /* 1st line of multi-line string */
811 EXT int multi_end INIT(0);              /* last line of multi-line string */
812 EXT int multi_open INIT(0);             /* delimiter of said string */
813 EXT int multi_close INIT(0);            /* delimiter of said string */
814
815 FILE *popen();
816 /* char *str_get(); */
817 STR *interp();
818 void free_arg();
819 STIO *stio_new();
820 void hoistmust();
821 void scanconst();
822
823 EXT struct stat statbuf;
824 EXT struct stat statcache;
825 STAB *statstab INIT(Nullstab);
826 STR *statname;
827 #ifndef MSDOS
828 EXT struct tms timesbuf;
829 #endif
830 EXT int uid;
831 EXT int euid;
832 EXT int gid;
833 EXT int egid;
834 UIDTYPE getuid();
835 UIDTYPE geteuid();
836 GIDTYPE getgid();
837 GIDTYPE getegid();
838 EXT int unsafe;
839
840 #ifdef DEBUGGING
841 EXT VOLATILE int debug INIT(0);
842 EXT int dlevel INIT(0);
843 EXT int dlmax INIT(128);
844 EXT char *debname;
845 EXT char *debdelim;
846 #define YYDEBUG 1
847 #endif
848 EXT int perldb INIT(0);
849 #define YYMAXDEPTH 300
850
851 EXT line_t cmdline INIT(NOLINE);
852
853 EXT STR str_undef;
854 EXT STR str_no;
855 EXT STR str_yes;
856
857 /* runtime control stuff */
858
859 EXT struct loop {
860     char *loop_label;           /* what the loop was called, if anything */
861     int loop_sp;                /* stack pointer to copy stuff down to */
862     jmp_buf loop_env;
863 } *loop_stack;
864
865 EXT int loop_ptr INIT(-1);
866 EXT int loop_max INIT(128);
867
868 EXT jmp_buf top_env;
869
870 EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
871
872 struct ufuncs {
873     int (*uf_val)();
874     int (*uf_set)();
875     int uf_index;
876 };
877
878 EXT ARRAY *stack;               /* THE STACK */
879
880 EXT ARRAY * VOLATILE savestack;         /* to save non-local values on */
881
882 EXT ARRAY *tosave;              /* strings to save on recursive subroutine */
883
884 EXT ARRAY *lineary;             /* lines of script for debugger */
885 EXT ARRAY *dbargs;              /* args to call listed by caller function */
886
887 EXT ARRAY *fdpid;               /* keep fd-to-pid mappings for mypopen */
888 EXT HASH *pidstatus;            /* keep pid-to-status mappings for waitpid */
889
890 EXT int *di;                    /* for tmp use in debuggers */
891 EXT char *dc;
892 EXT short *ds;
893
894 /* Fix these up for __STDC__ */
895 EXT long basetime INIT(0);
896 char *mktemp();
897 #ifndef STANDARD_C
898 /* All of these are in stdlib.h or time.h for ANSI C */
899 double atof();
900 long time();
901 struct tm *gmtime(), *localtime();
902 char *index(), *rindex();
903 char *strcpy(), *strcat();
904 #endif /* ! STANDARD_C */
905
906 #ifdef EUNICE
907 #define UNLINK unlnk
908 int unlnk();
909 #else
910 #define UNLINK unlink
911 #endif
912
913 #ifndef HAS_SETREUID
914 #ifdef HAS_SETRESUID
915 #define setreuid(r,e) setresuid(r,e,-1)
916 #define HAS_SETREUID
917 #endif
918 #endif
919 #ifndef HAS_SETREGID
920 #ifdef HAS_SETRESGID
921 #define setregid(r,e) setresgid(r,e,-1)
922 #define HAS_SETREGID
923 #endif
924 #endif