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