diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2011-10-06 14:37:57 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2011-10-06 14:37:57 +0000 |
commit | c57455af3a5cb0eabd6df9d5fda29e1bd5d2468e (patch) | |
tree | 5ecbd7753b8b0de384d20fd0c0c62707e74a00d4 | |
parent | 6010bfd61356cc1cff4d9a12bcebb083e31d9e77 (diff) |
Better error message on unexpected newline; noted by and ok deraadt@
-rw-r--r-- | usr.bin/bc/bc.y | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y index 4314d99e205..1499a94ba94 100644 --- a/usr.bin/bc/bc.y +++ b/usr.bin/bc/bc.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: bc.y,v 1.39 2011/08/03 08:48:19 otto Exp $ */ +/* $OpenBSD: bc.y,v 1.40 2011/10/06 14:37:56 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -945,6 +945,10 @@ yyerror(char *s) if (yyin != NULL && feof(yyin)) n = asprintf(&str, "%s: %s:%d: %s: unexpected EOF", __progname, filename, lineno, s); + else if (yytext[0] == '\n') + n = asprintf(&str, + "%s: %s:%d: %s: newline unexpected", + __progname, filename, lineno, s); else if (isspace(yytext[0]) || !isprint(yytext[0])) n = asprintf(&str, "%s: %s:%d: %s: ascii char 0x%02x unexpected", |