BSD 4_4_Lite1 development
[unix-history] / usr / src / contrib / perl-4.036 / str.h
CommitLineData
9b7d628a
C
1/* $RCSfile: str.h,v $$Revision: 4.0.1.4 $$Date: 92/06/08 15:41:45 $
2 *
3 * Copyright (c) 1991, 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 * $Log: str.h,v $
9 * Revision 4.0.1.4 92/06/08 15:41:45 lwall
10 * patch20: fixed confusion between a *var's real name and its effective name
11 * patch20: removed implicit int declarations on functions
12 *
13 * Revision 4.0.1.3 91/11/05 18:41:47 lwall
14 * patch11: random cleanup
15 * patch11: solitary subroutine references no longer trigger typo warnings
16 *
17 * Revision 4.0.1.2 91/06/07 11:58:33 lwall
18 * patch4: new copyright notice
19 *
20 * Revision 4.0.1.1 91/04/12 09:16:12 lwall
21 * patch1: you may now use "die" and "caller" in a signal handler
22 *
23 * Revision 4.0 91/03/20 01:40:04 lwall
24 * 4.0 baseline.
25 *
26 */
27
28struct string {
29 char * str_ptr; /* pointer to malloced string */
30 STRLEN str_len; /* allocated size */
31 union {
32 double str_nval; /* numeric value, if any */
33 long str_useful; /* is this search optimization effective? */
34 ARG *str_args; /* list of args for interpreted string */
35 HASH *str_hash; /* string represents an assoc array (stab?) */
36 ARRAY *str_array; /* string represents an array */
37 CMD *str_cmd; /* command for this source line */
38 struct {
39 STAB *stb_stab; /* magic stab for magic "key" string */
40 HASH *stb_stash; /* which symbol table this stab is in */
41 } stb_u;
42 } str_u;
43 STRLEN str_cur; /* length of str_ptr as a C string */
44 STR *str_magic; /* while free, link to next free str */
45 /* while in use, ptr to "key" for magic items */
46 unsigned char str_pok; /* state of str_ptr */
47 unsigned char str_nok; /* state of str_nval */
48 unsigned char str_rare; /* used by search strings */
49 unsigned char str_state; /* one of SS_* below */
50 /* also used by search strings for backoff */
51#ifdef TAINT
52 bool str_tainted; /* 1 if possibly under control of $< */
53#endif
54};
55
56struct stab { /* should be identical, except for str_ptr */
57 STBP * str_ptr; /* pointer to malloced string */
58 STRLEN str_len; /* allocated size */
59 union {
60 double str_nval; /* numeric value, if any */
61 long str_useful; /* is this search optimization effective? */
62 ARG *str_args; /* list of args for interpreted string */
63 HASH *str_hash; /* string represents an assoc array (stab?) */
64 ARRAY *str_array; /* string represents an array */
65 CMD *str_cmd; /* command for this source line */
66 struct {
67 STAB *stb_stab; /* magic stab for magic "key" string */
68 HASH *stb_stash; /* which symbol table this stab is in */
69 } stb_u;
70 } str_u;
71 STRLEN str_cur; /* length of str_ptr as a C string */
72 STR *str_magic; /* while free, link to next free str */
73 /* while in use, ptr to "key" for magic items */
74 unsigned char str_pok; /* state of str_ptr */
75 unsigned char str_nok; /* state of str_nval */
76 unsigned char str_rare; /* used by search strings */
77 unsigned char str_state; /* one of SS_* below */
78 /* also used by search strings for backoff */
79#ifdef TAINT
80 bool str_tainted; /* 1 if possibly under control of $< */
81#endif
82};
83
84#define str_stab stb_u.stb_stab
85#define str_stash stb_u.stb_stash
86
87/* some extra info tacked to some lvalue strings */
88
89struct lstring {
90 struct string lstr;
91 STRLEN lstr_offset;
92 STRLEN lstr_len;
93};
94
95/* These are the values of str_pok: */
96#define SP_VALID 1 /* str_ptr is valid */
97#define SP_FBM 2 /* string was compiled for fbm search */
98#define SP_STUDIED 4 /* string was studied */
99#define SP_CASEFOLD 8 /* case insensitive fbm search */
100#define SP_INTRP 16 /* string was compiled for interping */
101#define SP_TAIL 32 /* fbm string is tail anchored: /foo$/ */
102#define SP_MULTI 64 /* symbol table entry probably isn't a typo */
103#define SP_TEMP 128 /* string slated to die, so can be plundered */
104
105#define Nullstr Null(STR*)
106
107/* These are the values of str_state: */
108#define SS_NORM 0 /* normal string */
109#define SS_INCR 1 /* normal string, incremented ptr */
110#define SS_SARY 2 /* array on save stack */
111#define SS_SHASH 3 /* associative array on save stack */
112#define SS_SINT 4 /* integer on save stack */
113#define SS_SLONG 5 /* long on save stack */
114#define SS_SSTRP 6 /* STR* on save stack */
115#define SS_SHPTR 7 /* HASH* on save stack */
116#define SS_SNSTAB 8 /* non-stab on save stack */
117#define SS_SCSV 9 /* callsave structure on save stack */
118#define SS_SAPTR 10 /* ARRAY* on save stack */
119#define SS_HASH 253 /* carrying an hash */
120#define SS_ARY 254 /* carrying an array */
121#define SS_FREE 255 /* in free list */
122/* str_state may have any value 0-255 when used to hold fbm pattern, in which */
123/* case it indicates offset to rarest character in screaminstr key */
124
125/* the following macro updates any magic values this str is associated with */
126
127#ifdef TAINT
128#define STABSET(x) \
129 (x)->str_tainted |= tainted; \
130 if ((x)->str_magic) \
131 stabset((x)->str_magic,(x))
132#else
133#define STABSET(x) \
134 if ((x)->str_magic) \
135 stabset((x)->str_magic,(x))
136#endif
137
138#define STR_SSET(dst,src) if (dst != src) str_sset(dst,src)
139
140EXT STR **tmps_list;
141EXT int tmps_max INIT(-1);
142EXT int tmps_base INIT(-1);
143
144char *str_2ptr();
145double str_2num();
146STR *str_mortal();
147STR *str_2mortal();
148STR *str_make();
149STR *str_nmake();
150STR *str_smake();
151int str_cmp();
152int str_eq();
153void str_magic();
154void str_insert();
155void str_numset();
156void str_sset();
157void str_nset();
158void str_set();
159void str_chop();
160void str_cat();
161void str_scat();
162void str_ncat();
163void str_reset();
164void str_taintproper();
165void str_taintenv();
166STRLEN str_len();
167
168#define MULTI (3)