1
1

History: don't drop valid keys after 1st invalid one.

Old behavior: while reading some history from ~/.mc/history file,
the all keys after 1st invalid key are ignored.

New behavior: ignored invlaid keys only. All valid keys are
get.

Signed-off-by: Andrew Borodin <borodin@borodin.zarya>
Этот коммит содержится в:
Andrew Borodin 2009-06-24 14:30:59 +04:00 коммит произвёл Andrew Borodin
родитель 372d3c6cd3
Коммит 66a15c9163

Просмотреть файл

@ -891,39 +891,39 @@ GList *
history_get (const char *input_name)
{
int i;
GList *hist;
GList *hist = NULL;
char *profile;
mc_config_t *cfg;
char **keys;
size_t keys_num = 0;
char *this_entry;
hist = NULL;
if (!num_history_items_recorded) /* this is how to disable */
return NULL;
if (!input_name)
return NULL;
if (!*input_name)
if (!input_name || !*input_name)
return NULL;
profile = concat_dir_and_file (home_dir, HISTORY_FILE_NAME);
cfg = mc_config_init(profile);
for (i = 0;; i++) {
cfg = mc_config_init (profile);
/* get number of keys */
keys = mc_config_get_keys (cfg, input_name, &keys_num);
g_strfreev (keys);
for (i = 0; i < keys_num; i++) {
char key_name[BUF_TINY];
g_snprintf (key_name, sizeof (key_name), "%d", i);
this_entry = mc_config_get_string(cfg, input_name, key_name, "");
if (!*this_entry){
g_free(this_entry);
break;
}
this_entry = mc_config_get_string (cfg, input_name, key_name, "");
hist = list_append_unique (hist, this_entry);
if (this_entry && *this_entry)
hist = list_append_unique (hist, this_entry);
}
mc_config_deinit(cfg);
mc_config_deinit (cfg);
g_free (profile);
/* return pointer to the last entry in the list */
hist = g_list_last (hist);
return hist;
return g_list_last (hist);
}
void