mirror of
https://github.com/MidnightCommander/mc
synced 2025-02-04 01:14:17 +03:00
Merge branch 'm-utf-8' of ssh://www.midnight-commander.org:2222/git/mc into m-utf-8
* 'm-utf-8' of ssh://www.midnight-commander.org:2222/git/mc: Fixed coredump in editor after help call. src/menu.c (create_menu): don't translate menu entry text if ENABLE_NLS isn't defined. src/strutil.h: created align_crt_t type for string alignment on terminal. fix: uninitialized variable "p" in str_8bit_fit_to_term
This commit is contained in:
commit
95ecd0ce54
12
src/help.c
12
src/help.c
@ -69,7 +69,7 @@
|
||||
#define STRING_LINK_END "\03"
|
||||
#define STRING_NODE_END "\04"
|
||||
|
||||
static char *data;
|
||||
static char *data = NULL; /* Pointer to the loaded data file */
|
||||
static int help_lines; /* Lines in help viewer */
|
||||
static int history_ptr; /* For the history queue */
|
||||
static const char *main_node; /* The main node */
|
||||
@ -781,14 +781,18 @@ translate_file (char *filedata)
|
||||
conv = str_crt_conv_from ("UTF-8");
|
||||
|
||||
if (conv != INVALID_CONV) {
|
||||
g_free (data);
|
||||
|
||||
if (str_convert (conv, filedata, translated_data) != ESTR_FAILURE) {
|
||||
data = translated_data->str;
|
||||
g_string_free (translated_data, FALSE);
|
||||
} else {
|
||||
data = NULL;
|
||||
g_string_free (translated_data, TRUE);
|
||||
}
|
||||
str_close_conv (conv);
|
||||
}
|
||||
g_string_free (translated_data, TRUE);
|
||||
} else
|
||||
g_string_free (translated_data, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
@ -804,7 +808,7 @@ interactive_display (const char *filename, const char *node)
|
||||
else
|
||||
filedata = load_mc_home_file ("mc.hlp", &hlpfile);
|
||||
|
||||
if (data == NULL) {
|
||||
if (filedata == NULL) {
|
||||
message (D_ERROR, MSG_ERROR, _(" Cannot open file %s \n %s "), filename ? filename : hlpfile,
|
||||
unix_error_string (errno));
|
||||
}
|
||||
|
@ -53,7 +53,9 @@ create_menu (const char *name, menu_entry *entries, int count, const char *help_
|
||||
register menu_entry* mp;
|
||||
for (mp = entries; count--; mp++) {
|
||||
if (mp->label[0] != '\0') {
|
||||
#ifdef ENABLE_NLS
|
||||
mp->label = _(mp->label);
|
||||
#endif
|
||||
mp->text = parse_hotkey (mp->label);
|
||||
len = hotkey_width (mp->text);
|
||||
|
||||
|
@ -70,7 +70,7 @@ typedef struct format_e {
|
||||
struct format_e *next;
|
||||
int requested_field_len;
|
||||
int field_len;
|
||||
int just_mode;
|
||||
align_crt_t just_mode;
|
||||
int expand;
|
||||
const char *(*string_fn)(file_entry *, int len);
|
||||
const char *title;
|
||||
@ -419,7 +419,7 @@ static struct {
|
||||
const char *id;
|
||||
int min_size;
|
||||
int expands;
|
||||
int default_just;
|
||||
align_crt_t default_just;
|
||||
const char *title;
|
||||
int use_in_gui;
|
||||
const char *(*string_fn)(file_entry *, int);
|
||||
@ -1304,7 +1304,7 @@ parse_display_format (WPanel *panel, const char *format, char **error, int issta
|
||||
format_e *darr, *old = 0, *home = 0; /* The formats we return */
|
||||
int total_cols = 0; /* Used columns by the format */
|
||||
int set_justify; /* flag: set justification mode? */
|
||||
int justify = 0; /* Which mode. */
|
||||
align_crt_t justify = J_LEFT; /* Which mode. */
|
||||
int items = 0; /* Number of items in the format */
|
||||
size_t i;
|
||||
|
||||
|
@ -407,7 +407,7 @@ str_term_form (const char *text)
|
||||
}
|
||||
|
||||
const char *
|
||||
str_fit_to_term (const char *text, int width, int just_mode)
|
||||
str_fit_to_term (const char *text, int width, align_crt_t just_mode)
|
||||
{
|
||||
return used_class.fit_to_term (text, width, just_mode);
|
||||
}
|
||||
|
@ -52,28 +52,26 @@ typedef enum {
|
||||
ESTR_FAILURE = 2
|
||||
} estr_t;
|
||||
|
||||
/* constanst originally from screen.c
|
||||
* used for alignment strings on terminal
|
||||
/* alignment strings on terminal
|
||||
*/
|
||||
#define J_LEFT 0x01
|
||||
#define J_RIGHT 0x02
|
||||
#define J_CENTER 0x03
|
||||
/*
|
||||
if there is enough space for string on terminal, string is centered
|
||||
otherwise is aligned to left
|
||||
*/
|
||||
#define J_CENTER_LEFT 0x04
|
||||
typedef enum {
|
||||
J_LEFT = 0x01,
|
||||
J_RIGHT = 0x02,
|
||||
J_CENTER = 0x03,
|
||||
/* if there is enough space for string on terminal,
|
||||
* string is centered otherwise is aligned to left */
|
||||
J_CENTER_LEFT = 0x04,
|
||||
/* fit alignment, if string is to long, is truncated with '~' */
|
||||
J_LEFT_FIT = 0x11,
|
||||
J_RIGHT_FIT = 0x12,
|
||||
J_CENTER_FIT = 0x13,
|
||||
J_CENTER_LEFT_FIT = 0x14
|
||||
} align_crt_t;
|
||||
|
||||
#define IS_FIT(x) ((x) & 0x0010)
|
||||
#define MAKE_FIT(x) ((x) | 0x0010)
|
||||
#define HIDE_FIT(x) ((x) & 0x000f)
|
||||
|
||||
/* fit alignment, if string is to long, is truncated with '~' */
|
||||
#define J_LEFT_FIT 0x11
|
||||
#define J_RIGHT_FIT 0x12
|
||||
#define J_CENTER_FIT 0x13
|
||||
#define J_CENTER_LEFT_FIT 0x14
|
||||
|
||||
#define INVALID_CONV ((GIConv) (-1))
|
||||
|
||||
/* standard convertors */
|
||||
@ -85,7 +83,7 @@ extern GIConv str_cnv_not_convert;
|
||||
/* all functions in str_class must be defined for every encoding */
|
||||
struct str_class {
|
||||
estr_t (*vfs_convert_to) (GIConv coder, const char *string,
|
||||
int size, GString *buffer); /*I*/
|
||||
int size, GString *buffer); /*I*/
|
||||
void (*insert_replace_char) (GString *buffer);
|
||||
int (*is_valid_string) (const char *); /*I*/
|
||||
int (*is_valid_char) (const char *, size_t); /*I*/
|
||||
@ -108,7 +106,7 @@ struct str_class {
|
||||
int (*tolower) (const char *, char **, size_t *);
|
||||
void (*fix_string) (char *); /*I*/
|
||||
const char *(*term_form) (const char *); /*I*/
|
||||
const char *(*fit_to_term) (const char *, int, int); /*I*/
|
||||
const char *(*fit_to_term) (const char *, int, align_crt_t); /*I*/
|
||||
const char *(*term_trim) (const char *text, int width); /*I*/
|
||||
void (*msg_term_size) (const char *, int *, int *); /*I*/
|
||||
const char *(*term_substring) (const char *, int, int); /*I*/
|
||||
@ -366,7 +364,7 @@ const char *str_term_form (const char *text);
|
||||
* result is completed with spaces to width
|
||||
* I
|
||||
*/
|
||||
const char *str_fit_to_term (const char *text, int width, int just_mode);
|
||||
const char *str_fit_to_term (const char *text, int width, align_crt_t just_mode);
|
||||
|
||||
/* like str_term_form, but when text is wider than width, three dots are
|
||||
* inserted at begin and result is completed with suffix of text
|
||||
|
@ -208,7 +208,7 @@ str_8bit_term_form (const char *text)
|
||||
}
|
||||
|
||||
static const char *
|
||||
str_8bit_fit_to_term (const char *text, int width, int just_mode)
|
||||
str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode)
|
||||
{
|
||||
static char result[BUF_MEDIUM];
|
||||
char *actual;
|
||||
@ -381,11 +381,11 @@ str_8bit_msg_term_size (const char *text, int *lines, int *columns)
|
||||
char *q;
|
||||
char c = '\0';
|
||||
int width;
|
||||
p = tmp;
|
||||
|
||||
(*lines) = 1;
|
||||
(*columns) = 0;
|
||||
tmp = g_strdup ((char *)text);
|
||||
p = tmp;
|
||||
for (;;)
|
||||
{
|
||||
q = strchr (p, '\n');
|
||||
|
@ -201,7 +201,7 @@ str_ascii_term_form (const char *text)
|
||||
}
|
||||
|
||||
static const char *
|
||||
str_ascii_fit_to_term (const char *text, int width, int just_mode)
|
||||
str_ascii_fit_to_term (const char *text, int width, align_crt_t just_mode)
|
||||
{
|
||||
static char result[BUF_MEDIUM];
|
||||
char *actual;
|
||||
|
@ -575,7 +575,7 @@ utf8_tool_compose (char *buffer, size_t size)
|
||||
|
||||
|
||||
static const char *
|
||||
str_utf8_fit_to_term (const char *text, int width, int just_mode)
|
||||
str_utf8_fit_to_term (const char *text, int width, align_crt_t just_mode)
|
||||
{
|
||||
static char result[BUF_MEDIUM * 6];
|
||||
const struct term_form *pre_form;
|
||||
|
Loading…
x
Reference in New Issue
Block a user