mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Ticket #1532: Key configuration doesn't save properly
Problem: need to escape ';' char (as '\;'), but mc_config_set_string function escape this to '\\;' Solution: Added mc_config_direct_set_string() function. Also, into src/learn.c characters '\' and ';' is escaped manually. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
b4b3b80b4f
commit
87979e779b
11
src/learn.c
11
src/learn.c
@ -47,6 +47,7 @@
|
||||
#include "learn.h"
|
||||
#include "wtools.h"
|
||||
#include "strutil.h"
|
||||
#include "strescape.h"
|
||||
|
||||
#define UX 4
|
||||
#define UY 3
|
||||
@ -311,12 +312,18 @@ learn_save (void)
|
||||
int i;
|
||||
int profile_changed = 0;
|
||||
char *section = g_strconcat ("terminal:", getenv ("TERM"), (char *) NULL);
|
||||
char *esc_str;
|
||||
|
||||
for (i = 0; i < learn_total; i++) {
|
||||
if (learnkeys [i].sequence != NULL) {
|
||||
profile_changed = 1;
|
||||
mc_config_set_string(mc_main_config, section,
|
||||
key_name_conv_tab [i].name, learnkeys [i].sequence);
|
||||
|
||||
esc_str = strutils_escape (learnkeys [i].sequence, -1, ";\\", TRUE);
|
||||
|
||||
mc_config_direct_set_string(mc_main_config, section,
|
||||
key_name_conv_tab [i].name, esc_str);
|
||||
|
||||
g_free(esc_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,10 @@ int *mc_config_get_int_list (mc_config_t *, const gchar *,
|
||||
|
||||
/* mcconfig/set.c: */
|
||||
|
||||
void
|
||||
mc_config_direct_set_string (mc_config_t *, const gchar *,
|
||||
const gchar *, const gchar *);
|
||||
|
||||
void
|
||||
mc_config_set_string (mc_config_t *, const gchar *,
|
||||
const gchar *, const gchar *);
|
||||
|
@ -35,19 +35,14 @@ extern int utf8_display;
|
||||
/*** file scope variables **********************************************/
|
||||
|
||||
/*** file scope functions **********************************************/
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/*** public functions **************************************************/
|
||||
|
||||
void
|
||||
mc_config_set_string (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, const gchar * value)
|
||||
static gchar *
|
||||
mc_config_normalize_before_save(const gchar * value)
|
||||
{
|
||||
GIConv conv;
|
||||
GString *buffer;
|
||||
|
||||
if (!mc_config || !group || !param || !value)
|
||||
return;
|
||||
|
||||
if (utf8_display)
|
||||
{
|
||||
buffer = g_string_new(value);
|
||||
@ -69,8 +64,45 @@ mc_config_set_string (mc_config_t * mc_config, const gchar * group,
|
||||
str_close_conv (conv);
|
||||
}
|
||||
|
||||
g_key_file_set_string (mc_config->handle, group, param, buffer->str);
|
||||
g_string_free(buffer, TRUE);
|
||||
return g_string_free(buffer, FALSE);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
/*** public functions **************************************************/
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
void
|
||||
mc_config_direct_set_string (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, const gchar * value)
|
||||
{
|
||||
gchar *buffer;
|
||||
|
||||
if (!mc_config || !group || !param || !value)
|
||||
return;
|
||||
|
||||
buffer = mc_config_normalize_before_save(value);
|
||||
|
||||
g_key_file_set_value (mc_config->handle, group, param, buffer);
|
||||
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
void
|
||||
mc_config_set_string (mc_config_t * mc_config, const gchar * group,
|
||||
const gchar * param, const gchar * value)
|
||||
{
|
||||
gchar *buffer;
|
||||
|
||||
if (!mc_config || !group || !param || !value)
|
||||
return;
|
||||
|
||||
buffer = mc_config_normalize_before_save(value);
|
||||
|
||||
g_key_file_set_string (mc_config->handle, group, param, buffer);
|
||||
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
Loading…
Reference in New Issue
Block a user