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