Commit cc61952d authored by Rafaël Carré's avatar Rafaël Carré

ncurses: fix KeyToUTF8() breakage introduced in [22313]

parent c887fde7
...@@ -426,12 +426,9 @@ static void Run( intf_thread_t *p_intf ) ...@@ -426,12 +426,9 @@ static void Run( intf_thread_t *p_intf )
} }
/* following functions are local */ /* following functions are local */
#ifdef HAVE_NCURSESW_CURSES_H
# define KeyToUTF8( i, psz ) psz
#else
static char *KeyToUTF8( int i_key, char *psz_part ) static char *KeyToUTF8( int i_key, char *psz_part )
{ {
char *psz_utf8, *psz; char *psz_utf8;
int len = strlen( psz_part ); int len = strlen( psz_part );
if( len == 6 ) if( len == 6 )
{ {
...@@ -442,10 +439,14 @@ static char *KeyToUTF8( int i_key, char *psz_part ) ...@@ -442,10 +439,14 @@ static char *KeyToUTF8( int i_key, char *psz_part )
psz_part[len] = (char)i_key; psz_part[len] = (char)i_key;
#ifdef HAVE_NCURSESW_CURSES_H
psz_utf8 = strdup( psz_part );
#else
psz_utf8 = FromLocaleDup( psz_part ); psz_utf8 = FromLocaleDup( psz_part );
/* Ugly check for incomplete bytes sequences /* Ugly check for incomplete bytes sequences
* (in case of non-UTF8 multibyte local encoding) */ * (in case of non-UTF8 multibyte local encoding) */
char *psz;
for( psz = psz_utf8; *psz; psz++ ) for( psz = psz_utf8; *psz; psz++ )
if( ( *psz == '?' ) && ( *psz_utf8 != '?' ) ) if( ( *psz == '?' ) && ( *psz_utf8 != '?' ) )
{ {
...@@ -461,11 +462,11 @@ static char *KeyToUTF8( int i_key, char *psz_part ) ...@@ -461,11 +462,11 @@ static char *KeyToUTF8( int i_key, char *psz_part )
free( psz_utf8 ); free( psz_utf8 );
return NULL; return NULL;
} }
#endif
memset( psz_part, 0, 6 ); memset( psz_part, 0, 6 );
return psz_utf8; return psz_utf8;
} }
#endif
static inline int RemoveLastUTF8Entity( char *psz, int len ) static inline int RemoveLastUTF8Entity( char *psz, int len )
{ {
......
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