Exemple #1
0
static void
learn_save (void)
{
    int i;
    char *section;
    gboolean profile_changed = FALSE;

    section = g_strconcat ("terminal:", getenv ("TERM"), (char *) NULL);

    for (i = 0; i < learn_total; i++)
        if (learnkeys[i].sequence != NULL)
        {
            char *esc_str;

            esc_str = strutils_escape (learnkeys[i].sequence, -1, ";\\", TRUE);
            mc_config_set_string_raw_value (mc_global.main_config, section,
                                            key_name_conv_tab[i].name, esc_str);
            g_free (esc_str);

            profile_changed = TRUE;
        }

    /* On the one hand no good idea to save the complete setup but 
     * without 'Auto save setup' the new key-definitions will not be 
     * saved unless the user does an 'Options/Save Setup'. 
     * On the other hand a save-button that does not save anything to 
     * disk is much worse.
     */
    if (profile_changed)
        mc_config_save_file (mc_global.main_config, NULL);

    g_free (section);
}
Exemple #2
0
/* *INDENT-OFF* */
END_PARAMETRIZED_TEST
/* *INDENT-ON* */

/* --------------------------------------------------------------------------------------------- */

/* @Test(group='Integration') */
/* *INDENT-OFF* */
START_TEST (emulate__learn_save)
/* *INDENT-ON* */
{
    /* given */
    char *actual_value;

    {
        char *esc_str;

        esc_str = strutils_escape ("T;E\\X;T-FOR-\\T;E;S\\TI;N'G", -1, ";", TRUE);
        mc_config_set_string_raw (mc_config, "test-group1", "test-param1", esc_str);
        g_free (esc_str);
    }

    config_object__reopen ();

    /* when */
    actual_value = mc_config_get_string_raw (mc_config, "test-group1", "test-param1", "not-exists");

    /* then */
    mctest_assert_str_eq (actual_value, "T\\;E\\X\\;T-FOR-\\T\\;E\\;S\\TI\\;N'G");
    g_free (actual_value);
}
Exemple #3
0
END_TEST

/* --------------------------------------------------------------------------------------------- */

START_TEST (emulate__learn_save)
{
    mc_config_t *mc_config;
    char *actual_value, *esc_str;
    char *ini_filename = NULL;
    GError *error = NULL;

    ini_filename = g_build_filename(WORKDIR, "test-emulate__learn_save.ini",NULL);
    unlink(ini_filename);

    mc_config = mc_config_init (ini_filename, FALSE);
    if (mc_config == NULL)
    {
        fail("unable to create mc_congif_t object!");
        return;
    }

    esc_str = strutils_escape ("T;E\\X;T-FOR-\\T;E;S\\TI;N'G", -1, ";", TRUE);
    mc_config_set_string_raw (mc_config, "test-group1", "test-param1", esc_str);
    g_free (esc_str);

    if (!mc_config_save_file (mc_config, &error))
    {
        fail("Unable to save config file: %s",error->message);
        g_error_free(error);
    }

    mc_config_deinit (mc_config);
    mc_config = mc_config_init (ini_filename, FALSE);

    actual_value = mc_config_get_string_raw( mc_config, "test-group1", "test-param1", "not-exists");
    fail_unless_strcmp("T\\;E\\X\\;T-FOR-\\T\\;E\\;S\\TI\\;N'G");
    g_free(actual_value);

    mc_config_deinit (mc_config);
    g_free(ini_filename);
}
Exemple #4
0
char *
strutils_regex_escape (const char *src)
{
    return strutils_escape (src, -1, ESCAPE_REGEX_CHARS, TRUE);
}
Exemple #5
0
char *
strutils_glob_escape (const char *src)
{
    return strutils_escape (src, -1, ESCAPE_GLOB_CHARS, TRUE);
}
Exemple #6
0
char *
strutils_shell_escape (const char *src)
{
    return strutils_escape (src, -1, ESCAPE_SHELL_CHARS, FALSE);
}