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