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