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