]> andersk Git - splint.git/blame - src/Headers/cstring.h
*** empty log message ***
[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
49# ifdef WIN32
50extern void cstring_replaceAll (cstring p_s, char p_old, char p_snew) /*@modifies p_s@*/ ;
51# endif
52
53extern void cstring_replaceLit (/*@unique@*/ cstring p_s, char *p_old, char *p_snew);
990ec868 54extern char cstring_firstChar (cstring p_s) /*@*/ ;
55extern char cstring_secondChar (cstring p_s) /*@*/ ;
885824d3 56extern char cstring_lastChar (cstring p_s) /*@*/ ;
57extern char cstring_getChar (cstring p_s, int p_n);
58extern void cstring_setChar (cstring p_s, int p_n, char p_c);
59
60# define cstring_secondChar(s) cstring_getChar (s, 2)
61
62extern /*@exposed@*/ /*@notnull@*/ char *
63 cstring_toCharsSafe (/*@temp@*/ /*@exposed@*/ /*@returned@*/ cstring p_s)
64 /*@*/ ;
65
66extern int cstring_length (cstring p_s) /*@*/ ;
67extern bool cstring_contains (/*@unique@*/ cstring p_c, cstring p_sub) /*@*/ ;
68extern bool cstring_containsChar (cstring p_c, char p_ch) /*@*/ ;
69extern bool cstring_equal (cstring p_c1, cstring p_c2) /*@*/ ;
70extern bool cstring_equalCaseInsensitive (cstring p_c1, cstring p_c2) /*@*/ ;
71extern bool cstring_equalLen (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
72extern bool cstring_equalLenCaseInsensitive (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
73extern bool cstring_equalPrefix (cstring p_c1, char *p_c2) /*@*/ ;
74extern bool cstring_equalCanonicalPrefix (cstring p_c1, char *p_c2) /*@*/ ;
75extern bool cstring_equalLit (cstring p_c1, char *p_c2) /*@*/ ;
76extern int cstring_compare (cstring p_c1, cstring p_c2) /*@*/ ;
77extern int cstring_xcompare (cstring *p_c1, cstring *p_c2) /*@*/ ;
78
79# ifndef NOLCL
80extern bool cstring_hasNonAlphaNumBar (cstring p_s) /*@*/ ;
81# endif
82
83extern cstring cstring_elide (cstring p_s, int p_len) /*@*/ ;
84extern cstring cstring_clip (/*@returned@*/ cstring p_s, int p_len)
85 /*@modifies p_s@*/ ;
86extern void cstring_stripChars (cstring p_s, const char *p_clist) /*@modifies p_s@*/ ;
87
88extern /*@dependent@*/ cstring
89 cstring_bsearch (cstring p_key,
90 char **p_table,
91 int p_nentries);
92
93extern bool cstring_lessthan (cstring p_s1, cstring p_s2) /*@*/ ;
94# define cstring_lessthan(s1, s2) (cstring_compare (s1, s2) < 0)
95
96# define cstring_equalLit(s, lit) \
97 (mstring_equal (cstring_toCharsSafe (s), lit))
98
99extern bool cstring_equalFree (/*@only@*/ cstring p_c1, /*@only@*/ cstring p_c2);
100
101/* really exposed! */
102extern cstring
103 cstring_fromChars (/*@returned@*/ /*@null@*/
104 const /*@exposed@*/ /*@temp@*/ char *p_cp) /*@*/ ;
105
106extern cstring
107 cstring_fromCharsO (/*@null@*/ /*@only@*/ char *p_cp) /*@*/ ;
108/*@-mustfree@*/
109# define cstring_fromCharsO(s) cstring_fromChars(s)
110/*@=mustfree@*/
111
112extern cstring cstring_fromCharsNew (/*@null@*/ char *p_s) /*@*/ ;
113# define cstring_fromCharsNew(s) cstring_copy(cstring_fromChars(s))
114
115# ifndef NOLCL
116extern /*@exposed@*/ /*@notnull@*/
117 char *cstring_toCharsSafeO (/*@only@*/ /*@exposed@*/ /*@returned@*/ cstring p_s);
118/*@-mustfree@*/
119# define cstring_toCharsSafeO(s) cstring_toCharsSafe(s)
120/*@=mustfree@*/
121# endif
122
123extern void cstring_free (/*@only@*/ cstring p_s);
124
125/*@constant null cstring cstring_undefined;@*/
126# define cstring_undefined ((cstring)NULL)
127
128extern /*@falsenull@*/ bool cstring_isDefined (cstring p_s) /*@*/ ;
129extern /*@truenull@*/ bool cstring_isUndefined (cstring p_s) /*@*/ ;
130
2934b455 131extern /*@truenull@*/ bool cstring_isEmpty (cstring p_s) /*@*/ ;
885824d3 132extern /*@falsenull@*/ bool cstring_isNonEmpty (cstring p_s) /*@*/ ;
133
134# define cstring_isDefined(s) ((s) != cstring_undefined)
135# define cstring_isUndefined(s) (!cstring_isDefined(s))
136
137# define cstring_isEmpty(s) (cstring_length(s) == 0)
138# define cstring_isNonEmpty(s) (!cstring_isEmpty(s))
139
140extern cstring cstring_makeLiteral (char *) /*@*/ ;
141extern /*@observer@*/ /*@dependent@*/ cstring
142 cstring_makeLiteralTemp (char *) /*@*/ ;
143
144# define cstring_makeLiteral(s) (cstring_copy (cstring_fromChars (s)))
145# define cstring_makeLiteralTemp(s) (cstring_fromChars (s))
146
147extern cstring cstring_capitalize (cstring p_s) /*@*/ ;
148extern cstring cstring_capitalizeFree (/*@only@*/ cstring p_s) /*@modifies p_s@*/ ;
149extern cstring cstring_fill (cstring p_s, int p_n) /*@*/ ;
150extern cstring cstring_prefix (cstring p_s, int p_n) /*@*/ ;
151extern /*@observer@*/ cstring cstring_suffix (cstring p_s, int p_n) /*@*/ ;
152extern cstring cstring_concat (cstring p_s, cstring p_t) /*@*/ ;
153
154extern cstring
155 cstring_concatFree (/*@only@*/ cstring p_s, /*@only@*/ cstring p_t)
156 /*@modifies p_s, p_t@*/ ;
157
158extern cstring
159 cstring_concatFree1 (/*@only@*/ cstring p_s, cstring p_t)
160 /*@modifies p_s@*/ ;
161
162# ifndef NOLCL
163extern cstring
164 cstring_concatChars (/*@only@*/ cstring p_s, char *p_t)
165 /*@modifies p_s@*/ ;
166
167extern lsymbol cstring_toSymbol (/*@only@*/ cstring p_s) /*@*/ ;
168# endif
169
170extern void cstring_markOwned (/*@owned@*/ cstring p_s) /*@modifies p_s@*/ ;
171
172extern cstring cstring_beforeChar (cstring p_s, char p_c) /*@*/ ;
173
174/*@iter cstring_chars (sef cstring s, yield char c);@*/
175# define cstring_chars(s, m_c) \
176 if (cstring_isDefined (s)) \
177 { char *m_current = (char *) (s); \
178 char m_c; \
179 for (; (m_c = *m_current) != '\0'; m_current++) {
180# define end_cstring_chars }}
181
182extern /*@observer@*/ cstring cstring_advanceWhiteSpace (cstring) /*@*/ ;
183
2934b455 184extern /*@only@*/ /*@notnull@*/ cstring
185cstring_copySegment (cstring p_s, int p_findex, int p_tindex) /*@*/ ;
186
885824d3 187extern bool cstring_containsLit (/*@unique@*/ cstring p_c, char *p_sub) /*@*/ ;
188# define cstring_containsLit(c,sub) \
189 (cstring_contains (c, cstring_fromChars (sub)))
190
28bf4b0b 191/*drl added July 2, 001 */
192extern int cstring_compareLit (/*@unique@*/ cstring p_c, char *p_sub) /*@*/ ;
193# define cstring_compareLit(c,sub) \
194 (cstring_compare (c, cstring_fromChars (sub)))
195
885824d3 196# else
197# error "Multiple include"
198# endif
199
200
201
This page took 0.071035 seconds and 5 git commands to generate.