From 53306cab3dabf761f459f8f5fdc4b30eca6ec707 Mon Sep 17 00:00:00 2001 From: evans1629 Date: Thu, 12 Dec 2002 23:42:45 +0000 Subject: [PATCH] Added code to support CSV output (-csv flag). --- src/Headers/annotationInfo.h | 4 +- src/Headers/basic.h | 1 + src/Headers/cpplib.h | 3 +- src/Headers/flag_codes.h | 2 +- src/Headers/flags.h | 2 + src/Headers/globals.h | 3 + src/Headers/symtable.h | 2 +- src/annotationInfo.c | 42 +++++++------- src/checking.c | 4 +- src/constraintGeneration.c | 2 +- src/cppexp.c | 2 +- src/cpplib.c | 4 +- src/cprim.c | 1 + src/fileTable.c | 6 +- src/flags.c | 11 +++- src/flags.def | 16 +++++- src/functionClauseList.c | 2 +- src/globals.c | 1 + src/inputStream.c | 4 +- src/llerror.c | 103 +++++++++++++++++++++++++---------- src/llmain.c | 32 ++++++++++- src/lslinit.c | 2 + src/message.c | 9 ++- src/osd.c | 2 +- src/symtable.c | 12 ++-- src/usymtab.c | 5 +- 26 files changed, 197 insertions(+), 80 deletions(-) diff --git a/src/Headers/annotationInfo.h b/src/Headers/annotationInfo.h index 1e1dac7..7c8b63a 100644 --- a/src/Headers/annotationInfo.h +++ b/src/Headers/annotationInfo.h @@ -48,8 +48,8 @@ annotationInfo_create (/*@only@*/ cstring p_name, /*@only@*/ mtContextNode p_context, int p_value, /*@only@*/ fileloc p_loc) /*@*/ ; -extern /*@observer@*/ cstring annotationInfo_unparse (annotationInfo p_ainfo); -extern /*@observer@*/ fileloc annotationInfo_getLoc (annotationInfo p_ainfo) /*@*/ ; +extern /*@observer@*/ cstring annotationInfo_unparse (annotationInfo p_a); +extern /*@observer@*/ fileloc annotationInfo_getLoc (annotationInfo p_a) /*@*/ ; extern void annotationInfo_free (/*@only@*/ annotationInfo) ; diff --git a/src/Headers/basic.h b/src/Headers/basic.h index f894e91..3ad11cb 100644 --- a/src/Headers/basic.h +++ b/src/Headers/basic.h @@ -9,6 +9,7 @@ # ifdef HAVE_CONFIG_H # ifdef WIN32 + /* Win32 uses its own hand-generated config file */ # include "../../winconfig.h" # else diff --git a/src/Headers/cpplib.h b/src/Headers/cpplib.h index cdefe6b..1633d67 100644 --- a/src/Headers/cpplib.h +++ b/src/Headers/cpplib.h @@ -222,8 +222,7 @@ cpplib_createDefinition (/*@dependent@*/ cstring p_def, fileloc p_loc, extern void cpplib_reserve (/*@sef@*/ cppReader *, /*@sef@*/ size_t); #define cpplib_reserve(PFILE, N) \ - (cpplib_getWritten (PFILE) + (N) > (PFILE)->token_buffer_size \ - && (cppReader_growBuffer (PFILE, (N)), 0)) + (((cpplib_getWritten (PFILE) + (N) > (PFILE)->token_buffer_size)) ? cppReader_growBuffer (PFILE, (N)) : (void) 0) /* Append string STR (of length N) to PFILE's output buffer. Assume there is enough space. */ diff --git a/src/Headers/flag_codes.h b/src/Headers/flag_codes.h index 8f5531a..5f403b4 100644 --- a/src/Headers/flag_codes.h +++ b/src/Headers/flag_codes.h @@ -30,7 +30,7 @@ typedef enum # define NUMVALUEFLAGS 14 /*@constant int NUMSTRINGFLAGS; @*/ -# define NUMSTRINGFLAGS 27 +# define NUMSTRINGFLAGS 28 /*@iter allFlagCodes (yield flagcode f); @*/ # define allFlagCodes(m_code) \ diff --git a/src/Headers/flags.h b/src/Headers/flags.h index 9251134..e441ade 100644 --- a/src/Headers/flags.h +++ b/src/Headers/flags.h @@ -49,6 +49,8 @@ extern /*@observer@*/ cstring flagcode_unparse (flagcode p_code) /*@*/ ; extern int flagcode_valueIndex (flagcode p_f) /*@*/ ; extern int flagcode_stringIndex (flagcode p_f) /*@*/ ; +extern int flagcode_priority (flagcode p_code) /*@*/ ; + extern bool flagcode_equal (flagcode p_code1, flagcode p_code2) /*@*/ ; # define flagcode_equal(c1, c2) ((c1) == (c2)) diff --git a/src/Headers/globals.h b/src/Headers/globals.h index 5b30848..4022c45 100644 --- a/src/Headers/globals.h +++ b/src/Headers/globals.h @@ -21,6 +21,9 @@ extern /*@owned@*/ fileloc g_currentloc; /* stream for error messages */ /*@unchecked@*/ extern /*@relnull@*/ /*@dependent@*/ /*:open:*/ FILE *g_errorstream; +/* stream for error messages */ +/*@unchecked@*/ extern /*@null@*/ /*@dependent@*/ /*:open:*/ FILE *g_csvstream; + /*@-ansireserved@*/ /* This macro is defined by flex. */ /*@constant external int ECHO@*/ diff --git a/src/Headers/symtable.h b/src/Headers/symtable.h index e9a72a9..ee01409 100644 --- a/src/Headers/symtable.h +++ b/src/Headers/symtable.h @@ -183,7 +183,7 @@ extern void varInfo_free (/*@only@*/ varInfo p_v); extern /*@only@*/ lslOpSet symtable_opsWithLegalDomain (symtable p_tab, /*@temp@*/ /*@null@*/ nameNode p_n, - sortSetList p_argSorts, sort p_qual); + sortSetList p_argSorts, sort p_q); extern /*@observer@*/ sigNodeSet symtable_possibleOps (symtable p_tab, nameNode p_n); extern bool symtable_opExistsWithArity(symtable p_tab, nameNode p_n, int p_arity); diff --git a/src/annotationInfo.c b/src/annotationInfo.c index 26e7bcc..75d36fc 100644 --- a/src/annotationInfo.c +++ b/src/annotationInfo.c @@ -43,26 +43,26 @@ annotationInfo annotationInfo_create (cstring name, return res; } -void annotationInfo_free (annotationInfo ainfo) +void annotationInfo_free (annotationInfo a) { - if (annotationInfo_isDefined (ainfo)) + if (annotationInfo_isDefined (a)) { - cstring_free (ainfo->name); - fileloc_free (ainfo->loc); - mtContextNode_free (ainfo->context); /* evans 2002-01-03 */ - sfree (ainfo); + cstring_free (a->name); + fileloc_free (a->loc); + mtContextNode_free (a->context); /* evans 2002-01-03 */ + sfree (a); } } -cstring annotationInfo_getName (annotationInfo ainfo) +cstring annotationInfo_getName (annotationInfo a) { - llassert (annotationInfo_isDefined (ainfo)); - return ainfo->name; + llassert (annotationInfo_isDefined (a)); + return a->name; } -/*@observer@*/ cstring annotationInfo_unparse (annotationInfo ainfo) +/*@observer@*/ cstring annotationInfo_unparse (annotationInfo a) { - return annotationInfo_getName (ainfo); + return annotationInfo_getName (a); } /*@observer@*/ metaStateInfo annotationInfo_getState (annotationInfo a) /*@*/ @@ -71,10 +71,10 @@ cstring annotationInfo_getName (annotationInfo ainfo) return a->state; } -/*@observer@*/ fileloc annotationInfo_getLoc (annotationInfo ainfo) /*@*/ +/*@observer@*/ fileloc annotationInfo_getLoc (annotationInfo a) /*@*/ { - llassert (annotationInfo_isDefined (ainfo)); - return ainfo->loc; + llassert (annotationInfo_isDefined (a)); + return a->loc; } int annotationInfo_getValue (annotationInfo a) /*@*/ @@ -146,21 +146,21 @@ bool annotationInfo_matchesContextRef (annotationInfo a, sRef sr) } } -cstring annotationInfo_dump (annotationInfo ainfo) +cstring annotationInfo_dump (annotationInfo a) { - llassert (annotationInfo_isDefined (ainfo)); - return ainfo->name; + llassert (annotationInfo_isDefined (a)); + return a->name; } /*@observer@*/ annotationInfo annotationInfo_undump (char **s) { cstring mname = reader_readUntil (s, '.'); - annotationInfo ainfo; + annotationInfo a; llassert (cstring_isDefined (mname)); - ainfo = context_lookupAnnotation (mname); + a = context_lookupAnnotation (mname); - if (annotationInfo_isUndefined (ainfo)) + if (annotationInfo_isUndefined (a)) { llfatalerrorLoc (message ("Library uses undefined annotation %s. Must use same -mts flags as when library was created.", @@ -169,7 +169,7 @@ cstring annotationInfo_dump (annotationInfo ainfo) else { cstring_free (mname); - return ainfo; + return a; } BADBRANCHRET (annotationInfo_undefined); diff --git a/src/checking.c b/src/checking.c index 6fe1b23..6731b09 100644 --- a/src/checking.c +++ b/src/checking.c @@ -41,7 +41,7 @@ static /*@only@*/ cstring printBadArgs (sortSetList p_args); static /*@only@*/ sortSet - standardOperators (/*@null@*/ nameNode p_n, sortSetList p_argSorts, sort p_qual); + standardOperators (/*@null@*/ nameNode p_n, sortSetList p_argSorts, sort p_q); static bool isStandardOperator (/*@null@*/ nameNode p_n); static void assignSorts (termNode p_t, sort p_s); @@ -543,7 +543,7 @@ static bool isStandardOperator (/*@null@*/ nameNode n) } static /*@only@*/ sortSet -standardOperators (/*@null@*/ nameNode n, sortSetList argSorts, /*@unused@*/ sort qual) +standardOperators (/*@null@*/ nameNode n, sortSetList argSorts, /*@unused@*/ sort q) { sortSet argSet; sortSet ret = sortSet_new (); diff --git a/src/constraintGeneration.c b/src/constraintGeneration.c index dfb737d..e43f9f5 100644 --- a/src/constraintGeneration.c +++ b/src/constraintGeneration.c @@ -2242,7 +2242,7 @@ constraintList checkCall (/*@dependent@*/ exprNode fcn, exprNodeList arglist) preconditions = constraintList_makeNew(); } - // drl remember to remove this code before you make a pslint release. + /*@i523@ drl remember to remove this code before you make a splint release. */ /* if (context_getFlag (FLG_IMPLICTCONSTRAINT) ) { diff --git a/src/cppexp.c b/src/cppexp.c index 588eaf1..3dda026 100644 --- a/src/cppexp.c +++ b/src/cppexp.c @@ -1305,7 +1305,7 @@ cppReader_parseExpression (cppReader *pfile) { struct operation *new_stack; size_t old_size = size_fromInt ((char *) limit - (char *) stack); - size_t new_size = 2 * old_size; + size_t new_size = (size_t) (2 * old_size); if (stack != init_stack) { diff --git a/src/cpplib.c b/src/cpplib.c index 08e8f97..7abb0d1 100644 --- a/src/cpplib.c +++ b/src/cpplib.c @@ -7609,7 +7609,7 @@ void cpplib_initializeReader (cppReader *pfile) /* Must be done after library is nlist->got_name_map = 0; nlist->next = NULL; - if (opts->first_system_include == NULL) + /*@i2523@*/ if (opts->first_system_include == NULL) { opts->first_system_include = nlist; } @@ -7624,7 +7624,7 @@ void cpplib_initializeReader (cppReader *pfile) /* Must be done after library is cppReader_appendIncludeChain (pfile, opts->after_include, opts->last_after_include); - if (opts->first_system_include == NULL) + /*@i523@*/ if (opts->first_system_include == NULL) { opts->first_system_include = opts->after_include; } diff --git a/src/cprim.c b/src/cprim.c index 3f48794..6dd1be1 100644 --- a/src/cprim.c +++ b/src/cprim.c @@ -243,6 +243,7 @@ cprim_closeEnoughAux (cprim c1, cprim c2, bool deep) || (cprim_isAnyChar (c2) && context_msgCharInt ())) { return TRUE; } + /*@fallthrough@*/ default: ; } diff --git a/src/fileTable.c b/src/fileTable.c index 7c2f606..701e5f5 100644 --- a/src/fileTable.c +++ b/src/fileTable.c @@ -1011,7 +1011,11 @@ fileTable_addOpen (fileTable ft, /*@observer@*/ FILE *f, /*@only@*/ cstring fnam FILE *fileTable_createFile (fileTable ft, cstring fname) { - int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR); +# ifdef WIN32 + int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL); /* not supported by VS.net: , S_IRUSR | S_IWUSR); */ +# else + int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR); +# endif if (fdesc == -1) { diff --git a/src/flags.c b/src/flags.c index 4763a50..118f521 100644 --- a/src/flags.c +++ b/src/flags.c @@ -1671,7 +1671,7 @@ flags_processFlags (bool inCommandLine, 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)) { @@ -1959,3 +1959,12 @@ flags_processFlags (bool inCommandLine, 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; +} diff --git a/src/flags.def b/src/flags.def index 28976cc..dbab4de 100644 --- a/src/flags.def +++ b/src/flags.def @@ -54,7 +54,7 @@ /*@notfunction@*/ # define globalExtraArgFlag FALSE, FALSE, TRUE, FALSE, ARG_SPECIAL /*@notfunction@*/ -# define globalFileFlag FALSE, FALSE, TRUE, FALSE, ARG_FILE +# define globalFileFlag FALSE, TRUE, TRUE, FALSE, ARG_FILE /*@=namechecks@*/ /* @@ -3277,6 +3277,20 @@ static flaglist flags = "show location information for load files", NULL, 0, 0 }, + { + FK_FORMAT, FK_DISPLAY, globalFileFlag, + "csv", + FLG_CSV, + "produce comma-separated values (CSV) warnings output file", + NULL, 0, 0 + }, + { + FK_FORMAT, FK_DISPLAY, plainFlag, + "csvoverwrite", + FLG_CSVOVERWRITE, + "overwrite exisiting CVS output file", + NULL, 0, 0 + }, { FK_FORMAT, FK_DISPLAY, plainFlag, "parenfileformat", diff --git a/src/functionClauseList.c b/src/functionClauseList.c index c05d8b0..f35d6a5 100644 --- a/src/functionClauseList.c +++ b/src/functionClauseList.c @@ -198,7 +198,7 @@ functionClauseList_getImplictConstraints (functionClauseList s) else { llassert (FALSE); - // fix this + /*@i2523 fix this */ } } } diff --git a/src/globals.c b/src/globals.c index 38504c3..845b48e 100644 --- a/src/globals.c +++ b/src/globals.c @@ -46,6 +46,7 @@ int g_prevCodeLine = 0; FILE *g_warningstream = NULL; FILE *g_messagestream = NULL; FILE *g_errorstream = NULL; +FILE *g_csvstream = NULL; /* ** These were in llmain.c. Most should not be globals... diff --git a/src/inputStream.c b/src/inputStream.c index c77990b..95b102a 100644 --- a/src/inputStream.c +++ b/src/inputStream.c @@ -103,7 +103,7 @@ inputStream_create (cstring name, cstring suffix, bool echo) oname = s->name; s->name = fileLib_cleanName (s->name); - cstring_free (oname); /* evans 2002-07-12: why no error without this?! */ + /*@i523@*/ cstring_free (oname); /* evans 2002-07-12: why no error without this?! */ s->lineNo = 0; s->charNo = 0; @@ -114,7 +114,7 @@ inputStream_create (cstring name, cstring suffix, bool echo) s->stringSourceTail = NULL; s->buffer[0] = '\0'; - return s; + /*@i523@*/ return s; } extern /*@only@*/ inputStream diff --git a/src/llerror.c b/src/llerror.c index 16ab431..150046f 100644 --- a/src/llerror.c +++ b/src/llerror.c @@ -49,13 +49,21 @@ static int mcount = 0; static /*@only@*/ cstring saveOneMessage = cstring_undefined; static /*@only@*/ fileloc lastparseerror = fileloc_undefined; static /*@only@*/ fileloc lastbug = fileloc_undefined; -static bool llgenerrorreal (char *p_srcFile, int p_srcLine, - /*@only@*/ cstring p_s, fileloc p_fl, bool p_iserror, bool p_indent) +static bool llgenerrorreal (flagcode p_code, + char *p_srcFile, int p_srcLine, + /*@only@*/ cstring p_s, + /*@temp@*/ cstring p_addtext, + fileloc p_fl, bool p_iserror, bool p_indent) /*@modifies g_warningstream@*/ ; -static bool llgenerroraux (char *p_srcFile, int p_srcLine, - /*@only@*/ cstring p_s, fileloc p_fl, bool p_iserror, bool p_indent) +static bool llgenerroraux (flagcode p_code, char *p_srcFile, int p_srcLine, + /*@only@*/ cstring p_s, + /*@temp@*/ cstring p_addtext, + fileloc p_fl, bool p_iserror, bool p_indent) /*@modifies g_warningstream@*/ ; +static void generateCSV (flagcode p_code, cstring p_s, cstring p_addtext, fileloc p_fl) + /*@modifies g_csvstream@*/ ; + static void printError (FILE *p_stream, /*@only@*/ cstring p_sc) /*@globals lastfileloclen @*/ /*@modifies *p_stream@*/ ; @@ -842,12 +850,15 @@ llgentypeerroraux (char *srcFile, int srcLine, } else { - if (llgenerroraux (srcFile, srcLine, s, fl, TRUE, FALSE)) + if (hcode != INVALID_FLAG && hcode != ocode) + { + code = hcode; + } + + if (llgenerroraux (ocode, srcFile, srcLine, s, flagcodeHint (code), fl, TRUE, FALSE)) { - if (hcode != INVALID_FLAG && hcode != ocode) + if (code != ocode) { - code = hcode; - if (context_flagOn (code, fl)) { /* The flag is alreay set, something buggy in the flag code */ @@ -858,7 +869,7 @@ llgentypeerroraux (char *srcFile, int srcLine, { llshowhint (code); } - } + } else { llsuppresshint ('-', code); @@ -899,7 +910,7 @@ xllgenformattypeerror (char *srcFile, int srcLine, bool xllgenerror (char *srcFile, int srcLine, flagcode o, /*@only@*/ cstring s, fileloc fl) { - if (llgenerroraux (srcFile, srcLine, s, fl, TRUE, FALSE)) + if (llgenerroraux (o, srcFile, srcLine, s, flagcodeHint (o), fl, TRUE, FALSE)) { llnosuppresshint (o); flagcode_recordError (o); @@ -920,7 +931,7 @@ xllgenhinterror (char *srcFile, int srcLine, { if (!context_suppressFlagMsg (o, fl)) { - if (llgenerroraux (srcFile, srcLine, s, fl, TRUE, FALSE)) + if (llgenerroraux (o, srcFile, srcLine, s, hint, fl, TRUE, FALSE)) { flagcode_recordError (o); @@ -950,14 +961,17 @@ xllgenhinterror (char *srcFile, int srcLine, } static bool -llrealerror (char *srcFile, int srcLine, /*@only@*/ cstring s, fileloc fl) +llrealerror (flagcode code, char *srcFile, int srcLine, /*@only@*/ cstring s, /*@temp@*/ cstring addtext, fileloc fl) { - return (llgenerrorreal (srcFile, srcLine, s, fl, TRUE, FALSE)); + return (llgenerrorreal (code, srcFile, srcLine, s, addtext, fl, TRUE, FALSE)); } static bool -llgenerroraux (char *srcFile, int srcLine, - /*@only@*/ cstring s, fileloc fl, bool iserror, bool indent) +llgenerroraux (flagcode code, + char *srcFile, int srcLine, + /*@only@*/ cstring s, + cstring addtext, + fileloc fl, bool iserror, bool indent) { if (context_inSuppressZone (fl)) { @@ -965,7 +979,7 @@ llgenerroraux (char *srcFile, int srcLine, return FALSE; } - if (llgenerrorreal (srcFile, srcLine, s, fl, iserror, indent)) { + if (llgenerrorreal (code, srcFile, srcLine, s, addtext, fl, iserror, indent)) { return TRUE; } else { return FALSE; @@ -978,7 +992,7 @@ xllforceerror (char *srcFile, int srcLine, { flagcode_recordError (code); - if (llgenerrorreal (srcFile, srcLine, s, fl, TRUE, FALSE)) { + if (llgenerrorreal (code, srcFile, srcLine, s, cstring_undefined, fl, TRUE, FALSE)) { closeMessage (); return TRUE; } else { @@ -986,9 +1000,34 @@ xllforceerror (char *srcFile, int srcLine, } } +static void generateCSV (flagcode code, cstring s, cstring addtext, fileloc fl) +{ + + if (g_csvstream != NULL) { + /* Warning, Flag Code, Flag Name, Priority, File, Line, Column, Warning Text, Additional Text */ + fprintf (g_csvstream, "%d,%d,%s,%d,%s,%d,%d,\"%s\"", + context_numErrors (), + (int) code, /* flag code */ + cstring_toCharsSafe (flagcode_unparse (code)), /* flag name */ + flagcode_priority (code), /* priority */ + cstring_toCharsSafe (fileloc_outputFilename (fl)), + fileloc_lineno (fl), + fileloc_column (fl), + cstring_toCharsSafe (s)); + + if (cstring_isDefined (addtext)) { + fprintf (g_csvstream, ",\"%s\"\n", cstring_toCharsSafe (addtext)); + } else { + fprintf (g_csvstream, "\n"); + } + } +} + static bool -llgenerrorreal (char *srcFile, int srcLine, - /*@only@*/ cstring s, fileloc fl, bool iserror, bool indent) +llgenerrorreal (flagcode code, char *srcFile, int srcLine, + /*@only@*/ cstring s, + cstring addtext, + fileloc fl, bool iserror, bool indent) { cstring flstring; @@ -1148,6 +1187,8 @@ llgenerrorreal (char *srcFile, int srcLine, flstring = fileloc_unparse (fl); lastfileloclen = cstring_length (flstring); + generateCSV (code, s, addtext, fl); + if (indent) { printError (g_warningstream, message (" %q: %q", flstring, s)); @@ -1158,6 +1199,7 @@ llgenerrorreal (char *srcFile, int srcLine, } showSourceLoc (srcFile, srcLine); + return TRUE; } @@ -1624,6 +1666,7 @@ void genppllerrorhint (flagcode code, /*@only@*/ cstring s, { if (context_getFlag (code)) { + generateCSV (code, s, hint, g_currentloc); prepareMessage (); context_clearPreprocessing (); llerror (code, s); @@ -1711,7 +1754,7 @@ bool xlloptgenerror (char *srcFile, int srcLine, { DPRINTF (("xllopt: %s", s)); - if (llrealerror (srcFile, srcLine, s, loc)) + if (llrealerror (o, srcFile, srcLine, s, flagcodeHint (o), loc)) { DPRINTF (("Here we are!")); llsuppresshint ('-', o); @@ -1744,7 +1787,7 @@ bool xoptgenerror2 (char *srcFile, int srcLine, } else { - if (llrealerror (srcFile, srcLine, s, loc)) + if (llrealerror (f1, srcFile, srcLine, s, flagcodeHint (f1), loc)) { llsuppresshint2 ('-', f1, f2); flagcode_recordError (f2); @@ -1779,7 +1822,7 @@ bool xoptgenerror2n (char *srcFile, int srcLine, } else { - if (llrealerror (srcFile, srcLine, s, loc)) + if (llrealerror (f1, srcFile, srcLine, s, flagcodeHint (f2), loc)) { llsuppresshint ('+', f2); flagcode_recordError (f2); @@ -1796,7 +1839,7 @@ bool xoptgenerror2n (char *srcFile, int srcLine, bool xllnoptgenerror (char *srcFile, int srcLine, flagcode o, /*@only@*/ cstring s, fileloc loc) { - if (llrealerror (srcFile, srcLine, s, loc)) + if (llrealerror (o, srcFile, srcLine, s, flagcodeHint (o), loc)) { llsuppresshint ('+', o); flagcode_recordError (o); @@ -1867,19 +1910,23 @@ void xllparseerror (char *srcFile, int srcLine, cstring s) } bool xfsgenerror (char *srcFile, int srcLine, - flagSpec fs, /*@only@*/ cstring s, fileloc fl) + flagSpec fs, /*@only@*/ cstring s, fileloc fl) { if (flagSpec_isOn (fs, fl)) { - if (llgenerroraux (srcFile, srcLine, s, fl, TRUE, FALSE)) + flagcode firston = flagSpec_getFirstOn (fs, fl); + + if (llgenerroraux (firston, srcFile, srcLine, s, + flagcodeHint (firston), + fl, TRUE, FALSE)) { - llsuppresshint ('-', flagSpec_getFirstOn (fs, fl)); - flagcode_recordError (flagSpec_getFirstOn (fs, fl)); + llsuppresshint ('-', firston); + flagcode_recordError (firston); return TRUE; } else { - flagcode_recordSuppressed (flagSpec_getFirstOn (fs, fl)); + flagcode_recordSuppressed (firston); return FALSE; } } diff --git a/src/llmain.c b/src/llmain.c index 8b177b1..fa9b8fe 100644 --- a/src/llmain.c +++ b/src/llmain.c @@ -673,7 +673,29 @@ int main (int argc, char *argv[]) argc - 1, argv + 1); showHerald (); - + + if (context_getFlag (FLG_CSV)) { + cstring fname = context_getString (FLG_CSV); + + if (cstring_isDefined (fname)) { + if (osd_fileExists (fname) && !context_getFlag (FLG_CSVOVERWRITE)) { + lldiagmsg (message ("Specified CSV output file already exists (use +csvoverwrite to automatically overwrite): %s", + fname)); + } else { + g_csvstream = fopen (cstring_toCharsSafe (fname), "w"); + + DPRINTF (("Creating: %s", fname)); + if (g_csvstream == NULL) { + lldiagmsg (message ("Cannot open file for CSV output: %s", fname)); + } else { + displayScan (message ("Starting CSV output file: %s", context_getString (FLG_CSV))); + fprintf (g_csvstream, + "Warning, Flag Code, Flag Name, Priority, File, Line, Column, Warning Text, Additional Text\n"); + } + } + } + } + # ifdef DOANNOTS initAnnots (); # endif @@ -928,12 +950,16 @@ int main (int argc, char *argv[]) # endif cleanupFiles (); - + + if (g_csvstream != NULL) { + displayScan (message ("Closing CSV file: %s", context_getString (FLG_CSV))); + check (fclose (g_csvstream) == 0); + } + if (context_getFlag (FLG_SHOWSUMMARY)) { summarizeErrors (); } - { bool isQuiet = context_getFlag (FLG_QUIET); diff --git a/src/lslinit.c b/src/lslinit.c index 64d6919..f117411 100644 --- a/src/lslinit.c +++ b/src/lslinit.c @@ -37,6 +37,8 @@ # include "syntable.h" # include "lslinit.h" # include "lclinit.h" +# include "lclscan.h" +# include "lclscanline.h" /* needed to parse init files */ # include "shift.h" diff --git a/src/message.c b/src/message.c index 41757a5..de50dab 100644 --- a/src/message.c +++ b/src/message.c @@ -40,9 +40,16 @@ typedef enum XPERCENT, XCTYPE, XPLURAL, XREPREFIX, XFILELOC, XPOINTER } ccode; -/* char *s, anytype v */ +/*@function void GETPRINTF (char *p_s, anytype p_v) modifies strbuf@*/ + /*@notfunction@*/ +# ifndef WIN32 + /* ISO requires this, but not all implementations (e.g., Microsoft's) provide it */ # define GETPRINTF(s,v) (snprintf (strbuf, 64, s, v), mstring_copy (strbuf)) +# else + /* MS provides _snprintf instead */ +# define GETPRINTF(s,v) (_snprintf (strbuf, 64, s, v), mstring_copy (strbuf)) +# endif /* ** returns control code indicated by *c, and diff --git a/src/osd.c b/src/osd.c index 3d75cf6..68e90c8 100644 --- a/src/osd.c +++ b/src/osd.c @@ -1126,7 +1126,7 @@ cstring osd_outputPath (cstring filename) { /* Give up if the result gets to be longer than the absolute path name. */ - if (rel_buffer + filename_len <= rel_buf_p + 3) + /*@i423@*/ if (rel_buffer + filename_len <= rel_buf_p + 3) { sfree (rel_buffer); return cstring_copy (filename); diff --git a/src/symtable.c b/src/symtable.c index 636183f..7c0c92f 100644 --- a/src/symtable.c +++ b/src/symtable.c @@ -1043,7 +1043,7 @@ parseLine (char *line, inputStream srce, mapping map) llassert (lineptr != NULL); lineptr = strchr (lineptr + 1, ' '); /* go past namestr */ llassert (lineptr != NULL); - col = 5 + lineptr - line; /* 5 for initial "%LCL "*/ + col = 5 + ((int) (lineptr - line)); /* 5 for initial "%LCL "*/ lclbug (message ("%q: Imported files contains unknown base sort", fileloc_unparseRawCol (importfile, inputStream_thisLineNumber (srce), col))); @@ -1107,7 +1107,7 @@ parseLine (char *line, inputStream srce, mapping map) llassert (lineptr != NULL); lineptr = strchr (lineptr + 1, ' '); /* go past namestr */ llassert (lineptr != NULL); - col = 5 + lineptr - line; /* 5 for initial "%LCL "*/ + col = 5 + ((int) (lineptr - line)); /* 5 for initial "%LCL "*/ if (sort_isNoSort (bsort)) { @@ -1158,7 +1158,7 @@ parseLine (char *line, inputStream srce, mapping map) lineptr = strchr (lineptr + 1, ' '); /* go past namestr */ llassert (lineptr != NULL); - col = 5 + lineptr - line; /* 5 for initial "%LCL "*/ + col = 5 + ((int) (lineptr - line)); /* 5 for initial "%LCL "*/ if (sort_isNoSort (bsort)) { @@ -1340,7 +1340,7 @@ parseLine (char *line, inputStream srce, mapping map) lineptr = strchr (lineptr + 1, ' '); /* go past namestr */ llassert (lineptr != NULL); - col = 5 + lineptr - line; /* 5 for initial "%LCL "*/ + col = 5 + ((int) (lineptr - line)); /* 5 for initial "%LCL "*/ if (sort_isNoSort (bsort)) { lclplainerror (message ("%q: unknown base sort\n", @@ -2093,7 +2093,7 @@ domainMatches (ltokenList domain, sortSetList argSorts) /*@only@*/ lslOpSet symtable_opsWithLegalDomain (symtable tab, /*@temp@*/ /*@null@*/ nameNode n, - sortSetList argSorts, sort qual) + sortSetList argSorts, sort q) { /* handles nil qual */ lslOpSet ops = lslOpSet_new (); @@ -2114,7 +2114,7 @@ domainMatches (ltokenList domain, sortSetList argSorts) { rangeSort = sigNode_rangeSort (sig); - if ((qual == 0) || (sort_equal (rangeSort, qual))) + if ((q == NULL) || (sort_equal (rangeSort, q))) { if (domainMatches (sig->domain, argSorts)) { diff --git a/src/usymtab.c b/src/usymtab.c index 1f70646..cf207a3 100644 --- a/src/usymtab.c +++ b/src/usymtab.c @@ -350,7 +350,8 @@ usymtab_destroyMod (void) /*@modifies utab, globtab, filetab@*/ /*@globals kille DPRINTF (("Destroy usymtab [%p]: %d", utab, utab->nentries)); usymtab_freeAux (utab); utab = usymtab_undefined; -} + /*@-globstate@*/ +} /*@=globstate@*/ void usymtab_initGlobalMarker () /*@globals globtab@*/ @@ -5408,7 +5409,7 @@ void usymtab_free () dbgfree = TRUE; usymtab_freeAux (utab); utab = usymtab_undefined; -} +/*@i523@*/ } static int usymtab_lexicalLevel (void) /*@globals utab@*/ { -- 2.45.2