Module Name:    src
Committed By:   uwe
Date:           Tue Nov 20 21:41:31 UTC 2018

Modified Files:
        src/lib/libcurses: cchar.c

Log Message:
Don't hide assignments inside tests.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/cchar.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcurses/cchar.c
diff -u src/lib/libcurses/cchar.c:1.7 src/lib/libcurses/cchar.c:1.8
--- src/lib/libcurses/cchar.c:1.7	Tue Nov 20 17:48:19 2018
+++ src/lib/libcurses/cchar.c	Tue Nov 20 21:41:31 2018
@@ -1,4 +1,4 @@
-/*   $NetBSD: cchar.c,v 1.7 2018/11/20 17:48:19 uwe Exp $ */
+/*   $NetBSD: cchar.c,v 1.8 2018/11/20 21:41:31 uwe Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: cchar.c,v 1.7 2018/11/20 17:48:19 uwe Exp $");
+__RCSID("$NetBSD: cchar.c,v 1.8 2018/11/20 21:41:31 uwe Exp $");
 #endif						  /* not lint */
 
 #include <string.h>
@@ -58,11 +58,11 @@ getcchar(const cchar_t *wcval, wchar_t *
 	wchar_t *wp;
 	size_t len;
 
-	if (opts)
+	if (__predict_false(opts != NULL))
 		return ERR;
 
-	len = (wp = wmemchr(wcval->vals, L'\0', CCHARW_MAX))
-		? wp - wcval->vals : CCHARW_MAX;
+	wp = wmemchr(wcval->vals, L'\0', CCHARW_MAX);
+	len = wp ? wp - wcval->vals : CCHARW_MAX;
 
 	if (wch == NULL)
 		return (int)len;
@@ -95,10 +95,12 @@ setcchar(cchar_t *wcval, const wchar_t *
 	int i;
 	size_t len;
 
-	if (opts || (len = wcslen(wch)) > CCHARW_MAX
-		|| (len > 1 && wcwidth(wch[0]) < 0)) {
+	if (__predict_false(opts != NULL))
+		return ERR;
+
+	len = wcslen(wch);
+	if (len > CCHARW_MAX || (len > 1 && wcwidth(wch[0]) < 0))
 		return ERR;
-	}
 
 	/*
 	 * If we have a following spacing-character, stop at that point.  We

Reply via email to