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