]> andersk Git - splint.git/blobdiff - src/flags.c
Fixed line numbering when multi-line macro parameters are used.
[splint.git] / src / flags.c
index 299e05a2c0540c9b5e41778f9bf2cdda48515aed..8ddf84361066f812428f2f25898cbe65bfec6d45 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-2002 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
 ** 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
 */
 /*
 ** flags.c
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "portab.h"
 
@@ -54,10 +54,11 @@ static flagcatinfo categories[] =
   { FK_ANSI, "ansi", "violations of constraints imposed by ANSI/ISO standard" } ,
   { FK_ARRAY, "arrays", "special checking involving arrays" } ,
   { FK_BOOL, "booleans", "checking and naming of boolean types" } ,
-  { FK_COMMENTS, "comments", "interpretation of semantic comments" } ,
+  { FK_COMMENTS, "comments", "warnings about (normal) comments" } ,
+  { FK_SYNCOMMENTS, "syncomments", "interpretation of annotation comments" } ,
   { FK_COMPLETE, "complete", "completely defined, used, or specified system" } ,
   { FK_CONTROL, "controlflow", "suspicious control structures" } ,
-  { FK_DEBUG, "debug", "flags for debugging lclint" } ,
+  { FK_DEBUG, "debug", "flags for debugging splint" } ,
   { FK_DECL, "declarations", "consistency of declarations" } ,
   { FK_DEF, "definition", "undefined storage errors" } ,
   { FK_DIRECT, "directories", "set directores" } ,
@@ -66,11 +67,15 @@ static flagcatinfo categories[] =
   { FK_ERRORS, "errors", "control expected errors, summary reporting" } ,
   { FK_EXPORT, "export", "control what may be exported" } ,
   { FK_EXPOSURE, "exposure", "representation exposure" } ,
+  { FK_EXTENSIBLE, "extensible", "user-defined checks and annotations" },
   { FK_FILES, "files", "control system files" } ,
   { FK_FORMAT, "format", "control format of warning messages" } ,
   { FK_GLOBALS, "globals", "use of global and file static variables" },
   { FK_HEADERS, "headers", "control inclusion and generation of header files" },
   { FK_HELP, "help", "on-line help" },
+  { FK_BOUNDS, "memorybounds", "out-of-bounds memory accesses" },
+  { FK_HINTS, "hints", "control display of warning hints" },
+  { FK_SYSTEMFUNCTIONS, "systemfunctions", "special properties of exit and main" },
   { FK_IMPLICIT, "implicit", "control implicit annotations and interpretations" } ,
   { FK_INIT, "initializations", "initialization files" } ,
   { FK_ITER, "iterators", "checking iterator definitions and uses" } ,
@@ -101,6 +106,7 @@ static flagcatinfo categories[] =
   { FK_UNRECOG, "unrecognized", "unrecognized identifiers" } ,
   { FK_UNSPEC, "unconstrained", "checking in the presence of unconstrained functions" } ,
   { FK_WARNUSE, "warnuse", "use of possibly problematic function" } ,
+  { FK_ITS4, "its4", "its4 compatibility flags (report warnings for uses of possibly insecure functions)" } ,
   { FK_SYNTAX, NULL, NULL } ,
   { FK_TYPE, NULL, NULL } ,
   { FK_SECRET, NULL, NULL } ,
@@ -110,11 +116,36 @@ static flagcatinfo categories[] =
 
 typedef enum {
   ARG_NONE,
-  ARG_VALUE,
-  ARG_STRING,
-  ARG_SPECIAL
+  ARG_NUMBER,    /* number */
+  ARG_CHAR,      /* char */
+  ARG_STRING,    /* string */
+  ARG_FILE,      /* filename (also a string) */
+  ARG_DIRECTORY, /* directory (also a string) */
+  ARG_PATH,      /* path */
+  ARG_SPECIAL   /* ? */
 } argcode;
 
+static /*@observer@*/ cstring argcode_unparse (argcode arg)
+{
+  switch (arg) 
+    {
+    case ARG_STRING: return cstring_makeLiteralTemp ("string"); 
+    case ARG_FILE: return cstring_makeLiteralTemp ("filename"); 
+    case ARG_DIRECTORY: return cstring_makeLiteralTemp ("directory");
+    case ARG_PATH: return cstring_makeLiteralTemp ("path"); 
+    case ARG_NUMBER: return cstring_makeLiteralTemp ("number");
+    case ARG_CHAR: return cstring_makeLiteralTemp ("character");
+    case ARG_NONE: 
+      BADBRANCH;
+    case ARG_SPECIAL:
+      BADBRANCH;
+    }
+# ifdef WIN32
+/* Make Microsoft VC++ happy */
+# pragma warning (disable:4715) 
+# endif
+}      
+
 typedef struct { 
   flagkind main;
   flagkind sub;
@@ -154,10 +185,16 @@ static bn_mstring mode_names[] =
 
 /*@+enumint@*/
 
+static cstring getFlagModeSettings (flagcode p_flag) /*@modifies internalState@*/ ;
 static cstring describeFlagCode (flagcode p_flag) /*@*/ ;
 static cstringSList sortedFlags (void) /*@*/ ;
 static /*@observer@*/ cstring categoryName (flagkind p_kind) /*@*/ ;
+
+static flagcode flags_identifyFlagAux (cstring p_s, bool p_quiet) /*@modifies g_msgstream@*/ ;
+
+# if 0
 static /*@unused@*/ cstring listModes (void) /*@*/ ;
+# endif
 
 bool flagcode_isSpecialFlag (flagcode f)
 {
@@ -270,6 +307,8 @@ flagcode_recordError (flagcode f)
        }
       else
        {
+         /*drl bee: ec*/
+         /*drl bee: ec*/
          flags[f].nreported = flags[f].nreported + 1;
        }
     }
@@ -284,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
@@ -300,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));
@@ -332,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))
@@ -350,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));
@@ -365,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;
@@ -379,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),
@@ -402,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)
@@ -423,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);
@@ -447,12 +496,196 @@ printAllFlags (bool desc, bool full)
     }
 }
 
+void
+printFlagManual (bool html)
+{
+  /*
+  ** Prints all flags by category, in order they appear in flags.def
+  */
+
+  flagkind lastCategory = FK_NONE;
+
+  allFlags (f) {
+    cstring flagname;
+    cstring flagtype = cstring_undefined;
+
+    if (f.main != lastCategory)
+      {
+       if (html)
+         {
+           llmsg (message ("\n<h4>%s</h4>\n", categoryName (f.main)));
+         }
+       else
+         {
+           llmsg (message ("\n%s\n%s\n",
+                           categoryName (f.main),
+                           cstring_makeLiteralTemp ("===================================")));
+         }
+
+       lastCategory = f.main;
+      }
+
+    if (f.argtype == ARG_NONE || f.argtype == ARG_SPECIAL)
+      {
+       if (html) 
+         {
+           flagname = message ("<tt>%s</tt>", cstring_fromChars (f.flag));
+         }
+       else
+         {
+           flagname = cstring_fromCharsNew (f.flag);
+         }
+      }
+    else
+      {
+       if (flagcode_hasString (f.code)) 
+         {
+           if (html)
+             {
+               flagname = message ("<tt>%s <em>&lt;%s&gt;</em></tt>",
+                                   cstring_fromChars (f.flag), argcode_unparse (f.argtype));
+             }
+           else
+             {
+               flagname = message ("%s <%s>", cstring_fromChars (f.flag), argcode_unparse (f.argtype));
+             }
+           
+           if (cstring_isDefined (context_getString (f.code)))
+             {
+               if (html)
+                 {
+                   flagname = message ("%q <font color=\"blue\">[%s]</font>", flagname,
+                                       context_getString (f.code));
+                 }
+               else
+                 {
+                   flagname = message ("%q [%s]", flagname,
+                                       context_getString (f.code));
+                 }
+             }
+         }
+       else if (f.argtype == ARG_CHAR)
+         {
+           if (html)
+             {
+               flagname = message ("<tt>%s <em>&lt;%s&gt;</em></tt> <font color=\"blue\">[%c]</font>",
+                                   cstring_fromChars (f.flag), argcode_unparse (f.argtype),
+                                   (char) context_getValue (f.code));
+             }
+           else
+             {
+               flagname = message ("%s <%s> [%c]", cstring_fromChars (f.flag), argcode_unparse (f.argtype),
+                                   (char) context_getValue (f.code));
+             }
+         }
+       else 
+         {
+           llassert (f.argtype == ARG_NUMBER);
+
+           if (html)
+             {
+               flagname = message ("<tt>%s <em>&lt;%s&gt;</em> <font color=\"blue\">[%d]</font>",
+                                   cstring_fromChars (f.flag), argcode_unparse (f.argtype),
+                                   context_getValue (f.code));
+             }
+           else
+             {
+               flagname = message ("%s <%s> [%d]", cstring_fromChars (f.flag), argcode_unparse (f.argtype),
+                                   context_getValue (f.code));
+             }
+         }
+      }
+
+    if (f.isIdem)
+      {
+       if (html)
+         {
+           flagtype = message("%q<font color=\"green\">-</font>", flagtype);
+         }
+       else
+         {
+           flagtype = message("%q<->", flagtype);
+         }
+      }
+    
+    if (f.isGlobal)
+      {
+       if (html)
+         {
+           flagtype = message ("%q<font color=\"green\"><em>global</em></font>", flagtype);
+         }
+       else
+         {
+           flagtype = message ("%q<G>", flagtype);
+         }
+      }
+
+    if (f.isSpecial)
+      {
+       if (html)
+         {
+           flagtype = message ("%q<font color=\"orange\"><em>shortcut</em></font>", flagtype);
+         }
+       else
+         {
+           flagtype = message("%q<S>", flagtype);
+         }
+      }
+    
+    if (f.isModeFlag)
+      {
+       if (html)
+         {
+           flagtype = message ("%q mode:<tt>%q</tt>>", flagtype, getFlagModeSettings (f.code));
+         }
+       else
+         {
+           flagtype = message ("%q<M:%q>", flagtype, getFlagModeSettings (f.code));
+         }
+      }
+    else /* its a plain flag */
+      {
+       if (html)
+         {
+           flagtype = message ("%q plain:<tt>%s</tt>", flagtype,
+                               cstring_makeLiteralTemp (context_getFlag (f.code) ? "+" : "-"));
+         }
+       else
+         {
+           flagtype = message ("%q<P:%s>", flagtype,
+                               cstring_makeLiteralTemp (context_getFlag (f.code) ? "+" : "-"));
+         }
+      }
+    
+    llmsg (message ("%s: %s", flagname, flagtype));
+
+    if (html)
+      {
+       llgenindentmsgnoloc (cstring_makeLiteral ("<blockquote>"));
+      }
+
+    if (mstring_isDefined (f.hint))
+      {
+       llgenindentmsgnoloc (cstring_fromCharsNew (f.hint));
+      }
+    else
+      {
+       llgenindentmsgnoloc (message ("%q.", cstring_capitalize (cstring_fromChars (f.desc))));
+      }
+
+    if (html)
+      {
+       llgenindentmsgnoloc (cstring_makeLiteral ("</blockquote>"));
+      }
+  } end_allFlags ;
+}
+
 cstring
 describeFlagCode (flagcode flag)
 {
   cstring ret = cstring_undefined;
   fflag f;
-
+  
   if (flagcode_isInvalid (flag))
     {
       return (cstring_makeLiteral ("<invalid>"));
@@ -460,9 +693,9 @@ describeFlagCode (flagcode flag)
 
   context_resetAllFlags ();
   
+  /*drl bee: mRug*/
   f = flags[flag];
   ret = cstring_copy (cstring_fromChars (f.desc));
-
   
   if (f.sub != FK_NONE)
     {
@@ -484,40 +717,19 @@ describeFlagCode (flagcode flag)
            }
        }
     }
-
+  
   if (f.isModeFlag)
     {
-      bool first = TRUE;
-
-      allModes (mname)
-       {
-         context_setMode (cstring_fromChars (mname));
-
-         if (first)
-           {
-             ret = message ("%q\nMode Settings: %s %s",
-                            ret, cstring_fromChars (mname), 
-                            cstring_makeLiteralTemp 
-                            (context_getFlag (flag) ? "+" : "-"));
-             first = FALSE;
-           }
-         else
-           {
-             ret = message ("%q, %s %s",
-                            ret, cstring_fromChars (mname),
-                            cstring_makeLiteralTemp 
-                            (context_getFlag (flag) ? "+" : "-"));
-           }
-       } end_allModes;
+      ret = message ("%q\nMode Settings: %q",
+                    ret, getFlagModeSettings (flag));
     }
   else
     {
       ret = message ("%q\nDefault Setting: %s",
                     ret, 
-                    cstring_makeLiteralTemp 
-                    (context_getFlag (flag) ? "+" : "-"));
+                    cstring_makeLiteralTemp (context_getFlag (flag) ? "+" : "-"));
     }
-
+  
   if (f.isGlobal)
     {
       ret = message("%q\nSet globally only", ret);
@@ -526,52 +738,70 @@ describeFlagCode (flagcode flag)
     {
       ret = message("%q\nSet locally", ret);
     }
-
+  
   switch (f.argtype)
     {
     case ARG_NONE:
     case ARG_SPECIAL:
       break;
-    case ARG_VALUE:
-      if (flag == FLG_COMMENTCHAR)
-       {
-         ret = message("%q\nCharacter Argument.  Default: %h",
-                       ret, (char) context_getValue (flag));
-       }
-      else
-       {
-         ret = message("%q\nNumeric Argument.  Default: %d",
-                       ret,
-                       context_getValue (flag));
-       }
+    case ARG_NUMBER:
+      ret = message("%q\nNumeric Argument.  Default: %d",
+                   ret,
+                   context_getValue (flag));
+      break;
+    case ARG_CHAR:
+      ret = message("%q\nCharacter Argument.  Default: %h",
+                   ret, (char) context_getValue (flag));
       break;
     case ARG_STRING:
+    case ARG_FILE:
+    case ARG_PATH:
+    case ARG_DIRECTORY:
+      {
       if (cstring_isDefined (context_getString (flag)))
        {
-         ret = message("%q\nString Argument.  Default: %s",
+         ret = message("%q\n%q argument.  Default: %s",
                        ret,
+                       cstring_capitalize (argcode_unparse (f.argtype)),
                        context_getString (flag));
        }
       else
        {
-         ret = message("%q\nString Argument.  No default.", ret);
+         ret = message("%q\n%s argument.  No default.", 
+                       ret,
+                       cstring_capitalize (argcode_unparse (f.argtype)));
        }
       break;
+      }
     }
-
+  
   if (mstring_isDefined (f.hint))
     {
       ret = message("%q\n\3%s", ret, cstring_fromChars (f.hint));
     }
-
+  
   return ret;
 }
+  
+static cstring getFlagModeSettings (flagcode flag)
+{
+  cstring res = cstring_undefined;
+  
+  allModes (mname)
+    {
+      context_setModeNoWarn (cstring_fromChars (mname));
+      
+      res = message ("%q%s", res, cstring_makeLiteralTemp (context_getFlag (flag) ? "+" : "-"));
+    } end_allModes;
+
+  return res;
+}
 
 cstring
 describeFlag (cstring flagname)
 {
   cstring oflagname = cstring_copy (flagname);
-  flagcode f = identifyFlag (flagname);
+  flagcode f = flags_identifyFlag (flagname);
 
   if (flagcode_isSkip (f))
     {
@@ -598,7 +828,7 @@ describeFlag (cstring flagname)
          cstring_free (oflagname);
 
          return
-           (message ("%s: predefined mode (see User's Guide for information)",
+           (message ("%s: predefined mode (see Manual for information)",
                      flagname));
        }
       else
@@ -637,6 +867,11 @@ void printAlphaFlags ()
 /*@observer@*/ cstring
 flagcode_unparse (flagcode code)
 {
+  if (code == INVALID_FLAG)
+    {
+      return cstring_makeLiteralTemp ("<invalid flag>");
+    }
+
   return cstring_fromChars (flags[code].flag);
 }
 
@@ -667,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",
@@ -697,23 +933,40 @@ 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
+flags_identifyFlag (cstring s)
+{
+  return flags_identifyFlagAux (s, FALSE);
 }
 
 flagcode
-identifyFlag (cstring s)
+flags_identifyFlagQuiet (cstring s)
+{
+  return flags_identifyFlagAux (s, TRUE);
+}
+
+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;
@@ -739,206 +992,216 @@ identifyFlag (cstring s)
       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"))
-    {
-      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;
-    }
-
-  /*
-  ** For our European friends...
-  */
-
-  if (cstring_equalLit (s, "isolib"))
-    {
-      return FLG_ANSILIB;
-    }
-
-  if (cstring_equalLit (s, "isostrictlib"))
-    {
-      return FLG_STRICTLIB;
-    }
-
-  if (cstring_equalLit (s, "ansistrictlib"))
-    {
-      return FLG_STRICTLIB;
-    }
-
-  if (cstring_equalLit (s, "skipisoheaders"))
-    {
-      return FLG_SKIPANSIHEADERS;
-    }
-
-  if (cstring_equalLit (s, "isoreserved"))
-    {
-      return FLG_ANSIRESERVED;
-    }
-
-  if (cstring_equalLit (s, "isoreservedinternal"))
-    {
-      return FLG_ANSIRESERVEDLOCAL;
-    }
-
-  if (cstring_equalLit (s, "isolimits"))
-    {
-      return FLG_ANSILIMITS;
-    }
-
-  /*
-  ** Obsolete Flags
-  */
   
-  if (cstring_equalLit (s, "accessunspec"))
-    {
-      flagWarning 
-       (cstring_makeLiteralTemp
-        ("accessunspec flag is not supported by LCLint version 2.0 or "
-         "later.  It has been replaced by accessmodule, accessfile and "
-         "accessfunction to provide more precise control of accessibility "
-         "of representations.  For more information, "
-         "see lclint -help accessmodule"));
-      
-      return SKIP_FLAG;
-    }
-
-  if (cstring_equalLit (s, "staticmods"))
+  if (res == INVALID_FLAG)
     {
-      flagWarning 
-       (cstring_makeLiteralTemp
-        ("staticmods flag is obsolete.  You probably "
-         "want impcheckmodstatics.  For more information, "
-         "see lclint -help impcheckmodstatics"));
+      /*
+      ** Synonyms
+      */
       
-      return SKIP_FLAG;
-    }
-
-  if (cstring_equalLit (s, "bool"))
-    {
-      flagWarning
-       (cstring_makeLiteralTemp ("bool flag is obsolete.  It never really "
-                                 "made sense in the first place."));
+      if (cstring_equalLit (cflag, "pred"))
+       {
+         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;
-    }
-  
-  if (cstring_equalLit (s, "ansi"))
-    {
-      flagWarning
-       (cstring_makeLiteralTemp ("ansi flag is obsolete.  You probably "
-                                 "want noparams and/or oldstyle."));
+      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;
+       }
       
-      return SKIP_FLAG;
-    }
-    
-  if (cstring_equalLit (s, "stdio"))
-    {
-      flagWarning 
-       (cstring_makeLiteralTemp
-        ("stdio flag is obsolete.  You may "
-         "want strictlib or one of the gloabls "
-         "checking flags.  For more information, "
-         "see lclint -help strictlib or lclint -help flags globals"));
+      /*
+      ** Obsolete Flags
+      */
       
-      return SKIP_FLAG;
+      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."));
+         
+         res = SKIP_FLAG;
+       }
+      else if (cstring_equalLit (cflag, "staticmods"))
+       {
+         if (!quiet) 
+           {
+             llerror_flagWarning 
+               (cstring_makeLiteral
+                ("staticmods flag is obsolete.  You probably "
+                 "want impcheckmodstatics.  For more information, "
+                 "see splint -help impcheckmodstatics"));
+           }
+         
+         res = SKIP_FLAG;
+       }
+      else if (cstring_equalLit (cflag, "bool"))
+       {
+         if (!quiet) 
+           {
+             llerror_flagWarning
+               (cstring_makeLiteral ("bool flag is obsolete.  It never really "
+                                     "made sense in the first place."));
+           }
+         
+         res = SKIP_FLAG;
+       }
+      else if (cstring_equalLit (cflag, "shiftsigned"))
+       {
+         if (!quiet) 
+           {
+             llerror_flagWarning
+               (cstring_makeLiteral ("shiftsigned flag is obsolete.  You probably "
+                                     "want bitwisesigned, shiftnegative or shiftimplementation."));
+           }
+         
+         res = SKIP_FLAG;
+       }
+      else if (cstring_equalLit (cflag, "ansi"))
+       {
+         if (!quiet) 
+           {
+             llerror_flagWarning
+               (cstring_makeLiteral ("ansi flag is obsolete.  You probably "
+                                     "want noparams and/or oldstyle."));
+           }
+         
+         res = SKIP_FLAG;
+       }
+      else if (cstring_equalLit (cflag, "stdio"))
+       {
+         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 INVALID_FLAG;
+  cstring_free (cflag);
+  return res;
 }
 
 void setValueFlag (flagcode opt, cstring arg)
@@ -1034,7 +1297,7 @@ describeModes ()
 
   cstringSList_elements (sflags, flagname)
     {
-      flagcode code = identifyFlag (flagname);
+      flagcode code = flags_identifyFlag (flagname);
       fflag currentflag = flags[code];
       
       if (mstring_isDefined (currentflag.desc) && flagcode_isModeFlag (code))
@@ -1067,7 +1330,8 @@ describeModes ()
   return (s);
 }
 
-static cstring
+# if 0
+static /*@unused@*/ cstring
 listModes (void)
 {
   cstring s = cstring_makeLiteral ("\t");
@@ -1088,6 +1352,7 @@ listModes (void)
 
   return s;
 }
+# endif
 
 bool
 isMode (cstring s)
@@ -1111,14 +1376,22 @@ extern bool flagcode_hasArgument (flagcode f)
   return (flags[f].argtype != ARG_NONE);
 }
 
-extern bool flagcode_hasValue (flagcode f)
+extern bool flagcode_hasNumber (flagcode f)
+{
+  return (flags[f].argtype == ARG_NUMBER);
+}
+
+extern bool flagcode_hasChar (flagcode f)
 {
-  return (flags[f].argtype == ARG_VALUE);
+  return (flags[f].argtype == ARG_CHAR);
 }
 
 extern bool flagcode_hasString (flagcode f)
 {
-  return (flags[f].argtype == ARG_STRING);
+  return (flags[f].argtype == ARG_STRING
+         || flags[f].argtype == ARG_FILE
+         || flags[f].argtype == ARG_DIRECTORY
+         || flags[f].argtype == ARG_PATH);
 }
 
 extern int flagcode_valueIndex (flagcode f)
@@ -1133,7 +1406,7 @@ extern int flagcode_valueIndex (flagcode f)
 
       allFlagCodes (code)
        {
-         if (flagcode_hasValue (code))
+         if (flagcode_hasNumber (code) || flagcode_hasChar (code))
            {
              llassert (nv < NUMVALUEFLAGS);
              DPRINTF (("Value flag: %s [%d]", flagcode_unparse (code), (int) code));
@@ -1151,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;
        }
@@ -1194,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.069143 seconds and 4 git commands to generate.