]> andersk Git - splint.git/blobdiff - src/flags.c
Fixed -help <mode> bug.
[splint.git] / src / flags.c
index 086fae0811d1d739fbe9c973af8a1174b5c9fd05..c26a6c63816193ae44c70706830db9dffa947ba8 100644 (file)
@@ -28,9 +28,9 @@
 # include "splintMacros.nf"
 # include "basic.h"
 # include "osd.h"
-# include "portab.h"
 # include "rcfiles.h"
 # include "lslinit.h"
+# include "llmain.h"
 
 /*
 ** from the CC man page:
@@ -128,6 +128,11 @@ typedef enum {
   ARG_SPECIAL   /* ? */
 } argcode;
 
+# ifdef WIN32
+/* Make Microsoft VC++ happy */
+# pragma warning (disable:4715)
+# endif
+
 static /*@observer@*/ cstring argcode_unparse (argcode arg)
 {
   switch (arg) 
@@ -143,14 +148,10 @@ static /*@observer@*/ cstring argcode_unparse (argcode arg)
     case ARG_SPECIAL:
       BADBRANCH;
     }
-# ifdef WIN32
-/* Make Microsoft VC++ happy */
-# pragma warning (disable:4715) 
-# endif
 }      
 
 # ifdef WIN32
-# pragma warning (enable:4715) 
+# pragma warning (default : 4715)
 # endif
 
 typedef struct { 
@@ -341,8 +342,6 @@ flagcode_recordError (flagcode f)
        }
       else
        {
-         /*drl bee: ec*/
-         /*drl bee: ec*/
          flags[f].nreported = flags[f].nreported + 1;
        }
     }
@@ -357,8 +356,7 @@ flagcode_recordSuppressed (flagcode f)
 {
   llassertprint (f != INVALID_FLAG, ("flagcode: %s", flagcode_unparse (f)));
 
-  /*drl bee: ec*/
-    /*drl bee: ec*/   flags[f].nsuppressed = flags[f].nsuppressed + 1;
+  flags[f].nsuppressed = flags[f].nsuppressed + 1;
 }
 
 int
@@ -374,7 +372,6 @@ flagcodeHint (flagcode f)
 {
   llassert (f != INVALID_FLAG);
 
-  /*drl bee: ec*/
   if (mstring_isDefined (flags[f].hint))
     {
       return (cstring_fromChars (flags[f].hint));
@@ -407,7 +404,6 @@ 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))
@@ -426,7 +422,6 @@ 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));
@@ -442,7 +437,6 @@ static int categoryIndex (flagkind kind)
 
   for (i = 0; categories[i].kind != FK_NONE; i++)
     {
-        /*drl bee: mRug*/
       if (categories[i].kind == kind)
        {
          return i;
@@ -457,7 +451,6 @@ 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),
@@ -480,7 +473,6 @@ listAllCategories (void)
 
   for (i = 0; categories[i].kind != FK_NONE; i++)
     {
-              /*drl bee: mRug*/
       flagkind kind = categories[i].kind ;
 
       if (categories[i].describe != NULL)
@@ -502,7 +494,6 @@ printAllFlags (bool desc, bool full)
 
       cstringSList_elements (fl, el)
        {
-         /*@i22@*/ /*find out why this is necessary*/
          cstring tmp;
          tmp = cstring_copy(el);
          llmsg (message ("%q\n\n", describeFlag (tmp)));
@@ -714,6 +705,40 @@ printFlagManual (bool html)
   } end_allFlags ;
 }
 
+cstring 
+describeMode (cstring mode)
+{
+  cstringSList sflags = sortedFlags ();
+  cstring res = message ("Predefined mode %s sets: ", mode);
+
+  llassert (flags_isModeName (mode));
+
+  context_setMode (mode);
+
+  cstringSList_elements (sflags, flagname)
+    {
+      flagcode code = flags_identifyFlag (flagname);
+      fflag currentflag = flags[code];
+      
+      if (mstring_isDefined (currentflag.desc) && flagcode_isModeFlag (code))
+       {
+         if (context_getFlag (code))
+           {
+             res = message ("%q\n   +%s", res, cstring_fromChars (currentflag.flag));
+           }
+         else
+           {
+             res = message ("%q\n   -%s", res, cstring_fromChars (currentflag.flag)); 
+           }
+       }
+    } end_cstringSList_elements;
+  
+  cstringSList_free (sflags);
+
+  res = cstring_appendChar (res, '\n');
+  return (res);
+}
+
 cstring
 describeFlagCode (flagcode flag)
 {
@@ -725,9 +750,13 @@ describeFlagCode (flagcode flag)
       return (cstring_makeLiteral ("<invalid>"));
     }
 
+  if (flagcode_isModeName (flag)) 
+    {
+      return (cstring_makeLiteral ("<mode flag>"));
+    }
+
   context_resetAllFlags ();
   
-  /*drl bee: mRug*/
   f = flags[flag];
   ret = cstring_copy (cstring_fromChars (f.desc));
   
@@ -860,10 +889,7 @@ describeFlag (cstring flagname)
       if (flags_isModeName (flagname))
        {
          cstring_free (oflagname);
-
-         return
-           (message ("%s: predefined mode (see Manual for information)",
-                     flagname));
+         return describeMode (flagname);
        }
       else
        {
@@ -968,7 +994,6 @@ canonicalizeFlag (cstring s)
       } ;
   char *current;
   
-  /*drl bee: ia*/
   while ((current = transform[i]) != NULL)
     {
       if (cstring_containsLit (res, current))
@@ -1489,7 +1514,6 @@ extern int flagcode_valueIndex (flagcode f)
     {
       /* static valueFlags must be defined */
       /*@-usedef@*/
-      /*drl bee: sta*/
       if (f == valueFlags[i]) /*@=usedef@*/
        {
          return i;
@@ -1533,7 +1557,6 @@ extern int flagcode_stringIndex (flagcode f)
 
   for (i = 0; i < NUMSTRINGFLAGS; i++)
     {
-              /*drl bee: sta*/
       /*@-usedef@*/ if (f == stringFlags[i]) /*@=usedef@*/
        {
          return i;
@@ -1673,9 +1696,16 @@ flags_processFlags (bool inCommandLine,
       if (*thisarg == '-' || *thisarg == '+')
        {
          bool set = (*thisarg == '+');
-         cstring flagname = cstring_fromChars (thisarg + 1); /* skip '-' or '+' */
-         flagcode opt = flags_identifyFlag (flagname);
+         cstring flagname;
+         flagcode opt;
+
+         if (*(thisarg + 1) == '-') { /* allow -- before flags */
+           flagname = cstring_fromChars (thisarg + 2);
+         } else {
+           flagname = cstring_fromChars (thisarg + 1);
+         }
 
+         opt = flags_identifyFlag (flagname);
          DPRINTF (("Flag [%s]: %s", flagname, flagcode_unparse (opt)));
          
          if (flagcode_isInvalid (opt))
This page took 0.0526 seconds and 4 git commands to generate.