From bbe9636fd8db2af188f6e20bacd31225301b0aa6 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 17 Dec 2009 20:04:43 +0000 Subject: 2009-12-17 Jerker Back * libc/iconv/lib/local.h[!__GNUC__]: Add alternative version of ICONV_ZERO_MB_STATE_T macro. * libc/iconv/lib/ucsconv.c (ucs_based_conversion_get_state): Use temporary local variable nullstate to hold empty mbstate_t. --- newlib/libc/iconv/lib/local.h | 4 ++++ newlib/libc/iconv/lib/ucsconv.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'newlib/libc/iconv') diff --git a/newlib/libc/iconv/lib/local.h b/newlib/libc/iconv/lib/local.h index 85f22634c..fd386c5fb 100644 --- a/newlib/libc/iconv/lib/local.h +++ b/newlib/libc/iconv/lib/local.h @@ -41,7 +41,11 @@ #define ICONV_DATA_EXT ".cct" /* This macro is used to zero mbstate_t objects */ +#ifdef __GNUC__ #define ICONV_ZERO_MB_STATE_T ((mbstate_t){0, {0}}) +#else +#define ICONV_ZERO_MB_STATE_T {0} +#endif /* Define the maximum multi-byte character length produced by iconv library */ #if MB_LEN_MAX < 6 diff --git a/newlib/libc/iconv/lib/ucsconv.c b/newlib/libc/iconv/lib/ucsconv.c index 4dab2e19d..cc5ceb953 100644 --- a/newlib/libc/iconv/lib/ucsconv.c +++ b/newlib/libc/iconv/lib/ucsconv.c @@ -258,20 +258,21 @@ _DEFUN(ucs_based_conversion_get_state, (data, state, direction), int direction) { iconv_ucs_conversion_t *uc = (iconv_ucs_conversion_t *)data; + mbstate_t nullstate = ICONV_ZERO_MB_STATE_T; if (direction == 0) { if (uc->to_ucs.handlers->get_state != NULL) uc->to_ucs.handlers->get_state (uc->to_ucs.data, state); else - *state = ICONV_ZERO_MB_STATE_T; + *state = nullstate; /* internal copy */ } else { if (uc->from_ucs.handlers->get_state != NULL) uc->from_ucs.handlers->get_state (uc->from_ucs.data, state); else - *state = ICONV_ZERO_MB_STATE_T; + *state = nullstate; /* internal copy */ } return; -- cgit v1.2.3