Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/regex - Print the symbolic error using regerr...
details: https://anonhg.NetBSD.org/src/rev/e6f34d4fc08e
branches: trunk
changeset: 771047:e6f34d4fc08e
user: christos <christos%NetBSD.org@localhost>
date: Sun Nov 06 18:34:48 2011 +0000
description:
- Print the symbolic error using regerror, as well as the pattern that caused
it.
- Add the ability to set the number of repetitions in the pattern from
cpp since TRE handles things poorly:
- It runs the machine out of memory with rep=9 (we use rep=9999)
- It truncates the pattern with rep=9999
diffstat:
tests/lib/libc/regex/t_exhaust.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diffs (50 lines):
diff -r 3bd64f72a7ec -r e6f34d4fc08e tests/lib/libc/regex/t_exhaust.c
--- a/tests/lib/libc/regex/t_exhaust.c Sun Nov 06 18:32:39 2011 +0000
+++ b/tests/lib/libc/regex/t_exhaust.c Sun Nov 06 18:34:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_exhaust.c,v 1.3 2011/11/04 15:48:10 christos Exp $ */
+/* $NetBSD: t_exhaust.c,v 1.4 2011/11/06 18:34:48 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_exhaust.c,v 1.3 2011/11/04 15:48:10 christos Exp $");
+__RCSID("$NetBSD: t_exhaust.c,v 1.4 2011/11/06 18:34:48 christos Exp $");
#include <stdio.h>
#include <regex.h>
@@ -46,6 +46,9 @@
#include <err.h>
#include <atf-c.h>
+#ifndef REGEX_MAXSIZE
+#define REGEX_MAXSIZE 9999
+#endif
static char *
mkstr(const char *str, size_t len)
@@ -179,14 +182,18 @@
int e;
for (size_t i = 0; i < __arraycount(tests); i++) {
- char *d = (*tests[i].pattern)(9999);
+ char *d = (*tests[i].pattern)(REGEX_MAXSIZE);
e = regcomp(&re, d, tests[i].type);
- free(d);
if (e) {
+ char ebuf[1024];
+ (void)regerror(e, &re, ebuf, sizeof(ebuf));
ATF_REQUIRE_MSG(e == REG_ESPACE,
- "regcomp returned %d for pattern %zu", e, i);
+ "regcomp returned %d (%s) for pattern %zu [%s]", e, ebuf,
+ i, d);
+ free(d);
continue;
}
+ free(d);
(void)regexec(&re, "aaaaaaaaaaa", 0, NULL, 0);
regfree(&re);
}
Home |
Main Index |
Thread Index |
Old Index