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