mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Fix forgot calls of iconv (replace with g_iconv)
This commit is contained in:
parent
3236fe285c
commit
cada92062a
@ -65,9 +65,9 @@ static char *codeset;
|
||||
// function for encoding specific operations
|
||||
static struct str_class used_class;
|
||||
|
||||
iconv_t str_cnv_to_term;
|
||||
iconv_t str_cnv_from_term;
|
||||
iconv_t str_cnv_not_convert;
|
||||
GIConv str_cnv_to_term;
|
||||
GIConv str_cnv_from_term;
|
||||
GIConv str_cnv_not_convert;
|
||||
|
||||
// if enc is same encoding like on terminal
|
||||
static int
|
||||
@ -273,17 +273,17 @@ str_insert_replace_char (GString * buffer)
|
||||
}
|
||||
|
||||
int
|
||||
str_translate_char (str_conv_t conv, char *keys, size_t ch_size,
|
||||
str_translate_char (GIConv conv, char *keys, size_t ch_size,
|
||||
char *output, size_t out_size)
|
||||
{
|
||||
size_t left;
|
||||
size_t cnv;
|
||||
|
||||
iconv (conv, NULL, NULL, NULL, NULL);
|
||||
g_iconv (conv, NULL, NULL, NULL, NULL);
|
||||
|
||||
left = (ch_size == (size_t) (-1)) ? strlen (keys) : ch_size;
|
||||
|
||||
cnv = iconv (conv, &keys, &left, &output, &out_size);
|
||||
cnv = g_iconv (conv, &keys, &left, &output, &out_size);
|
||||
if (cnv == (size_t) (-1))
|
||||
{
|
||||
if (errno == EINVAL)
|
||||
@ -354,21 +354,21 @@ str_init_strings (const char *termenc)
|
||||
codeset = g_strdup ((termenc != NULL)
|
||||
? termenc : str_detect_termencoding ());
|
||||
|
||||
str_cnv_not_convert = iconv_open (codeset, codeset);
|
||||
str_cnv_not_convert = g_iconv_open (codeset, codeset);
|
||||
if (str_cnv_not_convert == INVALID_CONV)
|
||||
{
|
||||
if (termenc != NULL)
|
||||
{
|
||||
g_free (codeset);
|
||||
codeset = g_strdup (str_detect_termencoding ());
|
||||
str_cnv_not_convert = iconv_open (codeset, codeset);
|
||||
str_cnv_not_convert = g_iconv_open (codeset, codeset);
|
||||
}
|
||||
|
||||
if (str_cnv_not_convert == INVALID_CONV)
|
||||
{
|
||||
g_free (codeset);
|
||||
codeset = g_strdup ("ascii");
|
||||
str_cnv_not_convert = iconv_open (codeset, codeset);
|
||||
str_cnv_not_convert = g_iconv_open (codeset, codeset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ str_init_strings (const char *termenc)
|
||||
void
|
||||
str_uninit_strings ()
|
||||
{
|
||||
iconv_close (str_cnv_not_convert);
|
||||
g_iconv_close (str_cnv_not_convert);
|
||||
}
|
||||
|
||||
const char *
|
||||
|
@ -65,18 +65,17 @@
|
||||
#define J_CENTER_LEFT_FIT 0x14
|
||||
|
||||
// redefinition of iconv_t, so is not needed include iconv.h in other files.
|
||||
typedef iconv_t str_conv_t;
|
||||
#define INVALID_CONV ((iconv_t) (-1))
|
||||
|
||||
// standard convertors
|
||||
extern str_conv_t str_cnv_to_term;
|
||||
extern str_conv_t str_cnv_from_term;
|
||||
extern GIConv str_cnv_to_term;
|
||||
extern GIConv str_cnv_from_term;
|
||||
// from terminal encoding to terminal encoding
|
||||
extern str_conv_t str_cnv_not_convert;
|
||||
extern GIConv str_cnv_not_convert;
|
||||
|
||||
// all functions in str_class must be defined for every encoding
|
||||
struct str_class {
|
||||
int (*vfs_convert_to) (str_conv_t coder, const char *string,
|
||||
int (*vfs_convert_to) (GIConv coder, const char *string,
|
||||
int size, GString *buffer); //I
|
||||
void (*insert_replace_char) (GString *buffer);
|
||||
int (*is_valid_string) (const char *); //I
|
||||
@ -195,7 +194,7 @@ void str_uninit_strings ();
|
||||
* return 0 if conversion was successfully, ESTR_PROBLEM if ch contains only
|
||||
* part of characters, ESTR_FAILURE if conversion is not possible
|
||||
*/
|
||||
int str_translate_char (str_conv_t conv, char *ch, size_t ch_size,
|
||||
int str_translate_char (GIConv conv, char *ch, size_t ch_size,
|
||||
char *output, size_t out_size);
|
||||
|
||||
/* test, if text is valid in terminal encoding
|
||||
|
@ -164,7 +164,7 @@ str_8bit_length2 (const char *text, int size)
|
||||
}
|
||||
|
||||
int
|
||||
str_8bit_vfs_convert_to (str_conv_t coder, const char *string,
|
||||
str_8bit_vfs_convert_to (GIConv coder, const char *string,
|
||||
int size, GString * buffer)
|
||||
{
|
||||
int result;
|
||||
|
@ -330,71 +330,8 @@ str_utf8_questmark_sustb (char **string, size_t * left, GString * buffer)
|
||||
g_string_append_c (buffer, '?');
|
||||
}
|
||||
|
||||
/*
|
||||
static int
|
||||
_str_utf8_vfs_convert_to (str_conv_t coder, const char *string,
|
||||
int size, GString * buffer)
|
||||
{
|
||||
int state = 0;
|
||||
size_t left;
|
||||
size_t nconv;
|
||||
char *composed, *c;
|
||||
const char *start, *end;
|
||||
|
||||
errno = 0;
|
||||
|
||||
size = (size >= 0) ? size : strlen (string);
|
||||
if (coder == (iconv_t) (-1))
|
||||
return ESTR_FAILURE;
|
||||
iconv (coder, NULL, NULL, NULL, NULL);
|
||||
|
||||
start = string;
|
||||
while (size > 0)
|
||||
{
|
||||
end = strchr (start, PATH_SEP);
|
||||
end = (end == NULL || end >= start + size) ? start + size : end + 1;
|
||||
if (g_utf8_validate (start, end - start, NULL))
|
||||
{
|
||||
c = composed =
|
||||
g_utf8_normalize (start, end - start,
|
||||
G_NORMALIZE_DEFAULT_COMPOSE);
|
||||
left = strlen (composed);
|
||||
while (((int) left) > 0)
|
||||
{
|
||||
nconv =
|
||||
iconv (coder, &c, &left, &(buffer->actual),
|
||||
&(buffer->remain));
|
||||
if (nconv == (size_t) (-1))
|
||||
{
|
||||
switch (errno)
|
||||
{
|
||||
case EINVAL:
|
||||
g_free (composed);
|
||||
return ESTR_FAILURE;
|
||||
case EILSEQ:
|
||||
str_utf8_questmark_sustb (&c, &left, buffer);
|
||||
state = ESTR_PROBLEM;
|
||||
break;
|
||||
case E2BIG:
|
||||
str_incrase_buffer (buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free (composed);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_string_append_len (buffer, start, end - start);
|
||||
}
|
||||
size -= end - start;
|
||||
start = end;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
*/
|
||||
static int
|
||||
str_utf8_vfs_convert_to (str_conv_t coder, const char *string,
|
||||
str_utf8_vfs_convert_to (GIConv coder, const char *string,
|
||||
int size, GString * buffer)
|
||||
{
|
||||
int result;
|
||||
|
@ -3654,7 +3654,7 @@ static void
|
||||
view_select_encoding (WView *view)
|
||||
{
|
||||
char *enc;
|
||||
iconv_t conv;
|
||||
GIConv conv;
|
||||
struct cache_line *line;
|
||||
|
||||
enc = input_dialog ("Encoding", "Paste encoding", NULL, "");
|
||||
|
Loading…
Reference in New Issue
Block a user