/*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2000 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2002 University of Virginia,
** Massachusetts Institute of Technology
**
** This program is free software; you can redistribute it and/or modify it
**
** For information on lclint: lclint-request@cs.virginia.edu
** To report a bug: lclint-bug@cs.virginia.edu
-** For more information: http://lclint.cs.virginia.edu
+** For more information: http://www.splint.org
*/
/*
** cstring.c
*/
+/*
+ * Herbert 06/12/2000
+ * - use drive spec specials with OS2 like with WIN32
+ * - cstring_replaceAll () needed in cpplib.c
+ */
+
# include "lclintMacros.nf"
# include "basic.h"
# include "osd.h"
# include "portab.h"
-static /*@only@*/ /*@notnull@*/
+/*@only@*/ /*@notnull@*/
cstring cstring_newEmpty (void)
{
return (cstring_create (0));
return val;
}
+cstring cstring_afterChar (cstring s, char c)
+{
+ llassert (cstring_isDefined (s));
+ return strchr (s, c);
+}
+
cstring cstring_beforeChar (cstring s, char c)
{
if (cstring_isDefined (s))
** Replaces all occurances of old in s with new.
*/
-# ifdef WIN32
void cstring_replaceAll (cstring s, char old, char snew)
{
}
}
-# endif
void cstring_replaceLit (/*@unique@*/ cstring s, char *old, char *snew)
{
else return (cstring_genericEqual (c1, c2, len, TRUE, FALSE) != CGE_DISTINCT);
}
-bool cstring_equalPrefix (cstring c1, char *c2)
+bool cstring_equalPrefix (cstring c1, cstring c2)
{
llassert (c2 != NULL);
return (strncmp (c1, c2, strlen (c2)) == 0);
}
-bool cstring_equalCanonicalPrefix (cstring c1, char *c2)
+bool cstring_equalPrefixLit (cstring c1, const char *c2)
{
llassert (c2 != NULL);
return (strlen (c2) == 0);
}
-# ifdef WIN32
- /*
- ** If one has a drive specification, but the other doesn't, skip it.
- */
-
- if (strchr (c1, ':') == NULL
- && strchr (c2, ':') != NULL)
- {
- c2 = strchr (c2 + 1, ':');
- }
- else
- {
- if (strchr (c2, ':') == NULL
- && strchr (c1, ':') != NULL)
- {
- c1 = strchr (c1 + 1, ':');
- }
- }
-
- {
- int len = size_toInt (strlen (c2));
- int i = 0;
- int slen = 0;
-
- if (cstring_length (c1) < len)
- {
- return FALSE;
- }
-
- for (i = 0; i < len; i++)
- {
- if (c1[slen] == c2[i]
- || (osd_isConnectChar (c1[slen]) && osd_isConnectChar (c2[i])))
- {
- ;
- }
- else
- {
- /*
- ** We allow \\ to match \ because MS-DOS screws up the directory
- ** names.
- */
-
- if (c1[slen] == '\\'
- && (slen > 0
- && c1[slen - 1] == '\\'
- && c2[i - 1] == '\\'))
- {
- slen++;
- if (c1[slen] != c2[i])
- {
- return FALSE;
- }
- }
- else
- {
- return FALSE;
- }
- }
-
- slen++;
- if (slen >= cstring_length (c1))
- {
- return FALSE;
- }
- }
- }
-
- return TRUE;
-# else
return (strncmp (c1, c2, strlen (c2)) == 0);
-# endif
}
int cstring_xcompare (cstring *c1, cstring *c2)
return s;
}
+/*@only@*/ /*@notnull@*/ cstring
+cstring_copySegment (cstring s, int findex, int tindex)
+{
+ cstring res = cstring_create (tindex - findex + 1);
+
+ llassert (cstring_isDefined (s));
+ llassert (cstring_length (s) > tindex);
+
+ strncpy (res, (s + findex), size_fromInt ((tindex - findex + 1)));
+ return res;
+}
+
# ifndef NOLCL
lsymbol cstring_toSymbol (cstring s)
{
- lsymbol res = lsymbol_fromChars (cstring_toCharsSafe (s));
+ lsymbol res = lsymbol_fromString (s);
cstring_free (s);
return res;
return cstring_undefined;
}
+
+