summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2011-04-04 18:48:18 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2011-04-04 18:48:18 +0000
commit788f34f1b10c3c5829fe9c0201e518c45cbad8be (patch)
tree352f6ec5770db67d0843b53c87a4e29bc3a1cebf /lib
parenta8e7f1ce7e893a79ccb159df76d5ca916e9eb5f4 (diff)
Make wcwidth() callers cope with -1 return value. Doesn't affect the build yet.
ok nicm
Diffstat (limited to 'lib')
-rw-r--r--lib/libedit/chartype.c8
-rw-r--r--lib/libedit/chartype.h4
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/libedit/chartype.c b/lib/libedit/chartype.c
index bfa5a80d58b..96d6d158b14 100644
--- a/lib/libedit/chartype.c
+++ b/lib/libedit/chartype.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chartype.c,v 1.1 2010/06/30 00:05:35 nicm Exp $ */
+/* $OpenBSD: chartype.c,v 1.2 2011/04/04 18:48:17 stsp Exp $ */
/* $NetBSD: chartype.c,v 1.4 2010/04/15 00:55:57 christos Exp $ */
/*-
@@ -258,6 +258,9 @@ protected int
ct_visual_width(Char c)
{
int t = ct_chr_class(c);
+#ifdef WIDECHAR
+ int w;
+#endif
switch (t) {
case CHTYPE_ASCIICTL:
return 2; /* ^@ ^? etc. */
@@ -267,7 +270,8 @@ ct_visual_width(Char c)
return 0; /* Should this be 1 instead? */
#ifdef WIDECHAR
case CHTYPE_PRINT:
- return wcwidth(c);
+ w = wcwidth(c);
+ return (w == -1 ? 0 : w);
case CHTYPE_NONPRINT:
if (c > 0xffff) /* prefer standard 4-byte display over 5-byte */
return 8; /* \U+12345 */
diff --git a/lib/libedit/chartype.h b/lib/libedit/chartype.h
index db957bbc8e8..6808fc446bd 100644
--- a/lib/libedit/chartype.h
+++ b/lib/libedit/chartype.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: chartype.h,v 1.1 2010/06/30 00:05:35 nicm Exp $ */
+/* $OpenBSD: chartype.h,v 1.2 2011/04/04 18:48:17 stsp Exp $ */
/* $NetBSD: chartype.h,v 1.5 2010/04/15 00:55:57 christos Exp $ */
/*-
@@ -106,7 +106,7 @@
#define Strtol(p,e,b) wcstol(p,e,b)
-#define Width(c) wcwidth(c)
+#define Width(c) (wcwidth(c) == -1 ? 0 : wcwidth(c))
#else /* NARROW */