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.
This commit is contained in:
rillig 2021-02-07 20:27:40 +00:00
parent b30645eb36
commit c2ad8acebe
1 changed files with 7 additions and 2 deletions

View File

@ -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>
@ -380,7 +380,12 @@ include BEGIN(incl);
}
. {
/* 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]);
}
%%