]> andersk Git - splint.git/blobdiff - src/flagMarkerList.c
noexpand always false.
[splint.git] / src / flagMarkerList.c
index 803a1547d5756efd4fc1cf210bfb91d2ad8ed2bc..7b557cf392c0cf4dd2786e9bd223781677812184 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2003 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -17,9 +17,9 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** 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 information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
+** For more information: http://www.splint.org
 */
 /*
 ** flagMarkerList.c
 ** invariant: flagMarker's are listed in order
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 
 static int flagMarkerList_lastBeforeLoc (flagMarkerList p_s, fileloc p_loc) /*@*/ ;
 
+static bool
+flagMarkerList_contains (flagMarkerList p_s, flagMarker p_fm) /*@*/ ;
+
 flagMarkerList
   flagMarkerList_new ()
 {
@@ -69,12 +72,19 @@ flagMarkerList_grow (flagMarkerList s)
   s->elements = newelements;
 }
 
-void flagMarkerList_add (flagMarkerList s, flagMarker fm)
+bool flagMarkerList_add (flagMarkerList s, flagMarker fm)
 {
   int i = s->nelements - 1;
   int lastloc;
 
-  DPRINTF (("Flag marker: %s", flagMarker_unparse (fm)));
+  DPRINTF (("Add: %s", flagMarker_unparse (fm)));
+
+  if (flagMarkerList_contains (s, fm))
+    {
+      flagMarker_free (fm);
+      DPRINTF (("List contains: %s", flagMarkerList_unparse (s)));
+      return FALSE;
+    }
 
   if (i > 0)
     {
@@ -114,7 +124,7 @@ void flagMarkerList_add (flagMarkerList s, flagMarker fm)
                }
 
              flagMarker_free (fm);
-             return;
+             return FALSE;
            }
        }
       else 
@@ -132,12 +142,14 @@ void flagMarkerList_add (flagMarkerList s, flagMarker fm)
                        {
                          if (llforceerror 
                              (FLG_WARNFLAGS,
-                              cstring_makeLiteral ("Cannot set flag inside ignore "
-                                                   "count region."),
+                              cstring_makeLiteral
+                              ("Cannot set flag inside ignore "
+                               "count region."),
                               flagMarker_getLoc (fm))) 
                            {
                              llgenindentmsg 
-                               (cstring_makeLiteral ("Ignore count region starts"),
+                               (cstring_makeLiteral 
+                                ("Ignore count region starts"),
                                 flagMarker_getLoc (nlast));
                              DPRINTF (("Last: %s / %s",
                                        fileloc_unparse (flagMarker_getLoc (last)),
@@ -162,7 +174,7 @@ void flagMarkerList_add (flagMarkerList s, flagMarker fm)
                        }
                      
                      flagMarker_free (fm);
-                     return;
+                     return FALSE;
                    }
                }
            }
@@ -205,7 +217,7 @@ void flagMarkerList_add (flagMarkerList s, flagMarker fm)
     }
 
   s->nelements++;
-  DPRINTF (("Add flag ==> %s", flagMarkerList_unparse (s)));
+  return TRUE;
 }
 
 void flagMarkerList_checkSuppressCounts (flagMarkerList s)
@@ -215,12 +227,14 @@ void flagMarkerList_checkSuppressCounts (flagMarkerList s)
   fileloc loc = fileloc_undefined;
   bool inCount = FALSE;
   int i;
-
   
   for (i = 0; i < s->nelements; i++)
     {
       flagMarker current = s->elements[i];
-
+      DPRINTF (("flagMarker: %s / %s",
+               flagMarker_unparse (current),
+               bool_unparse (inCount)));
+      
       if (flagMarker_isIgnoreCount (current))
        {
          llassert (!inCount);
@@ -228,7 +242,7 @@ void flagMarkerList_checkSuppressCounts (flagMarkerList s)
          nexpected = flagMarker_getCount (current);
          loc = flagMarker_getLoc (current);
          nsuppressed = 0;
-               }
+       }
       else if (flagMarker_isIgnoreOff (current))
        {
          if (inCount)
@@ -326,23 +340,6 @@ flagMarkerList_free (flagMarkerList s)
   sfree (s);
 }
 
-/*
-** returns YES iff
-**    > in ignore region (there is an ignore ON marker not followed by OFF)
-**    > code is OFF (-)
-**
-** returns NO iff
-**    > not in ignore region
-**    > code is ON (+)
-**
-** returns MAYBE iff
-**    > not in ignore region
-**    > code is unset or =
-**
-** requires: invariant for flagMarkerList:
-**    flagMarker's are sorted by line and col
-*/
-
 static int
 flagMarkerList_lastBeforeLoc (flagMarkerList s, fileloc loc)
 {
@@ -361,6 +358,41 @@ flagMarkerList_lastBeforeLoc (flagMarkerList s, fileloc loc)
 
   return -1;
 }
+
+static bool
+flagMarkerList_contains (flagMarkerList s, flagMarker fm)
+{
+  int i;
+
+  for (i = s->nelements - 1; i >= 0; i--) 
+    {
+      flagMarker current = s->elements[i];
+      
+      if (flagMarker_equal (current, fm))
+       {
+         return TRUE;
+       }
+    }
+
+  return FALSE;
+}
+
+/*
+** returns YES iff
+**    > in ignore region (there is an ignore ON marker not followed by OFF)
+**    > code is OFF (-)
+**
+** returns NO iff
+**    > not in ignore region
+**    > code is ON (+)
+**
+** returns MAYBE iff
+**    > not in ignore region
+**    > code is unset or =
+**
+** requires: invariant for flagMarkerList:
+**    flagMarker's are sorted by line and col
+*/
          
 ynm
 flagMarkerList_suppressError (flagMarkerList s, flagcode code, fileloc loc)
This page took 0.065935 seconds and 4 git commands to generate.