Module Name: src
Committed By: christos
Date: Tue Nov 15 23:54:14 UTC 2011
Modified Files:
src/lib/libedit: chartype.h
Log Message:
Since Width() is used only for display purposes we don't want to pass -1 for
unprintable characters.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libedit/chartype.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/chartype.h
diff -u src/lib/libedit/chartype.h:1.8 src/lib/libedit/chartype.h:1.9
--- src/lib/libedit/chartype.h:1.8 Fri Jul 29 19:44:44 2011
+++ src/lib/libedit/chartype.h Tue Nov 15 18:54:14 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.h,v 1.8 2011/07/29 23:44:44 christos Exp $ */
+/* $NetBSD: chartype.h,v 1.9 2011/11/15 23:54:14 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -105,7 +105,12 @@
#define Strtol(p,e,b) wcstol(p,e,b)
-#define Width(c) wcwidth(c)
+static inline size_t
+Width(wchar_t c)
+{
+ int w = wcwidth(c);
+ return (w < 0) ? 0 : (size_t)w;
+}
#else /* NARROW */