Commit | Line | Data |
1462b684 |
1 | /* $RCSfile: perl.h,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:25:10 $ |
a687059c |
2 | * |
352d5a3a |
3 | * Copyright (c) 1991, Larry Wall |
a687059c |
4 | * |
352d5a3a |
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 |
7 | * |
8 | * $Log: perl.h,v $ |
1462b684 |
9 | * Revision 4.0.1.3 91/06/10 01:25:10 lwall |
10 | * patch10: certain pattern optimizations were botched |
11 | * |
352d5a3a |
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 | * |
35c8bce7 |
17 | * Revision 4.0.1.1 91/04/11 17:49:51 lwall |
18 | * patch1: hopefully straightened out some of the Xenix mess |
19 | * |
fe14fcc3 |
20 | * Revision 4.0 91/03/20 01:37:56 lwall |
21 | * 4.0 baseline. |
8d063cd8 |
22 | * |
23 | */ |
24 | |
35c8bce7 |
25 | #define VOIDWANT 1 |
ac58e20f |
26 | #include "config.h" |
27 | |
0f85fab0 |
28 | #ifdef MSDOS |
fe14fcc3 |
29 | /* This stuff now in the MS-DOS config.h file. */ |
0f85fab0 |
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 | */ |
fe14fcc3 |
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 |
0f85fab0 |
49 | /* |
50 | * The following symbols are defined if your operating system supports |
51 | * password and group functions in general. All Unix systems do. |
52 | */ |
fe14fcc3 |
53 | #define HAS_GROUP |
54 | #define HAS_PASSWD |
0f85fab0 |
55 | |
56 | #endif /* !MSDOS */ |
57 | |
352d5a3a |
58 | #if defined(__STDC__) || defined(_AIX) || defined(__stdc__) |
59 | # define STANDARD_C 1 |
60 | #endif |
61 | |
62 | #if defined(HASVOLATILE) || defined(STANDARD_C) |
663a0e37 |
63 | #define VOLATILE volatile |
663a0e37 |
64 | #else |
65 | #define VOLATILE |
663a0e37 |
66 | #endif |
67 | |
a687059c |
68 | #ifdef IAMSUID |
69 | # ifndef TAINT |
70 | # define TAINT |
71 | # endif |
72 | #endif |
73 | |
fe14fcc3 |
74 | #ifndef HAS_VFORK |
03a14243 |
75 | # define vfork fork |
76 | #endif |
77 | |
fe14fcc3 |
78 | #ifdef HAS_GETPGRP2 |
79 | # ifndef HAS_GETPGRP |
80 | # define HAS_GETPGRP |
663a0e37 |
81 | # endif |
82 | # define getpgrp getpgrp2 |
83 | #endif |
84 | |
fe14fcc3 |
85 | #ifdef HAS_SETPGRP2 |
86 | # ifndef HAS_SETPGRP |
87 | # define HAS_SETPGRP |
663a0e37 |
88 | # endif |
89 | # define setpgrp setpgrp2 |
90 | #endif |
91 | |
fe14fcc3 |
92 | #include <stdio.h> |
93 | #include <ctype.h> |
94 | #include <setjmp.h> |
95 | #ifndef MSDOS |
352d5a3a |
96 | #ifdef PARAM_NEEDS_TYPES |
97 | #include <sys/types.h> |
03a14243 |
98 | #endif |
352d5a3a |
99 | #include <sys/param.h> |
100 | #endif |
101 | #ifdef STANDARD_C |
fe14fcc3 |
102 | /* Use all the "standard" definitions */ |
103 | #include <stdlib.h> |
104 | #include <string.h> |
352d5a3a |
105 | #endif /* STANDARD_C */ |
03a14243 |
106 | |
fe14fcc3 |
107 | #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234 |
108 | #undef HAS_MEMCMP |
663a0e37 |
109 | #endif |
fe14fcc3 |
110 | |
111 | #ifdef HAS_MEMCPY |
112 | |
352d5a3a |
113 | # ifndef STANDARD_C |
fe14fcc3 |
114 | # ifndef memcpy |
115 | extern char * memcpy(), *memset(); |
450a55e4 |
116 | extern int memcmp(); |
fe14fcc3 |
117 | # endif /* ndef memcpy */ |
352d5a3a |
118 | # endif /* ndef STANDARD_C */ |
fe14fcc3 |
119 | |
352d5a3a |
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 |
fe14fcc3 |
126 | #endif /* HAS_MEMCPY */ |
8d063cd8 |
127 | |
fe14fcc3 |
128 | #ifndef HAS_BCMP /* prefer bcmp slightly 'cuz it doesn't order */ |
352d5a3a |
129 | # ifndef bcmp |
130 | # define bcmp(s1,s2,l) memcmp(s1,s2,l) |
131 | # endif |
d9d8d8de |
132 | #endif |
378cc40b |
133 | |
134 | #ifndef _TYPES_ /* If types.h defines this it's easy. */ |
135 | #ifndef major /* Does everyone's types.h define this? */ |
8d063cd8 |
136 | #include <sys/types.h> |
378cc40b |
137 | #endif |
138 | #endif |
139 | |
ae986130 |
140 | #ifdef I_NETINET_IN |
141 | #include <netinet/in.h> |
142 | #endif |
143 | |
8d063cd8 |
144 | #include <sys/stat.h> |
135863df |
145 | |
663a0e37 |
146 | #ifdef I_TIME |
147 | # include <time.h> |
ffed7fef |
148 | #endif |
663a0e37 |
149 | |
fe14fcc3 |
150 | #ifdef I_SYS_TIME |
663a0e37 |
151 | # ifdef SYSTIMEKERNEL |
152 | # define KERNEL |
153 | # endif |
154 | # include <sys/time.h> |
155 | # ifdef SYSTIMEKERNEL |
156 | # undef KERNEL |
157 | # endif |
a687059c |
158 | #endif |
135863df |
159 | |
d9d8d8de |
160 | #ifndef MSDOS |
8d063cd8 |
161 | #include <sys/times.h> |
d9d8d8de |
162 | #endif |
8d063cd8 |
163 | |
fe14fcc3 |
164 | #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR)) |
165 | #undef HAS_STRERROR |
663a0e37 |
166 | #endif |
167 | |
168 | #include <errno.h> |
d9d8d8de |
169 | #ifndef MSDOS |
663a0e37 |
170 | #ifndef errno |
171 | extern int errno; /* ANSI allows errno to be an lvalue expr */ |
172 | #endif |
d9d8d8de |
173 | #endif |
663a0e37 |
174 | |
35c8bce7 |
175 | #ifndef strerror |
fe14fcc3 |
176 | #ifdef HAS_STRERROR |
663a0e37 |
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 |
35c8bce7 |
183 | #endif |
663a0e37 |
184 | |
a687059c |
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 */ |
fe14fcc3 |
192 | #ifdef HAS_SOCKETPAIR |
193 | #undef HAS_SOCKETPAIR |
a687059c |
194 | #endif |
fe14fcc3 |
195 | #ifdef HAS_NDBM |
196 | #undef HAS_NDBM |
a687059c |
197 | #endif |
198 | #endif |
199 | |
fe14fcc3 |
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 |
a687059c |
213 | #include <ndbm.h> |
214 | #define SOME_DBM |
fe14fcc3 |
215 | #ifdef HAS_ODBM |
216 | #undef HAS_ODBM |
ae986130 |
217 | #endif |
a687059c |
218 | #else |
fe14fcc3 |
219 | #ifdef HAS_ODBM |
a687059c |
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() |
fe14fcc3 |
234 | #endif /* HAS_ODBM */ |
235 | #endif /* HAS_NDBM */ |
236 | #endif /* HAS_GDBM */ |
a687059c |
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 | |
35c8bce7 |
250 | #if defined(I_DIRENT) |
663a0e37 |
251 | # include <dirent.h> |
252 | # define DIRENT dirent |
ae986130 |
253 | #else |
fe14fcc3 |
254 | # ifdef I_SYS_NDIR |
79a0689e |
255 | # include <sys/ndir.h> |
663a0e37 |
256 | # define DIRENT direct |
257 | # else |
fe14fcc3 |
258 | # ifdef I_SYS_DIR |
79a0689e |
259 | # ifdef hp9000s500 |
260 | # include <ndir.h> /* may be wrong in the future */ |
261 | # else |
262 | # include <sys/dir.h> |
263 | # endif |
663a0e37 |
264 | # define DIRENT direct |
265 | # endif |
266 | # endif |
a687059c |
267 | #endif |
268 | |
352d5a3a |
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 | |
c623bd54 |
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 |
fe14fcc3 |
299 | # ifdef S_IFBLK |
300 | # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) |
301 | # else |
302 | # define S_ISBLK(m) (0) |
303 | # endif |
c623bd54 |
304 | #endif |
305 | |
306 | #ifndef S_ISREG |
307 | # define S_ISREG(m) ((m & S_IFMT) == S_IFREG) |
308 | #endif |
309 | |
310 | #ifndef S_ISFIFO |
fe14fcc3 |
311 | # ifdef S_IFIFO |
312 | # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) |
313 | # else |
314 | # define S_ISFIFO(m) (0) |
315 | # endif |
c623bd54 |
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 | |
352d5a3a |
376 | #ifdef f_next |
377 | #undef f_next |
378 | #endif |
379 | |
450a55e4 |
380 | typedef unsigned int STRLEN; |
381 | |
8d063cd8 |
382 | typedef struct arg ARG; |
383 | typedef struct cmd CMD; |
384 | typedef struct formcmd FCMD; |
385 | typedef struct scanpat SPAT; |
8d063cd8 |
386 | typedef struct stio STIO; |
378cc40b |
387 | typedef struct sub SUBR; |
8d063cd8 |
388 | typedef struct string STR; |
389 | typedef struct atbl ARRAY; |
390 | typedef struct htbl HASH; |
378cc40b |
391 | typedef struct regexp REGEXP; |
a687059c |
392 | typedef struct stabptrs STBP; |
393 | typedef struct stab STAB; |
d9d8d8de |
394 | typedef struct callsave CSV; |
8d063cd8 |
395 | |
378cc40b |
396 | #include "handy.h" |
397 | #include "regexp.h" |
8d063cd8 |
398 | #include "str.h" |
378cc40b |
399 | #include "util.h" |
8d063cd8 |
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 | |
450a55e4 |
408 | #if defined(iAPX286) || defined(M_I286) || defined(I80286) |
a687059c |
409 | # define I286 |
410 | #endif |
411 | |
352d5a3a |
412 | #ifndef STANDARD_C |
135863df |
413 | #ifdef CHARSPRINTF |
414 | char *sprintf(); |
415 | #else |
416 | int sprintf(); |
417 | #endif |
a687059c |
418 | #endif |
135863df |
419 | |
8d063cd8 |
420 | EXT char *Yes INIT("1"); |
421 | EXT char *No INIT(""); |
422 | |
a687059c |
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 */ |
8d063cd8 |
440 | |
135863df |
441 | #ifdef DEBUGGING |
a687059c |
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 | "" ))) |
135863df |
449 | #endif |
450 | |
a687059c |
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 |
8d063cd8 |
458 | #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) |
a687059c |
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 */ |
8d063cd8 |
472 | EXT STR *Str; |
473 | |
474 | #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) |
475 | |
450a55e4 |
476 | #ifndef MSDOS |
a687059c |
477 | #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len) |
450a55e4 |
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 */ |
a687059c |
485 | |
486 | #ifndef BYTEORDER |
ffed7fef |
487 | #define BYTEORDER 0x1234 |
a687059c |
488 | #endif |
489 | |
fe14fcc3 |
490 | #if defined(htonl) && !defined(HAS_HTONL) |
491 | #define HAS_HTONL |
ae986130 |
492 | #endif |
fe14fcc3 |
493 | #if defined(htons) && !defined(HAS_HTONS) |
494 | #define HAS_HTONS |
ae986130 |
495 | #endif |
fe14fcc3 |
496 | #if defined(ntohl) && !defined(HAS_NTOHL) |
497 | #define HAS_NTOHL |
ae986130 |
498 | #endif |
fe14fcc3 |
499 | #if defined(ntohs) && !defined(HAS_NTOHS) |
500 | #define HAS_NTOHS |
ae986130 |
501 | #endif |
fe14fcc3 |
502 | #ifndef HAS_HTONL |
d9d8d8de |
503 | #if (BYTEORDER & 0xffff) != 0x4321 |
fe14fcc3 |
504 | #define HAS_HTONS |
505 | #define HAS_HTONL |
506 | #define HAS_NTOHS |
507 | #define HAS_NTOHL |
a687059c |
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 |
d9d8d8de |
515 | #if (BYTEORDER & 0xffff) == 0x4321 |
fe14fcc3 |
516 | #undef HAS_HTONS |
517 | #undef HAS_HTONL |
518 | #undef HAS_NTOHS |
519 | #undef HAS_NTOHL |
a687059c |
520 | #endif |
521 | #endif |
522 | |
0f85fab0 |
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 | |
8d063cd8 |
534 | CMD *add_label(); |
535 | CMD *block_head(); |
536 | CMD *append_line(); |
537 | CMD *make_acmd(); |
538 | CMD *make_ccmd(); |
a687059c |
539 | CMD *make_icmd(); |
8d063cd8 |
540 | CMD *invert(); |
541 | CMD *addcond(); |
542 | CMD *addloop(); |
543 | CMD *wopt(); |
378cc40b |
544 | CMD *over(); |
8d063cd8 |
545 | |
8d063cd8 |
546 | STAB *stabent(); |
378cc40b |
547 | STAB *genstab(); |
8d063cd8 |
548 | |
378cc40b |
549 | ARG *stab2arg(); |
8d063cd8 |
550 | ARG *op_new(); |
551 | ARG *make_op(); |
8d063cd8 |
552 | ARG *make_match(); |
553 | ARG *make_split(); |
a687059c |
554 | ARG *rcatmaybe(); |
378cc40b |
555 | ARG *listish(); |
a687059c |
556 | ARG *maybelistish(); |
378cc40b |
557 | ARG *localize(); |
a687059c |
558 | ARG *fixeval(); |
559 | ARG *jmaybe(); |
378cc40b |
560 | ARG *l(); |
a687059c |
561 | ARG *fixl(); |
378cc40b |
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(); |
8d063cd8 |
568 | |
8d063cd8 |
569 | STR *str_new(); |
570 | STR *stab_str(); |
a687059c |
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(); |
378cc40b |
579 | |
580 | SUBR *make_sub(); |
8d063cd8 |
581 | |
582 | FCMD *load_format(); |
583 | |
584 | char *scanpat(); |
585 | char *scansubst(); |
586 | char *scantrans(); |
587 | char *scanstr(); |
fe14fcc3 |
588 | char *scanident(); |
8d063cd8 |
589 | char *str_append_till(); |
590 | char *str_gets(); |
a687059c |
591 | char *str_grow(); |
8d063cd8 |
592 | |
8d063cd8 |
593 | bool do_open(); |
594 | bool do_close(); |
595 | bool do_print(); |
378cc40b |
596 | bool do_aprint(); |
597 | bool do_exec(); |
598 | bool do_aexec(); |
8d063cd8 |
599 | |
600 | int do_subst(); |
378cc40b |
601 | int cando(); |
602 | int ingroup(); |
8d063cd8 |
603 | |
378cc40b |
604 | void str_replace(); |
605 | void str_inc(); |
606 | void str_dec(); |
8d063cd8 |
607 | void str_free(); |
a687059c |
608 | void stab_clear(); |
378cc40b |
609 | void do_join(); |
378cc40b |
610 | void do_sprintf(); |
a687059c |
611 | void do_accept(); |
ac58e20f |
612 | void do_pipe(); |
a687059c |
613 | void do_vecset(); |
fe14fcc3 |
614 | void do_unshift(); |
615 | void do_execfree(); |
616 | void magicalize(); |
617 | void magicname(); |
a687059c |
618 | void savelist(); |
619 | void saveitem(); |
620 | void saveint(); |
621 | void savelong(); |
622 | void savesptr(); |
623 | void savehptr(); |
624 | void restorelist(); |
ac58e20f |
625 | void repeatcpy(); |
a687059c |
626 | HASH *savehash(); |
627 | ARRAY *saveary(); |
378cc40b |
628 | |
ac58e20f |
629 | EXT char **origargv; |
630 | EXT int origargc; |
fe14fcc3 |
631 | EXT char **origenviron; |
35c8bce7 |
632 | extern char **environ; |
633 | |
a687059c |
634 | EXT line_t subline INIT(0); |
635 | EXT STR *subname INIT(Nullstr); |
8d063cd8 |
636 | EXT int arybase INIT(0); |
637 | |
638 | struct outrec { |
d9d8d8de |
639 | long o_lines; |
640 | char *o_str; |
641 | int o_len; |
8d063cd8 |
642 | }; |
643 | |
644 | EXT struct outrec outrec; |
645 | EXT struct outrec toprec; |
646 | |
a687059c |
647 | EXT STAB *stdinstab INIT(Nullstab); |
8d063cd8 |
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); |
378cc40b |
656 | EXT STAB *incstab INIT(Nullstab); |
a687059c |
657 | EXT STAB *leftstab INIT(Nullstab); |
658 | EXT STAB *amperstab INIT(Nullstab); |
659 | EXT STAB *rightstab INIT(Nullstab); |
660 | EXT STAB *DBstab INIT(Nullstab); |
d9d8d8de |
661 | EXT STAB *DBline INIT(Nullstab); |
a687059c |
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 */ |
8d063cd8 |
669 | |
670 | EXT STR *freestrroot INIT(Nullstr); |
378cc40b |
671 | EXT STR *lastretstr INIT(Nullstr); |
a687059c |
672 | EXT STR *DBsingle INIT(Nullstr); |
d9d8d8de |
673 | EXT STR *DBtrace INIT(Nullstr); |
674 | EXT STR *DBsignal INIT(Nullstr); |
a687059c |
675 | |
676 | EXT int lastspbase; |
677 | EXT int lastsize; |
8d063cd8 |
678 | |
fe14fcc3 |
679 | EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEF"); |
378cc40b |
680 | EXT char *origfilename; |
ac58e20f |
681 | EXT FILE * VOLATILE rsfp; |
8d063cd8 |
682 | EXT char buf[1024]; |
a687059c |
683 | EXT char *bufptr; |
684 | EXT char *oldbufptr; |
685 | EXT char *oldoldbufptr; |
686 | EXT char *bufend; |
8d063cd8 |
687 | |
688 | EXT STR *linestr INIT(Nullstr); |
689 | |
fe14fcc3 |
690 | EXT char *rs INIT("\n"); |
691 | EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */ |
a687059c |
692 | EXT int rslen INIT(1); |
8d063cd8 |
693 | EXT char *ofs INIT(Nullch); |
a687059c |
694 | EXT int ofslen INIT(0); |
8d063cd8 |
695 | EXT char *ors INIT(Nullch); |
a687059c |
696 | EXT int orslen INIT(0); |
8d063cd8 |
697 | EXT char *ofmt INIT(Nullch); |
698 | EXT char *inplace INIT(Nullch); |
a687059c |
699 | EXT char *nointrp INIT(""); |
8d063cd8 |
700 | |
378cc40b |
701 | EXT bool preprocess INIT(FALSE); |
702 | EXT bool minus_n INIT(FALSE); |
703 | EXT bool minus_p INIT(FALSE); |
fe14fcc3 |
704 | EXT bool minus_l INIT(FALSE); |
378cc40b |
705 | EXT bool minus_a INIT(FALSE); |
706 | EXT bool doswitches INIT(FALSE); |
707 | EXT bool dowarn INIT(FALSE); |
450a55e4 |
708 | EXT bool doextract INIT(FALSE); |
378cc40b |
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 */ |
a687059c |
712 | EXT bool sawi INIT(FALSE); /* study must assume case insensitive */ |
713 | EXT bool sawvec INIT(FALSE); |
ac58e20f |
714 | EXT bool localizing INIT(FALSE); /* are we processing a local() list? */ |
a687059c |
715 | |
352d5a3a |
716 | #ifndef MAXSYSFD |
717 | # define MAXSYSFD 2 |
718 | #endif |
719 | EXT int maxsysfd INIT(MAXSYSFD); /* top fd to pass to subprocesses */ |
720 | |
ae986130 |
721 | #ifdef CSH |
722 | char *cshname INIT(CSH); |
723 | int cshlen INIT(0); |
724 | #endif /* CSH */ |
a687059c |
725 | |
726 | #ifdef TAINT |
727 | EXT bool tainted INIT(FALSE); /* using variables controlled by $< */ |
728 | #endif |
378cc40b |
729 | |
450a55e4 |
730 | #ifndef MSDOS |
378cc40b |
731 | #define TMPPATH "/tmp/perl-eXXXXXX" |
450a55e4 |
732 | #else |
57ebbfd0 |
733 | #define TMPPATH "plXXXXXX" |
450a55e4 |
734 | #endif /* MSDOS */ |
378cc40b |
735 | EXT char *e_tmpname; |
736 | EXT FILE *e_fp INIT(Nullfp); |
737 | |
8d063cd8 |
738 | EXT char tokenbuf[256]; |
a687059c |
739 | EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */ |
ac58e20f |
740 | EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */ |
a687059c |
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 */ |
8d063cd8 |
749 | |
750 | FILE *popen(); |
751 | /* char *str_get(); */ |
752 | STR *interp(); |
753 | void free_arg(); |
754 | STIO *stio_new(); |
1462b684 |
755 | void hoistmust(); |
8d063cd8 |
756 | |
757 | EXT struct stat statbuf; |
a687059c |
758 | EXT struct stat statcache; |
759 | STAB *statstab INIT(Nullstab); |
760 | STR *statname; |
d9d8d8de |
761 | #ifndef MSDOS |
8d063cd8 |
762 | EXT struct tms timesbuf; |
d9d8d8de |
763 | #endif |
378cc40b |
764 | EXT int uid; |
765 | EXT int euid; |
a687059c |
766 | EXT int gid; |
767 | EXT int egid; |
378cc40b |
768 | UIDTYPE getuid(); |
769 | UIDTYPE geteuid(); |
770 | GIDTYPE getgid(); |
771 | GIDTYPE getegid(); |
772 | EXT int unsafe; |
8d063cd8 |
773 | |
774 | #ifdef DEBUGGING |
ac58e20f |
775 | EXT VOLATILE int debug INIT(0); |
8d063cd8 |
776 | EXT int dlevel INIT(0); |
a687059c |
777 | EXT int dlmax INIT(128); |
778 | EXT char *debname; |
779 | EXT char *debdelim; |
d96024cf |
780 | #define YYDEBUG 1 |
8d063cd8 |
781 | #endif |
a687059c |
782 | EXT int perldb INIT(0); |
fe14fcc3 |
783 | #define YYMAXDEPTH 300 |
8d063cd8 |
784 | |
378cc40b |
785 | EXT line_t cmdline INIT(NOLINE); |
786 | |
a687059c |
787 | EXT STR str_undef; |
8d063cd8 |
788 | EXT STR str_no; |
789 | EXT STR str_yes; |
790 | |
791 | /* runtime control stuff */ |
792 | |
793 | EXT struct loop { |
a687059c |
794 | char *loop_label; /* what the loop was called, if anything */ |
795 | int loop_sp; /* stack pointer to copy stuff down to */ |
8d063cd8 |
796 | jmp_buf loop_env; |
a687059c |
797 | } *loop_stack; |
8d063cd8 |
798 | |
799 | EXT int loop_ptr INIT(-1); |
a687059c |
800 | EXT int loop_max INIT(128); |
8d063cd8 |
801 | |
802 | EXT jmp_buf top_env; |
803 | |
ac58e20f |
804 | EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */ |
8d063cd8 |
805 | |
450a55e4 |
806 | struct ufuncs { |
807 | int (*uf_val)(); |
808 | int (*uf_set)(); |
809 | int uf_index; |
810 | }; |
811 | |
a687059c |
812 | EXT ARRAY *stack; /* THE STACK */ |
813 | |
ac58e20f |
814 | EXT ARRAY * VOLATILE savestack; /* to save non-local values on */ |
378cc40b |
815 | |
816 | EXT ARRAY *tosave; /* strings to save on recursive subroutine */ |
817 | |
a687059c |
818 | EXT ARRAY *lineary; /* lines of script for debugger */ |
d9d8d8de |
819 | EXT ARRAY *dbargs; /* args to call listed by caller function */ |
a687059c |
820 | |
d9d8d8de |
821 | EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */ |
822 | EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */ |
a687059c |
823 | |
ac58e20f |
824 | EXT int *di; /* for tmp use in debuggers */ |
825 | EXT char *dc; |
826 | EXT short *ds; |
827 | |
fe14fcc3 |
828 | /* Fix these up for __STDC__ */ |
829 | EXT long basetime INIT(0); |
830 | char *mktemp(); |
352d5a3a |
831 | #ifndef STANDARD_C |
fe14fcc3 |
832 | /* All of these are in stdlib.h or time.h for ANSI C */ |
8d063cd8 |
833 | double atof(); |
a687059c |
834 | long time(); |
8d063cd8 |
835 | struct tm *gmtime(), *localtime(); |
378cc40b |
836 | char *index(), *rindex(); |
837 | char *strcpy(), *strcat(); |
352d5a3a |
838 | #endif /* ! STANDARD_C */ |
8d063cd8 |
839 | |
8d063cd8 |
840 | #ifdef EUNICE |
378cc40b |
841 | #define UNLINK unlnk |
842 | int unlnk(); |
8d063cd8 |
843 | #else |
844 | #define UNLINK unlink |
845 | #endif |
a687059c |
846 | |
fe14fcc3 |
847 | #ifndef HAS_SETREUID |
848 | #ifdef HAS_SETRESUID |
a687059c |
849 | #define setreuid(r,e) setresuid(r,e,-1) |
fe14fcc3 |
850 | #define HAS_SETREUID |
a687059c |
851 | #endif |
852 | #endif |
fe14fcc3 |
853 | #ifndef HAS_SETREGID |
854 | #ifdef HAS_SETRESGID |
a687059c |
855 | #define setregid(r,e) setresgid(r,e,-1) |
fe14fcc3 |
856 | #define HAS_SETREGID |
a687059c |
857 | #endif |
858 | #endif |