]> git.sesse.net Git - vlc/commitdiff
* charset.c: don't return a pointer to a buffer allocated on the stack!
authorCyril Deguet <asmax@videolan.org>
Sat, 6 Aug 2005 19:09:54 +0000 (19:09 +0000)
committerCyril Deguet <asmax@videolan.org>
Sat, 6 Aug 2005 19:09:54 +0000 (19:09 +0000)
 * all: removed some warnings

modules/gui/skins2/controls/ctrl_list.cpp
modules/gui/skins2/controls/ctrl_slider.cpp
modules/gui/skins2/src/skin_common.hpp
src/extras/getopt.c
src/libvlc.c
src/misc/charset.c

index 1538cbfef43749f7b0690961a562a41f6d0d6481..df62b82b5b4c60202172c5788eb183e45b234c7f 100644 (file)
@@ -39,7 +39,7 @@
 #   include "solaris_specific.h" // for lrint
 #endif
 
-#define SCROLL_STEP 0.05
+#define SCROLL_STEP 0.05f
 #define LINE_INTERVAL 1  // Number of pixels inserted between 2 lines
 
 
index 23f91a5c34aad33f75d73756707872575d7b1e2b..702540387e8c517acc5e9b822bc57c2a5e36b255 100644 (file)
@@ -35,7 +35,7 @@
 
 
 #define RANGE 40
-#define SCROLL_STEP 0.05
+#define SCROLL_STEP 0.05f
 
 
 CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
index c6429ec680700593123db787453d42f86110f217..d38ec54185f5e2b04a0a2c59b5229d042d198f6b 100644 (file)
@@ -46,6 +46,11 @@ class ThemeRepository;
 #   define M_PI 3.14159265358979323846
 #endif
 
+#ifdef _MSC_VER
+// turn off 'warning C4355: 'this' : used in base member initializer list'\r
+#pragma warning ( disable:4355 )
+#endif
+
 // Useful macros
 #define SKINS_DELETE( p ) \
    if( p ) \
index 024caf045e8305ae7bab72ad36b52de79c4c34bd..eb0bf0df0ab01935668d2071471c60719c0a10ca 100644 (file)
@@ -216,8 +216,6 @@ static char *posixly_correct;
 /* Avoid depending on library functions or files
    whose names are inconsistent.  */
 
-char *getenv();
-
 static char *
      my_index(str, chr)
      const char *str;
index 91a5f0ad045bcc033707248fb39c9fc063f1315e..4f4216aac1f41763e3674b0563a5b9477952dfcc 100644 (file)
@@ -258,7 +258,10 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
     module_t    *p_help_module;
     playlist_t  *p_playlist;
     vlc_value_t  val;
+#if defined( ENABLE_NLS ) \
+     && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
     char *       psz_language;
+#endif
 
     if( !p_vlc )
     {
index a7980e028ee0be890daa056fce53255ba64b07bb..97966c9dc4012679e801fbad816729cdfb724d9f 100644 (file)
@@ -203,14 +203,13 @@ static const char* vlc_charset_aliases( const char *psz_name )
 
 /* Returns charset from "language_COUNTRY.charset@modifier" string */
 #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, '.' );
 
     if( psz_dot != NULL )
     {
         const char *psz_modifier;
-        char buf[2 + 10 + 1];
 
         psz_dot++;
 
@@ -218,17 +217,20 @@ static const char *vlc_encoding_from_locale( char *psz_locale )
         psz_modifier = strchr( psz_dot, '@' );
 
         if( psz_modifier == NULL )
-            return psz_dot;
+        {
+            strcpy( psz_charset, psz_dot );
+            return;
+        }
         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 );
-            buf[ psz_modifier - psz_dot ] = '\0';
-            return buf;
+            memcpy( psz_charset, psz_dot, psz_modifier - psz_dot );
+            psz_charset[ psz_modifier - psz_dot ] = '\0';
+            return;
         }
     }
     /* try language mapping */
-    return vlc_encoding_from_language( psz_locale );
+    strcpy( psz_charset, vlc_encoding_from_language( psz_locale ) );
 }
 #endif
 
@@ -244,6 +246,7 @@ vlc_bool_t vlc_current_charset( char **psz_charset )
 # else
     /* On old systems which lack it, use setlocale or getenv.  */
     const char *psz_locale = NULL;
+    char buf[2 + 10 + 1];
 
     /* 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
@@ -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,
      * 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 */
 
 #elif defined SYS_DARWIN
@@ -298,7 +302,8 @@ vlc_bool_t vlc_current_charset( char **psz_charset )
             locale = getenv( "LANG" );
     }
     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
     {
         /* OS/2 has a function returning the locale's codepage as a number. */