summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2005-03-17 16:59:32 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2005-03-17 16:59:32 +0000
commitee0cfb17979ec18bde07ddf7cb6e9fbfc3db18ac (patch)
tree03ca0207293c4f11a1eab9d41568b29b8ef5362b
parentebe0aee19a7323a6b2434f0efbc6785d3b14f2ea (diff)
Fix eof without newline handling. spotted by and ok deraadt@
-rw-r--r--usr.bin/bc/bc.y15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y
index 97482102909..e3f88b15685 100644
--- a/usr.bin/bc/bc.y
+++ b/usr.bin/bc/bc.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: bc.y,v 1.24 2004/10/19 07:36:51 otto Exp $ */
+/* $OpenBSD: bc.y,v 1.25 2005/03/17 16:59:31 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -31,7 +31,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: bc.y,v 1.24 2004/10/19 07:36:51 otto Exp $";
+static const char rcsid[] = "$OpenBSD: bc.y,v 1.25 2005/03/17 16:59:31 otto Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -190,6 +190,10 @@ input_item : semicolon_list NEWLINE
{
yyerrok;
}
+ | error QUIT
+ {
+ yyerrok;
+ }
;
semicolon_list : /* empty */
@@ -928,8 +932,11 @@ yyerror(char *s)
{
char *str, *p;
- if (isspace(yytext[0]) || !isprint(yytext[0]))
- asprintf(&str, "%s: %s:%d: %s: ascii char 0x%x unexpected",
+ if (feof(yyin))
+ asprintf(&str, "%s: %s:%d: %s: unexpected EOF",
+ __progname, filename, lineno, s);
+ else if (isspace(yytext[0]) || !isprint(yytext[0]))
+ asprintf(&str, "%s: %s:%d: %s: ascii char 0x%02x unexpected",
__progname, filename, lineno, s, yytext[0]);
else
asprintf(&str, "%s: %s:%d: %s: %s unexpected",