]> git.sesse.net Git - vlc/commitdiff
posix: drop support for non-UTF-8 operating systems
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 19 Mar 2012 18:46:09 +0000 (20:46 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 19 Mar 2012 20:12:44 +0000 (22:12 +0200)
This patch also removes support for legacy encodings:
 - in taglib, in the non-Windows code paths,
 - in the Internationalized Domain Names resolved (only glibc) and
 - in the GNOME VFS module.

Support for translation from/to UTF-8 was disabled by default 20 months
ago, and scheduled for removal, 14 months ago.

bin/cachegen.c
modules/access/gnomevfs.c
modules/meta_engine/taglib.cpp
src/network/getaddrinfo.c
src/posix/darwin_dirs.c
src/posix/dirs.c
src/posix/filesystem.c
src/posix/plugin.c

index 6fef55d8305f36c18115f55ce904199bce0158c0..1772b3dab3ff280d13c225f97dc8df60936d4f72 100644 (file)
 #include <stdlib.h>
 #include <stdbool.h>
 
-#ifdef HAVE_SETLOCALE
-# include <locale.h>
-#endif
-
 #ifdef HAVE_GETOPT_H
 # include <getopt.h>
 #endif
@@ -63,10 +59,6 @@ int main (int argc, char *argv[])
         { NULL,         no_argument,       NULL, '\0'}
     };
 
-#ifdef HAVE_SETLOCALE
-    setlocale (LC_CTYPE, ""); /* needed by FromLocale() */
-#endif
-
     int c;
     bool force = false;
 
index f65815210ba3bebd6d2748647458381f4f84c482..b9eebf7070cbd78f38f284545a375e677de7318a 100644 (file)
@@ -35,8 +35,6 @@
 
 #include <libgnomevfs/gnome-vfs.h>
 
-
-#include <vlc_charset.h>
 #include <vlc_url.h>
 
 /*****************************************************************************
@@ -87,7 +85,6 @@ static int Open( vlc_object_t *p_this )
     access_t       *p_access = (access_t*)p_this;
     access_sys_t   *p_sys = NULL;
     char           *psz_name = NULL;
-    char           *psz = NULL;
     char           *psz_uri = NULL;
     char           *psz_unescaped = NULL;
     char           *psz_expand_tilde = NULL;
@@ -121,9 +118,7 @@ static int Open( vlc_object_t *p_this )
     {
         psz_name = strdup( p_access->psz_location );
     }
-    psz = ToLocale( psz_name );
-    psz_expand_tilde = gnome_vfs_expand_initial_tilde( psz );
-    LocaleFree( psz );
+    psz_expand_tilde = gnome_vfs_expand_initial_tilde( psz_name );
 
     psz_unescaped = gnome_vfs_make_uri_from_shell_arg( psz_expand_tilde );
 
index ab11ccece1af5b5dff6c8baba1c21dc34bed6596..22b6ae1773c6ffb2fdf442945625c4d50a187912 100644 (file)
@@ -31,7 +31,6 @@
 #include <vlc_plugin.h>
 #include <vlc_demux.h>              /* demux_meta_t */
 #include <vlc_strings.h>            /* vlc_b64_decode_binary */
-#include <vlc_charset.h>            /* ToLocale, LocaleFree */
 #include <vlc_input.h>              /* for attachment_new */
 
 #ifdef WIN32
@@ -458,14 +457,7 @@ static int ReadMeta( vlc_object_t* p_this)
     f = FileRef( wpath );
     free( wpath );
 #else
-    const char* local_name = ToLocale( psz_path );
-    if( !local_name )
-    {
-        free( psz_path );
-        return VLC_EGENERIC;
-    }
-    f = FileRef( local_name );
-    LocaleFree( local_name );
+    f = FileRef( psz_path );
 #endif
     free( psz_path );
 
@@ -687,11 +679,7 @@ static int WriteMeta( vlc_object_t *p_this )
     f = FileRef( wpath );
     free( wpath );
 #else
-    const char* local_name = ToLocale( p_export->psz_file );
-    if( !local_name )
-        return VLC_EGENERIC;
-    f = FileRef( local_name );
-    LocaleFree( local_name );
+    f = FileRef( p_export->psz_file );
 #endif
 
     if( f.isNull() || !f.tag() || f.file()->readOnly() )
index 0d5cdf873792f36e0b29574145a777045c73535e..b57193bae696ea2a715e365feb5c0c8ac12c7ed3 100644 (file)
@@ -27,7 +27,6 @@
 #endif
 
 #include <vlc_common.h>
-#include <vlc_charset.h>
 
 #include <stddef.h> /* size_t */
 #include <string.h> /* strlen(), memcpy(), memset(), strchr() */
@@ -157,7 +156,6 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
     }
 
     int ret;
-    node = ToLocale (node);
 #ifdef WIN32
     /*
      * Winsock tries to resolve numerical IPv4 addresses as AAAA
@@ -186,6 +184,5 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
 #if defined(AI_IDN) || defined(WIN32)
 out:
 #endif
-    LocaleFree (node);
     return ret;
 }
index 96b1e16a2b33a8722fe00d1ff1fdd2d668bdccb6..a373971a74bd4a8e8cb445ae9e653793b145fdc8 100644 (file)
@@ -31,7 +31,6 @@
 #include <vlc_common.h>
 
 #include "../libvlc.h"
-#include <vlc_charset.h>
 #include <vlc_configuration.h>
 #include "config/configuration.h"
 
@@ -139,7 +138,7 @@ static char *config_GetHomeDir (void)
     if (home == NULL)
         home = "/tmp";
 
-    return FromLocaleDup (home);
+    return strdup (home);
 }
 
 static char *getAppDependentDir(vlc_userdir_t type)
index eb31a5698cace7037f6327b0bad15e2df89d1b24..e23f883b4310b52df1474375a7757ca97e0067c9 100644 (file)
@@ -28,7 +28,6 @@
 #include <vlc_common.h>
 
 #include "../libvlc.h"
-#include <vlc_charset.h>
 #include "config/configuration.h"
 
 #include <unistd.h>
@@ -87,7 +86,7 @@ static char *config_GetHomeDir (void)
     if (!home)
         return NULL;
 
-    return FromLocaleDup (home);
+    return strdup (home);
 }
 
 static char *config_GetAppDir (const char *xdg_name, const char *xdg_default)
@@ -98,16 +97,15 @@ static char *config_GetAppDir (const char *xdg_name, const char *xdg_default)
     /* XDG Base Directory Specification - Version 0.6 */
     snprintf (var, sizeof (var), "XDG_%s_HOME", xdg_name);
 
-    char *psz_home = FromLocale (getenv (var));
-    if( psz_home )
+    const char *home = getenv (var);
+    if (home != NULL)
     {
-        if( asprintf( &psz_dir, "%s/vlc", psz_home ) == -1 )
+        if (asprintf (&psz_dir, "%s/vlc", home) == -1)
             psz_dir = NULL;
-        LocaleFree (psz_home);
         return psz_dir;
     }
 
-    psz_home = config_GetHomeDir ();
+    char *psz_home = config_GetHomeDir ();
     if( psz_home == NULL
      || asprintf( &psz_dir, "%s/%s/vlc", psz_home, xdg_default ) == -1 )
         psz_dir = NULL;
@@ -215,9 +213,7 @@ static char *config_GetTypeDir (const char *xdg_name)
             path = strdup (home);
     }
 
-    char *ret = FromLocaleDup (path);
-    free (path);
-    return ret;
+    return path;
 }
 
 
index 5d8625fe408ac1fbffcfae3b5e05e5e9d81d893a..81dd3a9919173ae54029b661ef868b9cbbc4b9c1 100644 (file)
@@ -42,7 +42,6 @@
 #include <sys/socket.h>
 
 #include <vlc_common.h>
-#include <vlc_charset.h>
 #include <vlc_fs.h>
 #include "libvlc.h" /* vlc_mkdir */
 
@@ -69,19 +68,9 @@ int vlc_open (const char *filename, int flags, ...)
     flags |= O_CLOEXEC;
 #endif
 
-    const char *local_name = ToLocale (filename);
-
-    if (local_name == NULL)
-    {
-        errno = ENOENT;
-        return -1;
-    }
-
-    int fd = open (local_name, flags, mode);
+    int fd = open (filename, flags, mode);
     if (fd != -1)
         fcntl (fd, F_SETFD, FD_CLOEXEC);
-
-    LocaleFree (local_name);
     return fd;
 }
 
@@ -109,15 +98,8 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
     flags |= O_CLOEXEC;
 #endif
 
-    const char *local_name = ToLocale (filename);
-    if (local_name == NULL)
-    {
-        errno = ENOENT;
-        return -1;
-    }
-
 #ifdef HAVE_OPENAT
-    int fd = openat (dir, local_name, flags, mode);
+    int fd = openat (dir, filename, flags, mode);
     if (fd != -1)
         fcntl (fd, F_SETFD, FD_CLOEXEC);
 #else
@@ -125,8 +107,6 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
     errno = ENOSYS;
     (void) mode;
 #endif
-
-    LocaleFree (local_name);
     return fd;
 }
 
@@ -141,16 +121,7 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
  */
 int vlc_mkdir (const char *dirname, mode_t mode)
 {
-    char *locname = ToLocale (dirname);
-    if (unlikely(locname == NULL))
-    {
-        errno = ENOENT;
-        return -1;
-    }
-
-    int res = mkdir (locname, mode);
-    LocaleFree (locname);
-    return res;
+    return mkdir (dirname, mode);
 }
 
 /**
@@ -221,30 +192,11 @@ char *vlc_readdir( DIR *dir )
     if (val != 0)
         errno = val;
     else if (ent != NULL)
-#ifndef __APPLE__
-        path = FromLocaleDup (ent->d_name);
-#else
-        path = FromCharset ("UTF-8-MAC", ent->d_name, strlen (ent->d_name));
-#endif
+        path = strdup (ent->d_name);
     free (buf);
     return path;
 }
 
-static int vlc_statEx (const char *filename, struct stat *buf, bool deref)
-{
-    const char *local_name = ToLocale (filename);
-    if (unlikely(local_name == NULL))
-    {
-        errno = ENOENT;
-        return -1;
-    }
-
-    int res = deref ? stat (local_name, buf)
-                    : lstat (local_name, buf);
-    LocaleFree (local_name);
-    return res;
-}
-
 /**
  * Finds file/inode information, as stat().
  * Consider using fstat() instead, if possible.
@@ -253,7 +205,7 @@ static int vlc_statEx (const char *filename, struct stat *buf, bool deref)
  */
 int vlc_stat (const char *filename, struct stat *buf)
 {
-    return vlc_statEx (filename, buf, true);
+    return stat (filename, buf);
 }
 
 /**
@@ -264,7 +216,7 @@ int vlc_stat (const char *filename, struct stat *buf)
  */
 int vlc_lstat (const char *filename, struct stat *buf)
 {
-    return vlc_statEx (filename, buf, false);
+    return lstat (filename, buf);
 }
 
 /**
@@ -276,16 +228,7 @@ int vlc_lstat (const char *filename, struct stat *buf)
  */
 int vlc_unlink (const char *filename)
 {
-    const char *local_name = ToLocale (filename);
-    if (unlikely(local_name == NULL))
-    {
-        errno = ENOENT;
-        return -1;
-    }
-
-    int ret = unlink (local_name);
-    LocaleFree (local_name);
-    return ret;
+    return unlink (filename);
 }
 
 /**
@@ -298,23 +241,7 @@ int vlc_unlink (const char *filename)
  */
 int vlc_rename (const char *oldpath, const char *newpath)
 {
-    const char *lo = ToLocale (oldpath);
-    if (lo == NULL)
-        goto error;
-
-    const char *ln = ToLocale (newpath);
-    if (ln == NULL)
-    {
-        LocaleFree (lo);
-error:
-        errno = ENOENT;
-        return -1;
-    }
-
-    int ret = rename (lo, ln);
-    LocaleFree (lo);
-    LocaleFree (ln);
-    return ret;
+    return rename (oldpath, newpath);
 }
 
 /**
@@ -333,7 +260,7 @@ char *vlc_getcwd (void)
         /* Make sure $PWD is correct */
         if (stat (pwd, &s1) == 0 && stat (".", &s2) == 0
          && s1.st_dev == s2.st_dev && s1.st_ino == s2.st_ino)
-            return ToLocaleDup (pwd);
+            return strdup (pwd);
     }
 
     /* Otherwise iterate getcwd() until the buffer is big enough */
@@ -347,15 +274,7 @@ char *vlc_getcwd (void)
             break;
 
         if (getcwd (buf, size) != NULL)
-#ifdef ASSUME_UTF8
             return buf;
-#else
-        {
-            char *ret = ToLocaleDup (buf);
-            free (buf);
-            return ret; /* success */
-        }
-#endif
         free (buf);
 
         if (errno != ERANGE)
index aa99c8a9ffb43a51a4a10dca9daa4eb78dd237ae..db2b0ba7f97c2f1a04ea5b5bf9dcf1259a299583 100644 (file)
@@ -29,7 +29,6 @@
 #endif
 
 #include <vlc_common.h>
-#include <vlc_charset.h>
 #include "modules/modules.h"
 
 #include <sys/types.h>
  * Load a dynamically linked library using a system dependent method.
  *
  * \param p_this vlc object
- * \param psz_file library file
+ * \param path library file
  * \param p_handle the module handle returned
  * \return 0 on success as well as the module handle.
  */
-int module_Load( vlc_object_t *p_this, const char *psz_file,
-                 module_handle_t *p_handle, bool lazy )
+int module_Load (vlc_object_t *p_this, const char *path,
+                 module_handle_t *p_handle, bool lazy)
 {
 #if defined (RTLD_NOW)
     const int flags = lazy ? RTLD_LAZY : RTLD_NOW;
@@ -57,16 +56,13 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
 #else
     const int flags = 0;
 #endif
-    char *path = ToLocale( psz_file );
 
-    module_handle_t handle = dlopen( path, flags );
+    module_handle_t handle = dlopen (path, flags);
     if( handle == NULL )
     {
         msg_Warn( p_this, "cannot load module `%s' (%s)", path, dlerror() );
-        LocaleFree( path );
         return -1;
     }
-    LocaleFree( path );
     *p_handle = handle;
     return 0;
 }