Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libcurses/director tests/libcurses: error out on t...



details:   https://anonhg.NetBSD.org/src/rev/a0853d876d7c
branches:  trunk
changeset: 980543:a0853d876d7c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 07 20:27:40 2021 +0000

description:
tests/libcurses: error out on trying to parse /dev/zero

Be strict when parsing the tests.  Any unknown character is an error.
This avoids an endless loop when running "./director /dev/zero".  There
is no point in silently ignoring other invalid characters as well, as
this would only leave potential test writers in an unclear state,
without any benefit.

diffstat:

 tests/lib/libcurses/director/testlang_conf.l |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (24 lines):

diff -r fed3ea97ba69 -r a0853d876d7c tests/lib/libcurses/director/testlang_conf.l
--- a/tests/lib/libcurses/director/testlang_conf.l      Sun Feb 07 20:20:06 2021 +0000
+++ b/tests/lib/libcurses/director/testlang_conf.l      Sun Feb 07 20:27:40 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: testlang_conf.l,v 1.13 2021/02/07 19:49:32 rillig Exp $        */
+/*     $NetBSD: testlang_conf.l,v 1.14 2021/02/07 20:27:40 rillig Exp $        */
 
 /*-
  * Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -380,7 +380,12 @@
                }
 
 .              {
-                       /* FIXME: report syntax error */
+                       if (isprint((unsigned char)yytext[0]))
+                               errx(1, "%s:%zu: Invalid character '%c'",
+                                   cur_file, line + 1, yytext[0]);
+                       else
+                               errx(1, "%s:%zu: Invalid character '0x%02x'",
+                                   cur_file, line + 1, yytext[0]);
                }
 
 %%



Home | Main Index | Thread Index | Old Index