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