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