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