]> andersk Git - splint.git/blobdiff - src/flags.c
Fixed line numbering when multi-line macro parameters are used.
[splint.git] / src / flags.c
index f0bd9d1d137a99bdac9592b77327c7f6bbb0fb14..8ddf84361066f812428f2f25898cbe65bfec6d45 100644 (file)
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on splint: splint@cs.virginia.edu
-** To report a bug: splint-bug@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
 */
 /*
@@ -140,6 +140,10 @@ static /*@observer@*/ cstring argcode_unparse (argcode arg)
     case ARG_SPECIAL:
       BADBRANCH;
     }
+# ifdef WIN32
+/* Make Microsoft VC++ happy */
+# pragma warning (disable:4715) 
+# endif
 }      
 
 typedef struct { 
@@ -303,6 +307,8 @@ flagcode_recordError (flagcode f)
        }
       else
        {
+         /*drl bee: ec*/
+         /*drl bee: ec*/
          flags[f].nreported = flags[f].nreported + 1;
        }
     }
@@ -317,7 +323,8 @@ flagcode_recordSuppressed (flagcode f)
 {
   llassertprint (f != INVALID_FLAG, ("flagcode: %s", flagcode_unparse (f)));
 
-  flags[f].nsuppressed = flags[f].nsuppressed + 1;
+  /*drl bee: ec*/
+    /*drl bee: ec*/   flags[f].nsuppressed = flags[f].nsuppressed + 1;
 }
 
 int
@@ -333,6 +340,7 @@ flagcodeHint (flagcode f)
 {
   llassert (f != INVALID_FLAG);
 
+  /*drl bee: ec*/
   if (mstring_isDefined (flags[f].hint))
     {
       return (cstring_fromChars (flags[f].hint));
@@ -365,6 +373,7 @@ flagkind identifyCategory (cstring s)
 
   for (i = 0; categories[i].kind != FK_NONE; i++)
     {
+        /*drl bee: mRug*/
       if (mstring_isDefined (categories[i].name))
        {
          if (cstring_equalLit (s, categories[i].name))
@@ -383,6 +392,7 @@ static /*@observer@*/ cstring categoryName (flagkind kind)
 
   for (i = 0; categories[i].kind != FK_NONE; i++)
     {
+        /*drl bee: mrUg*/
       if (categories[i].kind == kind)
        {
          return (cstring_fromChars (categories[i].name));
@@ -398,6 +408,7 @@ static int categoryIndex (flagkind kind)
 
   for (i = 0; categories[i].kind != FK_NONE; i++)
     {
+        /*drl bee: mRug*/
       if (categories[i].kind == kind)
        {
          return i;
@@ -412,7 +423,7 @@ void printCategory (flagkind kind)
   int index = categoryIndex (kind);
 
   llassert (index >= 0);
-
+        /*drl bee: mRug*/
   llmsg (message ("%s (%d flags)\n\3%s\n\n", 
                  cstring_fromChars (categories[index].name), 
                  categorySize (kind),
@@ -435,6 +446,7 @@ listAllCategories (void)
 
   for (i = 0; categories[i].kind != FK_NONE; i++)
     {
+              /*drl bee: mRug*/
       flagkind kind = categories[i].kind ;
 
       if (categories[i].describe != NULL)
@@ -456,7 +468,11 @@ printAllFlags (bool desc, bool full)
 
       cstringSList_elements (fl, el)
        {
-         llmsg (message ("%q\n\n", describeFlag (el)));
+         /*@i22@*/ /*find out why this is necessary*/
+         cstring tmp;
+         tmp = cstring_copy(el);
+         llmsg (message ("%q\n\n", describeFlag (tmp)));
+         cstring_free(tmp);
        } end_cstringSList_elements ;
 
       cstringSList_free (fl);
@@ -677,6 +693,7 @@ describeFlagCode (flagcode flag)
 
   context_resetAllFlags ();
   
+  /*drl bee: mRug*/
   f = flags[flag];
   ret = cstring_copy (cstring_fromChars (f.desc));
   
@@ -885,10 +902,11 @@ flagcode_unparse (flagcode code)
 **    length        -> len
 */
 
-static void
+static /*@only@*/ cstring
 canonicalizeFlag (cstring s)
 {
   int i = 0;
+  cstring res = cstring_copy (s);
   static bn_mstring transform[] = 
     { 
       "function", "fcn",
@@ -915,18 +933,20 @@ canonicalizeFlag (cstring s)
       NULL
       } ;
   char *current;
-
+  
+  /*drl bee: ia*/
   while ((current = transform[i]) != NULL)
     {
-      if (cstring_containsLit (s, current))
+      if (cstring_containsLit (res, current))
        {
-         cstring_replaceLit (s, current, transform[i+1]);
+         cstring_replaceLit (res, current, transform[i+1]);
        }
       i += 2;
     }
 
   /* remove whitespace, -'s, and _'s */
-  cstring_stripChars (s, " -_");
+  cstring_stripChars (res, " -_");
+  return res;
 }
 
 flagcode
@@ -944,6 +964,9 @@ flags_identifyFlagQuiet (cstring s)
 static flagcode
 flags_identifyFlagAux (cstring s, bool quiet)
 {
+  cstring cflag;
+  flagcode res;
+
   if (cstring_length (s) == 0) {
     /* evs 2000-06-25: A malformed flag. */
     return INVALID_FLAG;
@@ -969,229 +992,216 @@ flags_identifyFlagAux (cstring s, bool quiet)
       return FLG_UNDEFINE;    /* no space after -D */
     }
 
-  canonicalizeFlag (s);
+  cflag = canonicalizeFlag (s);
+  res = INVALID_FLAG;
 
   allFlags (f)
     {
-      if (cstring_equal (cstring_fromChars (f.flag), s))
+      if (cstring_equal (cstring_fromChars (f.flag), cflag))
        {
-         return (f.code);
+         res = f.code;
+         break;
        }
     } end_allFlags;
-
-  /*
-  ** Synonyms
-  */
-
-  if (cstring_equalLit (s, "pred"))
-    {
-      return FLG_PREDBOOL;
-    }
-
-  if (cstring_equalLit (s, "modobserverstrict"))
-    {
-      return FLG_MODOBSERVERUNCON;
-    }
-
-  if (cstring_equalLit (s, "czechnames"))
-    {
-      return FLG_CZECH;
-    }
-
-  if (cstring_equalLit (s, "slovaknames"))
-    {
-      return FLG_SLOVAK;
-    }
-
-  if (cstring_equalLit (s, "czechoslovaknames"))
-    {
-      return FLG_CZECHOSLOVAK;
-    }
-
-  if (cstring_equalLit (s, "globunspec")
-          || cstring_equalLit (s, "globuncon"))
-    {
-      return FLG_GLOBUNSPEC;
-    }
-
-  if (cstring_equalLit (s, "modglobsunspec")
-          || cstring_equalLit (s, "modglobsuncon")
-          || cstring_equalLit (s, "modglobsnomods"))
-    {
-      return FLG_MODGLOBSUNSPEC;
-    }
-
-  if (cstring_equalLit (s, "export"))
-    {
-      return FLG_EXPORTANY;
-    }
-
-  if (cstring_equalLit (s, "macrospec"))
-    {
-      return FLG_MACRODECL;
-    }
   
-  if (cstring_equalLit (s, "ansireservedlocal"))
-    {
-      return FLG_ANSIRESERVEDLOCAL;
-    }
-
-  if (cstring_equalLit (s, "warnposix"))
+  if (res == INVALID_FLAG)
     {
-      return FLG_WARNPOSIX;
-    }
-
-  if (cstring_equalLit (s, "defuse"))
-    {
-      return FLG_USEDEF;
-    }
-
-  if (cstring_equalLit (s, "macroundef"))
-    {
-      return FLG_MACROUNDEF;
-    }
-
-  if (cstring_equalLit (s, "showcol"))
-    {
-      return FLG_SHOWCOL;
-    }
-
-  if (cstring_equalLit (s, "intbool"))
-    {
-      return FLG_BOOLINT;
-    }
-
-  if (cstring_equalLit (s, "intchar"))
-    {
-      return FLG_CHARINT;
-    }
-
-  if (cstring_equalLit (s, "intenum"))
-    {
-      return FLG_ENUMINT;
-    }
-
-  /*
-  ** Backwards compatibility for our American friends...
-  */
-
-  if (cstring_equalLit (s, "ansilib"))
-    {
-      return FLG_ANSILIB;
-    }
-
-  if (cstring_equalLit (s, "ansistrictlib"))
-    {
-      return FLG_STRICTLIB;
-    }
-
-  if (cstring_equalLit (s, "skipansiheaders"))
-    {
-      return FLG_SKIPANSIHEADERS;
-    }
-
-  if (cstring_equalLit (s, "ansireserved"))
-    {
-      return FLG_ANSIRESERVED;
-    }
-
-  if (cstring_equalLit (s, "ansireservedinternal"))
-    {
-      return FLG_ANSIRESERVEDLOCAL;
-    }
-
-  /*
-  ** Obsolete Flags
-  */
-  
-  if (cstring_equalLit (s, "accessunspec"))
-    {
-      if (!quiet) 
+      /*
+      ** Synonyms
+      */
+      
+      if (cstring_equalLit (cflag, "pred"))
        {
-         llerror_flagWarning 
-           (cstring_makeLiteral
-            ("accessunspec flag is no longer supported.  It has been replaced by accessmodule, accessfile and "
-             "accessfunction to provide more precise control of accessibility "
-             "of representations.  For more information, "
-             "see splint -help accessmodule"));
+         res = FLG_PREDBOOL;
+       }
+      else if (cstring_equalLit (cflag, "modobserverstrict"))
+       {
+         res = FLG_MODOBSERVERUNCON;
        }
+      else if (cstring_equalLit (cflag, "czechnames"))
+       {
+         res = FLG_CZECH;
+       }
+      else if (cstring_equalLit (cflag, "slovaknames"))
+       {
+         res = FLG_SLOVAK;
+       }
+      else if (cstring_equalLit (cflag, "czechoslovaknames"))
+       {
+         res = FLG_CZECHOSLOVAK;
+       }
+      else if (cstring_equalLit (cflag, "globunspec")
+              || cstring_equalLit (cflag, "globuncon"))
+       {
+         res = FLG_GLOBUNSPEC;
+       }
+      else if (cstring_equalLit (cflag, "modglobsunspec")
+              || cstring_equalLit (cflag, "modglobsuncon")
+              || cstring_equalLit (cflag, "modglobsnomods"))
+       {
+         res = FLG_MODGLOBSUNSPEC;
+       }
+      else if (cstring_equalLit (cflag, "export"))
+       {
+         res = FLG_EXPORTANY;
+       }
+      else if (cstring_equalLit (cflag, "macrospec"))
+       {
+         res = FLG_MACRODECL;
+       }
+      else if (cstring_equalLit (cflag, "ansireservedlocal"))
+       {
+         res = FLG_ISORESERVEDLOCAL;
+       }
+      else if (cstring_equalLit (cflag, "warnposix"))
+       {
+         res = FLG_WARNPOSIX;
+       }
+      else if (cstring_equalLit (cflag, "defuse"))
+       {
+         res = FLG_USEDEF;
+       }
+      else if (cstring_equalLit (cflag, "macroundef"))
+       {
+         res = FLG_MACROUNDEF;
+       }
+      else if (cstring_equalLit (cflag, "showcol"))
+       {
+         res = FLG_SHOWCOL;
+       }
+      else if (cstring_equalLit (cflag, "intbool"))
+       {
+         res = FLG_BOOLINT;
+       }
+      else if (cstring_equalLit (cflag, "intchar"))
+       {
+         res = FLG_CHARINT;
+       }
+      else if (cstring_equalLit (cflag, "intenum"))
+       {
+         res = FLG_ENUMINT;
+       }
+      /*
+      ** Backwards compatibility for our American friends...
+      */
       
-      return SKIP_FLAG;
-    }
-  else if (cstring_equalLit (s, "ansilimits"))
-    {
+      else if (cstring_equalLit (cflag, "ansilib"))
+       {
+         res = FLG_ANSILIB;
+       }
+      else if (cstring_equalLit (cflag, "ansistrictlib"))
+       {
+         res = FLG_STRICTLIB;
+       }
+      else if (cstring_equalLit (cflag, "skipansiheaders"))
+       {
+         res = FLG_SKIPISOHEADERS;
+       }
+      else if (cstring_equalLit (cflag, "ansireserved"))
+       {
+         res = FLG_ISORESERVED;
+       }
+      else if (cstring_equalLit (cflag, "ansireservedinternal"))
+       {
+         res = FLG_ISORESERVEDLOCAL;
+       }
+      
+      /*
+      ** Obsolete Flags
+      */
+      
+      else if (cstring_equalLit (cflag, "accessunspec"))
+       {
+         if (!quiet) 
+           {
+             llerror_flagWarning 
+               (cstring_makeLiteral
+                ("accessunspec flag is no longer supported.  It has been replaced by accessmodule, accessfile and "
+                 "accessfunction to provide more precise control of accessibility "
+                 "of representations.  For more information, "
+                 "see splint -help accessmodule"));
+           }
+         
+         res = SKIP_FLAG;
+       }
+      else if (cstring_equalLit (cflag, "ansilimits"))
+       {
          llerror_flagWarning 
            (cstring_makeLiteral
             ("ansilimits flag is no longer supported.  It has been replaced by ansi89limits and "
              "iso99limits to select either the lower translation limits imposed by the ANSI89 "
              "standard or the typically higher limits prescribed by ISO C99."));
-
-      return SKIP_FLAG;
-    }
-  else if (cstring_equalLit (s, "staticmods"))
-    {
-      if (!quiet) 
+         
+         res = SKIP_FLAG;
+       }
+      else if (cstring_equalLit (cflag, "staticmods"))
        {
-         llerror_flagWarning 
-           (cstring_makeLiteral
-            ("staticmods flag is obsolete.  You probably "
-             "want impcheckmodstatics.  For more information, "
-             "see splint -help impcheckmodstatics"));
+         if (!quiet) 
+           {
+             llerror_flagWarning 
+               (cstring_makeLiteral
+                ("staticmods flag is obsolete.  You probably "
+                 "want impcheckmodstatics.  For more information, "
+                 "see splint -help impcheckmodstatics"));
+           }
+         
+         res = SKIP_FLAG;
        }
-
-      return SKIP_FLAG;
-    }
-  else if (cstring_equalLit (s, "bool"))
-    {
-      if (!quiet) 
+      else if (cstring_equalLit (cflag, "bool"))
        {
-         llerror_flagWarning
-           (cstring_makeLiteral ("bool flag is obsolete.  It never really "
-                                 "made sense in the first place."));
+         if (!quiet) 
+           {
+             llerror_flagWarning
+               (cstring_makeLiteral ("bool flag is obsolete.  It never really "
+                                     "made sense in the first place."));
+           }
+         
+         res = SKIP_FLAG;
        }
-      
-      return SKIP_FLAG;
-    }
-  else if (cstring_equalLit (s, "shiftsigned"))
-    {
-      if (!quiet) 
+      else if (cstring_equalLit (cflag, "shiftsigned"))
        {
-         llerror_flagWarning
-           (cstring_makeLiteral ("shiftsigned flag is obsolete.  You probably "
-                                 "want bitwisesigned, shiftnegative or shiftsize."));
+         if (!quiet) 
+           {
+             llerror_flagWarning
+               (cstring_makeLiteral ("shiftsigned flag is obsolete.  You probably "
+                                     "want bitwisesigned, shiftnegative or shiftimplementation."));
+           }
+         
+         res = SKIP_FLAG;
        }
-      
-      return SKIP_FLAG;
-    }
-  else if (cstring_equalLit (s, "ansi"))
-    {
-      if (!quiet) 
+      else if (cstring_equalLit (cflag, "ansi"))
        {
-         llerror_flagWarning
-           (cstring_makeLiteral ("ansi flag is obsolete.  You probably "
-                                 "want noparams and/or oldstyle."));
+         if (!quiet) 
+           {
+             llerror_flagWarning
+               (cstring_makeLiteral ("ansi flag is obsolete.  You probably "
+                                     "want noparams and/or oldstyle."));
+           }
+         
+         res = SKIP_FLAG;
        }
-      
-      return SKIP_FLAG;
-    }
-  else if (cstring_equalLit (s, "stdio"))
-    {
-      if (!quiet) 
+      else if (cstring_equalLit (cflag, "stdio"))
        {
-         llerror_flagWarning 
-           (cstring_makeLiteral
-            ("stdio flag is obsolete.  You may "
-             "want strictlib or one of the gloabls "
-             "checking flags.  For more information, "
-             "see splint -help strictlib or splint -help flags globals"));
+         if (!quiet) 
+           {
+             llerror_flagWarning 
+               (cstring_makeLiteral
+                ("stdio flag is obsolete.  You may "
+                 "want strictlib or one of the gloabls "
+                 "checking flags.  For more information, "
+                 "see splint -help strictlib or splint -help flags globals"));
+           }
+         
+         res = SKIP_FLAG;
+       }
+      else
+       {
+         res = INVALID_FLAG;
        }
-      
-      return SKIP_FLAG;
-    }
-  else
-    {
-      return INVALID_FLAG;
     }
+
+  cstring_free (cflag);
+  return res;
 }
 
 void setValueFlag (flagcode opt, cstring arg)
@@ -1414,7 +1424,9 @@ extern int flagcode_valueIndex (flagcode f)
   for (i = 0; i < NUMVALUEFLAGS; i++)
     {
       /* static valueFlags must be defined */
-      /*@-usedef@*/ if (f == valueFlags[i]) /*@=usedef@*/
+      /*@-usedef@*/
+      /*drl bee: sta*/
+      if (f == valueFlags[i]) /*@=usedef@*/
        {
          return i;
        }
@@ -1457,6 +1469,7 @@ extern int flagcode_stringIndex (flagcode f)
 
   for (i = 0; i < NUMSTRINGFLAGS; i++)
     {
+              /*drl bee: sta*/
       /*@-usedef@*/ if (f == stringFlags[i]) /*@=usedef@*/
        {
          return i;
This page took 0.05991 seconds and 4 git commands to generate.