Module Name: src
Committed By: rillig
Date: Thu Feb 25 00:25:31 UTC 2021
Modified Files:
src/tests/lib/libcurses/director: testlang_conf.l
src/tests/lib/libcurses/tests: addchstr
Log Message:
libcurses: prevent unknown escpae sequences in tests
Before, '\b' was interpreted as a simple 'b', which is confusing for C
programmers. Same for '\a'. There is absolutely no reason to escape
letters, so fail early in these cases.
The '\h' in the test addchstr was obviously a typo that was easy to
detect, if only the compiler had been strict enough from the very
beginning.
The code is wider than 80 characters, same as the code that parses octal
escape sequences a few lines above it. This code will be refactored to
use less indentation in a follow-up commit.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/tests/lib/libcurses/director/testlang_conf.l
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/tests/addchstr
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libcurses/director/testlang_conf.l
diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.21 src/tests/lib/libcurses/director/testlang_conf.l:1.22
--- src/tests/lib/libcurses/director/testlang_conf.l:1.21 Mon Feb 15 07:06:27 2021
+++ src/tests/lib/libcurses/director/testlang_conf.l Thu Feb 25 00:25:31 2021
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: testlang_conf.l,v 1.21 2021/02/15 07:06:27 rillig Exp $ */
+/* $NetBSD: testlang_conf.l,v 1.22 2021/02/25 00:25:31 rillig Exp $ */
/*-
* Copyright 2009 Brett Lymn <[email protected]>
@@ -120,6 +120,10 @@ dequote(const char *s, size_t *len)
break;
default:
+ if (isalpha((unsigned char)*p))
+ errx(2,
+ "%s:%zu: invalid escape sequence '\\%c' in string literal",
+ cur_file, line, *p);
*q++ = *p++;
}
}
Index: src/tests/lib/libcurses/tests/addchstr
diff -u src/tests/lib/libcurses/tests/addchstr:1.3 src/tests/lib/libcurses/tests/addchstr:1.4
--- src/tests/lib/libcurses/tests/addchstr:1.3 Sat Oct 24 04:46:17 2020
+++ src/tests/lib/libcurses/tests/addchstr Thu Feb 25 00:25:31 2021
@@ -4,7 +4,7 @@ call OK refresh
compare addchstr.chk
call OK move 0 5
call OK bkgdset `\002\000`
-call OK addchstr `\004f\004g\004\h`
+call OK addchstr `\004f\004g\004h`
call OK refresh
compare addchstr2.chk
# check wrapping (should not wrap)