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

posix: drop support for non-UTF-8 operating systems

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