Commit 1a4ae567 authored by Cyril Deguet's avatar Cyril Deguet

* charset.c: don't return a pointer to a buffer allocated on the stack!

 * all: removed some warnings
parent 9bcabfda
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
# include "solaris_specific.h" // for lrint # include "solaris_specific.h" // for lrint
#endif #endif
#define SCROLL_STEP 0.05 #define SCROLL_STEP 0.05f
#define LINE_INTERVAL 1 // Number of pixels inserted between 2 lines #define LINE_INTERVAL 1 // Number of pixels inserted between 2 lines
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#define RANGE 40 #define RANGE 40
#define SCROLL_STEP 0.05 #define SCROLL_STEP 0.05f
CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf, CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
......
...@@ -46,6 +46,11 @@ class ThemeRepository; ...@@ -46,6 +46,11 @@ class ThemeRepository;
# define M_PI 3.14159265358979323846 # define M_PI 3.14159265358979323846
#endif #endif
#ifdef _MSC_VER
// turn off 'warning C4355: 'this' : used in base member initializer list'
#pragma warning ( disable:4355 )
#endif
// Useful macros // Useful macros
#define SKINS_DELETE( p ) \ #define SKINS_DELETE( p ) \
if( p ) \ if( p ) \
......
...@@ -216,8 +216,6 @@ static char *posixly_correct; ...@@ -216,8 +216,6 @@ static char *posixly_correct;
/* Avoid depending on library functions or files /* Avoid depending on library functions or files
whose names are inconsistent. */ whose names are inconsistent. */
char *getenv();
static char * static char *
my_index(str, chr) my_index(str, chr)
const char *str; const char *str;
......
...@@ -258,7 +258,10 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -258,7 +258,10 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
module_t *p_help_module; module_t *p_help_module;
playlist_t *p_playlist; playlist_t *p_playlist;
vlc_value_t val; vlc_value_t val;
#if defined( ENABLE_NLS ) \
&& ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
char * psz_language; char * psz_language;
#endif
if( !p_vlc ) if( !p_vlc )
{ {
......
...@@ -203,14 +203,13 @@ static const char* vlc_charset_aliases( const char *psz_name ) ...@@ -203,14 +203,13 @@ static const char* vlc_charset_aliases( const char *psz_name )
/* Returns charset from "language_COUNTRY.charset@modifier" string */ /* Returns charset from "language_COUNTRY.charset@modifier" string */
#if defined WIN32 || defined OS2 || !HAVE_LANGINFO_CODESET #if defined WIN32 || defined OS2 || !HAVE_LANGINFO_CODESET
static const char *vlc_encoding_from_locale( char *psz_locale ) static void vlc_encoding_from_locale( char *psz_locale, char *psz_charset )
{ {
char *psz_dot = strchr( psz_locale, '.' ); char *psz_dot = strchr( psz_locale, '.' );
if( psz_dot != NULL ) if( psz_dot != NULL )
{ {
const char *psz_modifier; const char *psz_modifier;
char buf[2 + 10 + 1];
psz_dot++; psz_dot++;
...@@ -218,17 +217,20 @@ static const char *vlc_encoding_from_locale( char *psz_locale ) ...@@ -218,17 +217,20 @@ static const char *vlc_encoding_from_locale( char *psz_locale )
psz_modifier = strchr( psz_dot, '@' ); psz_modifier = strchr( psz_dot, '@' );
if( psz_modifier == NULL ) if( psz_modifier == NULL )
return psz_dot; {
strcpy( psz_charset, psz_dot );
return;
}
if( 0 < ( psz_modifier - psz_dot ) if( 0 < ( psz_modifier - psz_dot )
&& ( psz_modifier - psz_dot ) < sizeof( buf )) && ( psz_modifier - psz_dot ) < 2 + 10 + 1 )
{ {
memcpy( buf, psz_dot, psz_modifier - psz_dot ); memcpy( psz_charset, psz_dot, psz_modifier - psz_dot );
buf[ psz_modifier - psz_dot ] = '\0'; psz_charset[ psz_modifier - psz_dot ] = '\0';
return buf; return;
} }
} }
/* try language mapping */ /* try language mapping */
return vlc_encoding_from_language( psz_locale ); strcpy( psz_charset, vlc_encoding_from_language( psz_locale ) );
} }
#endif #endif
...@@ -244,6 +246,7 @@ vlc_bool_t vlc_current_charset( char **psz_charset ) ...@@ -244,6 +246,7 @@ vlc_bool_t vlc_current_charset( char **psz_charset )
# else # else
/* On old systems which lack it, use setlocale or getenv. */ /* On old systems which lack it, use setlocale or getenv. */
const char *psz_locale = NULL; const char *psz_locale = NULL;
char buf[2 + 10 + 1];
/* But most old systems don't have a complete set of locales. Some /* But most old systems don't have a complete set of locales. Some
* (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't * (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't
...@@ -265,7 +268,8 @@ vlc_bool_t vlc_current_charset( char **psz_charset ) ...@@ -265,7 +268,8 @@ vlc_bool_t vlc_current_charset( char **psz_charset )
/* On some old systems, one used to set locale = "iso8859_1". On others, /* On some old systems, one used to set locale = "iso8859_1". On others,
* you set it to "language_COUNTRY.charset". Darwin only has LANG :( */ * you set it to "language_COUNTRY.charset". Darwin only has LANG :( */
psz_codeset = vlc_encoding_from_locale( (char *)psz_locale ); vlc_encoding_from_locale( (char *)psz_locale, buf );
psz_codeset = buf;
# endif /* HAVE_LANGINFO_CODESET */ # endif /* HAVE_LANGINFO_CODESET */
#elif defined SYS_DARWIN #elif defined SYS_DARWIN
...@@ -298,7 +302,8 @@ vlc_bool_t vlc_current_charset( char **psz_charset ) ...@@ -298,7 +302,8 @@ vlc_bool_t vlc_current_charset( char **psz_charset )
locale = getenv( "LANG" ); locale = getenv( "LANG" );
} }
if( psz_locale != NULL && psz_locale[0] != '\0' ) if( psz_locale != NULL && psz_locale[0] != '\0' )
psz_codeset = vlc_encoding_from_locale( psz_locale ); vlc_encoding_from_locale( psz_locale, buf );
psz_codeset = buf;
else else
{ {
/* OS/2 has a function returning the locale's codepage as a number. */ /* OS/2 has a function returning the locale's codepage as a number. */
......
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