1 /* $RCSfile: str.h,v $$Revision: 4.0.1.2 $$Date: 91/06/07 11:58:33 $
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.2 91/06/07 11:58:33 lwall
10 * patch4: new copyright notice
12 * Revision 4.0.1.1 91/04/12 09:16:12 lwall
13 * patch1: you may now use "die" and "caller" in a signal handler
15 * Revision 4.0 91/03/20 01:40:04 lwall
21 char * str_ptr; /* pointer to malloced string */
22 STRLEN str_len; /* allocated size */
24 double str_nval; /* numeric value, if any */
25 STAB *str_stab; /* magic stab for magic "key" string */
26 long str_useful; /* is this search optimization effective? */
27 ARG *str_args; /* list of args for interpreted string */
28 HASH *str_hash; /* string represents an assoc array (stab?) */
29 ARRAY *str_array; /* string represents an array */
30 CMD *str_cmd; /* command for this source line */
32 STRLEN str_cur; /* length of str_ptr as a C string */
33 STR *str_magic; /* while free, link to next free str */
34 /* while in use, ptr to "key" for magic items */
35 char str_pok; /* state of str_ptr */
36 char str_nok; /* state of str_nval */
37 unsigned char str_rare; /* used by search strings */
38 unsigned char str_state; /* one of SS_* below */
39 /* also used by search strings for backoff */
41 bool str_tainted; /* 1 if possibly under control of $< */
45 struct stab { /* should be identical, except for str_ptr */
46 STBP * str_ptr; /* pointer to malloced string */
47 STRLEN str_len; /* allocated size */
49 double str_nval; /* numeric value, if any */
50 STAB *str_stab; /* magic stab for magic "key" string */
51 long str_useful; /* is this search optimization effective? */
52 ARG *str_args; /* list of args for interpreted string */
53 HASH *str_hash; /* string represents an assoc array (stab?) */
54 ARRAY *str_array; /* string represents an array */
55 CMD *str_cmd; /* command for this source line */
57 STRLEN str_cur; /* length of str_ptr as a C string */
58 STR *str_magic; /* while free, link to next free str */
59 /* while in use, ptr to "key" for magic items */
60 char str_pok; /* state of str_ptr */
61 char str_nok; /* state of str_nval */
62 unsigned char str_rare; /* used by search strings */
63 unsigned char str_state; /* one of SS_* below */
64 /* also used by search strings for backoff */
66 bool str_tainted; /* 1 if possibly under control of $< */
70 /* some extra info tacked to some lvalue strings */
78 /* These are the values of str_pok: */
79 #define SP_VALID 1 /* str_ptr is valid */
80 #define SP_FBM 2 /* string was compiled for fbm search */
81 #define SP_STUDIED 4 /* string was studied */
82 #define SP_CASEFOLD 8 /* case insensitive fbm search */
83 #define SP_INTRP 16 /* string was compiled for interping */
84 #define SP_TAIL 32 /* fbm string is tail anchored: /foo$/ */
85 #define SP_MULTI 64 /* symbol table entry probably isn't a typo */
86 #define SP_TEMP 128 /* string slated to die, so can be plundered */
88 #define Nullstr Null(STR*)
90 /* These are the values of str_state: */
91 #define SS_NORM 0 /* normal string */
92 #define SS_INCR 1 /* normal string, incremented ptr */
93 #define SS_SARY 2 /* array on save stack */
94 #define SS_SHASH 3 /* associative array on save stack */
95 #define SS_SINT 4 /* integer on save stack */
96 #define SS_SLONG 5 /* long on save stack */
97 #define SS_SSTRP 6 /* STR* on save stack */
98 #define SS_SHPTR 7 /* HASH* on save stack */
99 #define SS_SNSTAB 8 /* non-stab on save stack */
100 #define SS_SCSV 9 /* callsave structure on save stack */
101 #define SS_SAPTR 10 /* ARRAY* on save stack */
102 #define SS_HASH 253 /* carrying an hash */
103 #define SS_ARY 254 /* carrying an array */
104 #define SS_FREE 255 /* in free list */
105 /* str_state may have any value 0-255 when used to hold fbm pattern, in which */
106 /* case it indicates offset to rarest character in screaminstr key */
108 /* the following macro updates any magic values this str is associated with */
112 (x)->str_tainted |= tainted; \
113 if ((x)->str_magic) \
114 stabset((x)->str_magic,(x))
117 if ((x)->str_magic) \
118 stabset((x)->str_magic,(x))
121 #define STR_SSET(dst,src) if (dst != src) str_sset(dst,src)
124 EXT int tmps_max INIT(-1);
125 EXT int tmps_base INIT(-1);