]> andersk Git - splint.git/blame - src/Headers/cstring.h
Fixed problem with handleing oldsytle function declarations.
[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
86d93ed3 23extern /*@notnull@*/ cstring cstring_create (int p_n) /*@*/ /*@ensures maxSet(result) == p_n @*/ ;
2934b455 24extern /*@only@*/ /*@notnull@*/ cstring cstring_newEmpty (void) ;
885824d3 25extern /*@notnull@*/ cstring cstring_appendChar (/*@only@*/ cstring p_s1, char p_c);
26
86d93ed3 27extern cstring cstring_concatLength (/*@only@*/ cstring p_s1, char *p_s2, int p_len) /*@*/ /*@requires maxSet(p_s2) >= (p_len - 1) @*/;
885824d3 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) /*@*/ ;
86d93ed3 32extern cstring cstring_copy (cstring p_s) /*@*/ /*@ensures maxSet(result) == maxRead(p_s) /\ maxRead(result) == maxRead(p_s) @*/ ;
33extern cstring cstring_copyLength (char *p_s, int p_len) /*@*/ /*@requires maxSet(p_s) >= (p_len - 1) @*/;
885824d3 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,
86d93ed3 47 bool p_lookalike) /*@*/ /*@requires maxRead(p_s) >= p_nchars /\ maxRead(p_t) >= p_nchars @*/ ;
885824d3 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
92b2ba2c 52extern void cstring_replaceLit (/*@unique@*/ cstring p_s, char *p_old, char *p_snew)
53 /*@modifies p_s@*/
54 /*@requires maxRead(p_snew) >= 0 /\ maxRead(p_old) >= 0 /\ maxRead(p_old) >= maxRead(p_snew) @*/;
55
990ec868 56extern char cstring_firstChar (cstring p_s) /*@*/ ;
57extern char cstring_secondChar (cstring p_s) /*@*/ ;
885824d3 58extern char cstring_lastChar (cstring p_s) /*@*/ ;
59extern char cstring_getChar (cstring p_s, int p_n);
86d93ed3 60extern void cstring_setChar (cstring p_s, int p_n, char p_c) /*@requires maxRead(p_s) >= (p_n - 1) /\ maxSet(p_s) >= (p_n - 1) @*/ ;
885824d3 61
62# define cstring_secondChar(s) cstring_getChar (s, 2)
63
ccf0a4a8 64extern /*@exposed@*/ /*@notnull@*/ /*@untainted@*/ char *
885824d3 65 cstring_toCharsSafe (/*@temp@*/ /*@exposed@*/ /*@returned@*/ cstring p_s)
66 /*@*/ ;
67
86d93ed3 68 extern int cstring_length (cstring p_s) /*@*/ /*@ensures result == maxRead(p_s) @*/;
885824d3 69extern bool cstring_contains (/*@unique@*/ cstring p_c, cstring p_sub) /*@*/ ;
70extern bool cstring_containsChar (cstring p_c, char p_ch) /*@*/ ;
71extern bool cstring_equal (cstring p_c1, cstring p_c2) /*@*/ ;
72extern bool cstring_equalCaseInsensitive (cstring p_c1, cstring p_c2) /*@*/ ;
73extern bool cstring_equalLen (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
74extern bool cstring_equalLenCaseInsensitive (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
68de3f33 75extern bool cstring_equalPrefix (cstring p_c1, cstring p_c2) /*@*/ ;
76extern bool cstring_equalPrefixLit (cstring p_c1, /*@observer@*/ const char *p_c2) /*@*/ ;
885824d3 77extern bool cstring_equalLit (cstring p_c1, char *p_c2) /*@*/ ;
78extern int cstring_compare (cstring p_c1, cstring p_c2) /*@*/ ;
79extern int cstring_xcompare (cstring *p_c1, cstring *p_c2) /*@*/ ;
80
81# ifndef NOLCL
82extern bool cstring_hasNonAlphaNumBar (cstring p_s) /*@*/ ;
83# endif
84
85extern cstring cstring_elide (cstring p_s, int p_len) /*@*/ ;
86extern cstring cstring_clip (/*@returned@*/ cstring p_s, int p_len)
87 /*@modifies p_s@*/ ;
88extern void cstring_stripChars (cstring p_s, const char *p_clist) /*@modifies p_s@*/ ;
89
90extern /*@dependent@*/ cstring
91 cstring_bsearch (cstring p_key,
92 char **p_table,
93 int p_nentries);
94
95extern bool cstring_lessthan (cstring p_s1, cstring p_s2) /*@*/ ;
96# define cstring_lessthan(s1, s2) (cstring_compare (s1, s2) < 0)
97
98# define cstring_equalLit(s, lit) \
99 (mstring_equal (cstring_toCharsSafe (s), lit))
100
101extern bool cstring_equalFree (/*@only@*/ cstring p_c1, /*@only@*/ cstring p_c2);
102
103/* really exposed! */
ccf0a4a8 104
105/*
106** Don't allow tainted cstring's
107*/
108
109extern /*@untained@*/ cstring
885824d3 110 cstring_fromChars (/*@returned@*/ /*@null@*/
ccf0a4a8 111 const /*:untainted@*/ /*@exposed@*/ /*@temp@*/ char *p_cp) /*@*/ ;
885824d3 112
113extern cstring
ccf0a4a8 114 cstring_fromCharsO (/*@null@*/ /*:untainted@*/ /*@only@*/ char *p_cp) /*@*/ ;
885824d3 115/*@-mustfree@*/
116# define cstring_fromCharsO(s) cstring_fromChars(s)
117/*@=mustfree@*/
118
ccf0a4a8 119extern cstring cstring_fromCharsNew (/*:untainted@*/ /*@null@*/ char *p_s) /*@*/ ;
885824d3 120# define cstring_fromCharsNew(s) cstring_copy(cstring_fromChars(s))
121
122# ifndef NOLCL
ccf0a4a8 123extern /*@exposed@*/ /*@notnull@*/ /*@untainted@*/
885824d3 124 char *cstring_toCharsSafeO (/*@only@*/ /*@exposed@*/ /*@returned@*/ cstring p_s);
125/*@-mustfree@*/
126# define cstring_toCharsSafeO(s) cstring_toCharsSafe(s)
127/*@=mustfree@*/
128# endif
129
130extern void cstring_free (/*@only@*/ cstring p_s);
131
132/*@constant null cstring cstring_undefined;@*/
133# define cstring_undefined ((cstring)NULL)
134
0e41eb0e 135extern /*@falsewhennull@*/ bool cstring_isDefined (cstring p_s) /*@*/ ;
136extern /*@nullwhentrue@*/ bool cstring_isUndefined (cstring p_s) /*@*/ ;
885824d3 137
0e41eb0e 138extern /*@nullwhentrue@*/ bool cstring_isEmpty (cstring p_s) /*@*/ ;
139extern /*@falsewhennull@*/ bool cstring_isNonEmpty (cstring p_s) /*@*/ ;
885824d3 140
141# define cstring_isDefined(s) ((s) != cstring_undefined)
142# define cstring_isUndefined(s) (!cstring_isDefined(s))
143
144# define cstring_isEmpty(s) (cstring_length(s) == 0)
145# define cstring_isNonEmpty(s) (!cstring_isEmpty(s))
146
147extern cstring cstring_makeLiteral (char *) /*@*/ ;
148extern /*@observer@*/ /*@dependent@*/ cstring
149 cstring_makeLiteralTemp (char *) /*@*/ ;
150
151# define cstring_makeLiteral(s) (cstring_copy (cstring_fromChars (s)))
152# define cstring_makeLiteralTemp(s) (cstring_fromChars (s))
153
86d93ed3 154extern cstring cstring_capitalize (cstring p_s) /*@*/ /*@requires maxSet(p_s) >= 0 @*/ ;
155extern cstring cstring_capitalizeFree (/*@only@*/ cstring p_s) /*@modifies p_s@*/ /*@requires maxSet(p_s) >= 0 /\ maxRead(p_s) >= 0 @*/ ;
156extern cstring cstring_fill (cstring p_s, int p_n) /*@*/ /*@requires p_n >= 0 @*/;
157extern cstring cstring_prefix (cstring p_s, int p_n) /*@*/ /*@requires maxRead(p_s) >= p_n /\ maxSet(p_s) >= p_n @*/ /*@ensures maxRead(result) == p_n /\ maxSet(result) == p_n @*/;
885824d3 158extern /*@observer@*/ cstring cstring_suffix (cstring p_s, int p_n) /*@*/ ;
86d93ed3 159extern cstring cstring_concat (cstring p_s, cstring p_t) /*@*/ /*@requires maxSet(p_s) >= 0 @*/;
885824d3 160
161extern cstring
162 cstring_concatFree (/*@only@*/ cstring p_s, /*@only@*/ cstring p_t)
163 /*@modifies p_s, p_t@*/ ;
164
165extern cstring
166 cstring_concatFree1 (/*@only@*/ cstring p_s, cstring p_t)
167 /*@modifies p_s@*/ ;
168
169# ifndef NOLCL
170extern cstring
171 cstring_concatChars (/*@only@*/ cstring p_s, char *p_t)
172 /*@modifies p_s@*/ ;
173
174extern lsymbol cstring_toSymbol (/*@only@*/ cstring p_s) /*@*/ ;
175# endif
176
177extern void cstring_markOwned (/*@owned@*/ cstring p_s) /*@modifies p_s@*/ ;
178
179extern cstring cstring_beforeChar (cstring p_s, char p_c) /*@*/ ;
68de3f33 180extern /*@exposed@*/ cstring cstring_afterChar (cstring p_s, char p_c) /*@*/ ;
885824d3 181
182/*@iter cstring_chars (sef cstring s, yield char c);@*/
183# define cstring_chars(s, m_c) \
184 if (cstring_isDefined (s)) \
185 { char *m_current = (char *) (s); \
186 char m_c; \
187 for (; (m_c = *m_current) != '\0'; m_current++) {
188# define end_cstring_chars }}
189
190extern /*@observer@*/ cstring cstring_advanceWhiteSpace (cstring) /*@*/ ;
191
2934b455 192extern /*@only@*/ /*@notnull@*/ cstring
193cstring_copySegment (cstring p_s, int p_findex, int p_tindex) /*@*/ ;
194
1810fe2a 195/*drl added 01/22/2001 Expands the escape squences i.e "\\n\\t\\000"
196 becomes "\n\t0" */
197extern cstring cstring_expandEscapes (cstring p_s);
198
199/*drl added 01/23/2001 Gives you the number of characters in an
200 expanded escape squences. This can be different from strlen bc/ of
201 escaped nulls. */
202int cstring_lengthExpandEscapes (cstring p_s);
203
204
885824d3 205extern bool cstring_containsLit (/*@unique@*/ cstring p_c, char *p_sub) /*@*/ ;
206# define cstring_containsLit(c,sub) \
207 (cstring_contains (c, cstring_fromChars (sub)))
208
28bf4b0b 209/*drl added July 2, 001 */
210extern int cstring_compareLit (/*@unique@*/ cstring p_c, char *p_sub) /*@*/ ;
211# define cstring_compareLit(c,sub) \
212 (cstring_compare (c, cstring_fromChars (sub)))
213
885824d3 214# else
215# error "Multiple include"
216# endif
217
218
219
This page took 2.401213 seconds and 5 git commands to generate.