Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/citrus correct the return values of wcrtomb(3) and ...



details:   https://anonhg.NetBSD.org/src/rev/60da78605c89
branches:  trunk
changeset: 570151:60da78605c89
user:      soda <soda%NetBSD.org@localhost>
date:      Sat Sep 25 22:53:46 2004 +0000

description:
correct the return values of wcrtomb(3) and wctomb(3).
These return values should include the length of shift sequence
to restore the initial shift state.

diffstat:

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

diffs (65 lines):

diff -r 60c0d1e015dc -r 60da78605c89 lib/libc/citrus/citrus_ctype_template.h
--- a/lib/libc/citrus/citrus_ctype_template.h   Sat Sep 25 22:08:48 2004 +0000
+++ b/lib/libc/citrus/citrus_ctype_template.h   Sat Sep 25 22:53:46 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: citrus_ctype_template.h,v 1.25 2004/01/02 21:49:35 itojun Exp $        */
+/*     $NetBSD: citrus_ctype_template.h,v 1.26 2004/09/25 22:53:46 soda Exp $  */
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -573,6 +573,9 @@
        char buf[MB_LEN_MAX];
        int err = 0;
        size_t sz;
+#if _ENCODING_IS_STATE_DEPENDENT
+       size_t rsz = 0;
+#endif
 
        _DIAGASSERT(cl != NULL);
 
@@ -588,7 +591,6 @@
        sz = _ENCODING_MB_CUR_MAX(_CEI_TO_EI(_TO_CEI(cl)));
 #if _ENCODING_IS_STATE_DEPENDENT
        if (wc == L'\0') {
-               size_t rsz;
                /* reset state */
                err = _FUNCNAME(put_state_reset)(_CEI_TO_EI(_TO_CEI(cl)), s,
                                                 sz, psenc, &rsz);
@@ -601,6 +603,7 @@
        err = _FUNCNAME(wcrtomb_priv)(_CEI_TO_EI(_TO_CEI(cl)), s, sz,
                                      wc, psenc, nresult);
 #if _ENCODING_IS_STATE_DEPENDENT
+       *nresult += rsz;
 quit:
 #endif
        if (err == E2BIG)
@@ -658,6 +661,9 @@
        _ENCODING_STATE *psenc;
        _ENCODING_INFO *ei;
        size_t nr, sz;
+#if _ENCODING_IS_STATE_DEPENDENT
+       size_t rsz = 0;
+#endif
        int err = 0;
 
        _DIAGASSERT(cl != NULL);
@@ -674,7 +680,6 @@
        sz = _ENCODING_MB_CUR_MAX(_CEI_TO_EI(_TO_CEI(cl)));
 #if _ENCODING_IS_STATE_DEPENDENT
        if (wc == L'\0') {
-               size_t rsz;
                /* reset state */
                err = _FUNCNAME(put_state_reset)(_CEI_TO_EI(_TO_CEI(cl)), s,
                                                 sz, psenc, &rsz);
@@ -687,7 +692,11 @@
        }
 #endif
        err = _FUNCNAME(wcrtomb_priv)(ei, s, sz, wc, psenc, &nr);
+#if _ENCODING_IS_STATE_DEPENDENT
+       *nresult = (int)(nr + rsz);
+#else
        *nresult = (int)nr;
+#endif
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index