Commit | Line | Data |
35c8bce7 |
1 | /* $RCSfile: str.h,v $$Revision: 4.0.1.1 $$Date: 91/04/12 09:16:12 $ |
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 $ |
35c8bce7 |
9 | * Revision 4.0.1.1 91/04/12 09:16:12 lwall |
10 | * patch1: you may now use "die" and "caller" in a signal handler |
11 | * |
fe14fcc3 |
12 | * Revision 4.0 91/03/20 01:40:04 lwall |
13 | * 4.0 baseline. |
8d063cd8 |
14 | * |
15 | */ |
16 | |
17 | struct string { |
18 | char * str_ptr; /* pointer to malloced string */ |
e929a76b |
19 | STRLEN 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 */ |
395c3793 |
27 | CMD *str_cmd; /* command for this source line */ |
a687059c |
28 | } str_u; |
e929a76b |
29 | STRLEN str_cur; /* length of str_ptr as a C string */ |
30 | STR *str_magic; /* while free, link to next free str */ |
a687059c |
31 | /* while in use, ptr to "key" for magic items */ |
32 | char str_pok; /* state of str_ptr */ |
33 | char str_nok; /* state of str_nval */ |
34 | unsigned char str_rare; /* used by search strings */ |
35 | unsigned char str_state; /* one of SS_* below */ |
36 | /* also used by search strings for backoff */ |
37 | #ifdef TAINT |
38 | bool str_tainted; /* 1 if possibly under control of $< */ |
39 | #endif |
40 | }; |
41 | |
42 | struct stab { /* should be identical, except for str_ptr */ |
43 | STBP * str_ptr; /* pointer to malloced string */ |
e929a76b |
44 | STRLEN str_len; /* allocated size */ |
8d063cd8 |
45 | union { |
a687059c |
46 | double str_nval; /* numeric value, if any */ |
47 | STAB *str_stab; /* magic stab for magic "key" string */ |
48 | long str_useful; /* is this search optimization effective? */ |
49 | ARG *str_args; /* list of args for interpreted string */ |
50 | HASH *str_hash; /* string represents an assoc array (stab?) */ |
51 | ARRAY *str_array; /* string represents an array */ |
395c3793 |
52 | CMD *str_cmd; /* command for this source line */ |
a687059c |
53 | } str_u; |
e929a76b |
54 | STRLEN str_cur; /* length of str_ptr as a C string */ |
55 | STR *str_magic; /* while free, link to next free str */ |
a687059c |
56 | /* while in use, ptr to "key" for magic items */ |
8d063cd8 |
57 | char str_pok; /* state of str_ptr */ |
58 | char str_nok; /* state of str_nval */ |
a687059c |
59 | unsigned char str_rare; /* used by search strings */ |
60 | unsigned char str_state; /* one of SS_* below */ |
61 | /* also used by search strings for backoff */ |
62 | #ifdef TAINT |
63 | bool str_tainted; /* 1 if possibly under control of $< */ |
64 | #endif |
65 | }; |
66 | |
67 | /* some extra info tacked to some lvalue strings */ |
68 | |
69 | struct lstring { |
70 | struct string lstr; |
e929a76b |
71 | STRLEN lstr_offset; |
72 | STRLEN lstr_len; |
8d063cd8 |
73 | }; |
74 | |
a687059c |
75 | /* These are the values of str_pok: */ |
76 | #define SP_VALID 1 /* str_ptr is valid */ |
77 | #define SP_FBM 2 /* string was compiled for fbm search */ |
78 | #define SP_STUDIED 4 /* string was studied */ |
79 | #define SP_CASEFOLD 8 /* case insensitive fbm search */ |
80 | #define SP_INTRP 16 /* string was compiled for interping */ |
81 | #define SP_TAIL 32 /* fbm string is tail anchored: /foo$/ */ |
82 | #define SP_MULTI 64 /* symbol table entry probably isn't a typo */ |
34de22dd |
83 | #define SP_TEMP 128 /* string slated to die, so can be plundered */ |
a687059c |
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 */ |
395c3793 |
97 | #define SS_SCSV 9 /* callsave structure on save stack */ |
35c8bce7 |
98 | #define SS_SAPTR 10 /* ARRAY* on save stack */ |
a687059c |
99 | #define SS_HASH 253 /* carrying an hash */ |
100 | #define SS_ARY 254 /* carrying an array */ |
101 | #define SS_FREE 255 /* in free list */ |
102 | /* str_state may have any value 0-255 when used to hold fbm pattern, in which */ |
103 | /* case it indicates offset to rarest character in screaminstr key */ |
104 | |
8d063cd8 |
105 | /* the following macro updates any magic values this str is associated with */ |
106 | |
a687059c |
107 | #ifdef TAINT |
108 | #define STABSET(x) \ |
109 | (x)->str_tainted |= tainted; \ |
110 | if ((x)->str_magic) \ |
111 | stabset((x)->str_magic,(x)) |
112 | #else |
113 | #define STABSET(x) \ |
114 | if ((x)->str_magic) \ |
115 | stabset((x)->str_magic,(x)) |
116 | #endif |
117 | |
118 | #define STR_SSET(dst,src) if (dst != src) str_sset(dst,src) |
8d063cd8 |
119 | |
120 | EXT STR **tmps_list; |
378cc40b |
121 | EXT int tmps_max INIT(-1); |
122 | EXT int tmps_base INIT(-1); |
8d063cd8 |
123 | |
124 | char *str_2ptr(); |
125 | double str_2num(); |
fe14fcc3 |
126 | STR *str_mortal(); |
127 | STR *str_2mortal(); |
8d063cd8 |
128 | STR *str_make(); |
129 | STR *str_nmake(); |
a687059c |
130 | STR *str_smake(); |
131 | int str_cmp(); |
132 | int str_eq(); |
133 | void str_magic(); |
134 | void str_insert(); |
e929a76b |
135 | STRLEN str_len(); |