summaryrefslogtreecommitdiff
path: root/lib/libc/gen/vis.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2014-09-08 17:35:01 +0000
committerchristos <christos@NetBSD.org>2014-09-08 17:35:01 +0000
commit101bc7cc5c34864628cb00a77256a7aee9b12f47 (patch)
treeb3300849288f0609d9336e9febb47ea7eb9ea511 /lib/libc/gen/vis.c
parent068af80e166f48c0705f55cd27a64badc2e13042 (diff)
get rid of MB_STRZ as suggested by joerg.
Diffstat (limited to 'lib/libc/gen/vis.c')
-rw-r--r--lib/libc/gen/vis.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/libc/gen/vis.c b/lib/libc/gen/vis.c
index 2fc1c75b39d..4863bbea859 100644
--- a/lib/libc/gen/vis.c
+++ b/lib/libc/gen/vis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.c,v 1.61 2014/09/08 16:42:09 christos Exp $ */
+/* $NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -57,7 +57,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.61 2014/09/08 16:42:09 christos Exp $");
+__RCSID("$NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef __FBSDID
__FBSDID("$FreeBSD$");
@@ -105,7 +105,6 @@ static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *);
#define XTOA(c) L"0123456789ABCDEF"[c]
#define MAXEXTRAS 10
-#define MB_STRZ ((size_t)-1)
#if !HAVE_NBTOOL_CONFIG_H
#ifndef __NetBSD__
@@ -376,8 +375,6 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
/* Allocate space for the wide char strings */
psrc = pdst = extra = NULL;
- if (mblength == MB_STRZ)
- mblength = strlen(mbsrc);
if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
return -1;
if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
@@ -529,6 +526,15 @@ out:
free(psrc);
return error;
}
+
+static int
+istrsenvisxl(char *mbdst, size_t *dlen, const char *mbsrc,
+ int flags, const char *mbextra, int *cerr_ptr)
+{
+ return istrsenvisx(mbdst, dlen, mbsrc,
+ mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr);
+}
+
#endif
#if !HAVE_SVIS
@@ -572,13 +578,13 @@ snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra
int
strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
{
- return istrsenvisx(mbdst, NULL, mbsrc, MB_STRZ, flags, mbextra, NULL);
+ return istrsenvisxl(mbdst, NULL, mbsrc, flags, mbextra, NULL);
}
int
strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, MB_STRZ, flags, mbextra, NULL);
+ return istrsenvisxl(mbdst, &dlen, mbsrc, flags, mbextra, NULL);
}
int
@@ -647,13 +653,13 @@ nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
int
strvis(char *mbdst, const char *mbsrc, int flags)
{
- return istrsenvisx(mbdst, NULL, mbsrc, MB_STRZ, flags, "", NULL);
+ return istrsenvisxl(mbdst, NULL, mbsrc, flags, "", NULL);
}
int
strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, MB_STRZ, flags, "", NULL);
+ return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
}
/*