Commit | Line | Data |
34de22dd |
1 | /* $Header: str.h,v 3.0.1.4 90/11/10 02:07:52 lwall Locked $ |
a687059c |
2 | * |
3 | * Copyright (c) 1989, Larry Wall |
4 | * |
5 | * You may distribute under the terms of the GNU General Public License |
6 | * as specified in the README file that comes with the perl 3.0 kit. |
8d063cd8 |
7 | * |
8 | * $Log: str.h,v $ |
34de22dd |
9 | * Revision 3.0.1.4 90/11/10 02:07:52 lwall |
10 | * patch38: temp string values are now copied less often |
11 | * |
395c3793 |
12 | * Revision 3.0.1.3 90/10/16 10:44:04 lwall |
13 | * patch29: added caller |
14 | * patch29: scripts now run at almost full speed under the debugger |
15 | * |
e929a76b |
16 | * Revision 3.0.1.2 90/08/09 05:23:24 lwall |
17 | * patch19: various MSDOS and OS/2 patches folded in |
18 | * |
03a14243 |
19 | * Revision 3.0.1.1 89/10/26 23:24:42 lwall |
20 | * patch1: rearranged some structures to align doubles better on Gould |
21 | * |
a687059c |
22 | * Revision 3.0 89/10/18 15:23:49 lwall |
23 | * 3.0 baseline |
8d063cd8 |
24 | * |
25 | */ |
26 | |
27 | struct string { |
28 | char * str_ptr; /* pointer to malloced string */ |
e929a76b |
29 | STRLEN str_len; /* allocated size */ |
a687059c |
30 | union { |
31 | double str_nval; /* numeric value, if any */ |
32 | STAB *str_stab; /* magic stab for magic "key" string */ |
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 */ |
395c3793 |
37 | CMD *str_cmd; /* command for this source line */ |
a687059c |
38 | } str_u; |
e929a76b |
39 | STRLEN str_cur; /* length of str_ptr as a C string */ |
40 | STR *str_magic; /* while free, link to next free str */ |
a687059c |
41 | /* while in use, ptr to "key" for magic items */ |
42 | char str_pok; /* state of str_ptr */ |
43 | char str_nok; /* state of str_nval */ |
44 | unsigned char str_rare; /* used by search strings */ |
45 | unsigned char str_state; /* one of SS_* below */ |
46 | /* also used by search strings for backoff */ |
47 | #ifdef TAINT |
48 | bool str_tainted; /* 1 if possibly under control of $< */ |
49 | #endif |
50 | }; |
51 | |
52 | struct stab { /* should be identical, except for str_ptr */ |
53 | STBP * str_ptr; /* pointer to malloced string */ |
e929a76b |
54 | STRLEN str_len; /* allocated size */ |
8d063cd8 |
55 | union { |
a687059c |
56 | double str_nval; /* numeric value, if any */ |
57 | STAB *str_stab; /* magic stab for magic "key" string */ |
58 | long str_useful; /* is this search optimization effective? */ |
59 | ARG *str_args; /* list of args for interpreted string */ |
60 | HASH *str_hash; /* string represents an assoc array (stab?) */ |
61 | ARRAY *str_array; /* string represents an array */ |
395c3793 |
62 | CMD *str_cmd; /* command for this source line */ |
a687059c |
63 | } str_u; |
e929a76b |
64 | STRLEN str_cur; /* length of str_ptr as a C string */ |
65 | STR *str_magic; /* while free, link to next free str */ |
a687059c |
66 | /* while in use, ptr to "key" for magic items */ |
8d063cd8 |
67 | char str_pok; /* state of str_ptr */ |
68 | char str_nok; /* state of str_nval */ |
a687059c |
69 | unsigned char str_rare; /* used by search strings */ |
70 | unsigned char str_state; /* one of SS_* below */ |
71 | /* also used by search strings for backoff */ |
72 | #ifdef TAINT |
73 | bool str_tainted; /* 1 if possibly under control of $< */ |
74 | #endif |
75 | }; |
76 | |
77 | /* some extra info tacked to some lvalue strings */ |
78 | |
79 | struct lstring { |
80 | struct string lstr; |
e929a76b |
81 | STRLEN lstr_offset; |
82 | STRLEN lstr_len; |
8d063cd8 |
83 | }; |
84 | |
a687059c |
85 | /* These are the values of str_pok: */ |
86 | #define SP_VALID 1 /* str_ptr is valid */ |
87 | #define SP_FBM 2 /* string was compiled for fbm search */ |
88 | #define SP_STUDIED 4 /* string was studied */ |
89 | #define SP_CASEFOLD 8 /* case insensitive fbm search */ |
90 | #define SP_INTRP 16 /* string was compiled for interping */ |
91 | #define SP_TAIL 32 /* fbm string is tail anchored: /foo$/ */ |
92 | #define SP_MULTI 64 /* symbol table entry probably isn't a typo */ |
34de22dd |
93 | #define SP_TEMP 128 /* string slated to die, so can be plundered */ |
a687059c |
94 | |
8d063cd8 |
95 | #define Nullstr Null(STR*) |
96 | |
a687059c |
97 | /* These are the values of str_state: */ |
98 | #define SS_NORM 0 /* normal string */ |
99 | #define SS_INCR 1 /* normal string, incremented ptr */ |
100 | #define SS_SARY 2 /* array on save stack */ |
101 | #define SS_SHASH 3 /* associative array on save stack */ |
102 | #define SS_SINT 4 /* integer on save stack */ |
103 | #define SS_SLONG 5 /* long on save stack */ |
104 | #define SS_SSTRP 6 /* STR* on save stack */ |
105 | #define SS_SHPTR 7 /* HASH* on save stack */ |
106 | #define SS_SNSTAB 8 /* non-stab on save stack */ |
395c3793 |
107 | #define SS_SCSV 9 /* callsave structure on save stack */ |
a687059c |
108 | #define SS_HASH 253 /* carrying an hash */ |
109 | #define SS_ARY 254 /* carrying an array */ |
110 | #define SS_FREE 255 /* in free list */ |
111 | /* str_state may have any value 0-255 when used to hold fbm pattern, in which */ |
112 | /* case it indicates offset to rarest character in screaminstr key */ |
113 | |
8d063cd8 |
114 | /* the following macro updates any magic values this str is associated with */ |
115 | |
a687059c |
116 | #ifdef TAINT |
117 | #define STABSET(x) \ |
118 | (x)->str_tainted |= tainted; \ |
119 | if ((x)->str_magic) \ |
120 | stabset((x)->str_magic,(x)) |
121 | #else |
122 | #define STABSET(x) \ |
123 | if ((x)->str_magic) \ |
124 | stabset((x)->str_magic,(x)) |
125 | #endif |
126 | |
127 | #define STR_SSET(dst,src) if (dst != src) str_sset(dst,src) |
8d063cd8 |
128 | |
129 | EXT STR **tmps_list; |
378cc40b |
130 | EXT int tmps_max INIT(-1); |
131 | EXT int tmps_base INIT(-1); |
8d063cd8 |
132 | |
133 | char *str_2ptr(); |
134 | double str_2num(); |
135 | STR *str_static(); |
a687059c |
136 | STR *str_2static(); |
8d063cd8 |
137 | STR *str_make(); |
138 | STR *str_nmake(); |
a687059c |
139 | STR *str_smake(); |
140 | int str_cmp(); |
141 | int str_eq(); |
142 | void str_magic(); |
143 | void str_insert(); |
e929a76b |
144 | STRLEN str_len(); |