home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / languages / perl_5 / SOURCE / h / perl < prev    next >
Encoding:
Text File  |  1995-05-13  |  38.2 KB  |  1,571 lines

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