summaryrefslogtreecommitdiff
path: root/lib/libedit/refresh.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2016-02-14 14:49:34 +0000
committerchristos <christos@NetBSD.org>2016-02-14 14:49:34 +0000
commit3117a22c97d0dc4bf12da418d5034ec33dc02e38 (patch)
treefb568a9ff69b413e095a15cbe3663db14428f389 /lib/libedit/refresh.c
parent833b39ead90606d46a6f47ff8422f193f116f752 (diff)
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including the <wchar.h> header because using the data types defined there is deeply ingrained in the public interfaces of libedit. Now POSIX unconditionally requires that <wchar.h> defines the type wint_t. Consequently, it can be used unconditionally, no matter whether WIDECHAR is active or not. Consequently, the #define Int is pointless. Note that removing it is not gratuitious churn. Auditing for integer signedness problems is already hard when only fundamental types like "int" and "unsigned" are involved. It gets very hard when types come into the picture that have platform-dependent signedness, like "char" and "wint_t". Adding yet another layer on top, changing both the signedness and the width in a platform- dependent way, makes auditing yet harder, which IMHO is really dangerous. Note that while removing the #define, i already found one bug caused by this excessive complication - in the function re_putc() in refresh.c. If WIDECHAR was defined, it printed an Int = wint_t value with %c. Fortunately, that bug only affects debugging, not production. The fix is contained in the patch. With WIDECHAR, this doesn't change anything. For the case without WIDECHAR, i checked that none of the places wants to store values that might not fit in wint_t. This only changes internal interfaces; public ones remain unchanged.
Diffstat (limited to 'lib/libedit/refresh.c')
-rw-r--r--lib/libedit/refresh.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c
index 8c7cac9d5f4..f019d21e7cc 100644
--- a/lib/libedit/refresh.c
+++ b/lib/libedit/refresh.c
@@ -1,4 +1,4 @@
-/* $NetBSD: refresh.c,v 1.38 2016/02/11 19:21:04 christos Exp $ */
+/* $NetBSD: refresh.c,v 1.39 2016/02/14 14:49:34 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: refresh.c,v 1.38 2016/02/11 19:21:04 christos Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.39 2016/02/14 14:49:34 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -52,11 +52,11 @@ __RCSID("$NetBSD: refresh.c,v 1.38 2016/02/11 19:21:04 christos Exp $");
#include "el.h"
private void re_nextline(EditLine *);
-private void re_addc(EditLine *, Int);
+private void re_addc(EditLine *, wint_t);
private void re_update_line(EditLine *, Char *, Char *, int);
private void re_insert (EditLine *, Char *, int, int, Char *, int);
private void re_delete(EditLine *, Char *, int, int, int);
-private void re_fastputc(EditLine *, Int);
+private void re_fastputc(EditLine *, wint_t);
private void re_clear_eol(EditLine *, int, int, int);
private void re__strncopy(Char *, Char *, size_t);
private void re__copy_and_pad(Char *, const Char *, size_t);
@@ -125,7 +125,7 @@ re_nextline(EditLine *el)
* Draw c, expanding tabs, control chars etc.
*/
private void
-re_addc(EditLine *el, Int c)
+re_addc(EditLine *el, wint_t c)
{
switch (ct_chr_class((Char)c)) {
case CHTYPE_TAB: /* expand the tab */
@@ -161,10 +161,10 @@ re_addc(EditLine *el, Int c)
* Draw the character given
*/
protected void
-re_putc(EditLine *el, Int c, int shift)
+re_putc(EditLine *el, wint_t c, int shift)
{
int i, w = Width(c);
- ELRE_DEBUG(1, (__F, "printing %5x '%c'\r\n", c, c));
+ ELRE_DEBUG(1, (__F, "printing %5x '%lc'\r\n", c, c));
while (shift && (el->el_refresh.r_cursor.h + w > el->el_terminal.t_size.h))
re_putc(el, ' ', 1);
@@ -1052,7 +1052,7 @@ re_refresh_cursor(EditLine *el)
* Add a character fast.
*/
private void
-re_fastputc(EditLine *el, Int c)
+re_fastputc(EditLine *el, wint_t c)
{
int w = Width((Char)c);
while (w > 1 && el->el_cursor.h + w > el->el_terminal.t_size.h)