libc: Move MB_LEN_MAX from lib_wctob.c to limits.h
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I3a5addac99adb02f57aba05aa9fe2e6aaf31071d
This commit is contained in:
parent
4fe35cc87c
commit
57caa4e121
@ -49,7 +49,9 @@
|
||||
/********************************************************************************
|
||||
* Pre-processor Definitions
|
||||
********************************************************************************/
|
||||
|
||||
/* Default values for user configurable limits **********************************/
|
||||
|
||||
/* Maximum number of bytes in a filename (not including terminating null). */
|
||||
|
||||
#ifndef CONFIG_NAME_MAX
|
||||
@ -68,6 +70,13 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum length of any multibyte character in any locale.
|
||||
* We define this value here since the gcc header does not define
|
||||
* the correct value.
|
||||
*/
|
||||
|
||||
#define MB_LEN_MAX 1
|
||||
|
||||
/* Configurable limits required by POSIX ****************************************
|
||||
*
|
||||
* Required for all implementations:
|
||||
@ -303,6 +312,7 @@
|
||||
#define SEM_VALUE_MAX _POSIX_SEM_VALUE_MAX
|
||||
|
||||
/* Required for readv() and writev() */
|
||||
|
||||
/* There really is no upper limit on the number of vectors */
|
||||
|
||||
#define IOV_MAX INT_MAX
|
||||
|
@ -55,14 +55,14 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
size_t wcrtomb(FAR char *s, wchar_t wc, FAR mbstate_t * ps)
|
||||
size_t wcrtomb(FAR char *s, wchar_t wc, FAR mbstate_t *ps)
|
||||
{
|
||||
int retval = 0;
|
||||
char buf[10];
|
||||
char buf[MB_LEN_MAX];
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
retval = wctomb((char *)buf, L'\0');
|
||||
retval = wctomb(buf, L'\0');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -71,11 +71,11 @@ size_t wcrtomb(FAR char *s, wchar_t wc, FAR mbstate_t * ps)
|
||||
|
||||
if (retval == -1)
|
||||
{
|
||||
return (size_t) (-1);
|
||||
return (size_t)(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (size_t) retval;
|
||||
return (size_t)retval;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -44,27 +44,19 @@
|
||||
|
||||
#ifdef CONFIG_LIBC_WCHAR
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MB_LEN_MAX
|
||||
# define MB_LEN_MAX 8
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int wctob(wint_t wc)
|
||||
{
|
||||
unsigned char pmb[MB_LEN_MAX];
|
||||
char pmb[MB_LEN_MAX];
|
||||
|
||||
if (wc == WEOF)
|
||||
{
|
||||
return EOF;
|
||||
}
|
||||
|
||||
return wctomb((char *)pmb, wc) == 1 ? (int)pmb[0] : EOF;
|
||||
return wctomb(pmb, wc) == 1 ? (int)pmb[0] : EOF;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user