+
/*
** LCLint - annotation-assisted static program checker
** Copyright (C) 1994-2001 University of Virginia,
*/
# include <signal.h>
-
+# include <time.h>
/*
** Ensure that WIN32 and _WIN32 are both defined or both undefined.
*/
# include "cgrammar.h"
# include "llmain.h"
# include "portab.h"
-# include "cpp.h"
-# include "mtreader.h"
-# include <time.h>
+
extern /*@external@*/ int yydebug;
static void cleanupFiles (void);
static void showHelp (void);
static void interrupt (int p_i);
+
static void loadrc (/*@open@*/ FILE *p_rcfile, cstringSList *p_passThroughArgs)
- ; // /*@ensures closed p_rcfile@*/ ;
+ /*@ensures closed p_rcfile@*/ ;
+
static void describeVars (void);
static bool specialFlagsHelp (char *p_next);
static bool hasShownHerald = FALSE;
char *quotechar = strchr (curarg, '\"');
int offset = 0;
bool open = FALSE;
+ char *freearg = NULL;
while (quotechar != NULL)
{
}
}
+ llassert (quotechar != NULL);
*quotechar = '\0';
offset = (quotechar - arg) + 2;
(message ("%s\"\'%s",
cstring_fromChars (arg),
cstring_fromChars (quotechar + 1)));
+ freearg = arg;
open = FALSE;
}
else
(message ("%s\'\"%s",
cstring_fromChars (arg),
cstring_fromChars (quotechar + 1)));
+ freearg = arg;
open = TRUE;
}
if (open)
{
showHerald ();
- llerror (FLG_BADFLAG,
- message ("Unclosed quote in flag: %s",
- cstring_fromChars (arg)));
+ voptgenerror (FLG_BADFLAG,
+ message ("Unclosed quote in flag: %s",
+ cstring_fromChars (arg)),
+ g_currentloc);
}
else
{
BADBRANCH;
}
}
+
+ sfree (freearg);
}
void showHerald (void)
*/
{
- cstring incval = cstring_copy
- (osd_getEnvironmentVariable (cstring_makeLiteralTemp (INCLUDE_VAR)));
+ cstring incval = cstring_copy (osd_getEnvironmentVariable (INCLUDEPATH_VAR));
+ cstring oincval = incval;
if (cstring_isDefined (incval))
{
while (cstring_isDefined (incval))
{
/*@access cstring@*/
- char *nextsep = strchr (incval, SEPCHAR);
+ char *nextsep = strchr (incval, PATH_SEPARATOR);
if (nextsep != NULL)
{
cppAddIncludeDir (dir);
}
- *nextsep = SEPCHAR;
+ *nextsep = PATH_SEPARATOR;
incval = cstring_fromChars (nextsep + 1);
cstring_free (dir);
}
}
}
- cstring_free (incval);
+ cstring_free (oincval);
}
/*
else
{
DPRINTF (("Error!"));
- llgloberror (message ("Unrecognized option: %s",
- cstring_fromChars (thisarg)));
+ voptgenerror (FLG_BADFLAG,
+ message ("Unrecognized option: %s",
+ cstring_fromChars (thisarg)),
+ g_currentloc);
}
}
else
g_localSpecPath = cstring_toCharsSafe
(message ("%s%h%s",
cstring_fromChars (g_localSpecPath),
- SEPCHAR,
+ PATH_SEPARATOR,
dir));
/*@=mustfree@*/
/*@switchbreak@*/ break;
llmsglit (" --- directory containing lcl standard library files "
"(import with < ... >)");;
- {
- cstring dirs = context_getString (FLG_SYSTEMDIRS);
- llmsg (message
- ("systemdirs = %s (set by include envirnoment variable or -systemdirs)",
- dirs));
+ llmsg (message
+ ("include path = %q (set by environment variable %s and -I flags)",
+ cppReader_getIncludePath (), INCLUDEPATH_VAR));
- }
+ llmsglit (" --- path used to find #include'd files");
+
+ llmsg (message
+ ("systemdirs = %s (set by -systemdirs or envirnoment variable %s)", /*@i413223@*/
+ context_getString (FLG_SYSTEMDIRS),
+ INCLUDEPATH_VAR));
+
+ llmsglit (" --- if file is found on this path, it is treated as a system file for error reporting");
}
void
void
loadrc (/*@open@*/ FILE *rcfile, cstringSList *passThroughArgs)
- // /*@ensures closed rcfile@*/
+ /*@ensures closed rcfile@*/
{
char *s = mstring_create (MAX_LINE_LENGTH);
char *os = s;
else
{
showHerald ();
- llerror (FLG_SYNTAX,
- message ("Bad flag syntax (+ or - expected, "
- "+ is assumed): %s",
- cstring_fromChars (s)));
+ voptgenerror (FLG_BADFLAG,
+ message ("Bad flag syntax (+ or - expected, "
+ "+ is assumed): %s",
+ cstring_fromChars (s)),
+ g_currentloc);
s--;
set = TRUE;
}
}
else
{
- llerror (FLG_BADFLAG,
- message ("Unrecognized option: %s",
- cstring_fromChars (thisflag)));
+ voptgenerror (FLG_BADFLAG,
+ message ("Unrecognized option: %s",
+ cstring_fromChars (thisflag)),
+ g_currentloc);
}
}
else
if (opt == FLG_HELP)
{
showHerald ();
- llerror (FLG_BADFLAG,
- message ("Cannot use help in rc files"));
+ voptgenerror (FLG_BADFLAG,
+ message ("Cannot use help in rc files"),
+ g_currentloc);
}
else if (flagcode_isPassThrough (opt)) /* -D or -U */
{
if (cstring_isUndefined (extra))
{
showHerald ();
- llerror
+ voptgenerror
(FLG_BADFLAG,
message
("Flag %s must be followed by an argument",
- flagcode_unparse (opt)));
+ flagcode_unparse (opt)),
+ g_currentloc);
}
else
{
else
{
showHerald ();
- llerror
- (FLG_SYNTAX,
+ voptgenerror
+ (FLG_BADFLAG,
message ("Options file not found: %s",
- extra));
+ extra),
+ g_currentloc);
}
}
else if (opt == FLG_INIT)
}
else
{
- llerror
- (FLG_SYNTAX,
+ voptgenerror
+ (FLG_BADFLAG,
message ("Unmatched \" in option string: %s",
- extra));
+ extra),
+ g_currentloc);
}
}