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