summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid A. Wheeler <dwheeler@dwheeler.com>2013-09-02 18:37:08 -0400
committerDavid A. Wheeler <dwheeler@dwheeler.com>2013-09-02 18:37:08 -0400
commitee28e6d7c817a920b29059e8c82fc43b879d7eba (patch)
treea13ef17dac4b4b9b1134054d563f46f61fb4d126
parentedb7ba43644ef3753bff0e48dcf0f0cac7a82f6c (diff)
downloadsloccount-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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ml_count.c b/ml_count.c
index dc18f35..07cf39c 100644
--- a/ml_count.c
+++ b/ml_count.c
@@ -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;