for( ; mb_remain > 0 ; ++wc_count, ++pdest, mb_remain -= consumed,
psrc += consumed)
{
+#ifdef _LIBC
+ consumed = __mbrtowc (pdest, psrc, mb_remain, &mbs);
+#else
consumed = mbrtowc (pdest, psrc, mb_remain, &mbs);
+#endif
if (consumed <= 0)
/* failed to convert. maybe src contains binary data.
truncate_wchar (c)
CHAR_T c;
{
- unsigned char buf[MB_LEN_MAX];
- int retval = wctomb(buf, c);
- return retval > 0 ? buf[0] : (unsigned char)c;
+ unsigned char buf[MB_CUR_MAX];
+ mbstate_t state;
+ int retval;
+ memset (&state, '\0', sizeof (state));
+# ifdef _LIBC
+ retval = __wcrtomb (buf, c, &state);
+# else
+ retval = wcrtomb (buf, c, &state);
+# endif
+ return retval > 0 ? buf[0] : (unsigned char) c;
}
#endif /* WCHAR */
& ~(uintptr_t)(__alignof__(wctype_t) - 1);
wctype = *((wctype_t*)alignedp);
workp += CHAR_CLASS_SIZE;
+# ifdef _LIBC
+ if (__iswctype((wint_t)c, wctype))
+ goto char_set_matched;
+# else
if (iswctype((wint_t)c, wctype))
goto char_set_matched;
+# endif
}
/* match with collating_symbol? */
for (workp2 = workp + coll_symbol_length ; workp < workp2 ;)
{
const CHAR_T *backup_d = d, *backup_dend = dend;
- length = wcslen(workp);
+# ifdef _LIBC
+ length = __wcslen (workp);
+# else
+ length = wcslen (workp);
+# endif
/* If wcscoll(the collating symbol, whole string) > 0,
any substring of the string never match with the
collating symbol. */
- if (wcscoll(workp, d) > 0)
+# ifdef _LIBC
+ if (__wcscoll (workp, d) > 0)
+# else
+ if (wcscoll (workp, d) > 0)
+# endif
{
workp += length + 1;
continue;
str_buf[i] = TRANSLATE(*d);
str_buf[i+1] = '\0';
- match = wcscoll(workp, str_buf);
+# ifdef _LIBC
+ match = __wcscoll (workp, str_buf);
+# else
+ match = wcscoll (workp, str_buf);
+# endif
if (match == 0)
goto char_set_matched;
for (workp2 = workp + equiv_class_length ; workp < workp2 ;)
{
const CHAR_T *backup_d = d, *backup_dend = dend;
- length = wcslen(workp);
+# ifdef _LIBC
+ length = __wcslen (workp);
+# else
+ length = wcslen (workp);
+# endif
/* If wcscoll(the collating symbol, whole string) > 0,
any substring of the string never match with the
collating symbol. */
- if (wcscoll(workp, d) > 0)
+# ifdef _LIBC
+ if (__wcscoll (workp, d) > 0)
+# else
+ if (wcscoll (workp, d) > 0)
+# endif
{
workp += length + 1;
break;
str_buf[i] = TRANSLATE(*d);
str_buf[i+1] = '\0';
- match = wcscoll(workp, str_buf);
+# ifdef _LIBC
+ match = __wcscoll (workp, str_buf);
+# else
+ match = wcscoll (workp, str_buf);
+# endif
if (match == 0)
goto char_set_matched;
}
/* match with char_range? */
-#ifdef _LIBC
+# ifdef _LIBC
if (nrules != 0)
{
uint32_t collseqval;
}
}
else
-#endif
+# endif
{
/* We set range_start_char at str_buf[0], range_end_char
at str_buf[4], and compared char at str_buf[2]. */
range_end_char = str_buf + 4;
}
- if (wcscoll(range_start_char, str_buf+2) <= 0 &&
- wcscoll(str_buf+2, range_end_char) <= 0)
-
+# ifdef _LIBC
+ if (__wcscoll (range_start_char, str_buf+2) <= 0
+ && __wcscoll (str_buf+2, range_end_char) <= 0)
+# else
+ if (wcscoll (range_start_char, str_buf+2) <= 0
+ && wcscoll (str_buf+2, range_end_char) <= 0)
+# endif
goto char_set_matched;
}
}