1 /* $RCSfile: str.h,v $$Revision: 4.0.1.4 $$Date: 92/06/08 15:41:45 $
3 * Copyright (c) 1991, Larry Wall
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.
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
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
17 * Revision 4.0.1.2 91/06/07 11:58:33 lwall
18 * patch4: new copyright notice
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
23 * Revision 4.0 91/03/20 01:40:04 lwall
29 char * str_ptr; /* pointer to malloced string */
30 STRLEN str_len; /* allocated size */
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 */
39 STAB *stb_stab; /* magic stab for magic "key" string */
40 HASH *stb_stash; /* which symbol table this stab is in */
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 */
52 bool str_tainted; /* 1 if possibly under control of $< */
56 struct stab { /* should be identical, except for str_ptr */
57 STBP * str_ptr; /* pointer to malloced string */
58 STRLEN str_len; /* allocated size */
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 */
67 STAB *stb_stab; /* magic stab for magic "key" string */
68 HASH *stb_stash; /* which symbol table this stab is in */
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 */
80 bool str_tainted; /* 1 if possibly under control of $< */
84 #define str_stab stb_u.stb_stab
85 #define str_stash stb_u.stb_stash
87 /* some extra info tacked to some lvalue strings */
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 */
105 #define Nullstr Null(STR*)
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 */
125 /* the following macro updates any magic values this str is associated with */
129 (x)->str_tainted |= tainted; \
130 if ((x)->str_magic) \
131 stabset((x)->str_magic,(x))
134 if ((x)->str_magic) \
135 stabset((x)->str_magic,(x))
138 #define STR_SSET(dst,src) if (dst != src) str_sset(dst,src)
141 EXT int tmps_max INIT(-1);
142 EXT int tmps_base INIT(-1);
164 void str_taintproper();