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 @@
#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;
......
......@@ -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 );
......
......@@ -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() )
......
......@@ -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;
}
......@@ -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)
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -29,7 +29,6 @@
#endif
#include <vlc_common.h>
#include <vlc_charset.h>
#include "modules/modules.h"
#include <sys/types.h>
......@@ -43,12 +42,12 @@
* 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;
}
......
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