Commit 0b79316c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Suppress unused UTF-32 conversion functions

parent c3293262
......@@ -52,15 +52,10 @@ VLC_EXPORT( int, utf8_fprintf, ( FILE *, const char *, ... ) );
VLC_EXPORT( char *, EnsureUTF8, ( char * ) );
VLC_EXPORT( const char *, IsUTF8, ( const char * ) );
VLC_EXPORT( char *, FromUTF32, ( const uint32_t * ) );
#ifdef WIN32
VLC_EXPORT( char *, FromUTF16, ( const uint16_t * ) );
static inline char *FromWide( const wchar_t *in )
{
return (sizeof( wchar_t ) == 2)
? FromUTF16( (const uint16_t *)in )
: FromUTF32( (const uint32_t *)in );
}
#define FromWide FromUTF16
#endif
#if !defined (__PLUGIN__)
......
......@@ -426,7 +426,7 @@ struct module_symbols_t
void (*osd_Message_inner) (spu_t *, int, char *, ...);
int (*osd_ShowTextAbsolute_inner) (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t);
char * (*config_GetUserDir_inner) (void);
char * (*FromUTF32_inner) (const uint32_t *);
void *FromUTF32_deprecated;
int (*__input_Read_inner) (vlc_object_t *, input_item_t *, vlc_bool_t);
int (*__net_ConnectUDP_inner) (vlc_object_t *p_this, const char *psz_host, int i_port, int hlim);
void *__intf_Interact_deprecated;
......@@ -933,7 +933,6 @@ struct module_symbols_t
# define osd_Message (p_symbols)->osd_Message_inner
# define osd_ShowTextAbsolute (p_symbols)->osd_ShowTextAbsolute_inner
# define config_GetUserDir (p_symbols)->config_GetUserDir_inner
# define FromUTF32 (p_symbols)->FromUTF32_inner
# define __input_Read (p_symbols)->__input_Read_inner
# define __net_ConnectUDP (p_symbols)->__net_ConnectUDP_inner
# define intf_InteractionManage (p_symbols)->intf_InteractionManage_inner
......@@ -1415,7 +1414,6 @@ struct module_symbols_t
((p_symbols)->osd_Message_inner) = osd_Message; \
((p_symbols)->osd_ShowTextAbsolute_inner) = osd_ShowTextAbsolute; \
((p_symbols)->config_GetUserDir_inner) = config_GetUserDir; \
((p_symbols)->FromUTF32_inner) = FromUTF32; \
((p_symbols)->__input_Read_inner) = __input_Read; \
((p_symbols)->__net_ConnectUDP_inner) = __net_ConnectUDP; \
((p_symbols)->intf_InteractionManage_inner) = intf_InteractionManage; \
......@@ -1551,6 +1549,7 @@ struct module_symbols_t
(p_symbols)->playlist_NodeGroup_deprecated = NULL; \
(p_symbols)->playlist_NodeRemoveParent_deprecated = NULL; \
(p_symbols)->__vlc_fix_readdir_charset_deprecated = NULL; \
(p_symbols)->FromUTF32_deprecated = NULL; \
(p_symbols)->__intf_Interact_deprecated = NULL; \
(p_symbols)->__intf_UserProgress_deprecated = NULL; \
(p_symbols)->__intf_UserProgressUpdate_deprecated = NULL; \
......
......@@ -780,103 +780,13 @@ const char *IsUTF8( const char *str )
}
/**
* UTF32toUTF8(): converts an array from UTF-32 (host byte order)
* to UTF-8.
*
* @param src the UTF-32 table to be converted
* @param len the number of code points to be converted from src
* (ie. the number of uint32_t in the table pointed to by src)
* @param newlen an optional pointer. If not NULL, *newlen will
* contain the total number of bytes written.
*
* @return the result of the conversion (must be free'd())
* or NULL on error (in that case, *newlen is undefined).
*/
static char *
UTF32toUTF8( const uint32_t *src, size_t len, size_t *newlen )
{
char *res, *out;
/* allocate memory */
out = res = (char *)malloc( 6 * len );
if( res == NULL )
return NULL;
while( len > 0 )
{
uint32_t uv = *src++;
len--;
if( uv < 0x80 )
{
*out++ = uv;
continue;
}
else
if( uv < 0x800 )
{
*out++ = (( uv >> 6) | 0xc0);
*out++ = (( uv & 0x3f) | 0x80);
continue;
}
else
if( uv < 0x10000 )
{
*out++ = (( uv >> 12) | 0xe0);
*out++ = (((uv >> 6) & 0x3f) | 0x80);
*out++ = (( uv & 0x3f) | 0x80);
continue;
}
else
if( uv < 0x110000 )
{
*out++ = (( uv >> 18) | 0xf0);
*out++ = (((uv >> 12) & 0x3f) | 0x80);
*out++ = (((uv >> 6) & 0x3f) | 0x80);
*out++ = (( uv & 0x3f) | 0x80);
continue;
}
else
{
free( res );
return NULL;
}
}
len = out - res;
res = realloc( res, len );
if( newlen != NULL )
*newlen = len;
return res;
}
/**
* FromUTF32(): converts an UTF-32 string to UTF-8.
*
* @param src UTF-32 bytes sequence, aligned on a 32-bits boundary.
*
* @return the result of the conversion (must be free()'d),
* or NULL in case of error.
*/
char *FromUTF32( const uint32_t *src )
{
const uint32_t *in;
size_t len;
/* determine the size of the string */
for( len = 1, in = src; *in; len++ )
in++;
return UTF32toUTF8( src, len, NULL );
}
/**
* UTF16toUTF8: converts UTF-16 (host byte order) to UTF-8
*
* @param src UTF-16 bytes sequence, aligned on a 16-bits boundary
* @param len number of uint16_t to convert
*/
static char *
static inline char *
UTF16toUTF8( const uint16_t *in, size_t len, size_t *newlen )
{
char *res, *out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment