Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses waddch - instead of enclosing every statement ...



details:   https://anonhg.NetBSD.org/src/rev/1d5bc163d999
branches:  trunk
changeset: 994266:1d5bc163d999
user:      uwe <uwe%NetBSD.org@localhost>
date:      Mon Oct 29 01:19:54 2018 +0000

description:
waddch - instead of enclosing every statement in #ifdef HAVE_WCHAR
just provide two separate definitions.

Same object code is generated for all four combinations of debug/wchar.

diffstat:

 lib/libcurses/addch.c |  42 ++++++++++++++++++++++--------------------
 1 files changed, 22 insertions(+), 20 deletions(-)

diffs (82 lines):

diff -r 856f3ccabebd -r 1d5bc163d999 lib/libcurses/addch.c
--- a/lib/libcurses/addch.c     Mon Oct 29 01:02:16 2018 +0000
+++ b/lib/libcurses/addch.c     Mon Oct 29 01:19:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: addch.c,v 1.18 2017/01/06 14:06:00 roy Exp $   */
+/*     $NetBSD: addch.c,v 1.19 2018/10/29 01:19:54 uwe Exp $   */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addch.c    8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addch.c,v 1.18 2017/01/06 14:06:00 roy Exp $");
+__RCSID("$NetBSD: addch.c,v 1.19 2018/10/29 01:19:54 uwe Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -82,43 +82,45 @@
 
 #endif
 
+#ifdef HAVE_WCHAR
 /*
  * waddch --
  *     Add the character to the current position in the given window.
- *
  */
 int
 waddch(WINDOW *win, chtype ch)
 {
-#ifdef HAVE_WCHAR
        cchar_t cc;
-#else
-       __LDATA buf;
-#endif
 
-#ifdef HAVE_WCHAR
        __cursesi_chtype_to_cchar(ch, &cc);
-#else
-       buf.ch = (wchar_t)ch & __CHARTEXT;
-       buf.attr = (attr_t)ch & __ATTRIBUTES;
-#endif
-
 #ifdef DEBUG
-#ifdef HAVE_WCHAR
        __CTRACE(__CTRACE_INPUT,
                 "addch: %d : 0x%x (adding char as wide char)\n",
                 cc.vals[0], cc.attributes);
-#else
-       __CTRACE(__CTRACE_INPUT, "addch: %d : 0x%x\n", buf.ch, buf.attr);
-#endif
 #endif
 
-#ifdef HAVE_WCHAR
        return wadd_wch(win, &cc);
-#else
+}
+
+#else /* !HAVE_WCHAR */
+
+/*
+ * waddch --
+ *     Add the character to the current position in the given window.
+ */
+int
+waddch(WINDOW *win, chtype ch)
+{
+       __LDATA buf;
+
+       buf.ch = (wchar_t)ch & __CHARTEXT;
+       buf.attr = (attr_t)ch & __ATTRIBUTES;
+#ifdef DEBUG
+       __CTRACE(__CTRACE_INPUT, "addch: %d : 0x%x\n", buf.ch, buf.attr);
+#endif
        return __waddch(win, &buf);
-#endif
 }
+#endif /* !HAVE_WCHAR */
 
 int
 __waddch(WINDOW *win, __LDATA *dp)



Home | Main Index | Thread Index | Old Index