perl 4.0 patch 24: patch #20, continued
[p5sagit/p5-mst-13.2.git] / stab.h
CommitLineData
f0fcb552 1/* $RCSfile: stab.h,v $$Revision: 4.0.1.2 $$Date: 91/11/05 18:36:15 $
a687059c 2 *
d48672a2 3 * Copyright (c) 1991, Larry Wall
a687059c 4 *
d48672a2 5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
8d063cd8 7 *
8 * $Log: stab.h,v $
f0fcb552 9 * Revision 4.0.1.2 91/11/05 18:36:15 lwall
10 * patch11: length($x) was sometimes wrong for numeric $x
11 *
d48672a2 12 * Revision 4.0.1.1 91/06/07 11:56:35 lwall
13 * patch4: new copyright notice
14 * patch4: length($`), length($&), length($') now optimized to avoid string copy
15 *
fe14fcc3 16 * Revision 4.0 91/03/20 01:39:49 lwall
17 * 4.0 baseline.
8d063cd8 18 *
19 */
20
a687059c 21struct stabptrs {
22 char stbp_magic[4];
23 STR *stbp_val; /* scalar value */
24 struct stio *stbp_io; /* filehandle value */
25 FCMD *stbp_form; /* format value */
26 ARRAY *stbp_array; /* array value */
27 HASH *stbp_hash; /* associative array value */
76854fea 28 HASH *stbp_stash; /* symbol table for this stab */
a687059c 29 SUBR *stbp_sub; /* subroutine value */
30 int stbp_lastexpr; /* used by nothing_in_common() */
31 line_t stbp_line; /* line first declared at (for -w) */
32 char stbp_flags;
8d063cd8 33};
34
663a0e37 35#if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286))
36#define MICROPORT
37#endif
38
a687059c 39#define stab_magic(stab) (((STBP*)(stab->str_ptr))->stbp_magic)
40#define stab_val(stab) (((STBP*)(stab->str_ptr))->stbp_val)
41#define stab_io(stab) (((STBP*)(stab->str_ptr))->stbp_io)
42#define stab_form(stab) (((STBP*)(stab->str_ptr))->stbp_form)
43#define stab_xarray(stab) (((STBP*)(stab->str_ptr))->stbp_array)
663a0e37 44#ifdef MICROPORT /* Microport 2.4 hack */
45ARRAY *stab_array();
46#else
a687059c 47#define stab_array(stab) (((STBP*)(stab->str_ptr))->stbp_array ? \
48 ((STBP*)(stab->str_ptr))->stbp_array : \
49 ((STBP*)(aadd(stab)->str_ptr))->stbp_array)
663a0e37 50#endif
a687059c 51#define stab_xhash(stab) (((STBP*)(stab->str_ptr))->stbp_hash)
663a0e37 52#ifdef MICROPORT /* Microport 2.4 hack */
53HASH *stab_hash();
54#else
a687059c 55#define stab_hash(stab) (((STBP*)(stab->str_ptr))->stbp_hash ? \
56 ((STBP*)(stab->str_ptr))->stbp_hash : \
57 ((STBP*)(hadd(stab)->str_ptr))->stbp_hash)
663a0e37 58#endif /* Microport 2.4 hack */
76854fea 59#define stab_stash(stab) (((STBP*)(stab->str_ptr))->stbp_stash)
a687059c 60#define stab_sub(stab) (((STBP*)(stab->str_ptr))->stbp_sub)
61#define stab_lastexpr(stab) (((STBP*)(stab->str_ptr))->stbp_lastexpr)
62#define stab_line(stab) (((STBP*)(stab->str_ptr))->stbp_line)
63#define stab_flags(stab) (((STBP*)(stab->str_ptr))->stbp_flags)
64#define stab_name(stab) (stab->str_magic->str_ptr)
65
8d063cd8 66#define SF_VMAGIC 1 /* call routine to dereference STR val */
378cc40b 67#define SF_MULTI 2 /* seen more than once */
8d063cd8 68
69struct stio {
a687059c 70 FILE *ifp; /* ifp and ofp are normally the same */
71 FILE *ofp; /* but sockets need separate streams */
fe14fcc3 72#ifdef HAS_READDIR
a687059c 73 DIR *dirp; /* for opendir, readdir, etc */
74#endif
75 long lines; /* $. */
76 long page; /* $% */
77 long page_len; /* $= */
78 long lines_left; /* $- */
79 char *top_name; /* $^ */
80 STAB *top_stab; /* $^ */
81 char *fmt_name; /* $~ */
82 STAB *fmt_stab; /* $~ */
83 short subprocess; /* -| or |- */
8d063cd8 84 char type;
85 char flags;
86};
87
88#define IOF_ARGV 1 /* this fp iterates over ARGV */
89#define IOF_START 2 /* check for null ARGV and substitute '-' */
90#define IOF_FLUSH 4 /* this fp wants a flush after write op */
91
378cc40b 92struct sub {
93 CMD *cmd;
e929a76b 94 int (*usersub)();
95 int userindex;
76854fea 96 STAB *filestab;
378cc40b 97 long depth; /* >= 2 indicates recursive call */
98 ARRAY *tosave;
99};
100
8d063cd8 101#define Nullstab Null(STAB*)
102
d48672a2 103STRLEN stab_len();
104
a687059c 105#define STAB_STR(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_str(stab_val(tmpstab)->str_magic) : stab_val(tmpstab))
f0fcb552 106#define STAB_LEN(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_len(stab_val(tmpstab)->str_magic) : str_len(stab_val(tmpstab)))
a687059c 107#define STAB_GET(s) (tmpstab = (s), str_get(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab)))
108#define STAB_GNUM(s) (tmpstab = (s), str_gnum(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab)))
8d063cd8 109
110EXT STAB *tmpstab;
111
112EXT STAB *stab_index[128];
113
378cc40b 114EXT unsigned short statusvalue;
8d063cd8 115
a687059c 116EXT int delaymagic INIT(0);
117#define DM_DELAY 1
118#define DM_REUID 2
119#define DM_REGID 4
120
8d063cd8 121STAB *aadd();
122STAB *hadd();
76854fea 123STAB *fstab();