Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libcurses libcurses: prevent unknown escpae sequen...
details: https://anonhg.NetBSD.org/src/rev/72ad99a90850
branches: trunk
changeset: 981006:72ad99a90850
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Feb 25 00:25:31 2021 +0000
description:
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.
diffstat:
tests/lib/libcurses/director/testlang_conf.l | 6 +++++-
tests/lib/libcurses/tests/addchstr | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diffs (33 lines):
diff -r 8c7698c50fa0 -r 72ad99a90850 tests/lib/libcurses/director/testlang_conf.l
--- a/tests/lib/libcurses/director/testlang_conf.l Wed Feb 24 18:18:53 2021 +0000
+++ b/tests/lib/libcurses/director/testlang_conf.l Thu Feb 25 00:25:31 2021 +0000
@@ -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 <blymn%NetBSD.org@localhost>
@@ -120,6 +120,10 @@
break;
default:
+ if (isalpha((unsigned char)*p))
+ errx(2,
+ "%s:%zu: invalid escape sequence '\\%c' in string literal",
+ cur_file, line, *p);
*q++ = *p++;
}
}
diff -r 8c7698c50fa0 -r 72ad99a90850 tests/lib/libcurses/tests/addchstr
--- a/tests/lib/libcurses/tests/addchstr Wed Feb 24 18:18:53 2021 +0000
+++ b/tests/lib/libcurses/tests/addchstr Thu Feb 25 00:25:31 2021 +0000
@@ -4,7 +4,7 @@
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)
Home |
Main Index |
Thread Index |
Old Index