]> andersk Git - splint.git/blobdiff - src/flags.c
Fixed -help <mode> bug.
[splint.git] / src / flags.c
index a148f56d3040bd5a9020c3d12ba08c5a9a6b7093..c26a6c63816193ae44c70706830db9dffa947ba8 100644 (file)
@@ -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 { 
@@ -704,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)
 {
@@ -715,6 +750,11 @@ describeFlagCode (flagcode flag)
       return (cstring_makeLiteral ("<invalid>"));
     }
 
+  if (flagcode_isModeName (flag)) 
+    {
+      return (cstring_makeLiteral ("<mode flag>"));
+    }
+
   context_resetAllFlags ();
   
   f = flags[flag];
@@ -849,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
        {
@@ -1659,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.383821 seconds and 4 git commands to generate.