Remove only supported encodings from path.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
родитель
2a47d77351
Коммит
5007553299
@ -53,6 +53,9 @@
|
||||
|
||||
#include "src/execute.h"
|
||||
#include "src/wtools.h" /* message() */
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "src/charsets.h"
|
||||
#endif
|
||||
|
||||
struct sigaction startup_handler;
|
||||
|
||||
@ -630,7 +633,8 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
{
|
||||
/* "token/../foo" -> "foo" */
|
||||
#if HAVE_CHARSET
|
||||
if (strncmp (s, VFS_ENCODING_PREFIX, enc_prefix_len) == 0)
|
||||
if ((strncmp (s, VFS_ENCODING_PREFIX, enc_prefix_len) == 0)
|
||||
&& (is_supported_encoding (s + enc_prefix_len)))
|
||||
/* special case: remove encoding */
|
||||
str_move (s, p + 1);
|
||||
else
|
||||
@ -657,7 +661,8 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
if (s == lpath + 1)
|
||||
s[0] = 0;
|
||||
#if HAVE_CHARSET
|
||||
else if (strncmp (s, VFS_ENCODING_PREFIX, enc_prefix_len) == 0)
|
||||
else if ((strncmp (s, VFS_ENCODING_PREFIX, enc_prefix_len) == 0)
|
||||
&& (is_supported_encoding (s + enc_prefix_len)))
|
||||
{
|
||||
/* special case: remove encoding */
|
||||
s[0] = '.';
|
||||
|
@ -393,24 +393,6 @@ vfs_get_encoding (const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
/* return if encoding can by used in vfs (is ascci full compactible) */
|
||||
/* contains only a few encoding now */
|
||||
static gboolean
|
||||
vfs_supported_enconding (const char *encoding)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
int t;
|
||||
|
||||
for (t = 0; t < n_codepages; t++)
|
||||
result |= (g_ascii_strncasecmp (encoding, codepages[t].id,
|
||||
strlen (codepages[t].id)) == 0);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* now used only by vfs_translate_path, but could be used in other vfs
|
||||
* plugin to automatic detect encoding
|
||||
* path - path to translate
|
||||
@ -468,8 +450,10 @@ _vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer
|
||||
memcpy (encoding, semi, ms);
|
||||
encoding[ms] = '\0';
|
||||
|
||||
if (vfs_supported_enconding (encoding))
|
||||
#if HAVE_CHARSET
|
||||
if (is_supported_encoding (encoding))
|
||||
coder = str_crt_conv_to (encoding);
|
||||
#endif
|
||||
|
||||
if (coder != INVALID_CONV)
|
||||
{
|
||||
|
@ -162,6 +162,20 @@ get_codepage_index (const char *id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* return if encoding can by used in mc */
|
||||
gboolean
|
||||
is_supported_encoding (const char *encoding)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
size_t t;
|
||||
|
||||
for (t = 0; t < (size_t) n_codepages; t++)
|
||||
result |= (g_ascii_strncasecmp (encoding, codepages[t].id,
|
||||
strlen (codepages[t].id)) == 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static char
|
||||
translate_character (GIConv cd, char c)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ const char *get_codepage_id (const int n);
|
||||
int get_codepage_index (const char *id);
|
||||
int load_codepages_list (void);
|
||||
void free_codepages_list (void);
|
||||
gboolean is_supported_encoding (const char *encoding);
|
||||
char *init_translation_table (int cpsource, int cpdisplay);
|
||||
void convert_to_display (char *str);
|
||||
void convert_from_input (char *str);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user