]> andersk Git - splint.git/blobdiff - src/cstring.c
Updated copyright date.
[splint.git] / src / cstring.c
index eb876c84e18efaf97ac40eb2d1183b8be3070cac..fe847cae11f92a4906ff8b92da3c01cb4f722ba6 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** 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));
@@ -102,6 +108,12 @@ int cstring_toPosInt (cstring s)
   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))
@@ -182,7 +194,6 @@ bool cstring_containsChar (cstring c, char ch)
 ** Replaces all occurances of old in s with new.
 */
 
-# ifdef WIN32
 void cstring_replaceAll (cstring s, char old, char snew)
 {
   
@@ -200,7 +211,6 @@ void cstring_replaceAll (cstring s, char old, char snew)
 
           }
 }
-# endif
 
 void cstring_replaceLit (/*@unique@*/ cstring s, char *old, char *snew)
 {
@@ -422,7 +432,7 @@ bool cstring_equalLenCaseInsensitive (cstring c1, cstring c2, int len)
   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);
 
@@ -434,7 +444,7 @@ bool cstring_equalPrefix (cstring c1, char *c2)
   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);
 
@@ -443,78 +453,7 @@ bool cstring_equalCanonicalPrefix (cstring c1, char *c2)
       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)
@@ -866,10 +805,22 @@ cstring_create (int n)
   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;
@@ -940,3 +891,5 @@ extern /*@observer@*/ cstring cstring_advanceWhiteSpace (cstring s)
   return cstring_undefined;
 }
     
+
+
This page took 0.151773 seconds and 4 git commands to generate.