]> andersk Git - splint.git/blobdiff - src/flags.c
Fixed -help <mode> bug.
[splint.git] / src / flags.c
index b908b153959eb8cffa184ff035bd39520f111545..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 { 
@@ -493,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)));
@@ -705,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)
 {
@@ -716,6 +750,11 @@ describeFlagCode (flagcode flag)
       return (cstring_makeLiteral ("<invalid>"));
     }
 
+  if (flagcode_isModeName (flag)) 
+    {
+      return (cstring_makeLiteral ("<mode flag>"));
+    }
+
   context_resetAllFlags ();
   
   f = flags[flag];
@@ -850,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
        {
@@ -1660,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.040728 seconds and 4 git commands to generate.