Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/citrus - handle s==NULL case of wcrtomb.



details:   https://anonhg.NetBSD.org/src/rev/a774df303cc1
branches:  trunk
changeset: 541092:a774df303cc1
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Jan 01 15:57:12 2003 +0000

description:
- handle s==NULL case of wcrtomb.
- add a comment about it.

fix rest of PR 18269 by wurlitzer.

diffstat:

 lib/libc/citrus/citrus_ctype_template.h |  13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diffs (38 lines):

diff -r f4a9fc37cd3b -r a774df303cc1 lib/libc/citrus/citrus_ctype_template.h
--- a/lib/libc/citrus/citrus_ctype_template.h   Wed Jan 01 15:56:11 2003 +0000
+++ b/lib/libc/citrus/citrus_ctype_template.h   Wed Jan 01 15:57:12 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: citrus_ctype_template.h,v 1.19 2003/01/01 15:25:54 yamt Exp $  */
+/*     $NetBSD: citrus_ctype_template.h,v 1.20 2003/01/01 15:57:12 yamt Exp $  */
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -163,6 +163,8 @@
  *   - additional 6th parameter is the storage to be stored
  *     the return value in the real mbrtowc context.
  *   - return value means "errno" in the real wcrtomb context.
+ *   - caller should ensure that 2nd parameter isn't NULL.
+ *     (XXX inconsist with mbrtowc_priv)
  */
 
 static int _FUNCNAME(wcrtomb_priv)(_ENCODING_INFO * __restrict,
@@ -566,10 +568,19 @@
                         void * __restrict pspriv, size_t * __restrict nresult)
 {
        _ENCODING_STATE *psenc;
+       char buf[MB_LEN_MAX];
        int err = 0;
 
        _DIAGASSERT(cl != NULL);
 
+       if (s == NULL) {
+               /*
+                * use internal buffer.
+                */
+               s = buf;
+               wc = L'\0'; /* SUSv3 */
+       }
+
        _RESTART_BEGIN(wcrtomb, _TO_CEI(cl), pspriv, psenc);
        err = _FUNCNAME(wcrtomb_priv)(_CEI_TO_EI(_TO_CEI(cl)), s,
                            _ENCODING_MB_CUR_MAX(_CEI_TO_EI(_TO_CEI(cl))),



Home | Main Index | Thread Index | Old Index