From 1dbb84bcee2d0e6b753aeb71f1c15687731fe8c6 Mon Sep 17 00:00:00 2001 From: uz Date: Fri, 6 Aug 2010 09:17:43 +0000 Subject: [PATCH] Add some code that tries to skip unknown keywords that may have been added by later version of the debug info. git-svn-id: svn://svn.cc65.org/cc65/trunk@4787 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/dbginfo/dbginfo.c | 63 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/src/dbginfo/dbginfo.c b/src/dbginfo/dbginfo.c index 4f683ff6c..f996e1c42 100644 --- a/src/dbginfo/dbginfo.c +++ b/src/dbginfo/dbginfo.c @@ -771,6 +771,35 @@ static void MissingAttribute (InputData* D, const char* AttrName) +static void UnknownKeyword (InputData* D) +/* Print a warning about an unknown keyword in the file. Try to do smart + * recovery, so if later versions of the debug information add additional + * keywords, this code may be able to at least ignore them. + */ +{ + /* Output a warning */ + ParseError (D, CC65_WARNING, "Unknown keyword \"%s\" - skipping", + SB_GetConstBuf (&D->SVal)); + + /* Skip the identifier */ + NextToken (D); + + /* If an equal sign follows, ignore anything up to the next line end + * or comma. If a comma or line end follows, we're already done. If + * we have none of both, we ignore the remainder of the line. + */ + if (D->Tok == TOK_EQUAL) { + NextToken (D); + while (D->Tok != TOK_COMMA && D->Tok != TOK_EOL && D->Tok != TOK_EOF) { + NextToken (D); + } + } else if (D->Tok != TOK_COMMA && D->Tok != TOK_EOL && D->Tok != TOK_EOF) { + SkipLine (D); + } +} + + + /*****************************************************************************/ /* Scanner and parser */ /*****************************************************************************/ @@ -1083,7 +1112,14 @@ static void ParseFile (InputData* D) InfoBits |= MTime; break; - default: + case TOK_IDENT: + /* Try to skip unknown keywords that may have been added by + * a later version. + */ + UnknownKeyword (D); + break; + + default: UnexpectedToken (D); SkipLine (D); goto ErrorExit; @@ -1178,6 +1214,13 @@ static void ParseLine (InputData* D) InfoBits |= Range; break; + case TOK_IDENT: + /* Try to skip unknown keywords that may have been added by + * a later version. + */ + UnknownKeyword (D); + break; + default: UnexpectedToken (D); SkipLine (D); @@ -1272,6 +1315,13 @@ static void ParseVersion (InputData* D) InfoBits |= Minor; break; + case TOK_IDENT: + /* Try to skip unknown keywords that may have been added by + * a later version. + */ + UnknownKeyword (D); + break; + default: UnexpectedToken (D); SkipLine (D); @@ -1587,6 +1637,17 @@ cc65_dbginfo cc65_read_dbginfo (const char* FileName, cc65_errorfunc ErrFunc) ParseVersion (&D); break; + case TOK_IDENT: + /* Output a warning, then skip the line with the unknown + * keyword that may have been added by a later version. + */ + ParseError (&D, CC65_WARNING, + "Unknown keyword \"%s\" - skipping", + SB_GetConstBuf (&D.SVal)); + + SkipLine (&D); + break; + default: UnexpectedToken (&D);