From: eck Date: Tue, 12 Dec 1989 12:41:39 +0000 (+0000) Subject: SkipToNewLine() now recognizes strings and character constants X-Git-Tag: release-5-5~2014 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=24a1c0d390e587e110210852e759334f30c589b5;p=ack.git SkipToNewLine() now recognizes strings and character constants --- diff --git a/lang/cem/cpp.ansi/skip.c b/lang/cem/cpp.ansi/skip.c index 5433b90f7..b890cda1e 100644 --- a/lang/cem/cpp.ansi/skip.c +++ b/lang/cem/cpp.ansi/skip.c @@ -60,9 +60,20 @@ SkipToNewLine() { register int ch; register int garbage = 0; + register int delim = 0; while ((ch = GetChar()) != '\n') { - if (ch == '/') { + if (delim) { + if (ch == '\\') { + if (GetChar() == '\n') break; + } else if (ch == delim) { + delim = 0; + } + continue; + } else if (ch == '\'' || ch == '\"') { + delim = ch; + garbage = 1; + } else if (ch == '/') { if ((ch = GetChar()) == '*' && !InputLevel) { skipcomment(); continue; @@ -71,6 +82,7 @@ SkipToNewLine() if (!is_wsp(ch)) garbage = 1; } + if (delim) strict("unclosed opening %c", delim); ++LineNumber; return garbage; }