]> andersk Git - splint.git/blame - src/Headers/cstring.h
Adding redundantconstraints flags. Set constraintor and showconstraintlocation flags...
[splint.git] / src / Headers / cstring.h
CommitLineData
885824d3 1/*
2934b455 2** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001.
885824d3 3** See ../LICENSE for license information.
4**
5*/
6/*
7** cstring.h
8*/
9
10# ifndef CSTRING_H
11# define CSTRING_H
12
13/* does this cause problems on Solaris? linux? */
14/* sgi's don't like it */
15# ifndef IRIX
16# ifdef NULL /* hack so <strings.h> works */
17# undef NULL
18# endif
19# endif
20
21/* typedefs in forwardTypes */
22
23extern /*@notnull@*/ cstring cstring_create (int p_n) /*@*/ ;
2934b455 24extern /*@only@*/ /*@notnull@*/ cstring cstring_newEmpty (void) ;
885824d3 25extern /*@notnull@*/ cstring cstring_appendChar (/*@only@*/ cstring p_s1, char p_c);
26
27extern cstring cstring_concatLength (/*@only@*/ cstring p_s1, char *p_s2, int p_len) /*@*/ ;
28
29extern /*@notnull@*/ cstring cstring_prependChar (char p_c, /*@temp@*/ cstring p_s1);
30extern /*@notnull@*/ cstring cstring_prependCharO (char p_c, /*@only@*/ cstring p_s1);
31extern cstring cstring_downcase (cstring p_s) /*@*/ ;
32extern cstring cstring_copy (cstring p_s) /*@*/ ;
33extern cstring cstring_copyLength (char *p_s, int p_len) /*@*/ ;
34
35extern int cstring_toPosInt (cstring p_s) /*@*/ ;
36
37typedef enum {
38 CGE_SAME, /* no differences */
39 CGE_DISTINCT, /* significant differences */
40 CGE_CASE, /* case differences */
41 CGE_LOOKALIKE /* lookalike differences */
2934b455 42} cmpcode;
885824d3 43
44extern cmpcode cstring_genericEqual (cstring p_s, cstring p_t,
45 int p_nchars,
46 bool p_caseinsensitive,
47 bool p_lookalike) /*@*/ ;
48
68de3f33 49/* evans 2001-09-09 - removed conditional compilation on this (for WIN32, OS2) */
885824d3 50extern void cstring_replaceAll (cstring p_s, char p_old, char p_snew) /*@modifies p_s@*/ ;
885824d3 51
52extern void cstring_replaceLit (/*@unique@*/ cstring p_s, char *p_old, char *p_snew);
990ec868 53extern char cstring_firstChar (cstring p_s) /*@*/ ;
54extern char cstring_secondChar (cstring p_s) /*@*/ ;
885824d3 55extern char cstring_lastChar (cstring p_s) /*@*/ ;
56extern char cstring_getChar (cstring p_s, int p_n);
57extern void cstring_setChar (cstring p_s, int p_n, char p_c);
58
59# define cstring_secondChar(s) cstring_getChar (s, 2)
60
ccf0a4a8 61extern /*@exposed@*/ /*@notnull@*/ /*@untainted@*/ char *
885824d3 62 cstring_toCharsSafe (/*@temp@*/ /*@exposed@*/ /*@returned@*/ cstring p_s)
63 /*@*/ ;
64
65extern int cstring_length (cstring p_s) /*@*/ ;
66extern bool cstring_contains (/*@unique@*/ cstring p_c, cstring p_sub) /*@*/ ;
67extern bool cstring_containsChar (cstring p_c, char p_ch) /*@*/ ;
68extern bool cstring_equal (cstring p_c1, cstring p_c2) /*@*/ ;
69extern bool cstring_equalCaseInsensitive (cstring p_c1, cstring p_c2) /*@*/ ;
70extern bool cstring_equalLen (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
71extern bool cstring_equalLenCaseInsensitive (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
68de3f33 72extern bool cstring_equalPrefix (cstring p_c1, cstring p_c2) /*@*/ ;
73extern bool cstring_equalPrefixLit (cstring p_c1, /*@observer@*/ const char *p_c2) /*@*/ ;
885824d3 74extern bool cstring_equalLit (cstring p_c1, char *p_c2) /*@*/ ;
75extern int cstring_compare (cstring p_c1, cstring p_c2) /*@*/ ;
76extern int cstring_xcompare (cstring *p_c1, cstring *p_c2) /*@*/ ;
77
78# ifndef NOLCL
79extern bool cstring_hasNonAlphaNumBar (cstring p_s) /*@*/ ;
80# endif
81
82extern cstring cstring_elide (cstring p_s, int p_len) /*@*/ ;
83extern cstring cstring_clip (/*@returned@*/ cstring p_s, int p_len)
84 /*@modifies p_s@*/ ;
85extern void cstring_stripChars (cstring p_s, const char *p_clist) /*@modifies p_s@*/ ;
86
87extern /*@dependent@*/ cstring
88 cstring_bsearch (cstring p_key,
89 char **p_table,
90 int p_nentries);
91
92extern bool cstring_lessthan (cstring p_s1, cstring p_s2) /*@*/ ;
93# define cstring_lessthan(s1, s2) (cstring_compare (s1, s2) < 0)
94
95# define cstring_equalLit(s, lit) \
96 (mstring_equal (cstring_toCharsSafe (s), lit))
97
98extern bool cstring_equalFree (/*@only@*/ cstring p_c1, /*@only@*/ cstring p_c2);
99
100/* really exposed! */
ccf0a4a8 101
102/*
103** Don't allow tainted cstring's
104*/
105
106extern /*@untained@*/ cstring
885824d3 107 cstring_fromChars (/*@returned@*/ /*@null@*/
ccf0a4a8 108 const /*:untainted@*/ /*@exposed@*/ /*@temp@*/ char *p_cp) /*@*/ ;
885824d3 109
110extern cstring
ccf0a4a8 111 cstring_fromCharsO (/*@null@*/ /*:untainted@*/ /*@only@*/ char *p_cp) /*@*/ ;
885824d3 112/*@-mustfree@*/
113# define cstring_fromCharsO(s) cstring_fromChars(s)
114/*@=mustfree@*/
115
ccf0a4a8 116extern cstring cstring_fromCharsNew (/*:untainted@*/ /*@null@*/ char *p_s) /*@*/ ;
885824d3 117# define cstring_fromCharsNew(s) cstring_copy(cstring_fromChars(s))
118
119# ifndef NOLCL
ccf0a4a8 120extern /*@exposed@*/ /*@notnull@*/ /*@untainted@*/
885824d3 121 char *cstring_toCharsSafeO (/*@only@*/ /*@exposed@*/ /*@returned@*/ cstring p_s);
122/*@-mustfree@*/
123# define cstring_toCharsSafeO(s) cstring_toCharsSafe(s)
124/*@=mustfree@*/
125# endif
126
127extern void cstring_free (/*@only@*/ cstring p_s);
128
129/*@constant null cstring cstring_undefined;@*/
130# define cstring_undefined ((cstring)NULL)
131
0e41eb0e 132extern /*@falsewhennull@*/ bool cstring_isDefined (cstring p_s) /*@*/ ;
133extern /*@nullwhentrue@*/ bool cstring_isUndefined (cstring p_s) /*@*/ ;
885824d3 134
0e41eb0e 135extern /*@nullwhentrue@*/ bool cstring_isEmpty (cstring p_s) /*@*/ ;
136extern /*@falsewhennull@*/ bool cstring_isNonEmpty (cstring p_s) /*@*/ ;
885824d3 137
138# define cstring_isDefined(s) ((s) != cstring_undefined)
139# define cstring_isUndefined(s) (!cstring_isDefined(s))
140
141# define cstring_isEmpty(s) (cstring_length(s) == 0)
142# define cstring_isNonEmpty(s) (!cstring_isEmpty(s))
143
144extern cstring cstring_makeLiteral (char *) /*@*/ ;
145extern /*@observer@*/ /*@dependent@*/ cstring
146 cstring_makeLiteralTemp (char *) /*@*/ ;
147
148# define cstring_makeLiteral(s) (cstring_copy (cstring_fromChars (s)))
149# define cstring_makeLiteralTemp(s) (cstring_fromChars (s))
150
151extern cstring cstring_capitalize (cstring p_s) /*@*/ ;
152extern cstring cstring_capitalizeFree (/*@only@*/ cstring p_s) /*@modifies p_s@*/ ;
153extern cstring cstring_fill (cstring p_s, int p_n) /*@*/ ;
154extern cstring cstring_prefix (cstring p_s, int p_n) /*@*/ ;
155extern /*@observer@*/ cstring cstring_suffix (cstring p_s, int p_n) /*@*/ ;
156extern cstring cstring_concat (cstring p_s, cstring p_t) /*@*/ ;
157
158extern cstring
159 cstring_concatFree (/*@only@*/ cstring p_s, /*@only@*/ cstring p_t)
160 /*@modifies p_s, p_t@*/ ;
161
162extern cstring
163 cstring_concatFree1 (/*@only@*/ cstring p_s, cstring p_t)
164 /*@modifies p_s@*/ ;
165
166# ifndef NOLCL
167extern cstring
168 cstring_concatChars (/*@only@*/ cstring p_s, char *p_t)
169 /*@modifies p_s@*/ ;
170
171extern lsymbol cstring_toSymbol (/*@only@*/ cstring p_s) /*@*/ ;
172# endif
173
174extern void cstring_markOwned (/*@owned@*/ cstring p_s) /*@modifies p_s@*/ ;
175
176extern cstring cstring_beforeChar (cstring p_s, char p_c) /*@*/ ;
68de3f33 177extern /*@exposed@*/ cstring cstring_afterChar (cstring p_s, char p_c) /*@*/ ;
885824d3 178
179/*@iter cstring_chars (sef cstring s, yield char c);@*/
180# define cstring_chars(s, m_c) \
181 if (cstring_isDefined (s)) \
182 { char *m_current = (char *) (s); \
183 char m_c; \
184 for (; (m_c = *m_current) != '\0'; m_current++) {
185# define end_cstring_chars }}
186
187extern /*@observer@*/ cstring cstring_advanceWhiteSpace (cstring) /*@*/ ;
188
2934b455 189extern /*@only@*/ /*@notnull@*/ cstring
190cstring_copySegment (cstring p_s, int p_findex, int p_tindex) /*@*/ ;
191
885824d3 192extern bool cstring_containsLit (/*@unique@*/ cstring p_c, char *p_sub) /*@*/ ;
193# define cstring_containsLit(c,sub) \
194 (cstring_contains (c, cstring_fromChars (sub)))
195
28bf4b0b 196/*drl added July 2, 001 */
197extern int cstring_compareLit (/*@unique@*/ cstring p_c, char *p_sub) /*@*/ ;
198# define cstring_compareLit(c,sub) \
199 (cstring_compare (c, cstring_fromChars (sub)))
200
885824d3 201# else
202# error "Multiple include"
203# endif
204
205
206
This page took 0.135234 seconds and 5 git commands to generate.