diff options
author | David A. Wheeler <dwheeler@dwheeler.com> | 2013-09-02 18:37:08 -0400 |
---|---|---|
committer | David A. Wheeler <dwheeler@dwheeler.com> | 2013-09-02 18:37:08 -0400 |
commit | ee28e6d7c817a920b29059e8c82fc43b879d7eba (patch) | |
tree | a13ef17dac4b4b9b1134054d563f46f61fb4d126 | |
parent | edb7ba43644ef3753bff0e48dcf0f0cac7a82f6c (diff) | |
download | sloccount-git-ee28e6d7c817a920b29059e8c82fc43b879d7eba.tar.gz |
Fix bug in ml_count.c [from: a_m0d]
- "This patch fixes a bug with string handling in ml_count.c.
The bug occurs with escaped string characters - when a file
contains a quoted string character ('\"') then ml_count will
crash with the message
ml_count ERROR - terminated in string in
~/workspace/sloccount/trunk/../../basic//src/lexer.mll
This patch fixes this by ensuring that escaped quotation marks
do not mark the start of a string.
- See https://sourceforge.net/p/sloccount/patches/15/
-rw-r--r-- | ml_count.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -104,7 +104,9 @@ long sloc_count(char *filename, FILE *stream) { case '\\': /* Ignore next character if in string. But don't ignore newlines. */ - if (in_string && !ispeek('\n', stream)) + /* Also, eat a " character if it is escaped, so that we don't enter + * or exit a string */ + if ((in_string && !ispeek('\n', stream)) || ispeek('\"', stream)) getachar(stream); break; |