diff options
| author | bluhm <> | 2020-01-13 16:51:04 +0000 |
|---|---|---|
| committer | bluhm <> | 2020-01-13 16:51:04 +0000 |
| commit | d6e6d96f9db7851ece7cfafcc6e217f0a25409e4 (patch) | |
| tree | 0709f3cbdca623f6c0ad78c787bc7e6b29089b56 | |
| parent | 752a33fadc4f7ef62d2d88ddf0c9a72ac23dfbd4 (diff) | |
| download | openbsd-d6e6d96f9db7851ece7cfafcc6e217f0a25409e4.tar.gz openbsd-d6e6d96f9db7851ece7cfafcc6e217f0a25409e4.tar.bz2 openbsd-d6e6d96f9db7851ece7cfafcc6e217f0a25409e4.zip | |
Fix printf compiler warnings in wfp regress. Convert wchar to a
printable error message when failing.
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libc/wprintf/wfp.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/regress/lib/libc/wprintf/wfp.c b/src/regress/lib/libc/wprintf/wfp.c index fc3120b53c..fa9bc07166 100644 --- a/src/regress/lib/libc/wprintf/wfp.c +++ b/src/regress/lib/libc/wprintf/wfp.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: wfp.c,v 1.1 2011/04/24 08:00:22 stsp Exp $ */ | 1 | /* $OpenBSD: wfp.c,v 1.2 2020/01/13 16:51:04 bluhm Exp $ */ |
| 2 | /*- | 2 | /*- |
| 3 | * Copyright (c) 2002, 2005 David Schultz <das@FreeBSD.org> | 3 | * Copyright (c) 2002, 2005 David Schultz <das@FreeBSD.org> |
| 4 | * All rights reserved. | 4 | * All rights reserved. |
| @@ -201,18 +201,27 @@ smash_stack(void) | |||
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | void | 203 | void |
| 204 | _testfmt(const wchar_t *result, int line, const char *argstr, const wchar_t *fmt,...) | 204 | _testfmt(const wchar_t *result, int line, const char *argstr, |
| 205 | const wchar_t *fmt, ...) | ||
| 205 | { | 206 | { |
| 206 | wchar_t s[100]; | 207 | wchar_t ws[100]; |
| 207 | va_list ap; | 208 | va_list ap; |
| 208 | 209 | ||
| 209 | va_start(ap, fmt); | 210 | va_start(ap, fmt); |
| 210 | smash_stack(); | 211 | smash_stack(); |
| 211 | vswprintf(s, sizeof(s), fmt, ap); | 212 | vswprintf(ws, sizeof(ws)/sizeof(ws[0]), fmt, ap); |
| 212 | if (wcscmp(result, s) != 0) { | 213 | if (wcscmp(result, ws) != 0) { |
| 213 | fprintf(stderr, | 214 | const wchar_t *p = ws; |
| 214 | "%d: printf(\"%s\", %s) ==> [%s], expected [%s]\n", | 215 | char f[100], s[100], r[100]; |
| 215 | line, (char*)fmt, argstr, s, result); | 216 | |
| 216 | abort(); | 217 | memset(f, 0, sizeof(f)); |
| 218 | memset(s, 0, sizeof(s)); | ||
| 219 | memset(r, 0, sizeof(r)); | ||
| 220 | wcsrtombs(f, &fmt, sizeof(f) - 1, NULL); | ||
| 221 | wcsrtombs(s, &p, sizeof(s) - 1, NULL); | ||
| 222 | wcsrtombs(r, &result, sizeof(r) - 1, NULL); | ||
| 223 | |||
| 224 | errx(1, "line %d: printf(\"%s\", %s) ==> [%s], expected [%s]", | ||
| 225 | line, f, argstr, s, r); | ||
| 217 | } | 226 | } |
| 218 | } | 227 | } |
