Source-Changes-HG archive

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

[src/trunk]: src/distrib/utils/libhack handle the "special" wc NULL case.



details:   https://anonhg.NetBSD.org/src/rev/d2af20b2779f
branches:  trunk
changeset: 333744:d2af20b2779f
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 15 17:49:19 2014 +0000

description:
handle the "special" wc NULL case.

diffstat:

 distrib/utils/libhack/multibyte.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r 957ca07ff4cc -r d2af20b2779f distrib/utils/libhack/multibyte.c
--- a/distrib/utils/libhack/multibyte.c Sat Nov 15 15:01:41 2014 +0000
+++ b/distrib/utils/libhack/multibyte.c Sat Nov 15 17:49:19 2014 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: multibyte.c,v 1.5 2013/04/19 18:45:03 joerg Exp $      */
+/*      $NetBSD: multibyte.c,v 1.6 2014/11/15 17:49:19 christos Exp $      */
 
 /*
  * Ignore all multibyte sequences, removes all the citrus code.
@@ -12,7 +12,15 @@
 size_t
 mbrtowc(wchar_t *wc, const char *str, size_t max_sz, mbstate_t *ps)
 {
-       return str == NULL || (*wc = (unsigned char)*str) == 0 ? 0 : 1;
+       wchar_t c;
+
+       if (str == NULL)
+               return 0;
+
+       if (wc != NULL)
+               *wc = (unsigned char)*str;
+
+       return *str == '\0' ? 0 : 1;
 }
 
 size_t



Home | Main Index | Thread Index | Old Index