From 22e3e8e1a63ba947cae52e143f650df679fd46ba Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Fri, 12 Jun 2009 13:12:55 -0700 Subject: [PATCH] Handle end-of-file inside of comments, local declarations. --- libacc/acc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 816902e1f..a00a6334a 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -1995,18 +1995,21 @@ class Compiler : public ErrorSink { } } else if ((tok == '/') & (ch == '*')) { inp(); - while (ch) { - while (ch != '*') + while (ch && ch != EOF) { + while (ch != '*' && ch != EOF) inp(); inp(); if (ch == '/') ch = 0; } + if (ch == EOF) { + error("End of file inside comment."); + } inp(); next(); } else if ((tok == '/') & (ch == '/')) { inp(); - while (ch && (ch != '\n')) { + while (ch && (ch != '\n') && (ch != EOF)) { inp(); } inp(); @@ -2489,7 +2492,7 @@ class Compiler : public ErrorSink { Type base; while (acceptType(base)) { - while (tok != ';') { + while (tok != ';' && tok != EOF) { Type t = acceptPointerDeclaration(t); addLocalSymbol(); if (tok) {