X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/8fd556fb32e6886724d72e99270d429554f28ea6..a9ec328054b628447830161535f4915f715f49cd:/src/flags.c diff --git a/src/flags.c b/src/flags.c index b908b15..c26a6c6 100644 --- a/src/flags.c +++ b/src/flags.c @@ -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 ("")); } + if (flagcode_isModeName (flag)) + { + return (cstring_makeLiteral ("")); + } + 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))