Commit | Line | Data |
---|---|---|
a0d0e21e | 1 | /* perl.h |
a687059c | 2 | * |
a0d0e21e | 3 | * Copyright (c) 1987-1994, Larry Wall |
a687059c | 4 | * |
352d5a3a LW |
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 | * |
8d063cd8 | 8 | */ |
85e6fe83 LW |
9 | #ifndef H_PERL |
10 | #define H_PERL 1 | |
a0d0e21e | 11 | #define OVERLOAD |
8d063cd8 | 12 | |
728e2803 | 13 | /* |
14 | * STMT_START { statements; } STMT_END; | |
15 | * can be used as a single statement, as in | |
16 | * if (x) STMT_START { ... } STMT_END; else ... | |
17 | * | |
18 | * Trying to select a version that gives no warnings... | |
19 | */ | |
20 | #if !(defined(STMT_START) && defined(STMT_END)) | |
21 | # if defined(__GNUC__) && !defined(__STRICT_ANSI__) | |
22 | # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ | |
23 | # define STMT_END ) | |
24 | # else | |
25 | /* Now which other defined()s do we need here ??? */ | |
26 | # if (VOIDFLAGS) && (defined(sun) || defined(__sun__)) | |
27 | # define STMT_START if (1) | |
28 | # define STMT_END else (void)0 | |
29 | # else | |
30 | # define STMT_START do | |
31 | # define STMT_END while (0) | |
32 | # endif | |
33 | # endif | |
34 | #endif | |
35 | ||
79072805 LW |
36 | #include "embed.h" |
37 | ||
85e6fe83 | 38 | #define VOIDUSED 1 |
ac58e20f | 39 | #include "config.h" |
79072805 LW |
40 | |
41 | #ifndef BYTEORDER | |
42 | # define BYTEORDER 0x1234 | |
43 | #endif | |
44 | ||
45 | /* Overall memory policy? */ | |
46 | #ifndef CONSERVATIVE | |
47 | # define LIBERAL 1 | |
48 | #endif | |
49 | ||
50 | /* | |
51 | * The following contortions are brought to you on behalf of all the | |
52 | * standards, semi-standards, de facto standards, not-so-de-facto standards | |
53 | * of the world, as well as all the other botches anyone ever thought of. | |
54 | * The basic theory is that if we work hard enough here, the rest of the | |
55 | * code can be a lot prettier. Well, so much for theory. Sorry, Henry... | |
56 | */ | |
ac58e20f | 57 | |
ee0007ab LW |
58 | /* define this once if either system, instead of cluttering up the src */ |
59 | #if defined(MSDOS) || defined(atarist) | |
60 | #define DOSISH 1 | |
61 | #endif | |
62 | ||
a0d0e21e | 63 | #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus) |
352d5a3a LW |
64 | # define STANDARD_C 1 |
65 | #endif | |
66 | ||
67 | #if defined(HASVOLATILE) || defined(STANDARD_C) | |
79072805 LW |
68 | # ifdef __cplusplus |
69 | # define VOL // to temporarily suppress warnings | |
70 | # else | |
71 | # define VOL volatile | |
72 | # endif | |
663a0e37 | 73 | #else |
79072805 | 74 | # define VOL |
663a0e37 LW |
75 | #endif |
76 | ||
463ee0b2 LW |
77 | #define TAINT_IF(c) (tainted |= (c)) |
78 | #define TAINT_NOT (tainted = 0) | |
79 | #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s) | |
80 | #define TAINT_ENV() if (tainting) taint_env() | |
a687059c | 81 | |
f82b3d41 | 82 | #ifdef USE_BSDPGRP |
83 | # ifdef HAS_GETPGRP | |
84 | # define BSD_GETPGRP(pid) getpgrp((pid)) | |
663a0e37 | 85 | # endif |
f82b3d41 | 86 | # ifdef HAS_SETPGRP |
87 | # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp)) | |
c07a80fd | 88 | # endif |
89 | #else | |
f82b3d41 | 90 | # ifdef HAS_GETPGRP2 |
91 | # define BSD_GETPGRP(pid) getpgrp2((pid)) | |
92 | # ifndef HAS_GETPGRP | |
93 | # define HAS_GETPGRP | |
94 | # endif | |
95 | # endif | |
96 | # ifdef HAS_SETPGRP2 | |
97 | # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp)) | |
98 | # ifndef HAS_SETPGRP | |
99 | # define HAS_SETPGRP | |
100 | # endif | |
c07a80fd | 101 | # endif |
663a0e37 LW |
102 | #endif |
103 | ||
fe14fcc3 | 104 | #include <stdio.h> |
0c30d9ec | 105 | |
4633a7c4 | 106 | #ifdef USE_NEXT_CTYPE |
0c30d9ec | 107 | |
108 | #if NX_CURRENT_COMPILER_RELEASE >= 400 | |
109 | #include <objc/NXCType.h> | |
110 | #else /* NX_CURRENT_COMPILER_RELEASE < 400 */ | |
a0d0e21e | 111 | #include <appkit/NXCType.h> |
0c30d9ec | 112 | #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */ |
113 | ||
114 | #else /* !USE_NEXT_CTYPE */ | |
fe14fcc3 | 115 | #include <ctype.h> |
0c30d9ec | 116 | #endif /* USE_NEXT_CTYPE */ |
a0d0e21e | 117 | |
4633a7c4 LW |
118 | #ifdef I_LOCALE |
119 | #include <locale.h> | |
120 | #endif | |
121 | ||
a0d0e21e LW |
122 | #ifdef METHOD /* Defined by OSF/1 v3.0 by ctype.h */ |
123 | #undef METHOD | |
124 | #endif | |
125 | ||
fe14fcc3 | 126 | #include <setjmp.h> |
79072805 | 127 | |
a0d0e21e | 128 | #ifdef I_SYS_PARAM |
79072805 LW |
129 | # ifdef PARAM_NEEDS_TYPES |
130 | # include <sys/types.h> | |
131 | # endif | |
132 | # include <sys/param.h> | |
352d5a3a | 133 | #endif |
79072805 LW |
134 | |
135 | ||
136 | /* Use all the "standard" definitions? */ | |
a0d0e21e | 137 | #if defined(STANDARD_C) && defined(I_STDLIB) |
79072805 | 138 | # include <stdlib.h> |
352d5a3a | 139 | #endif /* STANDARD_C */ |
03a14243 | 140 | |
4633a7c4 LW |
141 | /* Maybe this comes after <stdlib.h> so we don't try to change |
142 | the standard library prototypes?. We'll use our own in | |
143 | proto.h instead. I guess. The patch had no explanation. | |
144 | */ | |
145 | #ifdef MYMALLOC | |
0c30d9ec | 146 | # ifndef DONT_HIDEMYMALLOC |
4633a7c4 LW |
147 | # define malloc Mymalloc |
148 | # define realloc Myremalloc | |
149 | # define free Myfree | |
0c30d9ec | 150 | # define calloc Mycalloc |
4633a7c4 LW |
151 | # endif |
152 | # define safemalloc malloc | |
153 | # define saferealloc realloc | |
154 | # define safefree free | |
0c30d9ec | 155 | # define safecalloc calloc |
4633a7c4 LW |
156 | #endif |
157 | ||
a0d0e21e LW |
158 | #define MEM_SIZE Size_t |
159 | ||
160 | #if defined(I_STRING) || defined(__cplusplus) | |
161 | # include <string.h> | |
162 | #else | |
163 | # include <strings.h> | |
164 | #endif | |
165 | ||
166 | #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr) | |
167 | #define strchr index | |
168 | #define strrchr rindex | |
169 | #endif | |
170 | ||
171 | #if defined(mips) && defined(ultrix) && !defined(__STDC__) | |
79072805 | 172 | # undef HAS_MEMCMP |
663a0e37 | 173 | #endif |
fe14fcc3 | 174 | |
16d20bd9 AD |
175 | #ifdef I_MEMORY |
176 | # include <memory.h> | |
177 | #endif | |
178 | ||
fe14fcc3 | 179 | #ifdef HAS_MEMCPY |
85e6fe83 | 180 | # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY) |
fe14fcc3 | 181 | # ifndef memcpy |
a0d0e21e | 182 | extern char * memcpy _((char*, char*, int)); |
ee0007ab LW |
183 | # endif |
184 | # endif | |
185 | #else | |
186 | # ifndef memcpy | |
187 | # ifdef HAS_BCOPY | |
188 | # define memcpy(d,s,l) bcopy(s,d,l) | |
189 | # else | |
190 | # define memcpy(d,s,l) my_bcopy(s,d,l) | |
191 | # endif | |
192 | # endif | |
193 | #endif /* HAS_MEMCPY */ | |
fe14fcc3 | 194 | |
ee0007ab | 195 | #ifdef HAS_MEMSET |
85e6fe83 | 196 | # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY) |
ee0007ab | 197 | # ifndef memset |
a0d0e21e | 198 | extern char *memset _((char*, int, int)); |
ee0007ab LW |
199 | # endif |
200 | # endif | |
201 | # define memzero(d,l) memset(d,0,l) | |
202 | #else | |
203 | # ifndef memzero | |
204 | # ifdef HAS_BZERO | |
205 | # define memzero(d,l) bzero(d,l) | |
206 | # else | |
207 | # define memzero(d,l) my_bzero(d,l) | |
208 | # endif | |
352d5a3a | 209 | # endif |
ee0007ab LW |
210 | #endif /* HAS_MEMSET */ |
211 | ||
212 | #ifdef HAS_MEMCMP | |
85e6fe83 | 213 | # if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY) |
ee0007ab | 214 | # ifndef memcmp |
a0d0e21e | 215 | extern int memcmp _((char*, char*, int)); |
ee0007ab LW |
216 | # endif |
217 | # endif | |
218 | #else | |
219 | # ifndef memcmp | |
ecfc5424 | 220 | # define memcmp my_memcmp |
352d5a3a | 221 | # endif |
ee0007ab | 222 | #endif /* HAS_MEMCMP */ |
8d063cd8 | 223 | |
f82b3d41 | 224 | /* XXX we prefer bcmp slightly for comparisons that don't care about ordering */ |
ee0007ab | 225 | #ifndef HAS_BCMP |
352d5a3a LW |
226 | # ifndef bcmp |
227 | # define bcmp(s1,s2,l) memcmp(s1,s2,l) | |
228 | # endif | |
ee0007ab LW |
229 | #endif /* HAS_BCMP */ |
230 | ||
85e6fe83 | 231 | #if !defined(HAS_MEMMOVE) && !defined(memmove) |
2304df62 | 232 | # if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY) |
79072805 LW |
233 | # define memmove(d,s,l) bcopy(s,d,l) |
234 | # else | |
2304df62 | 235 | # if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY) |
79072805 LW |
236 | # define memmove(d,s,l) memcpy(d,s,l) |
237 | # else | |
238 | # define memmove(d,s,l) my_bcopy(s,d,l) | |
239 | # endif | |
240 | # endif | |
d9d8d8de | 241 | #endif |
378cc40b LW |
242 | |
243 | #ifndef _TYPES_ /* If types.h defines this it's easy. */ | |
79072805 LW |
244 | # ifndef major /* Does everyone's types.h define this? */ |
245 | # include <sys/types.h> | |
246 | # endif | |
378cc40b LW |
247 | #endif |
248 | ||
ae986130 | 249 | #ifdef I_NETINET_IN |
79072805 | 250 | # include <netinet/in.h> |
ae986130 LW |
251 | #endif |
252 | ||
1aef975c | 253 | #ifdef I_SYS_STAT |
8d063cd8 | 254 | #include <sys/stat.h> |
1aef975c | 255 | #endif |
79072805 | 256 | |
a0d0e21e LW |
257 | /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives |
258 | like UTekV) are broken, sometimes giving false positives. Undefine | |
259 | them here and let the code below set them to proper values. | |
260 | ||
261 | The ghs macro stands for GreenHills Software C-1.8.5 which | |
262 | is the C compiler for sysV88 and the various derivatives. | |
263 | This header file bug is corrected in gcc-2.5.8 and later versions. | |
264 | --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94. */ | |
265 | ||
266 | #if defined(uts) || (defined(m88k) && defined(ghs)) | |
79072805 LW |
267 | # undef S_ISDIR |
268 | # undef S_ISCHR | |
269 | # undef S_ISBLK | |
270 | # undef S_ISREG | |
271 | # undef S_ISFIFO | |
272 | # undef S_ISLNK | |
ee0007ab | 273 | #endif |
135863df | 274 | |
663a0e37 LW |
275 | #ifdef I_TIME |
276 | # include <time.h> | |
ffed7fef | 277 | #endif |
663a0e37 | 278 | |
fe14fcc3 | 279 | #ifdef I_SYS_TIME |
85e6fe83 | 280 | # ifdef I_SYS_TIME_KERNEL |
663a0e37 LW |
281 | # define KERNEL |
282 | # endif | |
283 | # include <sys/time.h> | |
85e6fe83 | 284 | # ifdef I_SYS_TIME_KERNEL |
663a0e37 LW |
285 | # undef KERNEL |
286 | # endif | |
a687059c | 287 | #endif |
135863df | 288 | |
d9d8d8de | 289 | #ifndef MSDOS |
a0d0e21e | 290 | # if defined(HAS_TIMES) && defined(I_SYS_TIMES) |
85e6fe83 LW |
291 | # include <sys/times.h> |
292 | # endif | |
d9d8d8de | 293 | #endif |
8d063cd8 | 294 | |
fe14fcc3 | 295 | #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR)) |
79072805 | 296 | # undef HAS_STRERROR |
663a0e37 LW |
297 | #endif |
298 | ||
a0d0e21e LW |
299 | #ifndef HAS_MKFIFO |
300 | # ifndef mkfifo | |
301 | # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0)) | |
302 | # endif | |
303 | #endif /* !HAS_MKFIFO */ | |
304 | ||
663a0e37 | 305 | #include <errno.h> |
ed6116ce | 306 | #ifdef HAS_SOCKET |
85e6fe83 | 307 | # ifdef I_NET_ERRNO |
ed6116ce LW |
308 | # include <net/errno.h> |
309 | # endif | |
310 | #endif | |
748a9306 LW |
311 | #ifndef VMS |
312 | # define FIXSTATUS(sts) (U_L((sts) & 0xffff)) | |
313 | # define SHIFTSTATUS(sts) ((sts) >> 8) | |
314 | # define SETERRNO(errcode,vmserrcode) errno = (errcode) | |
315 | #else | |
316 | # define FIXSTATUS(sts) (U_L(sts)) | |
317 | # define SHIFTSTATUS(sts) (sts) | |
728e2803 | 318 | # define SETERRNO(errcode,vmserrcode) STMT_START {set_errno(errcode); set_vaxc_errno(vmserrcode);} STMT_END |
748a9306 | 319 | #endif |
ed6116ce | 320 | |
d9d8d8de | 321 | #ifndef MSDOS |
79072805 LW |
322 | # ifndef errno |
323 | extern int errno; /* ANSI allows errno to be an lvalue expr */ | |
324 | # endif | |
d9d8d8de | 325 | #endif |
663a0e37 | 326 | |
2304df62 | 327 | #ifdef HAS_STRERROR |
a0d0e21e LW |
328 | # ifdef VMS |
329 | char *strerror _((int,...)); | |
330 | # else | |
331 | char *strerror _((int)); | |
332 | # endif | |
2304df62 AD |
333 | # ifndef Strerror |
334 | # define Strerror strerror | |
335 | # endif | |
336 | #else | |
337 | # ifdef HAS_SYS_ERRLIST | |
79072805 LW |
338 | extern int sys_nerr; |
339 | extern char *sys_errlist[]; | |
2304df62 AD |
340 | # ifndef Strerror |
341 | # define Strerror(e) \ | |
79072805 | 342 | ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e]) |
2304df62 | 343 | # endif |
79072805 | 344 | # endif |
35c8bce7 | 345 | #endif |
663a0e37 | 346 | |
2304df62 | 347 | #ifdef I_SYS_IOCTL |
79072805 LW |
348 | # ifndef _IOCTL_ |
349 | # include <sys/ioctl.h> | |
350 | # endif | |
a687059c LW |
351 | #endif |
352 | ||
ee0007ab | 353 | #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000) |
79072805 LW |
354 | # ifdef HAS_SOCKETPAIR |
355 | # undef HAS_SOCKETPAIR | |
356 | # endif | |
2304df62 AD |
357 | # ifdef I_NDBM |
358 | # undef I_NDBM | |
79072805 | 359 | # endif |
a687059c LW |
360 | #endif |
361 | ||
a687059c | 362 | #if INTSIZE == 2 |
79072805 LW |
363 | # define htoni htons |
364 | # define ntohi ntohs | |
a687059c | 365 | #else |
79072805 LW |
366 | # define htoni htonl |
367 | # define ntohi ntohl | |
a687059c LW |
368 | #endif |
369 | ||
a0d0e21e | 370 | /* Configure already sets Direntry_t */ |
35c8bce7 | 371 | #if defined(I_DIRENT) |
663a0e37 | 372 | # include <dirent.h> |
a0d0e21e LW |
373 | # if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */ |
374 | # include <sys/dir.h> | |
375 | # endif | |
ae986130 | 376 | #else |
fe14fcc3 | 377 | # ifdef I_SYS_NDIR |
79a0689e | 378 | # include <sys/ndir.h> |
663a0e37 | 379 | # else |
fe14fcc3 | 380 | # ifdef I_SYS_DIR |
79a0689e LW |
381 | # ifdef hp9000s500 |
382 | # include <ndir.h> /* may be wrong in the future */ | |
383 | # else | |
384 | # include <sys/dir.h> | |
385 | # endif | |
663a0e37 LW |
386 | # endif |
387 | # endif | |
4633a7c4 | 388 | #endif |
a687059c | 389 | |
352d5a3a LW |
390 | #ifdef FPUTS_BOTCH |
391 | /* work around botch in SunOS 4.0.1 and 4.0.2 */ | |
392 | # ifndef fputs | |
79072805 | 393 | # define fputs(sv,fp) fprintf(fp,"%s",sv) |
352d5a3a LW |
394 | # endif |
395 | #endif | |
396 | ||
c623bd54 LW |
397 | /* |
398 | * The following gobbledygook brought to you on behalf of __STDC__. | |
399 | * (I could just use #ifndef __STDC__, but this is more bulletproof | |
400 | * in the face of half-implementations.) | |
401 | */ | |
402 | ||
403 | #ifndef S_IFMT | |
404 | # ifdef _S_IFMT | |
405 | # define S_IFMT _S_IFMT | |
406 | # else | |
407 | # define S_IFMT 0170000 | |
408 | # endif | |
409 | #endif | |
410 | ||
411 | #ifndef S_ISDIR | |
412 | # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) | |
413 | #endif | |
414 | ||
415 | #ifndef S_ISCHR | |
416 | # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) | |
417 | #endif | |
418 | ||
419 | #ifndef S_ISBLK | |
fe14fcc3 LW |
420 | # ifdef S_IFBLK |
421 | # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) | |
422 | # else | |
423 | # define S_ISBLK(m) (0) | |
424 | # endif | |
c623bd54 LW |
425 | #endif |
426 | ||
427 | #ifndef S_ISREG | |
428 | # define S_ISREG(m) ((m & S_IFMT) == S_IFREG) | |
429 | #endif | |
430 | ||
431 | #ifndef S_ISFIFO | |
fe14fcc3 LW |
432 | # ifdef S_IFIFO |
433 | # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) | |
434 | # else | |
435 | # define S_ISFIFO(m) (0) | |
436 | # endif | |
c623bd54 LW |
437 | #endif |
438 | ||
439 | #ifndef S_ISLNK | |
440 | # ifdef _S_ISLNK | |
441 | # define S_ISLNK(m) _S_ISLNK(m) | |
442 | # else | |
443 | # ifdef _S_IFLNK | |
444 | # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK) | |
445 | # else | |
446 | # ifdef S_IFLNK | |
447 | # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK) | |
448 | # else | |
449 | # define S_ISLNK(m) (0) | |
450 | # endif | |
451 | # endif | |
452 | # endif | |
453 | #endif | |
454 | ||
455 | #ifndef S_ISSOCK | |
456 | # ifdef _S_ISSOCK | |
457 | # define S_ISSOCK(m) _S_ISSOCK(m) | |
458 | # else | |
459 | # ifdef _S_IFSOCK | |
460 | # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK) | |
461 | # else | |
462 | # ifdef S_IFSOCK | |
463 | # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK) | |
464 | # else | |
465 | # define S_ISSOCK(m) (0) | |
466 | # endif | |
467 | # endif | |
468 | # endif | |
469 | #endif | |
470 | ||
471 | #ifndef S_IRUSR | |
472 | # ifdef S_IREAD | |
473 | # define S_IRUSR S_IREAD | |
474 | # define S_IWUSR S_IWRITE | |
475 | # define S_IXUSR S_IEXEC | |
476 | # else | |
477 | # define S_IRUSR 0400 | |
478 | # define S_IWUSR 0200 | |
479 | # define S_IXUSR 0100 | |
480 | # endif | |
481 | # define S_IRGRP (S_IRUSR>>3) | |
482 | # define S_IWGRP (S_IWUSR>>3) | |
483 | # define S_IXGRP (S_IXUSR>>3) | |
484 | # define S_IROTH (S_IRUSR>>6) | |
485 | # define S_IWOTH (S_IWUSR>>6) | |
486 | # define S_IXOTH (S_IXUSR>>6) | |
487 | #endif | |
488 | ||
489 | #ifndef S_ISUID | |
490 | # define S_ISUID 04000 | |
491 | #endif | |
492 | ||
493 | #ifndef S_ISGID | |
494 | # define S_ISGID 02000 | |
495 | #endif | |
496 | ||
79072805 LW |
497 | #ifdef ff_next |
498 | # undef ff_next | |
352d5a3a LW |
499 | #endif |
500 | ||
a0d0e21e | 501 | #if defined(cray) || defined(gould) || defined(i860) || defined(pyr) |
45d8adaa LW |
502 | # define SLOPPYDIVIDE |
503 | #endif | |
504 | ||
0c30d9ec | 505 | #if defined(cray) || defined(convex) || BYTEORDER > 0xffff |
ecfc5424 | 506 | # define HAS_QUAD |
45d8adaa LW |
507 | #endif |
508 | ||
748a9306 LW |
509 | #ifdef UV |
510 | #undef UV | |
511 | #endif | |
512 | ||
ecfc5424 | 513 | #ifdef HAS_QUAD |
45d8adaa | 514 | # ifdef cray |
ecfc5424 | 515 | # define Quad_t int |
45d8adaa | 516 | # else |
0c30d9ec | 517 | # if defined(convex) |
ecfc5424 | 518 | # define Quad_t long long |
45d8adaa | 519 | # else |
ecfc5424 | 520 | # define Quad_t long |
45d8adaa LW |
521 | # endif |
522 | # endif | |
748a9306 LW |
523 | typedef Quad_t IV; |
524 | typedef unsigned Quad_t UV; | |
79072805 | 525 | #else |
748a9306 LW |
526 | typedef long IV; |
527 | typedef unsigned long UV; | |
79072805 LW |
528 | #endif |
529 | ||
ee0007ab | 530 | typedef MEM_SIZE STRLEN; |
450a55e4 | 531 | |
79072805 LW |
532 | typedef struct op OP; |
533 | typedef struct cop COP; | |
534 | typedef struct unop UNOP; | |
535 | typedef struct binop BINOP; | |
536 | typedef struct listop LISTOP; | |
537 | typedef struct logop LOGOP; | |
538 | typedef struct condop CONDOP; | |
539 | typedef struct pmop PMOP; | |
540 | typedef struct svop SVOP; | |
541 | typedef struct gvop GVOP; | |
542 | typedef struct pvop PVOP; | |
79072805 LW |
543 | typedef struct loop LOOP; |
544 | ||
545 | typedef struct Outrec Outrec; | |
93a17b20 | 546 | typedef struct interpreter PerlInterpreter; |
79072805 | 547 | typedef struct ff FF; |
79072805 LW |
548 | typedef struct sv SV; |
549 | typedef struct av AV; | |
550 | typedef struct hv HV; | |
551 | typedef struct cv CV; | |
378cc40b | 552 | typedef struct regexp REGEXP; |
79072805 | 553 | typedef struct gp GP; |
0c30d9ec | 554 | typedef struct gv GV; |
8990e307 | 555 | typedef struct io IO; |
79072805 LW |
556 | typedef struct context CONTEXT; |
557 | typedef struct block BLOCK; | |
558 | ||
559 | typedef struct magic MAGIC; | |
ed6116ce | 560 | typedef struct xrv XRV; |
79072805 LW |
561 | typedef struct xpv XPV; |
562 | typedef struct xpviv XPVIV; | |
563 | typedef struct xpvnv XPVNV; | |
564 | typedef struct xpvmg XPVMG; | |
565 | typedef struct xpvlv XPVLV; | |
566 | typedef struct xpvav XPVAV; | |
567 | typedef struct xpvhv XPVHV; | |
568 | typedef struct xpvgv XPVGV; | |
569 | typedef struct xpvcv XPVCV; | |
570 | typedef struct xpvbm XPVBM; | |
571 | typedef struct xpvfm XPVFM; | |
8990e307 | 572 | typedef struct xpvio XPVIO; |
79072805 LW |
573 | typedef struct mgvtbl MGVTBL; |
574 | typedef union any ANY; | |
8d063cd8 | 575 | |
378cc40b | 576 | #include "handy.h" |
a0d0e21e | 577 | |
16d20bd9 AD |
578 | typedef I32 (*filter_t) _((int, SV *, int)); |
579 | #define FILTER_READ(idx, sv, len) filter_read(idx, sv, len) | |
580 | #define FILTER_DATA(idx) (AvARRAY(rsfp_filters)[idx]) | |
581 | #define FILTER_ISREADER(idx) (idx >= AvFILL(rsfp_filters)) | |
582 | ||
748a9306 | 583 | #ifdef DOSISH |
4633a7c4 LW |
584 | # if defined(OS2) |
585 | # include "os2ish.h" | |
586 | # else | |
748a9306 | 587 | # include "dosish.h" |
4633a7c4 | 588 | # endif |
a0d0e21e | 589 | #else |
748a9306 LW |
590 | # if defined(VMS) |
591 | # include "vmsish.h" | |
592 | # else | |
0c30d9ec | 593 | # if defined(PLAN9) |
594 | # include "./plan9/plan9ish.h" | |
595 | # else | |
596 | # include "unixish.h" | |
597 | # endif | |
748a9306 LW |
598 | # endif |
599 | #endif | |
600 | ||
0c30d9ec | 601 | #ifndef SH_PATH /* May be a variable. */ |
602 | # define SH_PATH BIN_SH | |
603 | #endif | |
604 | ||
748a9306 LW |
605 | #ifndef HAS_PAUSE |
606 | #define pause() sleep((32767<<16)+32767) | |
607 | #endif | |
608 | ||
609 | #ifndef IOCPARM_LEN | |
610 | # ifdef IOCPARM_MASK | |
611 | /* on BSDish systes we're safe */ | |
612 | # define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) | |
613 | # else | |
614 | /* otherwise guess at what's safe */ | |
615 | # define IOCPARM_LEN(x) 256 | |
616 | # endif | |
a0d0e21e LW |
617 | #endif |
618 | ||
79072805 LW |
619 | union any { |
620 | void* any_ptr; | |
621 | I32 any_i32; | |
a0d0e21e | 622 | IV any_iv; |
85e6fe83 | 623 | long any_long; |
a0d0e21e | 624 | void (*any_dptr) _((void*)); |
79072805 LW |
625 | }; |
626 | ||
378cc40b | 627 | #include "regexp.h" |
79072805 | 628 | #include "sv.h" |
378cc40b | 629 | #include "util.h" |
8d063cd8 | 630 | #include "form.h" |
79072805 LW |
631 | #include "gv.h" |
632 | #include "cv.h" | |
633 | #include "opcode.h" | |
634 | #include "op.h" | |
635 | #include "cop.h" | |
636 | #include "av.h" | |
637 | #include "hv.h" | |
638 | #include "mg.h" | |
639 | #include "scope.h" | |
8d063cd8 | 640 | |
4633a7c4 LW |
641 | /* work around some libPW problems */ |
642 | #ifdef DOINIT | |
643 | EXT char Error[1]; | |
644 | #endif | |
645 | ||
450a55e4 | 646 | #if defined(iAPX286) || defined(M_I286) || defined(I80286) |
a687059c LW |
647 | # define I286 |
648 | #endif | |
649 | ||
fe14fcc3 LW |
650 | #if defined(htonl) && !defined(HAS_HTONL) |
651 | #define HAS_HTONL | |
ae986130 | 652 | #endif |
fe14fcc3 LW |
653 | #if defined(htons) && !defined(HAS_HTONS) |
654 | #define HAS_HTONS | |
ae986130 | 655 | #endif |
fe14fcc3 LW |
656 | #if defined(ntohl) && !defined(HAS_NTOHL) |
657 | #define HAS_NTOHL | |
ae986130 | 658 | #endif |
fe14fcc3 LW |
659 | #if defined(ntohs) && !defined(HAS_NTOHS) |
660 | #define HAS_NTOHS | |
ae986130 | 661 | #endif |
fe14fcc3 | 662 | #ifndef HAS_HTONL |
d9d8d8de | 663 | #if (BYTEORDER & 0xffff) != 0x4321 |
fe14fcc3 LW |
664 | #define HAS_HTONS |
665 | #define HAS_HTONL | |
666 | #define HAS_NTOHS | |
667 | #define HAS_NTOHL | |
a687059c LW |
668 | #define MYSWAP |
669 | #define htons my_swap | |
670 | #define htonl my_htonl | |
671 | #define ntohs my_swap | |
672 | #define ntohl my_ntohl | |
673 | #endif | |
674 | #else | |
d9d8d8de | 675 | #if (BYTEORDER & 0xffff) == 0x4321 |
fe14fcc3 LW |
676 | #undef HAS_HTONS |
677 | #undef HAS_HTONL | |
678 | #undef HAS_NTOHS | |
679 | #undef HAS_NTOHL | |
a687059c LW |
680 | #endif |
681 | #endif | |
682 | ||
988174c1 LW |
683 | /* |
684 | * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'. | |
685 | * -DWS | |
686 | */ | |
687 | #if BYTEORDER != 0x1234 | |
688 | # define HAS_VTOHL | |
689 | # define HAS_VTOHS | |
690 | # define HAS_HTOVL | |
691 | # define HAS_HTOVS | |
692 | # if BYTEORDER == 0x4321 | |
693 | # define vtohl(x) ((((x)&0xFF)<<24) \ | |
694 | +(((x)>>24)&0xFF) \ | |
695 | +(((x)&0x0000FF00)<<8) \ | |
696 | +(((x)&0x00FF0000)>>8) ) | |
697 | # define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF)) | |
698 | # define htovl(x) vtohl(x) | |
699 | # define htovs(x) vtohs(x) | |
700 | # endif | |
701 | /* otherwise default to functions in util.c */ | |
702 | #endif | |
703 | ||
0f85fab0 | 704 | #ifdef CASTNEGFLOAT |
79072805 | 705 | #define U_S(what) ((U16)(what)) |
0f85fab0 | 706 | #define U_I(what) ((unsigned int)(what)) |
79072805 | 707 | #define U_L(what) ((U32)(what)) |
0f85fab0 | 708 | #else |
a0d0e21e | 709 | U32 cast_ulong _((double)); |
232e078e AD |
710 | #define U_S(what) ((U16)cast_ulong((double)(what))) |
711 | #define U_I(what) ((unsigned int)cast_ulong((double)(what))) | |
712 | #define U_L(what) (cast_ulong((double)(what))) | |
ee0007ab LW |
713 | #endif |
714 | ||
ed6116ce LW |
715 | #ifdef CASTI32 |
716 | #define I_32(what) ((I32)(what)) | |
a0d0e21e | 717 | #define I_V(what) ((IV)(what)) |
5d94fbed | 718 | #define U_V(what) ((UV)(what)) |
ed6116ce | 719 | #else |
a0d0e21e | 720 | I32 cast_i32 _((double)); |
232e078e | 721 | #define I_32(what) (cast_i32((double)(what))) |
a0d0e21e | 722 | IV cast_iv _((double)); |
232e078e | 723 | #define I_V(what) (cast_iv((double)(what))) |
5d94fbed AD |
724 | UV cast_uv _((double)); |
725 | #define U_V(what) (cast_uv((double)(what))) | |
ed6116ce LW |
726 | #endif |
727 | ||
79072805 LW |
728 | struct Outrec { |
729 | I32 o_lines; | |
d9d8d8de | 730 | char *o_str; |
79072805 | 731 | U32 o_len; |
8d063cd8 LW |
732 | }; |
733 | ||
352d5a3a LW |
734 | #ifndef MAXSYSFD |
735 | # define MAXSYSFD 2 | |
736 | #endif | |
ee0007ab | 737 | |
f82b3d41 | 738 | #ifndef TMPPATH |
739 | # define TMPPATH "/tmp/perl-eXXXXXX" | |
a0d0e21e | 740 | #endif |
79072805 LW |
741 | |
742 | #ifndef __cplusplus | |
a0d0e21e LW |
743 | Uid_t getuid _((void)); |
744 | Uid_t geteuid _((void)); | |
745 | Gid_t getgid _((void)); | |
746 | Gid_t getegid _((void)); | |
79072805 | 747 | #endif |
8d063cd8 LW |
748 | |
749 | #ifdef DEBUGGING | |
0c30d9ec | 750 | #ifndef Perl_debug_log |
751 | #define Perl_debug_log stderr | |
752 | #endif | |
d96024cf | 753 | #define YYDEBUG 1 |
79072805 LW |
754 | #define DEB(a) a |
755 | #define DEBUG(a) if (debug) a | |
756 | #define DEBUG_p(a) if (debug & 1) a | |
757 | #define DEBUG_s(a) if (debug & 2) a | |
758 | #define DEBUG_l(a) if (debug & 4) a | |
759 | #define DEBUG_t(a) if (debug & 8) a | |
760 | #define DEBUG_o(a) if (debug & 16) a | |
761 | #define DEBUG_c(a) if (debug & 32) a | |
762 | #define DEBUG_P(a) if (debug & 64) a | |
0c30d9ec | 763 | #define DEBUG_m(a) if (curinterp && debug & 128) a |
79072805 LW |
764 | #define DEBUG_f(a) if (debug & 256) a |
765 | #define DEBUG_r(a) if (debug & 512) a | |
766 | #define DEBUG_x(a) if (debug & 1024) a | |
767 | #define DEBUG_u(a) if (debug & 2048) a | |
768 | #define DEBUG_L(a) if (debug & 4096) a | |
769 | #define DEBUG_H(a) if (debug & 8192) a | |
770 | #define DEBUG_X(a) if (debug & 16384) a | |
8990e307 | 771 | #define DEBUG_D(a) if (debug & 32768) a |
79072805 LW |
772 | #else |
773 | #define DEB(a) | |
774 | #define DEBUG(a) | |
775 | #define DEBUG_p(a) | |
776 | #define DEBUG_s(a) | |
777 | #define DEBUG_l(a) | |
778 | #define DEBUG_t(a) | |
779 | #define DEBUG_o(a) | |
780 | #define DEBUG_c(a) | |
781 | #define DEBUG_P(a) | |
782 | #define DEBUG_m(a) | |
783 | #define DEBUG_f(a) | |
784 | #define DEBUG_r(a) | |
785 | #define DEBUG_x(a) | |
786 | #define DEBUG_u(a) | |
787 | #define DEBUG_L(a) | |
788 | #define DEBUG_H(a) | |
789 | #define DEBUG_X(a) | |
8990e307 | 790 | #define DEBUG_D(a) |
8d063cd8 | 791 | #endif |
fe14fcc3 | 792 | #define YYMAXDEPTH 300 |
8d063cd8 | 793 | |
79072805 LW |
794 | #define assert(what) DEB( { \ |
795 | if (!(what)) { \ | |
463ee0b2 | 796 | croak("Assertion failed: file \"%s\", line %d", \ |
79072805 LW |
797 | __FILE__, __LINE__); \ |
798 | exit(1); \ | |
799 | }}) | |
8d063cd8 | 800 | |
450a55e4 | 801 | struct ufuncs { |
a0d0e21e LW |
802 | I32 (*uf_val)_((IV, SV*)); |
803 | I32 (*uf_set)_((IV, SV*)); | |
804 | IV uf_index; | |
450a55e4 LW |
805 | }; |
806 | ||
fe14fcc3 | 807 | /* Fix these up for __STDC__ */ |
a0d0e21e LW |
808 | #ifndef __cplusplus |
809 | char *mktemp _((char*)); | |
810 | double atof _((const char*)); | |
811 | #endif | |
79072805 | 812 | |
352d5a3a | 813 | #ifndef STANDARD_C |
fe14fcc3 | 814 | /* All of these are in stdlib.h or time.h for ANSI C */ |
85e6fe83 | 815 | Time_t time(); |
8d063cd8 | 816 | struct tm *gmtime(), *localtime(); |
93a17b20 | 817 | char *strchr(), *strrchr(); |
378cc40b | 818 | char *strcpy(), *strcat(); |
352d5a3a | 819 | #endif /* ! STANDARD_C */ |
8d063cd8 | 820 | |
79072805 LW |
821 | |
822 | #ifdef I_MATH | |
823 | # include <math.h> | |
824 | #else | |
825 | # ifdef __cplusplus | |
826 | extern "C" { | |
827 | # endif | |
a0d0e21e | 828 | double exp _((double)); |
a0d0e21e LW |
829 | double log _((double)); |
830 | double sqrt _((double)); | |
831 | double modf _((double,double*)); | |
832 | double sin _((double)); | |
833 | double cos _((double)); | |
834 | double atan2 _((double,double)); | |
835 | double pow _((double,double)); | |
79072805 LW |
836 | # ifdef __cplusplus |
837 | }; | |
838 | # endif | |
839 | #endif | |
840 | ||
a0d0e21e LW |
841 | #ifndef __cplusplus |
842 | char *crypt _((const char*, const char*)); | |
843 | char *getenv _((const char*)); | |
844 | Off_t lseek _((int,Off_t,int)); | |
845 | char *getlogin _((void)); | |
846 | #endif | |
79072805 | 847 | |
16d20bd9 | 848 | #ifdef UNLINK_ALL_VERSIONS /* Currently only makes sense for VMS */ |
378cc40b | 849 | #define UNLINK unlnk |
a0d0e21e | 850 | I32 unlnk _((char*)); |
8d063cd8 LW |
851 | #else |
852 | #define UNLINK unlink | |
853 | #endif | |
a687059c | 854 | |
fe14fcc3 | 855 | #ifndef HAS_SETREUID |
85e6fe83 LW |
856 | # ifdef HAS_SETRESUID |
857 | # define setreuid(r,e) setresuid(r,e,(Uid_t)-1) | |
858 | # define HAS_SETREUID | |
859 | # endif | |
a687059c | 860 | #endif |
fe14fcc3 | 861 | #ifndef HAS_SETREGID |
85e6fe83 LW |
862 | # ifdef HAS_SETRESGID |
863 | # define setregid(r,e) setresgid(r,e,(Gid_t)-1) | |
864 | # define HAS_SETREGID | |
865 | # endif | |
a687059c | 866 | #endif |
ee0007ab LW |
867 | |
868 | #define SCAN_DEF 0 | |
869 | #define SCAN_TR 1 | |
870 | #define SCAN_REPL 2 | |
79072805 LW |
871 | |
872 | #ifdef DEBUGGING | |
4633a7c4 | 873 | # ifndef register |
a0d0e21e LW |
874 | # define register |
875 | # endif | |
c07a80fd | 876 | # ifdef MYMALLOC |
0c30d9ec | 877 | # ifndef DEBUGGING_MSTATS |
878 | # define DEBUGGING_MSTATS | |
879 | # endif | |
c07a80fd | 880 | # endif |
a0d0e21e | 881 | # define PAD_SV(po) pad_sv(po) |
79072805 | 882 | #else |
a0d0e21e | 883 | # define PAD_SV(po) curpad[po] |
79072805 LW |
884 | #endif |
885 | ||
886 | /****************/ | |
887 | /* Truly global */ | |
888 | /****************/ | |
889 | ||
890 | /* global state */ | |
a0d0e21e | 891 | EXT PerlInterpreter * curinterp; /* currently running interpreter */ |
0c30d9ec | 892 | /* VMS doesn't use environ array and NeXT has problems with crt0.o globals */ |
893 | #if !defined(VMS) && !(defined(NeXT) && defined(__DYNAMIC__)) | |
79072805 | 894 | extern char ** environ; /* environment variables supplied via exec */ |
0c30d9ec | 895 | #else |
896 | # if defined(NeXT) && defined(__DYNAMIC__) | |
897 | ||
898 | # include <mach-o/dyld.h> | |
899 | EXT char *** environ_pointer; | |
900 | # define environ (*environ_pointer) | |
901 | # endif | |
902 | #endif /* environ processing */ | |
903 | ||
79072805 LW |
904 | EXT int uid; /* current real user id */ |
905 | EXT int euid; /* current effective user id */ | |
906 | EXT int gid; /* current real group id */ | |
907 | EXT int egid; /* current effective group id */ | |
908 | EXT bool nomemok; /* let malloc context handle nomem */ | |
909 | EXT U32 an; /* malloc sequence number */ | |
463ee0b2 | 910 | EXT U32 cop_seqmax; /* statement sequence number */ |
c07a80fd | 911 | EXT U16 op_seqmax; /* op sequence number */ |
8990e307 | 912 | EXT U32 evalseq; /* eval sequence number */ |
463ee0b2 | 913 | EXT U32 sub_generation; /* inc to force methods to be looked up again */ |
79072805 LW |
914 | EXT char ** origenviron; |
915 | EXT U32 origalen; | |
a0d0e21e | 916 | EXT U32 * profiledata; |
84ea024a | 917 | EXT int maxo INIT(MAXO);/* Number of ops */ |
728e2803 | 918 | EXT char * osname; /* operating system */ |
79072805 | 919 | |
a0d0e21e LW |
920 | EXT XPV* xiv_arenaroot; /* list of allocated xiv areas */ |
921 | EXT IV ** xiv_root; /* free xiv list--shared by interpreters */ | |
8990e307 LW |
922 | EXT double * xnv_root; /* free xnv list--shared by interpreters */ |
923 | EXT XRV * xrv_root; /* free xrv list--shared by interpreters */ | |
924 | EXT XPV * xpv_root; /* free xpv list--shared by interpreters */ | |
4633a7c4 | 925 | EXT HE * he_root; /* free he list--shared by interpreters */ |
c07a80fd | 926 | EXT char * nice_chunk; /* a nice chunk of memory to reuse */ |
927 | EXT U32 nice_chunk_size;/* how nice the chunk of memory is */ | |
8990e307 | 928 | |
79072805 LW |
929 | /* Stack for currently executing thread--context switch must handle this. */ |
930 | EXT SV ** stack_base; /* stack->array_ary */ | |
931 | EXT SV ** stack_sp; /* stack pointer now */ | |
932 | EXT SV ** stack_max; /* stack->array_ary + stack->array_max */ | |
933 | ||
934 | /* likewise for these */ | |
935 | ||
936 | EXT OP * op; /* current op--oughta be in a global register */ | |
937 | ||
938 | EXT I32 * scopestack; /* blocks we've entered */ | |
939 | EXT I32 scopestack_ix; | |
940 | EXT I32 scopestack_max; | |
941 | ||
942 | EXT ANY* savestack; /* to save non-local values on */ | |
943 | EXT I32 savestack_ix; | |
944 | EXT I32 savestack_max; | |
945 | ||
946 | EXT OP ** retstack; /* returns we've pushed */ | |
947 | EXT I32 retstack_ix; | |
948 | EXT I32 retstack_max; | |
949 | ||
950 | EXT I32 * markstack; /* stackmarks we're remembering */ | |
951 | EXT I32 * markstack_ptr; /* stackmarks we're remembering */ | |
952 | EXT I32 * markstack_max; /* stackmarks we're remembering */ | |
953 | ||
954 | EXT SV ** curpad; | |
955 | ||
956 | /* temp space */ | |
957 | EXT SV * Sv; | |
958 | EXT XPV * Xpv; | |
f82b3d41 | 959 | EXT char buf[2048]; /* should be longer than PATH_MAX */ |
79072805 LW |
960 | EXT char tokenbuf[256]; |
961 | EXT struct stat statbuf; | |
ecfc5424 | 962 | #ifdef HAS_TIMES |
79072805 LW |
963 | EXT struct tms timesbuf; |
964 | #endif | |
463ee0b2 | 965 | EXT STRLEN na; /* for use in SvPV when length is Not Applicable */ |
79072805 LW |
966 | |
967 | /* for tmp use in stupid debuggers */ | |
968 | EXT int * di; | |
969 | EXT short * ds; | |
970 | EXT char * dc; | |
971 | ||
972 | /* handy constants */ | |
973 | EXT char * Yes INIT("1"); | |
974 | EXT char * No INIT(""); | |
975 | EXT char * hexdigit INIT("0123456789abcdef0123456789ABCDEFx"); | |
79072805 LW |
976 | EXT char * patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}"); |
977 | EXT char * vert INIT("|"); | |
978 | ||
8990e307 | 979 | EXT char warn_uninit[] |
a0d0e21e | 980 | INIT("Use of uninitialized value"); |
463ee0b2 LW |
981 | EXT char warn_nosemi[] |
982 | INIT("Semicolon seems to be missing"); | |
983 | EXT char warn_reserved[] | |
984 | INIT("Unquoted string \"%s\" may clash with future reserved word"); | |
985 | EXT char warn_nl[] | |
93a17b20 | 986 | INIT("Unsuccessful %s on filename containing newline"); |
a0d0e21e LW |
987 | EXT char no_wrongref[] |
988 | INIT("Can't use %s ref as %s ref"); | |
989 | EXT char no_symref[] | |
748a9306 | 990 | INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use"); |
93a17b20 | 991 | EXT char no_usym[] |
8990e307 | 992 | INIT("Can't use an undefined value as %s reference"); |
93a17b20 LW |
993 | EXT char no_aelem[] |
994 | INIT("Modification of non-creatable array value attempted, subscript %d"); | |
995 | EXT char no_helem[] | |
996 | INIT("Modification of non-creatable hash value attempted, subscript \"%s\""); | |
997 | EXT char no_modify[] | |
998 | INIT("Modification of a read-only value attempted"); | |
999 | EXT char no_mem[] | |
1000 | INIT("Out of memory!\n"); | |
1001 | EXT char no_security[] | |
463ee0b2 | 1002 | INIT("Insecure dependency in %s%s"); |
93a17b20 LW |
1003 | EXT char no_sock_func[] |
1004 | INIT("Unsupported socket function \"%s\" called"); | |
1005 | EXT char no_dir_func[] | |
1006 | INIT("Unsupported directory function \"%s\" called"); | |
1007 | EXT char no_func[] | |
1008 | INIT("The %s function is unimplemented"); | |
748a9306 LW |
1009 | EXT char no_myglob[] |
1010 | INIT("\"my\" variable %s can't be in a package"); | |
93a17b20 | 1011 | |
79072805 LW |
1012 | EXT SV sv_undef; |
1013 | EXT SV sv_no; | |
1014 | EXT SV sv_yes; | |
1015 | #ifdef CSH | |
1016 | EXT char * cshname INIT(CSH); | |
1017 | EXT I32 cshlen; | |
1018 | #endif | |
1019 | ||
1020 | #ifdef DOINIT | |
8e07c86e AD |
1021 | EXT char *sig_name[] = { SIG_NAME }; |
1022 | EXT int sig_num[] = { SIG_NUM }; | |
0c30d9ec | 1023 | EXT SV * psig_ptr[sizeof(sig_num)/sizeof(*sig_num)]; |
1024 | EXT SV * psig_name[sizeof(sig_num)/sizeof(*sig_num)]; | |
79072805 LW |
1025 | #else |
1026 | EXT char *sig_name[]; | |
8e07c86e | 1027 | EXT int sig_num[]; |
0c30d9ec | 1028 | EXT SV * psig_ptr[]; |
1029 | EXT SV * psig_name[]; | |
79072805 LW |
1030 | #endif |
1031 | ||
1032 | #ifdef DOINIT | |
79072805 LW |
1033 | EXT unsigned char fold[] = { /* fast case folding table */ |
1034 | 0, 1, 2, 3, 4, 5, 6, 7, | |
1035 | 8, 9, 10, 11, 12, 13, 14, 15, | |
1036 | 16, 17, 18, 19, 20, 21, 22, 23, | |
1037 | 24, 25, 26, 27, 28, 29, 30, 31, | |
1038 | 32, 33, 34, 35, 36, 37, 38, 39, | |
1039 | 40, 41, 42, 43, 44, 45, 46, 47, | |
1040 | 48, 49, 50, 51, 52, 53, 54, 55, | |
1041 | 56, 57, 58, 59, 60, 61, 62, 63, | |
1042 | 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g', | |
1043 | 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', | |
1044 | 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', | |
1045 | 'x', 'y', 'z', 91, 92, 93, 94, 95, | |
1046 | 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G', | |
1047 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', | |
1048 | 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', | |
1049 | 'X', 'Y', 'Z', 123, 124, 125, 126, 127, | |
1050 | 128, 129, 130, 131, 132, 133, 134, 135, | |
1051 | 136, 137, 138, 139, 140, 141, 142, 143, | |
1052 | 144, 145, 146, 147, 148, 149, 150, 151, | |
1053 | 152, 153, 154, 155, 156, 157, 158, 159, | |
1054 | 160, 161, 162, 163, 164, 165, 166, 167, | |
1055 | 168, 169, 170, 171, 172, 173, 174, 175, | |
1056 | 176, 177, 178, 179, 180, 181, 182, 183, | |
1057 | 184, 185, 186, 187, 188, 189, 190, 191, | |
1058 | 192, 193, 194, 195, 196, 197, 198, 199, | |
1059 | 200, 201, 202, 203, 204, 205, 206, 207, | |
1060 | 208, 209, 210, 211, 212, 213, 214, 215, | |
1061 | 216, 217, 218, 219, 220, 221, 222, 223, | |
1062 | 224, 225, 226, 227, 228, 229, 230, 231, | |
1063 | 232, 233, 234, 235, 236, 237, 238, 239, | |
1064 | 240, 241, 242, 243, 244, 245, 246, 247, | |
1065 | 248, 249, 250, 251, 252, 253, 254, 255 | |
1066 | }; | |
1067 | #else | |
1068 | EXT unsigned char fold[]; | |
1069 | #endif | |
1070 | ||
1071 | #ifdef DOINIT | |
1072 | EXT unsigned char freq[] = { /* letter frequencies for mixed English/C */ | |
1073 | 1, 2, 84, 151, 154, 155, 156, 157, | |
1074 | 165, 246, 250, 3, 158, 7, 18, 29, | |
1075 | 40, 51, 62, 73, 85, 96, 107, 118, | |
1076 | 129, 140, 147, 148, 149, 150, 152, 153, | |
1077 | 255, 182, 224, 205, 174, 176, 180, 217, | |
1078 | 233, 232, 236, 187, 235, 228, 234, 226, | |
1079 | 222, 219, 211, 195, 188, 193, 185, 184, | |
1080 | 191, 183, 201, 229, 181, 220, 194, 162, | |
1081 | 163, 208, 186, 202, 200, 218, 198, 179, | |
1082 | 178, 214, 166, 170, 207, 199, 209, 206, | |
1083 | 204, 160, 212, 216, 215, 192, 175, 173, | |
1084 | 243, 172, 161, 190, 203, 189, 164, 230, | |
1085 | 167, 248, 227, 244, 242, 255, 241, 231, | |
1086 | 240, 253, 169, 210, 245, 237, 249, 247, | |
1087 | 239, 168, 252, 251, 254, 238, 223, 221, | |
1088 | 213, 225, 177, 197, 171, 196, 159, 4, | |
1089 | 5, 6, 8, 9, 10, 11, 12, 13, | |
1090 | 14, 15, 16, 17, 19, 20, 21, 22, | |
1091 | 23, 24, 25, 26, 27, 28, 30, 31, | |
1092 | 32, 33, 34, 35, 36, 37, 38, 39, | |
1093 | 41, 42, 43, 44, 45, 46, 47, 48, | |
1094 | 49, 50, 52, 53, 54, 55, 56, 57, | |
1095 | 58, 59, 60, 61, 63, 64, 65, 66, | |
1096 | 67, 68, 69, 70, 71, 72, 74, 75, | |
1097 | 76, 77, 78, 79, 80, 81, 82, 83, | |
1098 | 86, 87, 88, 89, 90, 91, 92, 93, | |
1099 | 94, 95, 97, 98, 99, 100, 101, 102, | |
1100 | 103, 104, 105, 106, 108, 109, 110, 111, | |
1101 | 112, 113, 114, 115, 116, 117, 119, 120, | |
1102 | 121, 122, 123, 124, 125, 126, 127, 128, | |
1103 | 130, 131, 132, 133, 134, 135, 136, 137, | |
1104 | 138, 139, 141, 142, 143, 144, 145, 146 | |
1105 | }; | |
1106 | #else | |
1107 | EXT unsigned char freq[]; | |
1108 | #endif | |
1109 | ||
8990e307 LW |
1110 | #ifdef DEBUGGING |
1111 | #ifdef DOINIT | |
1112 | EXT char* block_type[] = { | |
1113 | "NULL", | |
1114 | "SUB", | |
1115 | "EVAL", | |
1116 | "LOOP", | |
1117 | "SUBST", | |
1118 | "BLOCK", | |
1119 | }; | |
1120 | #else | |
1121 | EXT char* block_type[]; | |
1122 | #endif | |
1123 | #endif | |
1124 | ||
79072805 LW |
1125 | /*****************************************************************************/ |
1126 | /* This lexer/parser stuff is currently global since yacc is hard to reenter */ | |
1127 | /*****************************************************************************/ | |
8990e307 | 1128 | /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */ |
79072805 | 1129 | |
a0d0e21e LW |
1130 | #include "perly.h" |
1131 | ||
79072805 LW |
1132 | typedef enum { |
1133 | XOPERATOR, | |
1134 | XTERM, | |
79072805 | 1135 | XREF, |
8990e307 | 1136 | XSTATE, |
a0d0e21e LW |
1137 | XBLOCK, |
1138 | XTERMBLOCK | |
79072805 LW |
1139 | } expectation; |
1140 | ||
a0d0e21e LW |
1141 | EXT U32 lex_state; /* next token is determined */ |
1142 | EXT U32 lex_defer; /* state after determined token */ | |
1143 | EXT expectation lex_expect; /* expect after determined token */ | |
1144 | EXT I32 lex_brackets; /* bracket count */ | |
1145 | EXT I32 lex_formbrack; /* bracket count at outer format level */ | |
1146 | EXT I32 lex_fakebrack; /* outer bracket is mere delimiter */ | |
1147 | EXT I32 lex_casemods; /* casemod count */ | |
1148 | EXT I32 lex_dojoin; /* doing an array interpolation */ | |
1149 | EXT I32 lex_starts; /* how many interps done on level */ | |
1150 | EXT SV * lex_stuff; /* runtime pattern from m// or s/// */ | |
1151 | EXT SV * lex_repl; /* runtime replacement from s/// */ | |
1152 | EXT OP * lex_op; /* extra info to pass back on op */ | |
1153 | EXT OP * lex_inpat; /* in pattern $) and $| are special */ | |
1154 | EXT I32 lex_inwhat; /* what kind of quoting are we in */ | |
1155 | EXT char * lex_brackstack; /* what kind of brackets to pop */ | |
1156 | EXT char * lex_casestack; /* what kind of case mods in effect */ | |
1157 | ||
1158 | /* What we know when we're in LEX_KNOWNEXT state. */ | |
1159 | EXT YYSTYPE nextval[5]; /* value of next token, if any */ | |
1160 | EXT I32 nexttype[5]; /* type of next token */ | |
1161 | EXT I32 nexttoke; | |
1162 | ||
79072805 LW |
1163 | EXT FILE * VOL rsfp INIT(Nullfp); |
1164 | EXT SV * linestr; | |
1165 | EXT char * bufptr; | |
1166 | EXT char * oldbufptr; | |
1167 | EXT char * oldoldbufptr; | |
1168 | EXT char * bufend; | |
8990e307 | 1169 | EXT expectation expect INIT(XSTATE); /* how to interpret ambiguous tokens */ |
16d20bd9 | 1170 | EXT AV * rsfp_filters; |
79072805 LW |
1171 | |
1172 | EXT I32 multi_start; /* 1st line of multi-line string */ | |
1173 | EXT I32 multi_end; /* last line of multi-line string */ | |
1174 | EXT I32 multi_open; /* delimiter of said string */ | |
1175 | EXT I32 multi_close; /* delimiter of said string */ | |
1176 | ||
1177 | EXT GV * scrgv; | |
1178 | EXT I32 error_count; /* how many errors so far, max 10 */ | |
1179 | EXT I32 subline; /* line this subroutine began on */ | |
1180 | EXT SV * subname; /* name of current subroutine */ | |
1181 | ||
748a9306 | 1182 | EXT CV * compcv; /* currently compiling subroutine */ |
93a17b20 | 1183 | EXT AV * comppad; /* storage for lexically scoped temporaries */ |
8990e307 LW |
1184 | EXT AV * comppad_name; /* variable names for "my" variables */ |
1185 | EXT I32 comppad_name_fill;/* last "introduced" variable offset */ | |
0c30d9ec | 1186 | EXT I32 comppad_name_floor;/* start of vars in innermost block */ |
8990e307 LW |
1187 | EXT I32 min_intro_pending;/* start of vars to introduce */ |
1188 | EXT I32 max_intro_pending;/* end of vars to introduce */ | |
79072805 | 1189 | EXT I32 padix; /* max used index in current "register" pad */ |
a0d0e21e | 1190 | EXT I32 padix_floor; /* how low may inner block reset padix */ |
748a9306 | 1191 | EXT I32 pad_reset_pending; /* reset pad on next attempted alloc */ |
79072805 LW |
1192 | EXT COP compiling; |
1193 | ||
79072805 LW |
1194 | EXT I32 thisexpr; /* name id for nothing_in_common() */ |
1195 | EXT char * last_uni; /* position of last named-unary operator */ | |
1196 | EXT char * last_lop; /* position of last list operator */ | |
8990e307 | 1197 | EXT OPCODE last_lop_op; /* last list operator */ |
93a17b20 | 1198 | EXT bool in_my; /* we're compiling a "my" declaration */ |
79072805 LW |
1199 | #ifdef FCRYPT |
1200 | EXT I32 cryptseen; /* has fast crypt() been initialized? */ | |
1201 | #endif | |
1202 | ||
85e6fe83 LW |
1203 | EXT U32 hints; /* various compilation flags */ |
1204 | ||
1205 | /* Note: the lowest 8 bits are reserved for | |
1206 | stuffing into op->op_private */ | |
1207 | #define HINT_INTEGER 0x00000001 | |
1208 | #define HINT_STRICT_REFS 0x00000002 | |
1209 | ||
1210 | #define HINT_BLOCK_SCOPE 0x00000100 | |
1211 | #define HINT_STRICT_SUBS 0x00000200 | |
1212 | #define HINT_STRICT_VARS 0x00000400 | |
0c30d9ec | 1213 | #define HINT_STRICT_UNTIE 0x00000800 |
85e6fe83 | 1214 | |
79072805 LW |
1215 | /**************************************************************************/ |
1216 | /* This regexp stuff is global since it always happens within 1 expr eval */ | |
1217 | /**************************************************************************/ | |
1218 | ||
1219 | EXT char * regprecomp; /* uncompiled string. */ | |
1220 | EXT char * regparse; /* Input-scan pointer. */ | |
1221 | EXT char * regxend; /* End of input for compile */ | |
1222 | EXT I32 regnpar; /* () count. */ | |
1223 | EXT char * regcode; /* Code-emit pointer; ®dummy = don't. */ | |
1224 | EXT I32 regsize; /* Code size. */ | |
a0d0e21e | 1225 | EXT I32 regnaughty; /* How bad is this pattern? */ |
79072805 LW |
1226 | EXT I32 regsawback; /* Did we see \1, ...? */ |
1227 | ||
1228 | EXT char * reginput; /* String-input pointer. */ | |
79072805 LW |
1229 | EXT char * regbol; /* Beginning of input, for ^ check. */ |
1230 | EXT char * regeol; /* End of input, for $ check. */ | |
1231 | EXT char ** regstartp; /* Pointer to startp array. */ | |
1232 | EXT char ** regendp; /* Ditto for endp. */ | |
a0d0e21e | 1233 | EXT U32 * reglastparen; /* Similarly for lastparen. */ |
79072805 | 1234 | EXT char * regtill; /* How far we are required to go. */ |
a0d0e21e LW |
1235 | EXT U16 regflags; /* are we folding, multilining? */ |
1236 | EXT char regprev; /* char before regbol, \n if none */ | |
79072805 LW |
1237 | |
1238 | /***********************************************/ | |
1239 | /* Global only to current interpreter instance */ | |
1240 | /***********************************************/ | |
1241 | ||
8990e307 | 1242 | #ifdef MULTIPLICITY |
79072805 LW |
1243 | #define IEXT |
1244 | #define IINIT(x) | |
1245 | struct interpreter { | |
1246 | #else | |
1247 | #define IEXT EXT | |
1248 | #define IINIT(x) INIT(x) | |
1249 | #endif | |
1250 | ||
1251 | /* pseudo environmental stuff */ | |
1252 | IEXT int Iorigargc; | |
1253 | IEXT char ** Iorigargv; | |
1254 | IEXT GV * Ienvgv; | |
1255 | IEXT GV * Isiggv; | |
1256 | IEXT GV * Iincgv; | |
1257 | IEXT char * Iorigfilename; | |
748a9306 LW |
1258 | IEXT SV * Idiehook; |
1259 | IEXT SV * Iwarnhook; | |
1260 | IEXT SV * Iparsehook; | |
79072805 | 1261 | |
c07a80fd | 1262 | /* Various states of an input record separator SV (rs, nrs) */ |
1263 | #define RsSNARF(sv) (! SvOK(sv)) | |
1264 | #define RsSIMPLE(sv) (SvOK(sv) && SvCUR(sv)) | |
1265 | #define RsPARA(sv) (SvOK(sv) && ! SvCUR(sv)) | |
1266 | ||
79072805 LW |
1267 | /* switches */ |
1268 | IEXT char * Icddir; | |
1269 | IEXT bool Iminus_c; | |
a5f75d66 | 1270 | IEXT char Ipatchlevel[10]; |
728e2803 | 1271 | IEXT char ** Ilocalpatches; |
c07a80fd | 1272 | IEXT SV * Inrs; |
2304df62 | 1273 | IEXT char * Isplitstr IINIT(" "); |
79072805 LW |
1274 | IEXT bool Ipreprocess; |
1275 | IEXT bool Iminus_n; | |
1276 | IEXT bool Iminus_p; | |
1277 | IEXT bool Iminus_l; | |
1278 | IEXT bool Iminus_a; | |
2304df62 | 1279 | IEXT bool Iminus_F; |
79072805 LW |
1280 | IEXT bool Idoswitches; |
1281 | IEXT bool Idowarn; | |
1282 | IEXT bool Idoextract; | |
79072805 LW |
1283 | IEXT bool Isawampersand; /* must save all match strings */ |
1284 | IEXT bool Isawstudy; /* do fbm_instr on all strings */ | |
1285 | IEXT bool Isawi; /* study must assume case insensitive */ | |
1286 | IEXT bool Isawvec; | |
1287 | IEXT bool Iunsafe; | |
1288 | IEXT bool Ido_undump; /* -u or dump seen? */ | |
1289 | IEXT char * Iinplace; | |
1290 | IEXT char * Ie_tmpname; | |
1291 | IEXT FILE * Ie_fp; | |
1292 | IEXT VOL U32 Idebug; | |
1293 | IEXT U32 Iperldb; | |
748a9306 LW |
1294 | /* This value may be raised by extensions for testing purposes */ |
1295 | IEXT int Iperl_destruct_level; /* 0=none, 1=full, 2=full with checks */ | |
79072805 LW |
1296 | |
1297 | /* magical thingies */ | |
85e6fe83 | 1298 | IEXT Time_t Ibasetime; /* $^T */ |
79072805 LW |
1299 | IEXT SV * Iformfeed; /* $^L */ |
1300 | IEXT char * Ichopset IINIT(" \n-"); /* $: */ | |
c07a80fd | 1301 | IEXT SV * Irs; /* $/ */ |
79072805 | 1302 | IEXT char * Iofs; /* $, */ |
8990e307 | 1303 | IEXT STRLEN Iofslen; |
79072805 | 1304 | IEXT char * Iors; /* $\ */ |
8990e307 | 1305 | IEXT STRLEN Iorslen; |
79072805 LW |
1306 | IEXT char * Iofmt; /* $# */ |
1307 | IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */ | |
1308 | IEXT int Imultiline; /* $*--do strings hold >1 line? */ | |
748a9306 | 1309 | IEXT U32 Istatusvalue; /* $? */ |
79072805 LW |
1310 | |
1311 | IEXT struct stat Istatcache; /* _ */ | |
1312 | IEXT GV * Istatgv; | |
1313 | IEXT SV * Istatname IINIT(Nullsv); | |
1314 | ||
1315 | /* shortcuts to various I/O objects */ | |
1316 | IEXT GV * Istdingv; | |
1317 | IEXT GV * Ilast_in_gv; | |
1318 | IEXT GV * Idefgv; | |
1319 | IEXT GV * Iargvgv; | |
1320 | IEXT GV * Idefoutgv; | |
79072805 LW |
1321 | IEXT GV * Iargvoutgv; |
1322 | ||
1323 | /* shortcuts to regexp stuff */ | |
1324 | IEXT GV * Ileftgv; | |
1325 | IEXT GV * Iampergv; | |
1326 | IEXT GV * Irightgv; | |
1327 | IEXT PMOP * Icurpm; /* what to do \ interps from */ | |
79072805 LW |
1328 | IEXT I32 * Iscreamfirst; |
1329 | IEXT I32 * Iscreamnext; | |
1330 | IEXT I32 Imaxscream IINIT(-1); | |
1331 | IEXT SV * Ilastscream; | |
1332 | ||
4633a7c4 LW |
1333 | /* shortcuts to misc objects */ |
1334 | IEXT GV * Ierrgv; | |
1335 | ||
79072805 LW |
1336 | /* shortcuts to debugging objects */ |
1337 | IEXT GV * IDBgv; | |
1338 | IEXT GV * IDBline; | |
1339 | IEXT GV * IDBsub; | |
1340 | IEXT SV * IDBsingle; | |
1341 | IEXT SV * IDBtrace; | |
1342 | IEXT SV * IDBsignal; | |
1343 | IEXT AV * Ilineary; /* lines of script for debugger */ | |
1344 | IEXT AV * Idbargs; /* args to call listed by caller function */ | |
1345 | ||
1346 | /* symbol tables */ | |
1347 | IEXT HV * Idefstash; /* main symbol table */ | |
1348 | IEXT HV * Icurstash; /* symbol table for current package */ | |
1349 | IEXT HV * Idebstash; /* symbol table for perldb package */ | |
1350 | IEXT SV * Icurstname; /* name of current package */ | |
93a17b20 LW |
1351 | IEXT AV * Ibeginav; /* names of BEGIN subroutines */ |
1352 | IEXT AV * Iendav; /* names of END subroutines */ | |
0c30d9ec | 1353 | IEXT HV * Istrtab; /* shared string table */ |
79072805 LW |
1354 | |
1355 | /* memory management */ | |
79072805 LW |
1356 | IEXT SV ** Itmps_stack; |
1357 | IEXT I32 Itmps_ix IINIT(-1); | |
1358 | IEXT I32 Itmps_floor IINIT(-1); | |
8990e307 LW |
1359 | IEXT I32 Itmps_max; |
1360 | IEXT I32 Isv_count; /* how many SV* are currently allocated */ | |
a0d0e21e | 1361 | IEXT I32 Isv_objcount; /* how many objects are currently allocated */ |
8990e307 LW |
1362 | IEXT SV* Isv_root; /* storage for SVs belonging to interp */ |
1363 | IEXT SV* Isv_arenaroot; /* list of areas for garbage collection */ | |
79072805 LW |
1364 | |
1365 | /* funky return mechanisms */ | |
1366 | IEXT I32 Ilastspbase; | |
1367 | IEXT I32 Ilastsize; | |
1368 | IEXT int Iforkprocess; /* so do_open |- can return proc# */ | |
1369 | ||
1370 | /* subprocess state */ | |
1371 | IEXT AV * Ifdpid; /* keep fd-to-pid mappings for my_popen */ | |
1372 | IEXT HV * Ipidstatus; /* keep pid-to-status mappings for waitpid */ | |
1373 | ||
1374 | /* internal state */ | |
463ee0b2 LW |
1375 | IEXT VOL int Iin_eval; /* trap "fatal" errors? */ |
1376 | IEXT OP * Irestartop; /* Are we propagating an error from croak? */ | |
79072805 | 1377 | IEXT int Idelaymagic; /* ($<,$>) = ... */ |
2304df62 | 1378 | IEXT bool Idirty; /* In the middle of tearing things down? */ |
748a9306 | 1379 | IEXT U8 Ilocalizing; /* are we processing a local() list? */ |
79072805 | 1380 | IEXT bool Itainted; /* using variables controlled by $< */ |
463ee0b2 | 1381 | IEXT bool Itainting; /* doing taint checks */ |
e50aee73 | 1382 | IEXT char * Iop_mask IINIT(NULL); /* masked operations for safe evals */ |
79072805 LW |
1383 | |
1384 | /* trace state */ | |
1385 | IEXT I32 Idlevel; | |
1386 | IEXT I32 Idlmax IINIT(128); | |
1387 | IEXT char * Idebname; | |
1388 | IEXT char * Idebdelim; | |
1389 | ||
1390 | /* current interpreter roots */ | |
748a9306 | 1391 | IEXT CV * Imain_cv; |
463ee0b2 LW |
1392 | IEXT OP * Imain_root; |
1393 | IEXT OP * Imain_start; | |
1394 | IEXT OP * Ieval_root; | |
1395 | IEXT OP * Ieval_start; | |
79072805 LW |
1396 | |
1397 | /* runtime control stuff */ | |
1398 | IEXT COP * VOL Icurcop IINIT(&compiling); | |
0c30d9ec | 1399 | IEXT COP * Icurcopdb IINIT(NULL); |
79072805 LW |
1400 | IEXT line_t Icopline IINIT(NOLINE); |
1401 | IEXT CONTEXT * Icxstack; | |
1402 | IEXT I32 Icxstack_ix IINIT(-1); | |
1403 | IEXT I32 Icxstack_max IINIT(128); | |
a5f75d66 | 1404 | IEXT Sigjmp_buf Itop_env; |
a0d0e21e | 1405 | IEXT I32 Irunlevel; |
79072805 LW |
1406 | |
1407 | /* stack stuff */ | |
0c30d9ec | 1408 | IEXT AV * Icurstack; /* THE STACK */ |
79072805 LW |
1409 | IEXT AV * Imainstack; /* the stack when nothing funny is happening */ |
1410 | IEXT SV ** Imystack_base; /* stack->array_ary */ | |
1411 | IEXT SV ** Imystack_sp; /* stack pointer now */ | |
1412 | IEXT SV ** Imystack_max; /* stack->array_ary + stack->array_max */ | |
1413 | ||
1414 | /* format accumulators */ | |
463ee0b2 LW |
1415 | IEXT SV * Iformtarget; |
1416 | IEXT SV * Ibodytarget; | |
1417 | IEXT SV * Itoptarget; | |
79072805 LW |
1418 | |
1419 | /* statics moved here for shared library purposes */ | |
93a17b20 | 1420 | IEXT SV Istrchop; /* return value from chop */ |
79072805 LW |
1421 | IEXT int Ifilemode; /* so nextargv() can preserve mode */ |
1422 | IEXT int Ilastfd; /* what to preserve mode on */ | |
1423 | IEXT char * Ioldname; /* what to preserve mode on */ | |
1424 | IEXT char ** IArgv; /* stuff to free from do_aexec, vfork safe */ | |
1425 | IEXT char * ICmd; /* stuff to free from do_aexec, vfork safe */ | |
1426 | IEXT OP * Isortcop; /* user defined sort routine */ | |
1427 | IEXT HV * Isortstash; /* which is in some package or other */ | |
1428 | IEXT GV * Ifirstgv; /* $a */ | |
1429 | IEXT GV * Isecondgv; /* $b */ | |
1430 | IEXT AV * Isortstack; /* temp stack during pp_sort() */ | |
1431 | IEXT AV * Isignalstack; /* temp stack during sighandler() */ | |
1432 | IEXT SV * Imystrk; /* temp key string for do_each() */ | |
1433 | IEXT I32 Idumplvl; /* indentation level on syntax tree dump */ | |
79072805 LW |
1434 | IEXT PMOP * Ioldlastpm; /* for saving regexp context during debugger */ |
1435 | IEXT I32 Igensym; /* next symbol for getsym() to define */ | |
1436 | IEXT bool Ipreambled; | |
3c81428c | 1437 | IEXT AV * Ipreambleav; |
79072805 LW |
1438 | IEXT int Ilaststatval IINIT(-1); |
1439 | IEXT I32 Ilaststype IINIT(OP_STAT); | |
1440 | ||
1441 | #undef IEXT | |
1442 | #undef IINIT | |
1443 | ||
8990e307 | 1444 | #ifdef MULTIPLICITY |
79072805 LW |
1445 | }; |
1446 | #else | |
1447 | struct interpreter { | |
1448 | char broiled; | |
1449 | }; | |
1450 | #endif | |
1451 | ||
1452 | #include "pp.h" | |
1453 | ||
1454 | #ifdef __cplusplus | |
1455 | extern "C" { | |
1456 | #endif | |
1457 | ||
a0d0e21e LW |
1458 | #ifdef __cplusplus |
1459 | # ifndef I_STDARG | |
1460 | # define I_STDARG 1 | |
1461 | # endif | |
1462 | #endif | |
1463 | ||
1464 | #ifdef I_STDARG | |
2304df62 AD |
1465 | # include <stdarg.h> |
1466 | #else | |
1467 | # ifdef I_VARARGS | |
1468 | # include <varargs.h> | |
1469 | # endif | |
1470 | #endif | |
1471 | ||
79072805 LW |
1472 | #include "proto.h" |
1473 | ||
a0d0e21e LW |
1474 | #ifdef EMBED |
1475 | #define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr) | |
1476 | #define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr) | |
1477 | #else | |
1478 | #define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr) | |
1479 | #define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr) | |
1480 | #endif | |
1481 | ||
79072805 LW |
1482 | #ifdef __cplusplus |
1483 | }; | |
1484 | #endif | |
1485 | ||
93a17b20 | 1486 | /* The following must follow proto.h */ |
79072805 LW |
1487 | |
1488 | #ifdef DOINIT | |
4633a7c4 | 1489 | EXT MGVTBL vtbl_sv = {magic_get, |
463ee0b2 LW |
1490 | magic_set, |
1491 | magic_len, | |
1492 | 0, 0}; | |
4633a7c4 LW |
1493 | EXT MGVTBL vtbl_env = {0, 0, 0, 0, 0}; |
1494 | EXT MGVTBL vtbl_envelem = {0, magic_setenv, | |
85e6fe83 LW |
1495 | 0, magic_clearenv, |
1496 | 0}; | |
4633a7c4 | 1497 | EXT MGVTBL vtbl_sig = {0, 0, 0, 0, 0}; |
0c30d9ec | 1498 | EXT MGVTBL vtbl_sigelem = {magic_getsig, |
1499 | magic_setsig, | |
1500 | 0, magic_clearsig, | |
1501 | 0}; | |
4633a7c4 | 1502 | EXT MGVTBL vtbl_pack = {0, 0, 0, magic_wipepack, |
a0d0e21e | 1503 | 0}; |
4633a7c4 | 1504 | EXT MGVTBL vtbl_packelem = {magic_getpack, |
463ee0b2 LW |
1505 | magic_setpack, |
1506 | 0, magic_clearpack, | |
1507 | 0}; | |
4633a7c4 | 1508 | EXT MGVTBL vtbl_dbline = {0, magic_setdbline, |
463ee0b2 | 1509 | 0, 0, 0}; |
4633a7c4 | 1510 | EXT MGVTBL vtbl_isa = {0, magic_setisa, |
463ee0b2 | 1511 | 0, 0, 0}; |
4633a7c4 | 1512 | EXT MGVTBL vtbl_isaelem = {0, magic_setisa, |
463ee0b2 | 1513 | 0, 0, 0}; |
4633a7c4 | 1514 | EXT MGVTBL vtbl_arylen = {magic_getarylen, |
463ee0b2 LW |
1515 | magic_setarylen, |
1516 | 0, 0, 0}; | |
4633a7c4 | 1517 | EXT MGVTBL vtbl_glob = {magic_getglob, |
463ee0b2 LW |
1518 | magic_setglob, |
1519 | 0, 0, 0}; | |
4633a7c4 | 1520 | EXT MGVTBL vtbl_mglob = {0, magic_setmglob, |
463ee0b2 | 1521 | 0, 0, 0}; |
4633a7c4 | 1522 | EXT MGVTBL vtbl_taint = {magic_gettaint,magic_settaint, |
463ee0b2 | 1523 | 0, 0, 0}; |
4633a7c4 | 1524 | EXT MGVTBL vtbl_substr = {0, magic_setsubstr, |
463ee0b2 | 1525 | 0, 0, 0}; |
4633a7c4 | 1526 | EXT MGVTBL vtbl_vec = {0, magic_setvec, |
463ee0b2 | 1527 | 0, 0, 0}; |
4633a7c4 | 1528 | EXT MGVTBL vtbl_pos = {magic_getpos, |
a0d0e21e LW |
1529 | magic_setpos, |
1530 | 0, 0, 0}; | |
4633a7c4 | 1531 | EXT MGVTBL vtbl_bm = {0, magic_setbm, |
463ee0b2 | 1532 | 0, 0, 0}; |
4633a7c4 | 1533 | EXT MGVTBL vtbl_uvar = {magic_getuvar, |
463ee0b2 LW |
1534 | magic_setuvar, |
1535 | 0, 0, 0}; | |
a0d0e21e LW |
1536 | |
1537 | #ifdef OVERLOAD | |
4633a7c4 | 1538 | EXT MGVTBL vtbl_amagic = {0, magic_setamagic, |
748a9306 | 1539 | 0, 0, magic_setamagic}; |
4633a7c4 | 1540 | EXT MGVTBL vtbl_amagicelem = {0, magic_setamagic, |
748a9306 | 1541 | 0, 0, magic_setamagic}; |
a0d0e21e LW |
1542 | #endif /* OVERLOAD */ |
1543 | ||
79072805 LW |
1544 | #else |
1545 | EXT MGVTBL vtbl_sv; | |
1546 | EXT MGVTBL vtbl_env; | |
1547 | EXT MGVTBL vtbl_envelem; | |
1548 | EXT MGVTBL vtbl_sig; | |
1549 | EXT MGVTBL vtbl_sigelem; | |
463ee0b2 LW |
1550 | EXT MGVTBL vtbl_pack; |
1551 | EXT MGVTBL vtbl_packelem; | |
79072805 | 1552 | EXT MGVTBL vtbl_dbline; |
463ee0b2 LW |
1553 | EXT MGVTBL vtbl_isa; |
1554 | EXT MGVTBL vtbl_isaelem; | |
79072805 LW |
1555 | EXT MGVTBL vtbl_arylen; |
1556 | EXT MGVTBL vtbl_glob; | |
93a17b20 | 1557 | EXT MGVTBL vtbl_mglob; |
463ee0b2 | 1558 | EXT MGVTBL vtbl_taint; |
79072805 LW |
1559 | EXT MGVTBL vtbl_substr; |
1560 | EXT MGVTBL vtbl_vec; | |
a0d0e21e | 1561 | EXT MGVTBL vtbl_pos; |
79072805 LW |
1562 | EXT MGVTBL vtbl_bm; |
1563 | EXT MGVTBL vtbl_uvar; | |
a0d0e21e LW |
1564 | |
1565 | #ifdef OVERLOAD | |
1566 | EXT MGVTBL vtbl_amagic; | |
1567 | EXT MGVTBL vtbl_amagicelem; | |
1568 | #endif /* OVERLOAD */ | |
1569 | ||
79072805 | 1570 | #endif |
85e6fe83 | 1571 | |
a0d0e21e LW |
1572 | #ifdef OVERLOAD |
1573 | EXT long amagic_generation; | |
1574 | ||
748a9306 | 1575 | #define NofAMmeth 29 |
a0d0e21e LW |
1576 | #ifdef DOINIT |
1577 | EXT char * AMG_names[NofAMmeth][2] = { | |
1578 | {"fallback","abs"}, | |
1579 | {"bool", "nomethod"}, | |
1580 | {"\"\"", "0+"}, | |
1581 | {"+","+="}, | |
1582 | {"-","-="}, | |
1583 | {"*", "*="}, | |
1584 | {"/", "/="}, | |
1585 | {"%", "%="}, | |
1586 | {"**", "**="}, | |
1587 | {"<<", "<<="}, | |
1588 | {">>", ">>="}, | |
748a9306 LW |
1589 | {"&", "&="}, |
1590 | {"|", "|="}, | |
1591 | {"^", "^="}, | |
a0d0e21e LW |
1592 | {"<", "<="}, |
1593 | {">", ">="}, | |
1594 | {"==", "!="}, | |
1595 | {"<=>", "cmp"}, | |
1596 | {"lt", "le"}, | |
1597 | {"gt", "ge"}, | |
1598 | {"eq", "ne"}, | |
a0d0e21e LW |
1599 | {"!", "~"}, |
1600 | {"++", "--"}, | |
1601 | {"atan2", "cos"}, | |
1602 | {"sin", "exp"}, | |
1603 | {"log", "sqrt"}, | |
1604 | {"x","x="}, | |
748a9306 LW |
1605 | {".",".="}, |
1606 | {"=","neg"} | |
a0d0e21e LW |
1607 | }; |
1608 | #else | |
1609 | EXT char * AMG_names[NofAMmeth][2]; | |
1610 | #endif /* def INITAMAGIC */ | |
1611 | ||
1612 | struct am_table { | |
1613 | long was_ok_sub; | |
1614 | long was_ok_am; | |
1615 | CV* table[NofAMmeth*2]; | |
1616 | long fallback; | |
1617 | }; | |
1618 | typedef struct am_table AMT; | |
1619 | ||
1620 | #define AMGfallNEVER 1 | |
1621 | #define AMGfallNO 2 | |
1622 | #define AMGfallYES 3 | |
1623 | ||
1624 | enum { | |
1625 | fallback_amg, abs_amg, | |
1626 | bool__amg, nomethod_amg, | |
1627 | string_amg, numer_amg, | |
1628 | add_amg, add_ass_amg, | |
1629 | subtr_amg, subtr_ass_amg, | |
1630 | mult_amg, mult_ass_amg, | |
1631 | div_amg, div_ass_amg, | |
1632 | mod_amg, mod_ass_amg, | |
1633 | pow_amg, pow_ass_amg, | |
1634 | lshift_amg, lshift_ass_amg, | |
1635 | rshift_amg, rshift_ass_amg, | |
748a9306 LW |
1636 | band_amg, band_ass_amg, |
1637 | bor_amg, bor_ass_amg, | |
1638 | bxor_amg, bxor_ass_amg, | |
a0d0e21e LW |
1639 | lt_amg, le_amg, |
1640 | gt_amg, ge_amg, | |
1641 | eq_amg, ne_amg, | |
1642 | ncmp_amg, scmp_amg, | |
1643 | slt_amg, sle_amg, | |
1644 | sgt_amg, sge_amg, | |
1645 | seq_amg, sne_amg, | |
a0d0e21e LW |
1646 | not_amg, compl_amg, |
1647 | inc_amg, dec_amg, | |
1648 | atan2_amg, cos_amg, | |
1649 | sin_amg, exp_amg, | |
1650 | log_amg, sqrt_amg, | |
1651 | repeat_amg, repeat_ass_amg, | |
748a9306 LW |
1652 | concat_amg, concat_ass_amg, |
1653 | copy_amg, neg_amg | |
a0d0e21e LW |
1654 | }; |
1655 | #endif /* OVERLOAD */ | |
1656 | ||
85e6fe83 | 1657 | #endif /* Include guard */ |