/*
** 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
# endif
}
+# ifdef WIN32
+# pragma warning (enable:4715)
+# endif
+
typedef struct {
flagkind main;
flagkind sub;
hadOne = TRUE;
}
- sprintf (buf, "%s%7d %9d", cstring_toCharsSafe (fs), nrep, nsup);
+ (void) snprintf (buf, 128, "%s%7d %9d", cstring_toCharsSafe (fs), nrep, nsup);
sumrep += nrep;
sumsup += nsup;
llmsglit (" ======== =========");
- sprintf (buf, "%s%7d %9d", cstring_toCharsSafe (ts), sumrep, sumsup);
+ (void) snprintf (buf, 128, "%s%7d %9d", cstring_toCharsSafe (ts), sumrep, sumsup);
cstring_free (ts);
llmsgplain (cstring_copy (cstring_fromChars (buf)));
}
}
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)
context_resetAllFlags ();
- /*drl bee: mRug*/
f = flags[flag];
ret = cstring_copy (cstring_fromChars (f.desc));
} ;
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;
fileIdList cfiles,
fileIdList lclfiles,
fileIdList mtfiles,
- cstringSList *passThroughArgs,
+ cstringList *passThroughArgs,
int argc, char **argv)
{
int i;
cstring flagname = cstring_fromChars (thisarg + 1); /* skip '-' or '+' */
flagcode opt = flags_identifyFlag (flagname);
- DPRINTF (("Flag: %s", flagcode_unparse (opt)));
+ DPRINTF (("Flag [%s]: %s", flagname, flagcode_unparse (opt)));
if (flagcode_isInvalid (opt))
{
** Following space is optional, don't include the -
*/
- *passThroughArgs = cstringSList_add (*passThroughArgs,
- cstring_fromChars (thisarg + 1));
+ *passThroughArgs = cstringList_add (*passThroughArgs,
+ cstring_fromCharsNew (thisarg + 1));
}
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
{
{
if (++i < argc)
{
- cstring arg = cstring_fromChars (argv[i]);
+ /*drl 10/21/2002
+ Changed this because arg can be freed when it's passed to
+ lslinit_setInitFile and freeing argv[i] causes a seg fault
+ */
+ cstring arg = cstring_fromCharsNew (argv[i]);
if (opt == FLG_OPTF)
{
}
else if (opt == FLG_INIT)
{
-# ifndef NOLCL
lslinit_setInitFile (inputStream_create
(arg,
cstring_makeLiteralTemp (LCLINIT_SUFFIX),
FALSE));
-# endif
break;
}
else
}
else
{
- setStringFlag (opt, cstring_copy (arg));
+ flags_setStringFlag (opt, cstring_copy (arg));
}
}
}
g_currentloc);
}
}
+
+ 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;
}