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.
This commit is contained in:
rillig 2021-02-25 00:25:31 +00:00
parent 0cd1e61982
commit 166112aa2a
2 changed files with 6 additions and 2 deletions

View File

@ -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>
@ -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++;
}
}

View File

@ -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)