/*
** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
** Massachusetts Institute of Technology
**
** This program is free software; you can redistribute it and/or modify it
# 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:
ARG_SPECIAL /* ? */
} argcode;
+# ifdef WIN32
+/* Make Microsoft VC++ happy */
+# pragma warning (disable:4715)
+# endif
+
static /*@observer@*/ cstring argcode_unparse (argcode arg)
{
switch (arg)
case ARG_SPECIAL:
BADBRANCH;
}
+}
+
# ifdef WIN32
-/* Make Microsoft VC++ happy */
-# pragma warning (disable:4715)
+# pragma warning (default : 4715)
# endif
-}
typedef struct {
flagkind main;
}
else
{
- /*drl bee: ec*/
- /*drl bee: ec*/
flags[f].nreported = flags[f].nreported + 1;
}
}
{
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
{
llassert (f != INVALID_FLAG);
- /*drl bee: ec*/
if (mstring_isDefined (flags[f].hint))
{
return (cstring_fromChars (flags[f].hint));
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))
for (i = 0; categories[i].kind != FK_NONE; i++)
{
- /*drl bee: mrUg*/
if (categories[i].kind == kind)
{
return (cstring_fromChars (categories[i].name));
for (i = 0; categories[i].kind != FK_NONE; i++)
{
- /*drl bee: mRug*/
if (categories[i].kind == kind)
{
return i;
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),
for (i = 0; categories[i].kind != FK_NONE; i++)
{
- /*drl bee: mRug*/
flagkind kind = categories[i].kind ;
if (categories[i].describe != NULL)
cstringSList_elements (fl, el)
{
- /*@i22@*/ /*find out why this is necessary*/
cstring tmp;
tmp = cstring_copy(el);
llmsg (message ("%q\n\n", describeFlag (tmp)));
} 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)
{
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));
if (flags_isModeName (flagname))
{
cstring_free (oflagname);
-
- return
- (message ("%s: predefined mode (see Manual for information)",
- flagname));
+ return describeMode (flagname);
}
else
{
} ;
char *current;
- /*drl bee: ia*/
while ((current = transform[i]) != NULL)
{
if (cstring_containsLit (res, current))
{
res = FLG_ENUMINT;
}
+ else if (cstring_equalLit (cflag, "intlong"))
+ {
+ res = FLG_LONGINT;
+ }
+ else if (cstring_equalLit (cflag, "intshort"))
+ {
+ res = FLG_SHORTINT;
+ }
/*
** Backwards compatibility for our American friends...
*/
return res;
}
-void setValueFlag (flagcode opt, cstring arg)
+void flags_setValueFlag (flagcode opt, cstring arg)
{
switch (opt)
{
case FLG_LIMIT:
case FLG_LINELEN:
case FLG_INDENTSPACES:
+ case FLG_LOCINDENTSPACES:
case FLG_BUGSLIMIT:
case FLG_EXTERNALNAMELEN:
case FLG_INTERNALNAMELEN:
}
}
break;
- BADDEFAULT;
+ BADDEFAULT;
}
}
-void setStringFlag (flagcode opt, /*@only@*/ cstring arg)
+void flags_setStringFlag (flagcode opt, /*@only@*/ cstring arg)
{
switch (opt)
{
{
/* static valueFlags must be defined */
/*@-usedef@*/
- /*drl bee: sta*/
if (f == valueFlags[i]) /*@=usedef@*/
{
return i;
for (i = 0; i < NUMSTRINGFLAGS; i++)
{
- /*drl bee: sta*/
/*@-usedef@*/ if (f == stringFlags[i]) /*@=usedef@*/
{
return i;
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);
+ }
- DPRINTF (("Flag: %s", flagcode_unparse (opt)));
+ opt = flags_identifyFlag (flagname);
+ DPRINTF (("Flag [%s]: %s", flagname, flagcode_unparse (opt)));
if (flagcode_isInvalid (opt))
{
}
else if (opt == FLG_INCLUDEPATH || opt == FLG_SPECPATH)
{
- cstring dir = cstring_suffix (cstring_fromChars (thisarg), 1); /* skip over I */
-
- DPRINTF (("Directory: %s", dir));
-
- switch (opt)
- {
- case FLG_INCLUDEPATH:
- cppAddIncludeDir (dir);
- /*@switchbreak@*/ break;
- case FLG_SPECPATH:
- /*@-mustfree@*/
- g_localSpecPath = cstring_toCharsSafe
- (message ("%s%h%s",
- cstring_fromChars (g_localSpecPath),
- PATH_SEPARATOR,
- dir));
- /*@=mustfree@*/
- /*@switchbreak@*/ break;
- BADDEFAULT;
+ if (mstring_length (thisarg) < 2) {
+ BADBRANCH;
+ } else {
+ if (mstring_equal (thisarg, "-I-")) {
+ cppAddIncludeDir (cstring_fromChars (thisarg)); /* Need to handle this specially. */
+ } else {
+ cstring dir = cstring_suffix (cstring_fromChars (thisarg), 2); /* skip over -I */
+
+ DPRINTF (("Length of thisarg [%s] %d", thisarg, cstring_length (thisarg)));
+
+ if (cstring_length (dir) == 0) {
+ DPRINTF (("space after directory: "));
+ if (++i < argc) {
+ dir = cstring_fromChars (argv[i]);
+ } else {
+ voptgenerror
+ (FLG_BADFLAG,
+ message
+ ("Flag %s must be followed by a directory name",
+ flagcode_unparse (opt)),
+ g_currentloc);
+ }
+ }
+
+ DPRINTF (("Got directory: [%s]", dir));
+
+ switch (opt)
+ {
+ case FLG_INCLUDEPATH:
+ cppAddIncludeDir (dir);
+ /*@switchbreak@*/ break;
+ case FLG_SPECPATH:
+ /*@-mustfree@*/
+ g_localSpecPath = cstring_toCharsSafe
+ (message ("%s%h%s",
+ cstring_fromChars (g_localSpecPath),
+ PATH_SEPARATOR,
+ dir));
+ /*@=mustfree@*/
+ /*@switchbreak@*/ break;
+ BADDEFAULT;
+ }
}
+ }
}
else if (flagcode_isModeName (opt))
{
{
if (++i < argc)
{
- setValueFlag (opt, cstring_fromChars (argv[i]));
+ flags_setValueFlag (opt, cstring_fromCharsNew (argv[i]));
}
else
{
{
if (++i < argc)
{
- setValueFlag (opt, cstring_fromChars (argv[i]));
+ flags_setValueFlag (opt, cstring_fromCharsNew (argv[i]));
}
else
{
}
else
{
- setStringFlag (opt, cstring_copy (arg));
+ flags_setStringFlag (opt, cstring_copy (arg));
}
}
}
cstringSList_free (fl); /* evans 2002-07-12: why wasn't this reported!?? */
}
+
+int flagcode_priority (/*@unused@*/ flagcode code)
+{
+ /*
+ ** For now, we do a really simple prioritization: all are 1
+ */
+
+ return 1;
+}