Quote:

Did run into a snag though with the following bit of code




To be fair, Glenn did say at the top of his post (my highlight):
Quote:

It also does some basic tests of matched quotes and parens (but not across multiple lines).




Unbalanced quotes and parenthese are a bugger to spot.

One way of avoiding them is to include pragmas which tell the checker to ignore errors. There is a powerful code checker for C called LINT, and even the best written code will generate a huge amount of warnings without the directives.

Another alternative is to look at the context and the final state. If you have an unbalanced opening parenthesis on a line the store the error. If you get an unbalanced closing parenthesis on a line then you can clear the error otherwise at the end of the file you repost the unbalanced parentheses.

Obviously an unbalanced closing parenthesis which is not in a string is always an error.

Unbalanced quotes are trickier. Two unbalanced quotes are really hard to deal with.

About the best guess you can make is to look at the text within the string, and if you spot strings which are only likely to be KiXtart code such as functions and variables then you can report the quote as unbalanced.

In the end though the most reliable solution is to report all the potential errors and allow the coder to determine whether they are real problems or not.