mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Merge branch '2827_tweak_without_charset'
* 2827_tweak_without_charset: Tests tweak and cleanup in case of --disable-charset option usage. Core, mceditor, mcviewer and mcdiffviewer code tweak and cleanup Ticket #2827: tweak and cleanup of code in case of --disable-charset option usage.
This commit is contained in:
commit
33e1525eeb
@ -29,8 +29,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -52,6 +50,8 @@ const char *cp_source = NULL;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
#define UNKNCHAR '\001'
|
||||
|
||||
#define OTHER_8BIT "Other_8_bit"
|
||||
|
||||
/*
|
||||
@ -571,5 +571,3 @@ convert_from_8bit_to_utf_c2 (const char input_char)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
@ -5,24 +5,11 @@
|
||||
#ifndef MC__CHARSETS_H
|
||||
#define MC__CHARSETS_H
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#define UNKNCHAR '\001'
|
||||
#else
|
||||
#define convert_to_display_c(c) (c)
|
||||
#define convert_from_input_c(c) (c)
|
||||
#define convert_to_display(str) do {} while (0)
|
||||
#define convert_from_input(str) do {} while (0)
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
#ifdef HAVE_CHARSET
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -104,6 +91,4 @@ convert_from_input_c (int c)
|
||||
return (int) conv_input[c];
|
||||
}
|
||||
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
#endif /* MC__CHARSETS_H */
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include "lib/search.h"
|
||||
#include "lib/strescape.h"
|
||||
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
@ -33,8 +33,6 @@
|
||||
#include "lib/search.h"
|
||||
#include "lib/strescape.h"
|
||||
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
@ -32,9 +32,11 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/search.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
#include "lib/charsets.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
|
@ -30,8 +30,6 @@
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/search.h"
|
||||
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
@ -34,8 +34,6 @@
|
||||
#include "lib/search.h"
|
||||
#include "lib/strescape.h"
|
||||
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
@ -32,8 +32,9 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/search.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
@ -550,7 +550,9 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
|
||||
if (flags & CANON_PATH_REMDOUBLEDOTS)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
const size_t enc_prefix_len = strlen (VFS_ENCODING_PREFIX);
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
/* Collapse "/.." with the previous part of path */
|
||||
p = lpath;
|
||||
|
@ -436,10 +436,12 @@ mc_opendir (const vfs_path_t * vpath)
|
||||
|
||||
path_element->dir.info = info;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
path_element->dir.converter = (path_element->encoding != NULL) ?
|
||||
str_crt_conv_from (path_element->encoding) : str_cnv_from_term;
|
||||
if (path_element->dir.converter == INVALID_CONV)
|
||||
path_element->dir.converter = str_cnv_from_term;
|
||||
#endif
|
||||
|
||||
handle = vfs_new_handle (path_element->class, vfs_path_element_clone (path_element));
|
||||
|
||||
@ -457,7 +459,9 @@ mc_readdir (DIR * dirp)
|
||||
struct vfs_class *vfs;
|
||||
struct dirent *entry = NULL;
|
||||
vfs_path_element_t *vfs_path_element;
|
||||
#ifdef HAVE_CHARSET
|
||||
estr_t state;
|
||||
#endif
|
||||
|
||||
if (!mc_readdir_result)
|
||||
{
|
||||
@ -491,9 +495,14 @@ mc_readdir (DIR * dirp)
|
||||
entry = (*vfs->readdir) (vfs_path_element->dir.info);
|
||||
if (entry == NULL)
|
||||
return NULL;
|
||||
|
||||
g_string_set_size (vfs_str_buffer, 0);
|
||||
#ifdef HAVE_CHARSET
|
||||
state =
|
||||
str_vfs_convert_from (vfs_path_element->dir.converter, entry->d_name, vfs_str_buffer);
|
||||
#else
|
||||
g_string_assign (vfs_str_buffer, entry->d_name);
|
||||
#endif
|
||||
mc_readdir_result->d_ino = entry->d_ino;
|
||||
g_strlcpy (mc_readdir_result->d_name, vfs_str_buffer->str, MAXNAMLEN + 1);
|
||||
}
|
||||
@ -516,11 +525,14 @@ mc_closedir (DIR * dirp)
|
||||
{
|
||||
vfs_path_element_t *vfs_path_element;
|
||||
vfs_path_element = vfs_class_data_find_by_handle (handle);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (vfs_path_element->dir.converter != str_cnv_from_term)
|
||||
{
|
||||
str_close_conv (vfs_path_element->dir.converter);
|
||||
vfs_path_element->dir.converter = INVALID_CONV;
|
||||
}
|
||||
#endif
|
||||
|
||||
result = vfs->closedir ? (*vfs->closedir) (vfs_path_element->dir.info) : -1;
|
||||
vfs_free_handle (handle);
|
||||
|
@ -172,6 +172,8 @@ vfs_canon (const char *path)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
/** get encoding after last #enc: or NULL, if part does not contain #enc:
|
||||
*
|
||||
* @param path string
|
||||
@ -208,6 +210,7 @@ vfs_get_encoding (const char *path)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** Extract the hostname and username from the path
|
||||
@ -380,9 +383,11 @@ vfs_path_from_str_deprecated_parser (char *path, vfs_path_flag_t flags)
|
||||
local = "";
|
||||
element->path = vfs_translate_path_n (local);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
element->encoding = vfs_get_encoding (local);
|
||||
element->dir.converter =
|
||||
(element->encoding != NULL) ? str_crt_conv_from (element->encoding) : INVALID_CONV;
|
||||
#endif
|
||||
|
||||
url_params = strchr (op, ':'); /* skip VFS prefix */
|
||||
if (url_params != NULL)
|
||||
@ -403,9 +408,11 @@ vfs_path_from_str_deprecated_parser (char *path, vfs_path_flag_t flags)
|
||||
element->class = g_ptr_array_index (vfs__classes_list, 0);
|
||||
element->path = vfs_translate_path_n (path);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
element->encoding = vfs_get_encoding (path);
|
||||
element->dir.converter =
|
||||
(element->encoding != NULL) ? str_crt_conv_from (element->encoding) : INVALID_CONV;
|
||||
#endif
|
||||
g_array_prepend_val (vpath->path, element);
|
||||
}
|
||||
|
||||
@ -463,8 +470,9 @@ vfs_path_from_str_uri_parser (char *path, vfs_path_flag_t flags)
|
||||
else
|
||||
{
|
||||
element->path = vfs_translate_path_n (slash_pointer + 1);
|
||||
#ifdef HAVE_CHARSET
|
||||
element->encoding = vfs_get_encoding (slash_pointer);
|
||||
|
||||
#endif
|
||||
*slash_pointer = '\0';
|
||||
}
|
||||
vfs_path_url_split (element, url_delimiter);
|
||||
@ -472,10 +480,14 @@ vfs_path_from_str_uri_parser (char *path, vfs_path_flag_t flags)
|
||||
else
|
||||
{
|
||||
element->path = vfs_translate_path_n (url_delimiter);
|
||||
#ifdef HAVE_CHARSET
|
||||
element->encoding = vfs_get_encoding (url_delimiter);
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_CHARSET
|
||||
element->dir.converter =
|
||||
(element->encoding != NULL) ? str_crt_conv_from (element->encoding) : INVALID_CONV;
|
||||
#endif
|
||||
g_array_prepend_val (vpath->path, element);
|
||||
|
||||
if ((real_vfs_prefix_start > path && *(real_vfs_prefix_start) == PATH_SEP) ||
|
||||
@ -490,9 +502,11 @@ vfs_path_from_str_uri_parser (char *path, vfs_path_flag_t flags)
|
||||
element = g_new0 (vfs_path_element_t, 1);
|
||||
element->class = g_ptr_array_index (vfs__classes_list, 0);
|
||||
element->path = vfs_translate_path_n (path);
|
||||
#ifdef HAVE_CHARSET
|
||||
element->encoding = vfs_get_encoding (path);
|
||||
element->dir.converter =
|
||||
(element->encoding != NULL) ? str_crt_conv_from (element->encoding) : INVALID_CONV;
|
||||
#endif
|
||||
g_array_prepend_val (vpath->path, element);
|
||||
}
|
||||
|
||||
@ -533,6 +547,8 @@ vfs_path_tokens_add_class_info (const vfs_path_element_t * element, GString * re
|
||||
|
||||
g_free (url_str);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (element->encoding != NULL)
|
||||
{
|
||||
if (ret_tokens->len > 0 && ret_tokens->str[ret_tokens->len - 1] != PATH_SEP)
|
||||
@ -541,6 +557,7 @@ vfs_path_tokens_add_class_info (const vfs_path_element_t * element, GString * re
|
||||
g_string_append (ret_tokens, element->encoding);
|
||||
g_string_append (ret_tokens, PATH_SEP_STR);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_string_append (ret_tokens, element_tokens->str);
|
||||
}
|
||||
@ -647,6 +664,7 @@ vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_fl
|
||||
g_free (url_str);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if ((flags & VPF_RECODE) == 0 && vfs_path_element_need_cleanup_converter (element))
|
||||
{
|
||||
if ((flags & VPF_HIDE_CHARSET) == 0)
|
||||
@ -662,6 +680,7 @@ vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_fl
|
||||
g_string_set_size (recode_buffer, 0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
vfs_append_from_path (element->path, is_relative);
|
||||
}
|
||||
@ -847,12 +866,14 @@ vfs_path_element_clone (const vfs_path_element_t * element)
|
||||
new_element->port = element->port;
|
||||
new_element->path = g_strdup (element->path);
|
||||
new_element->class = element->class;
|
||||
new_element->encoding = g_strdup (element->encoding);
|
||||
new_element->vfs_prefix = g_strdup (element->vfs_prefix);
|
||||
#ifdef HAVE_CHARSET
|
||||
new_element->encoding = g_strdup (element->encoding);
|
||||
if (vfs_path_element_need_cleanup_converter (element) && new_element->encoding != NULL)
|
||||
new_element->dir.converter = str_crt_conv_from (new_element->encoding);
|
||||
else
|
||||
new_element->dir.converter = element->dir.converter;
|
||||
#endif
|
||||
new_element->dir.info = element->dir.info;
|
||||
|
||||
return new_element;
|
||||
@ -876,13 +897,14 @@ vfs_path_element_free (vfs_path_element_t * element)
|
||||
g_free (element->password);
|
||||
g_free (element->host);
|
||||
g_free (element->path);
|
||||
g_free (element->encoding);
|
||||
g_free (element->vfs_prefix);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
g_free (element->encoding);
|
||||
|
||||
if (vfs_path_element_need_cleanup_converter (element))
|
||||
{
|
||||
str_close_conv (element->dir.converter);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_free (element);
|
||||
}
|
||||
@ -1010,12 +1032,13 @@ vfs_prefix_to_class (const char *prefix)
|
||||
*
|
||||
* @return TRUE if need cleanup converter or FALSE otherwise
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
gboolean
|
||||
vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element)
|
||||
{
|
||||
return (element->dir.converter != str_cnv_from_term && element->dir.converter != INVALID_CONV);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
@ -1051,8 +1074,9 @@ vfs_path_serialize (const vfs_path_t * vpath, GError ** error)
|
||||
|
||||
mc_config_set_string_raw (cpath, groupname, "path", element->path);
|
||||
mc_config_set_string_raw (cpath, groupname, "class-name", element->class->name);
|
||||
#ifdef HAVE_CHARSET
|
||||
mc_config_set_string_raw (cpath, groupname, "encoding", element->encoding);
|
||||
|
||||
#endif
|
||||
mc_config_set_string_raw (cpath, groupname, "vfs_prefix", element->vfs_prefix);
|
||||
|
||||
mc_config_set_string_raw (cpath, groupname, "user", element->user);
|
||||
@ -1120,9 +1144,12 @@ vfs_path_deserialize (const char *data, GError ** error)
|
||||
g_free (cfg_value);
|
||||
|
||||
element->path = mc_config_get_string_raw (cpath, groupname, "path", NULL);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
element->encoding = mc_config_get_string_raw (cpath, groupname, "encoding", NULL);
|
||||
element->dir.converter =
|
||||
(element->encoding != NULL) ? str_crt_conv_from (element->encoding) : INVALID_CONV;
|
||||
#endif
|
||||
|
||||
element->vfs_prefix = mc_config_get_string_raw (cpath, groupname, "vfs_prefix", NULL);
|
||||
|
||||
|
@ -38,12 +38,16 @@ typedef struct
|
||||
int port;
|
||||
char *path;
|
||||
struct vfs_class *class;
|
||||
#ifdef HAVE_CHARSET
|
||||
char *encoding;
|
||||
#endif
|
||||
char *vfs_prefix;
|
||||
|
||||
struct
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
GIConv converter;
|
||||
#endif
|
||||
DIR *info;
|
||||
} dir;
|
||||
} vfs_path_element_t;
|
||||
@ -77,7 +81,9 @@ void vfs_path_element_free (vfs_path_element_t * element);
|
||||
|
||||
struct vfs_class *vfs_prefix_to_class (const char *prefix);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
gboolean vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element);
|
||||
#endif
|
||||
|
||||
char *vfs_path_serialize (const vfs_path_t * vpath, GError ** error);
|
||||
vfs_path_t *vfs_path_deserialize (const char *data, GError ** error);
|
||||
|
@ -328,7 +328,9 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
}
|
||||
|
||||
path_element->host = g_strdup (rest);
|
||||
#ifdef HAVE_CHARSET
|
||||
path_element->dir.converter = INVALID_CONV;
|
||||
#endif
|
||||
|
||||
return path_element;
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ static vfs_path_t *current_path = NULL;
|
||||
static GPtrArray *vfs_openfiles;
|
||||
static long vfs_free_handle_list = -1;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* now used only by vfs_translate_path, but could be used in other vfs
|
||||
@ -108,9 +109,10 @@ static long vfs_free_handle_list = -1;
|
||||
static estr_t
|
||||
_vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer)
|
||||
{
|
||||
estr_t state = ESTR_SUCCESS;
|
||||
#ifdef HAVE_CHARSET
|
||||
const char *semi;
|
||||
const char *slash;
|
||||
estr_t state = ESTR_SUCCESS;
|
||||
|
||||
if (size == 0)
|
||||
return ESTR_SUCCESS;
|
||||
@ -148,10 +150,8 @@ _vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer
|
||||
memcpy (encoding, semi, ms);
|
||||
encoding[ms] = '\0';
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (is_supported_encoding (encoding))
|
||||
coder = str_crt_conv_to (encoding);
|
||||
#endif
|
||||
|
||||
if (coder != INVALID_CONV)
|
||||
{
|
||||
@ -169,6 +169,12 @@ _vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer
|
||||
/* path can be translated whole at once */
|
||||
state = str_vfs_convert_to (defcnv, path, size, buffer);
|
||||
}
|
||||
#else
|
||||
(void) size;
|
||||
(void) defcnv;
|
||||
|
||||
g_string_assign (buffer, path);
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
return state;
|
||||
}
|
||||
@ -579,6 +585,7 @@ _vfs_get_cwd (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
/**
|
||||
* Change encoding for last part (vfs_path_element_t) of vpath
|
||||
*
|
||||
@ -607,6 +614,7 @@ vfs_change_encoding (vfs_path_t * vpath, const char *encoding)
|
||||
|
||||
return vpath;
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -270,7 +270,9 @@ void vfs_free_handle (int handle);
|
||||
void vfs_setup_cwd (void);
|
||||
char *_vfs_get_cwd (void);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
vfs_path_t *vfs_change_encoding (vfs_path_t * vpath, const char *encoding);
|
||||
#endif
|
||||
|
||||
int vfs_preallocate (int dest_desc, off_t src_fsize, off_t dest_fsize);
|
||||
|
||||
|
@ -31,7 +31,9 @@
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/tty/key.h"
|
||||
#include "lib/widget.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "src/history.h"
|
||||
|
||||
|
@ -43,7 +43,9 @@
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h"
|
||||
#include "lib/strutil.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
|
||||
#include "src/filemanager/cmd.h" /* do_edit_at_line(), view_other_cmd() */
|
||||
@ -52,7 +54,9 @@
|
||||
|
||||
#include "src/keybind-defaults.h"
|
||||
#include "src/history.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "src/selcodepage.h"
|
||||
#endif
|
||||
|
||||
#include "ydiff.h"
|
||||
#include "internal.h"
|
||||
@ -142,16 +146,14 @@ dview_set_codeset (WDiff * dview)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
static void
|
||||
dview_select_encoding (WDiff * dview)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
if (do_select_codepage ())
|
||||
dview_set_codeset (dview);
|
||||
#else
|
||||
(void) dview;
|
||||
#endif
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
@ -2602,8 +2604,8 @@ dview_display_file (const WDiff * dview, int ord, int r, int c, int height, int
|
||||
next_ch =
|
||||
convert_from_utf_to_current_c (next_ch, dview->converter);
|
||||
else
|
||||
#endif
|
||||
next_ch = convert_to_display_c (next_ch);
|
||||
#endif
|
||||
|
||||
tty_print_anychar (next_ch);
|
||||
col++;
|
||||
@ -2678,8 +2680,8 @@ dview_display_file (const WDiff * dview, int ord, int r, int c, int height, int
|
||||
else if (dview->utf8)
|
||||
next_ch = convert_from_utf_to_current_c (next_ch, dview->converter);
|
||||
else
|
||||
#endif
|
||||
next_ch = convert_to_display_c (next_ch);
|
||||
#endif
|
||||
|
||||
tty_print_anychar (next_ch);
|
||||
col++;
|
||||
@ -3160,7 +3162,9 @@ dview_handle_key (WDiff * dview, int key)
|
||||
{
|
||||
unsigned long command;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
key = convert_from_input_c (key);
|
||||
#endif
|
||||
|
||||
command = keybind_lookup_keymap_command (diff_map, key);
|
||||
if ((command != CK_IgnoreKey) && (dview_execute_cmd (dview, command) == MSG_HANDLED))
|
||||
|
@ -60,13 +60,17 @@
|
||||
#include "lib/util.h" /* tilde_expand() */
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/widget.h"
|
||||
#include "lib/charsets.h"
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "src/history.h"
|
||||
#include "src/setup.h" /* option_tab_spacing */
|
||||
#include "src/main.h" /* mactos_t */
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "src/selcodepage.h"
|
||||
#endif
|
||||
#include "src/keybind-defaults.h"
|
||||
#include "src/util.h" /* check_for_default() */
|
||||
#include "src/filemanager/layout.h" /* mc_refresh() */
|
||||
|
@ -32,7 +32,9 @@
|
||||
#include "lib/search.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/widget.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "src/main.h"
|
||||
#include "src/history.h"
|
||||
|
@ -48,7 +48,10 @@
|
||||
#include "lib/skin.h"
|
||||
#include "lib/strutil.h" /* utf string functions */
|
||||
#include "lib/util.h" /* is_printable() */
|
||||
#include "lib/widget.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "src/setup.h" /* edit_tab_spacing */
|
||||
#include "src/main.h" /* macro_index */
|
||||
@ -729,8 +732,8 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
||||
else if (edit->utf8)
|
||||
c = convert_from_utf_to_current_c (c, edit->converter);
|
||||
else
|
||||
#endif
|
||||
c = convert_to_display_c (c);
|
||||
#endif
|
||||
|
||||
/* Caret notation for control characters */
|
||||
if (c < 32)
|
||||
|
@ -47,7 +47,9 @@
|
||||
#include "lib/tty/key.h" /* KEY_M_SHIFT */
|
||||
#include "lib/strutil.h" /* str_isutf8 () */
|
||||
#include "lib/util.h" /* is_printable() */
|
||||
#include "lib/charsets.h" /* convert_from_input_c() */
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "editwidget.h" /* WEdit */
|
||||
@ -79,12 +81,19 @@ edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch)
|
||||
{
|
||||
unsigned long command = (unsigned long) CK_InsertChar;
|
||||
int char_for_insertion = -1;
|
||||
int c;
|
||||
|
||||
/* an ordinary insertable character */
|
||||
if (!edit->extmod && x_key < 256)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
#ifndef HAVE_CHARSET
|
||||
if (is_printable (x_key))
|
||||
{
|
||||
char_for_insertion = x_key;
|
||||
goto fin;
|
||||
}
|
||||
#else
|
||||
int c;
|
||||
|
||||
if (edit->charpoint >= 4)
|
||||
{
|
||||
edit->charpoint = 0;
|
||||
@ -100,84 +109,67 @@ edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch)
|
||||
if (!mc_global.utf8_display)
|
||||
{
|
||||
/* source in 8-bit codeset */
|
||||
if (!edit->utf8)
|
||||
c = convert_from_input_c (x_key);
|
||||
|
||||
if (is_printable (c))
|
||||
{
|
||||
#endif /* HAVE_CHARSET */
|
||||
c = convert_from_input_c (x_key);
|
||||
if (is_printable (c))
|
||||
{
|
||||
if (!edit->utf8)
|
||||
char_for_insertion = c;
|
||||
goto fin;
|
||||
}
|
||||
#ifdef HAVE_CHARSET
|
||||
}
|
||||
else
|
||||
{
|
||||
c = convert_from_input_c (x_key);
|
||||
if (is_printable (c))
|
||||
{
|
||||
else
|
||||
char_for_insertion = convert_from_8bit_to_utf_c2 ((unsigned char) x_key);
|
||||
goto fin;
|
||||
}
|
||||
goto fin;
|
||||
}
|
||||
/* UTF-8 locale */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* source in UTF-8 codeset */
|
||||
/* UTF-8 locale */
|
||||
int res;
|
||||
|
||||
res = str_is_valid_char (edit->charbuf, edit->charpoint);
|
||||
if (res < 0 && res != -2)
|
||||
{
|
||||
edit->charpoint = 0; /* broken multibyte char, skip */
|
||||
goto fin;
|
||||
}
|
||||
|
||||
if (edit->utf8)
|
||||
{
|
||||
int res = str_is_valid_char (edit->charbuf, edit->charpoint);
|
||||
/* source in UTF-8 codeset */
|
||||
if (res < 0)
|
||||
{
|
||||
if (res != -2)
|
||||
{
|
||||
edit->charpoint = 0; /* broken multibyte char, skip */
|
||||
goto fin;
|
||||
}
|
||||
char_for_insertion = x_key;
|
||||
goto fin;
|
||||
}
|
||||
else
|
||||
{
|
||||
edit->charbuf[edit->charpoint] = '\0';
|
||||
edit->charpoint = 0;
|
||||
if (g_unichar_isprint (g_utf8_get_char (edit->charbuf)))
|
||||
{
|
||||
char_for_insertion = x_key;
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
|
||||
/* 8-bit source */
|
||||
edit->charbuf[edit->charpoint] = '\0';
|
||||
edit->charpoint = 0;
|
||||
if (g_unichar_isprint (g_utf8_get_char (edit->charbuf)))
|
||||
{
|
||||
char_for_insertion = x_key;
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int res = str_is_valid_char (edit->charbuf, edit->charpoint);
|
||||
/* 8-bit source */
|
||||
if (res < 0)
|
||||
{
|
||||
if (res != -2)
|
||||
{
|
||||
edit->charpoint = 0; /* broken multibyte char, skip */
|
||||
goto fin;
|
||||
}
|
||||
/* not finised multibyte input (in meddle multibyte utf-8 char) */
|
||||
goto fin;
|
||||
}
|
||||
else
|
||||
|
||||
if (g_unichar_isprint (g_utf8_get_char (edit->charbuf)))
|
||||
{
|
||||
if (g_unichar_isprint (g_utf8_get_char (edit->charbuf)))
|
||||
{
|
||||
c = convert_from_utf_to_current (edit->charbuf);
|
||||
edit->charbuf[0] = '\0';
|
||||
edit->charpoint = 0;
|
||||
char_for_insertion = c;
|
||||
goto fin;
|
||||
}
|
||||
/* unprinteble utf input, skip it */
|
||||
c = convert_from_utf_to_current (edit->charbuf);
|
||||
edit->charbuf[0] = '\0';
|
||||
edit->charpoint = 0;
|
||||
char_for_insertion = c;
|
||||
goto fin;
|
||||
}
|
||||
|
||||
/* unprinteble utf input, skip it */
|
||||
edit->charbuf[0] = '\0';
|
||||
edit->charpoint = 0;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
@ -1740,11 +1740,13 @@ toggle_listing_cmd (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
void
|
||||
encoding_cmd (void)
|
||||
{
|
||||
if (SELECTED_IS_PANEL)
|
||||
panel_change_encoding (MENU_PANEL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -101,7 +101,9 @@ void quick_cmd_no_menu (void);
|
||||
void info_cmd_no_menu (void);
|
||||
void quick_view_cmd (void);
|
||||
void toggle_listing_cmd (void);
|
||||
#ifdef HAVE_CHARSET
|
||||
void encoding_cmd (void);
|
||||
#endif
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
#endif /* MC__CMD_H */
|
||||
|
@ -46,7 +46,9 @@
|
||||
#include "lib/util.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/widget.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h" /* get_codepage_index */
|
||||
#endif
|
||||
|
||||
#include "src/setup.h" /* use_file_to_check_type */
|
||||
#include "src/execute.h"
|
||||
@ -601,7 +603,9 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_
|
||||
|
||||
/* Following variables are valid if *have_type is 1 */
|
||||
static char content_string[2048];
|
||||
#ifdef HAVE_CHARSET
|
||||
static char encoding_id[21]; /* CSISO51INISCYRILLIC -- 20 */
|
||||
#endif
|
||||
static size_t content_shift = 0;
|
||||
static int got_data = 0;
|
||||
|
||||
|
@ -684,20 +684,27 @@ static void
|
||||
put_current_path (void)
|
||||
{
|
||||
char *cwd_path;
|
||||
vfs_path_t *cwd_vpath;
|
||||
|
||||
if (!command_prompt)
|
||||
return;
|
||||
|
||||
cwd_vpath = remove_encoding_from_path (current_panel->cwd_vpath);
|
||||
cwd_path = vfs_path_to_str (cwd_vpath);
|
||||
command_insert (cmdline, cwd_path, FALSE);
|
||||
#ifdef HAVE_CHARSET
|
||||
{
|
||||
vfs_path_t *cwd_vpath;
|
||||
|
||||
cwd_vpath = remove_encoding_from_path (current_panel->cwd_vpath);
|
||||
cwd_path = vfs_path_to_str (cwd_vpath);
|
||||
vfs_path_free (cwd_vpath);
|
||||
}
|
||||
#else
|
||||
cwd_path = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
#endif
|
||||
|
||||
command_insert (cmdline, cwd_path, FALSE);
|
||||
if (cwd_path[strlen (cwd_path) - 1] != PATH_SEP)
|
||||
command_insert (cmdline, PATH_SEP_STR, FALSE);
|
||||
|
||||
g_free (cwd_path);
|
||||
vfs_path_free (cwd_vpath);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -706,7 +713,6 @@ static void
|
||||
put_other_path (void)
|
||||
{
|
||||
char *cwd_path;
|
||||
vfs_path_t *cwd_vpath;
|
||||
|
||||
if (get_other_type () != view_listing)
|
||||
return;
|
||||
@ -714,15 +720,23 @@ put_other_path (void)
|
||||
if (!command_prompt)
|
||||
return;
|
||||
|
||||
cwd_vpath = remove_encoding_from_path (other_panel->cwd_vpath);
|
||||
cwd_path = vfs_path_to_str (cwd_vpath);
|
||||
command_insert (cmdline, cwd_path, FALSE);
|
||||
#ifdef HAVE_CHARSET
|
||||
{
|
||||
vfs_path_t *cwd_vpath;
|
||||
|
||||
cwd_vpath = remove_encoding_from_path (other_panel->cwd_vpath);
|
||||
cwd_path = vfs_path_to_str (cwd_vpath);
|
||||
vfs_path_free (cwd_vpath);
|
||||
}
|
||||
#else
|
||||
cwd_path = vfs_path_to_str (other_panel->cwd_vpath);
|
||||
#endif
|
||||
|
||||
command_insert (cmdline, cwd_path, FALSE);
|
||||
if (cwd_path[strlen (cwd_path) - 1] != PATH_SEP)
|
||||
command_insert (cmdline, PATH_SEP_STR, FALSE);
|
||||
|
||||
g_free (cwd_path);
|
||||
vfs_path_free (cwd_vpath);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -58,7 +58,9 @@
|
||||
|
||||
#include "src/setup.h" /* For loading/saving panel options */
|
||||
#include "src/execute.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "src/selcodepage.h" /* select_charset (), SELECT_CHARSET_NO_TRANSLATE */
|
||||
#endif
|
||||
#include "src/keybind-defaults.h" /* global_keymap_t */
|
||||
#include "src/subshell.h" /* do_subshell_chdir() */
|
||||
|
||||
@ -1217,6 +1219,7 @@ panel_correct_path_to_show (WPanel * panel)
|
||||
* @return newly allocated string or NULL if path charset is same as system charset
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
static char *
|
||||
panel_get_encoding_info_str (WPanel * panel)
|
||||
{
|
||||
@ -1229,6 +1232,7 @@ panel_get_encoding_info_str (WPanel * panel)
|
||||
|
||||
return ret_str;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
@ -1264,6 +1268,7 @@ show_dir (WPanel * panel)
|
||||
|
||||
if (panel->is_panelized)
|
||||
tty_printf (" %s ", _("Panelize"));
|
||||
#ifdef HAVE_CHARSET
|
||||
else
|
||||
{
|
||||
tmp = panel_get_encoding_info_str (panel);
|
||||
@ -1274,6 +1279,8 @@ show_dir (WPanel * panel)
|
||||
g_free (tmp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (panel->active)
|
||||
tty_setcolor (REVERSE_COLOR);
|
||||
|
||||
@ -3802,60 +3809,6 @@ update_one_panel (int which, panel_update_flags_t flags, const char *current_fil
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Remove encode info from last path element.
|
||||
*
|
||||
*/
|
||||
|
||||
vfs_path_t *
|
||||
remove_encoding_from_path (const vfs_path_t * vpath)
|
||||
{
|
||||
vfs_path_t *ret_vpath;
|
||||
GString *tmp_conv;
|
||||
int indx;
|
||||
|
||||
ret_vpath = vfs_path_new ();
|
||||
|
||||
tmp_conv = g_string_new ("");
|
||||
|
||||
for (indx = 0; indx < vfs_path_elements_count (vpath); indx++)
|
||||
{
|
||||
GIConv converter;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
path_element = vfs_path_element_clone (vfs_path_get_by_index (vpath, indx));
|
||||
vfs_path_add_element (ret_vpath, path_element);
|
||||
|
||||
if (path_element->encoding == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
converter = str_crt_conv_to (path_element->encoding);
|
||||
if (converter == INVALID_CONV)
|
||||
continue;
|
||||
|
||||
g_free (path_element->encoding);
|
||||
path_element->encoding = NULL;
|
||||
|
||||
str_vfs_convert_from (converter, path_element->path, tmp_conv);
|
||||
|
||||
g_free (path_element->path);
|
||||
path_element->path = g_strdup (tmp_conv->str);
|
||||
|
||||
g_string_set_size (tmp_conv, 0);
|
||||
|
||||
str_close_conv (converter);
|
||||
str_close_conv (path_element->dir.converter);
|
||||
path_element->dir.converter = INVALID_CONV;
|
||||
}
|
||||
g_string_free (tmp_conv, TRUE);
|
||||
return ret_vpath;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
@ -4111,7 +4064,9 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
|
||||
panel->panel_name = g_strdup (panel_name);
|
||||
panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
panel->codepage = SELECT_CHARSET_NO_TRANSLATE;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < LIST_TYPES; i++)
|
||||
panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
|
||||
@ -4146,7 +4101,9 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
|
||||
|
||||
if (mc_chdir (panel->cwd_vpath) != 0)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
panel->codepage = SELECT_CHARSET_NO_TRANSLATE;
|
||||
#endif
|
||||
vfs_setup_cwd ();
|
||||
vfs_path_free (panel->cwd_vpath);
|
||||
panel->cwd_vpath = vfs_path_clone (vfs_get_raw_current_dir ());
|
||||
@ -4525,11 +4482,11 @@ panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order)
|
||||
* @param panel WPanel object
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
void
|
||||
panel_change_encoding (WPanel * panel)
|
||||
{
|
||||
const char *encoding = NULL;
|
||||
#ifdef HAVE_CHARSET
|
||||
char *errmsg;
|
||||
int r;
|
||||
|
||||
@ -4562,7 +4519,6 @@ panel_change_encoding (WPanel * panel)
|
||||
}
|
||||
|
||||
encoding = get_codepage_id (panel->codepage);
|
||||
#endif
|
||||
if (encoding != NULL)
|
||||
{
|
||||
char *cd_path;
|
||||
@ -4575,6 +4531,57 @@ panel_change_encoding (WPanel * panel)
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Remove encode info from last path element.
|
||||
*
|
||||
*/
|
||||
vfs_path_t *
|
||||
remove_encoding_from_path (const vfs_path_t * vpath)
|
||||
{
|
||||
vfs_path_t *ret_vpath;
|
||||
GString *tmp_conv;
|
||||
int indx;
|
||||
|
||||
ret_vpath = vfs_path_new ();
|
||||
|
||||
tmp_conv = g_string_new ("");
|
||||
|
||||
for (indx = 0; indx < vfs_path_elements_count (vpath); indx++)
|
||||
{
|
||||
GIConv converter;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
path_element = vfs_path_element_clone (vfs_path_get_by_index (vpath, indx));
|
||||
vfs_path_add_element (ret_vpath, path_element);
|
||||
|
||||
if (path_element->encoding == NULL)
|
||||
continue;
|
||||
|
||||
converter = str_crt_conv_to (path_element->encoding);
|
||||
if (converter == INVALID_CONV)
|
||||
continue;
|
||||
|
||||
g_free (path_element->encoding);
|
||||
path_element->encoding = NULL;
|
||||
|
||||
str_vfs_convert_from (converter, path_element->path, tmp_conv);
|
||||
|
||||
g_free (path_element->path);
|
||||
path_element->path = g_strdup (tmp_conv->str);
|
||||
|
||||
g_string_set_size (tmp_conv, 0);
|
||||
|
||||
str_close_conv (converter);
|
||||
str_close_conv (path_element->dir.converter);
|
||||
path_element->dir.converter = INVALID_CONV;
|
||||
}
|
||||
g_string_free (tmp_conv, TRUE);
|
||||
return ret_vpath;
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* This routine reloads the directory in both panels. It tries to
|
||||
|
@ -119,7 +119,9 @@ typedef struct WPanel
|
||||
char *panel_name; /* The panel name */
|
||||
struct stat dir_stat; /* Stat of current dir: used by execute () */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
int codepage; /* panel codepage */
|
||||
#endif
|
||||
|
||||
gboolean searching;
|
||||
char search_buffer[MC_MAXFILENAMELEN];
|
||||
@ -147,7 +149,11 @@ void panel_clean_dir (WPanel * panel);
|
||||
void panel_reload (WPanel * panel);
|
||||
void panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order);
|
||||
void panel_re_sort (WPanel * panel);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
void panel_change_encoding (WPanel * panel);
|
||||
vfs_path_t *remove_encoding_from_path (const vfs_path_t * vpath);
|
||||
#endif
|
||||
|
||||
void update_panels (panel_update_flags_t flags, const char *current_file);
|
||||
int set_panel_formats (WPanel * p);
|
||||
@ -164,8 +170,6 @@ void do_file_mark (WPanel * panel, int idx, int val);
|
||||
|
||||
gboolean do_panel_cd (struct WPanel *panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
|
||||
|
||||
vfs_path_t *remove_encoding_from_path (const vfs_path_t * vpath);
|
||||
|
||||
gsize panel_get_num_of_sortable_fields (void);
|
||||
const char **panel_get_sortable_fields (gsize *);
|
||||
const panel_field_t *panel_get_field_by_id (const char *);
|
||||
|
@ -31,8 +31,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -176,5 +174,3 @@ do_select_codepage (void)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
@ -55,7 +55,9 @@
|
||||
#include "lib/lock.h" /* lock_file() */
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
|
||||
#include "src/filemanager/layout.h"
|
||||
@ -513,7 +515,9 @@ mcview_handle_key (mcview_t * view, int key)
|
||||
{
|
||||
unsigned long command;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
key = convert_from_input_c (key);
|
||||
#endif
|
||||
|
||||
if (view->hex_mode)
|
||||
{
|
||||
|
@ -43,7 +43,9 @@
|
||||
#include "lib/search.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/widget.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "src/history.h"
|
||||
|
||||
|
@ -47,7 +47,9 @@
|
||||
#include "lib/lock.h" /* lock_file() and unlock_file() */
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@ -72,6 +74,7 @@ static const char hex_char[] = "0123456789ABCDEF";
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
static int
|
||||
utf8_to_int (char *str, int *char_width, gboolean * result)
|
||||
{
|
||||
@ -114,6 +117,7 @@ utf8_to_int (char *str, int *char_width, gboolean * result)
|
||||
*char_width = width;
|
||||
return ch;
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
@ -139,7 +143,9 @@ mcview_display_hex (mcview_t * view)
|
||||
int c;
|
||||
mark_t boldflag = MARK_NORMAL;
|
||||
struct hexedit_change_node *curr = view->change_list;
|
||||
#ifdef HAVE_CHARSET
|
||||
int ch = 0;
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
char hex_buff[10]; /* A temporary buffer for sprintf and mvwaddstr */
|
||||
int bytes; /* Number of bytes already printed on the line */
|
||||
@ -202,7 +208,7 @@ mcview_display_hex (mcview_t * view)
|
||||
curr = corr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_CHARSET */
|
||||
if (!mcview_get_byte (view, from, &c))
|
||||
break;
|
||||
|
||||
@ -297,7 +303,9 @@ mcview_display_hex (mcview_t * view)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
c = convert_to_display_c (c);
|
||||
#endif
|
||||
|
||||
if (!is_printable (c))
|
||||
c = '.';
|
||||
@ -312,9 +320,7 @@ mcview_display_hex (mcview_t * view)
|
||||
tty_print_anychar (ch);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
tty_print_char (c);
|
||||
}
|
||||
}
|
||||
|
||||
/* Save the cursor position for mcview_place_cursor() */
|
||||
|
@ -44,10 +44,14 @@
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h" /* save_file_position() */
|
||||
#include "lib/widget.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "src/main.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "src/selcodepage.h"
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
#include "mcviewer.h"
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h" /* load_file_position() */
|
||||
#include "lib/widget.h"
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "src/main.h"
|
||||
|
||||
|
@ -39,7 +39,9 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/skin.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "src/setup.h" /* option_tab_spacing */
|
||||
|
||||
@ -227,19 +229,10 @@ mcview_display_nroff (mcview_t * view)
|
||||
if (!g_unichar_isprint (c))
|
||||
c = '.';
|
||||
}
|
||||
else if (view->utf8)
|
||||
c = convert_from_utf_to_current_c (c, view->converter);
|
||||
else
|
||||
{
|
||||
if (view->utf8)
|
||||
{
|
||||
c = convert_from_utf_to_current_c (c, view->converter);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
c = convert_to_display_c (c);
|
||||
#ifdef HAVE_CHARSET
|
||||
}
|
||||
}
|
||||
c = convert_to_display_c (c);
|
||||
#endif
|
||||
tty_print_anychar (c);
|
||||
}
|
||||
|
@ -40,7 +40,9 @@
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/skin.h"
|
||||
#include "lib/util.h" /* is_printable() */
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "src/setup.h" /* option_tab_spacing */
|
||||
|
||||
@ -168,8 +170,9 @@ mcview_display_text (mcview_t * view)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
c = convert_to_display_c (c);
|
||||
|
||||
#endif
|
||||
if (!is_printable (c))
|
||||
c = '.';
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ TESTS = \
|
||||
path_cmp \
|
||||
path_len \
|
||||
path_manipulations \
|
||||
path_recode \
|
||||
path_serialize \
|
||||
relative_cd \
|
||||
tempdir \
|
||||
@ -24,6 +23,10 @@ TESTS = \
|
||||
vfs_split \
|
||||
vfs_s_get_path
|
||||
|
||||
if CHARSET
|
||||
TESTS += path_recode
|
||||
endif
|
||||
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
canonicalize_pathname_SOURCES = \
|
||||
|
@ -26,11 +26,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -49,13 +47,17 @@ setup (void)
|
||||
vfs_setup_work_dir ();
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
#ifdef HAVE_CHARSET
|
||||
load_codepages_list ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
free_codepages_list ();
|
||||
#endif
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
@ -79,9 +81,10 @@ START_TEST (test_path_compare)
|
||||
|
||||
path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", ==0);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
path_cmp_one_check ("/#enc:KOI8-R/тестовый/путь", "/тестовый/путь", <0);
|
||||
|
||||
path_cmp_one_check ("/тестовый/путь", "/#enc:KOI8-R/тестовый/путь", >0);
|
||||
#endif
|
||||
|
||||
path_cmp_one_check (NULL, "/тестовый/путь", -1);
|
||||
path_cmp_one_check ("/тестовый/путь", NULL, -1);
|
||||
|
@ -26,11 +26,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -49,12 +47,18 @@ setup (void)
|
||||
vfs_setup_work_dir ();
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
#ifdef HAVE_CHARSET
|
||||
load_codepages_list ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
free_codepages_list ();
|
||||
#endif
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
}
|
||||
@ -74,8 +78,9 @@ START_TEST (test_path_length)
|
||||
size_t result;
|
||||
|
||||
path_len_one_check ("/тестовый/путь", 26);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
path_len_one_check ("/#enc:KOI8-R/тестовый/путь", 38);
|
||||
#endif
|
||||
path_len_one_check (NULL, 0);
|
||||
}
|
||||
END_TEST
|
||||
|
@ -26,11 +26,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -73,13 +71,17 @@ setup (void)
|
||||
vfs_register_class (&vfs_test_ops3);
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
#ifdef HAVE_CHARSET
|
||||
load_codepages_list ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
free_codepages_list ();
|
||||
#endif
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
@ -127,12 +129,14 @@ START_TEST (test_vfs_path_tokens_count)
|
||||
fail_unless (tokens_count == 5, "actual: %zu; expected: 5\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
vpath = vfs_path_from_str (
|
||||
"/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://#enc:KOI8-R/bla-bla/some/path/test3://111/22/33"
|
||||
);
|
||||
tokens_count = vfs_path_tokens_count(vpath);
|
||||
fail_unless (tokens_count == 11, "actual: %zu; expected: 11\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
#endif
|
||||
}
|
||||
END_TEST
|
||||
|
||||
@ -176,11 +180,13 @@ START_TEST (test_vfs_path_tokens_get)
|
||||
/* get 'path2/path3' by 1,2 from LOCAL VFS */
|
||||
check_token_str ("test3://path1/path2/path3/path4", 1, 2, "path2/path3");
|
||||
|
||||
/* get 'path2/path3' by 1,2 from LOCAL VFS with encoding */
|
||||
#ifdef HAVE_CHARSET
|
||||
/* get 'path2/path3' by 1,2 from LOCAL VFS with encoding */
|
||||
check_token_str ("test3://path1/path2/test3://#enc:KOI8-R/path3/path4", 1, 2, "path2/test3://#enc:KOI8-R/path3");
|
||||
|
||||
/* get 'path2/path3' by 1,2 with encoding */
|
||||
check_token_str ("#enc:KOI8-R/path1/path2/path3/path4", 1, 2, "#enc:KOI8-R/path2/path3");
|
||||
#endif
|
||||
|
||||
/* get 'path2/path3' by 1,2 from non-LOCAL VFS */
|
||||
check_token_str ("test2://path1/path2/path3/path4", 1, 2, "test2://path2/path3");
|
||||
@ -213,7 +219,11 @@ START_TEST (test_vfs_path_append_vpath)
|
||||
{
|
||||
vfs_path_t *vpath1, *vpath2, *vpath3;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
vpath1 = vfs_path_from_str("/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://#enc:KOI8-R/bla-bla/some/path/test3://111/22/33");
|
||||
#else
|
||||
vpath1 = vfs_path_from_str("/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://bla-bla/some/path/test3://111/22/33");
|
||||
#endif
|
||||
vpath2 = vfs_path_from_str("/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/");
|
||||
|
||||
vpath3 = vfs_path_append_vpath_new (vpath1, vpath2, NULL);
|
||||
|
@ -31,10 +31,6 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "lib/strutil.h"
|
||||
|
@ -31,11 +31,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -77,19 +75,24 @@ setup (void)
|
||||
vfs_register_class (&vfs_test_ops3);
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
#ifdef HAVE_CHARSET
|
||||
load_codepages_list ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
free_codepages_list ();
|
||||
#endif
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#ifdef HAVE_CHARSET
|
||||
#define ETALON_PATH_STR "/local/path/#test1:user:pass@some.host:12345/bla-bla/some/path/#test2/#enc:KOI8-R/bla-bla/some/path#test3/111/22/33"
|
||||
#define ETALON_PATH_URL_STR "/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://#enc:KOI8-R/bla-bla/some/path/test3://111/22/33"
|
||||
#define ETALON_SERIALIZED_PATH \
|
||||
@ -113,6 +116,30 @@ teardown (void)
|
||||
"p4:pathv9:111/22/33" \
|
||||
"p10:class-namev7:testfs3" \
|
||||
"p10:vfs_prefixv5:test3"
|
||||
#else
|
||||
#define ETALON_PATH_STR "/local/path/#test1:user:pass@some.host:12345/bla-bla/some/path/#test2/bla-bla/some/path#test3/111/22/33"
|
||||
#define ETALON_PATH_URL_STR "/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://bla-bla/some/path/test3://111/22/33"
|
||||
#define ETALON_SERIALIZED_PATH \
|
||||
"g14:path-element-0" \
|
||||
"p4:pathv12:/local/path/" \
|
||||
"p10:class-namev7:localfs" \
|
||||
"g14:path-element-1" \
|
||||
"p4:pathv18:bla-bla/some/path/" \
|
||||
"p10:class-namev7:testfs1" \
|
||||
"p10:vfs_prefixv5:test1" \
|
||||
"p4:userv4:user" \
|
||||
"p8:passwordv4:pass" \
|
||||
"p4:hostv9:some.host" \
|
||||
"p4:portv5:12345" \
|
||||
"g14:path-element-2" \
|
||||
"p4:pathv17:bla-bla/some/path" \
|
||||
"p10:class-namev7:testfs2" \
|
||||
"p10:vfs_prefixv5:test2" \
|
||||
"g14:path-element-3" \
|
||||
"p4:pathv9:111/22/33" \
|
||||
"p10:class-namev7:testfs3" \
|
||||
"p10:vfs_prefixv5:test3"
|
||||
#endif
|
||||
|
||||
START_TEST (test_path_serialize_deserialize)
|
||||
{
|
||||
|
@ -26,12 +26,6 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
#include "lib/vfs/path.h"
|
||||
@ -65,14 +59,11 @@ setup (void)
|
||||
vfs_register_class (&vfs_test_ops1);
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
load_codepages_list ();
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
free_codepages_list ();
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
}
|
||||
|
@ -31,11 +31,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -201,7 +199,7 @@ START_TEST (test_vfs_path_from_to_partial_string_by_class)
|
||||
}
|
||||
END_TEST
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#define encoding_check( input , etalon ) \
|
||||
{ \
|
||||
vfs_path_t *vpath; \
|
||||
@ -284,6 +282,7 @@ START_TEST (test_vfs_path_encoding_at_end)
|
||||
}
|
||||
|
||||
END_TEST
|
||||
#endif /* HAVE_CHARSET */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#undef ETALON_PATH_STR
|
||||
@ -323,8 +322,10 @@ main (void)
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_string);
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_string2);
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_partial_string_by_class);
|
||||
#ifdef HAVE_CHARSET
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_string_encoding);
|
||||
tcase_add_test (tc_core, test_vfs_path_encoding_at_end);
|
||||
#endif
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_string_uri);
|
||||
/* *********************************** */
|
||||
|
||||
|
@ -91,6 +91,7 @@ free_my_statfs (void)
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
int
|
||||
select_charset (int center_y, int center_x, int current_charset, gboolean seldisplay)
|
||||
{
|
||||
@ -101,6 +102,7 @@ select_charset (int center_y, int center_x, int current_charset, gboolean seldis
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
update_xterm_title_path (void)
|
||||
|
Loading…
Reference in New Issue
Block a user