From ee229125aa2bfcaec0900ca584b9f2569057bea2 Mon Sep 17 00:00:00 2001 From: evans1629 Date: Sun, 7 Oct 2001 04:43:17 +0000 Subject: [PATCH] Fixed handling of octal constants. --- src/Makefile | 11 +++++++---- src/context.c | 2 +- src/cpplib.c | 10 +++++----- src/cscanner.l | 16 ++++++++++++++++ src/flags.c | 2 +- src/llmain.c | 12 ++++++++---- test/Makefile | 7 +++++-- test/longconstants.c | 4 ++++ test/longconstants.expect | 5 +++++ 9 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 test/longconstants.c create mode 100644 test/longconstants.expect diff --git a/src/Makefile b/src/Makefile index 4fe367c..af7f0af 100644 --- a/src/Makefile +++ b/src/Makefile @@ -203,9 +203,12 @@ stateClause.c: Headers/cgrammar_tokens.h ifeq ($(CHECK), 1) ${MAKE} $*.check endif - @echo '// Compiling '$*.c' / compiled: '`$(OFILES)`' (of 181 files)' $(CC) $(CPPFLAGS) $(CFLAGS) -c $*.c +### removed this: / compiled: '`$(OFILES)`' (of 181 files)' +### Apparently it is slow on some platforms... + + ### ### alternatives (tests, releases, backups, etc.) ### @@ -245,9 +248,9 @@ betarelease: cd ~/temp/lclint-`cat ${VERSION_NUMBER}`; rm -r test/temp cd ~/temp/lclint-`cat ${VERSION_NUMBER}`; rm -f *~ */*~ */*/*~ #* */#* */*/#* .#* */.#* */*/.#* */*.core cd ~/temp/lclint-`cat ${VERSION_NUMBER}`; rm -rf CVS */CVS */*/CVS */*/*/CVS */*/*/*/CVS - cd ~/temp/; tar czvf ~/public_html/lclint/lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`.src.tgz lclint-`cat ${SRCPWD}/${VERSION_NUMBER}` - chmod 644 ~/public_html/lclint/lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`.src.tgz - ls -l ~/public_html/lclint/lclint-*.tgz + cd ~/temp/; tar czvf ~/public_html/lclint/downloads/lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`.src.tgz lclint-`cat ${SRCPWD}/${VERSION_NUMBER}` + chmod 644 ~/public_html/lclint/downloads/lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`.src.tgz + ls -l ~/public_html/lclint/downloads/lclint-*.tgz @echo "Made release lclint-`cat ${VERSION_NUMBER}`" opt : diff --git a/src/context.c b/src/context.c index 4344a3f..b4fc25f 100644 --- a/src/context.c +++ b/src/context.c @@ -2847,7 +2847,7 @@ context_setString (flagcode flag, cstring val) } if (cstring_length (val) >= 1 - && cstring_firstChar (val) == '"') + && cstring_firstChar (val) == '\"') { llerror_flagWarning (message ("setting %s to string beginning with \". You probably " diff --git a/src/cpplib.c b/src/cpplib.c index ba7dada..499b9af 100644 --- a/src/cpplib.c +++ b/src/cpplib.c @@ -1635,7 +1635,7 @@ collect_expansion (cppReader *pfile, char *buf, char *limit, exp_p--; SKIP_WHITE_SPACE (p); if (p == limit || ! is_idstart[(int) *p] - || (*p == 'L' && p + 1 < limit && (p[1] == '\'' || p[1] == '"'))) + || (*p == 'L' && p + 1 < limit && (p[1] == '\'' || p[1] == '\"'))) cppReader_errorLit (pfile, cstring_makeLiteralTemp ("`#' operator is not followed by a macro argument name")); else @@ -1702,7 +1702,7 @@ collect_expansion (cppReader *pfile, char *buf, char *limit, id_len = p - id_beg; if (is_idstart[(int) c] - && ! (id_len == 1 && c == 'L' && (*p == '\'' || *p == '"'))) { + && ! (id_len == 1 && c == 'L' && (*p == '\'' || *p == '\"'))) { register struct arglist *arg; for (arg = arglist; arg != NULL; arg = arg->next) { @@ -1992,7 +1992,7 @@ create_definition (/*@exposed@*/ char *buf, char *limit, SKIP_WHITE_SPACE (bp); } else { switch (*bp) { - case '!': case '"': case '#': case '%': case '&': case '\'': + case '!': case '\"': case '#': case '%': case '&': case '\'': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case ':': case ';': case '<': case '=': case '>': case '?': case '[': case '\\': case ']': case '^': case '{': @@ -2057,7 +2057,7 @@ int cppReader_checkMacroName (cppReader *pfile, sym_length = size_fromInt (p - symname); if (sym_length == 0 - || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"'))) + || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '\"'))) cppReader_error (pfile, message ("invalid %s name", usage)); else if (!is_idstart[(int) *symname]) { @@ -2933,7 +2933,7 @@ special_symbol (hashNode hp, cppReader *pfile) if (!is_idstart[(int) *ip->cur]) goto oops; - if (ip->cur[0] == 'L' && (ip->cur[1] == '\'' || ip->cur[1] == '"')) + if (ip->cur[0] == 'L' && (ip->cur[1] == '\'' || ip->cur[1] == '\"')) goto oops; if ((hp = cppReader_lookup (ip->cur, -1, -1)) != 0) diff --git a/src/cscanner.l b/src/cscanner.l index d87930e..6930ccd 100644 --- a/src/cscanner.l +++ b/src/cscanner.l @@ -2983,6 +2983,22 @@ long processOctal () if (c >= '0' && c <= '7') { tval = (int) c - (int) '0'; + } else if (c == 'U' || c == 'L' || c == 'u' || c == 'l') { + index++; + while (yytext[index] != '\0') { + if (c == 'U' || c == 'L' || c == 'u' || c == 'l') { + ; + } else { + voptgenerror + (FLG_SYNTAX, + message ("Invalid character (%c) following specifier in octal constant: %s", + c, cstring_fromChars (yytext)), + g_currentloc); + } + index++; + } + + break; } else { voptgenerror (FLG_SYNTAX, diff --git a/src/flags.c b/src/flags.c index 9b5d4cd..5c92b6e 100644 --- a/src/flags.c +++ b/src/flags.c @@ -1072,7 +1072,7 @@ describeModes () return (s); } -static cstring +static /*@unused@*/ cstring listModes (void) { cstring s = cstring_makeLiteral ("\t"); diff --git a/src/llmain.c b/src/llmain.c index 347303a..1b8f4eb 100644 --- a/src/llmain.c +++ b/src/llmain.c @@ -2177,6 +2177,10 @@ llexit (int status) exit ((status == LLSUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE); } +/* +** This shouldn't be necessary, but Apple Darwin can't handle '"''s. +*/ + void loadrc (/*:open:*/ FILE *rcfile, cstringSList *passThroughArgs) /*@ensures closed rcfile@*/ @@ -2444,16 +2448,16 @@ loadrc (/*:open:*/ FILE *rcfile, cstringSList *passThroughArgs) } else if (flagcode_hasString (opt)) { - if (cstring_firstChar (extra) == '"') + if (cstring_firstChar (extra) == '\"') { - if (cstring_lastChar (extra) == '"') + if (cstring_lastChar (extra) == '\"') { char *extras = cstring_toCharsSafe (extra); - llassert (extras[strlen(extras) - 1] == '"'); + llassert (extras[strlen(extras) - 1] == '\"'); extras[strlen(extras) - 1] = '\0'; extra = cstring_fromChars (extras + 1); - DPRINTF (("Remove quites: %s", extra)); + DPRINTF (("Remove quotes: %s", extra)); } else { diff --git a/test/Makefile b/test/Makefile index ce8f523..3db48c4 100644 --- a/test/Makefile +++ b/test/Makefile @@ -13,7 +13,7 @@ .PHONY: compdestroy constannot controldepth csyntax czechnames czechoslovaknames .PHONY: deadparam decl enum exports external fields fileio flags forbody format funcpointer glob globals .PHONY: impabstract init inparam internal iter keep libs lintcomments -.PHONY: list macros macrosef merge mergestate modifies modtest moduncon mongoincludes +.PHONY: list longconstants macros macrosef merge mergestate modifies modtest moduncon mongoincludes .PHONY: noeffect null observer oldstyle outglob outparam postnotnull preds prefixes printflike rc .PHONY: refcounts release repexpose returned sharing slovaknames special .PHONY: specclauses stack staticarray @@ -57,7 +57,7 @@ UNITTESTS = \ abstptr abstract alias alttypes ansireserved argorder args blocks branchstate break cases cast \ charlit clauses commentchar compdestroy constannot controldepth csyntax czechnames czechoslovaknames deadparam \ decl enum exports external fields flags forbody format freearray funcpointer glob globals impabstract \ - init inparam internal iter keep libs linked lintcomments list macros macrosef merge modifies \ + init inparam internal iter keep libs linked lintcomments list longconstants macros macrosef merge modifies \ modtest moduncon mongoincludes mystrncat noeffect null observer oldstyle \ outglob outparam postnotnull preds prefixes \ printflike rc refcounts release repexpose returned sharing slovaknames specclauses special stack \ @@ -415,6 +415,9 @@ lintcomments: list: $(LCLINTR) list.c -expect 3 +longconstants: + $(LCLINTR) longconstants.c -expect 1 + macros: $(LCLINTR) macros -expect 17 $(LCLINTR) macros.c +allmacros -expect 34 diff --git a/test/longconstants.c b/test/longconstants.c new file mode 100644 index 0000000..5ec761b --- /dev/null +++ b/test/longconstants.c @@ -0,0 +1,4 @@ +long octlong = 07L; +long hexlong = 0x34L; +long llong = 3594UL; +unsigned long ullong = 3594UL; diff --git a/test/longconstants.expect b/test/longconstants.expect new file mode 100644 index 0000000..bc9e1d6 --- /dev/null +++ b/test/longconstants.expect @@ -0,0 +1,5 @@ + +longconstants.c:3:14: Variable llong initialized to type unsigned long int, + expects long int: 3594UL + +Finished LCLint checking --- 1 code error found, as expected -- 2.45.1