Skip to content

Commit

Permalink
Merge branch '4490_cleanup'
Browse files Browse the repository at this point in the history
* 4490_cleanup: (46 commits)
  Update po/*.po files.
  (mc_config_history_save): remove check because condition is always true here.
  (mc_config_history_get_recent_item): new API.
  Fix comments of history and panels.ini files location.
  lib/mcconfig/history.c: fix comments.
  src/editor/edit.c: fix coding style.
  (edit_insert_file): change variable type from int to gboolean.
  (edit_user_menu): avoid inverse logic.
  mcedit: rename user_menu() to edit_user_menu().
  mcedit: minor optimization.
  (edit_cursor_to_eol): reduce variable scope.
  (edit_execute_cmd): refactor loop.
  (insert_spaces_tab): refactor loop.
  Refactoring: avoid create an empty strings.
  (expand_format): remove intermediate variable.
  (strip_ext): refactor loop.
  mc.ext.ini.in: support webp images.
  tar: type accuracy.
  (oldgnu_get_sparse_info) fix conditional-uninitialized warning.
  (edit_print_string): refactor loop.
  ...
  • Loading branch information
aborodin committed Nov 6, 2023
2 parents cf7846c + 5ff8599 commit 1d5931a
Show file tree
Hide file tree
Showing 104 changed files with 5,628 additions and 4,361 deletions.
2 changes: 1 addition & 1 deletion doc/FAQ
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Frequently Asked Questions
You need a POSIX (Unix compatible) operating system. If you are
running Windows, use Cygwin.

To compile any edition you need to have glib >= 2.30 installed.
To compile any edition you need to have glib >= 2.32 installed.
It's available at https://download.gnome.org/sources/glib/.

If you want to use mouse on the Linux console you need the gpm daemon
Expand Down
2 changes: 1 addition & 1 deletion doc/HACKING
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ required:
Autoconf 2.64 and above (latest is recommended)
Automake 1.12 and above (latest is recommended)
Gettext 0.18.2 and above
Glib 2.30 and above
Glib 2.32 and above

Full list of requirements you can see at:
https://www.midnight-commander.org/wiki/doc/buildAndInstall/req
Expand Down
6 changes: 3 additions & 3 deletions doc/INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Build requirements for GNU Midnight Commander
- autoconf >= 2.64
- automake >= 1.12
- libtool
- glib2 >= 2.30
- glib2 >= 2.32
- slang2 or ncurses
- gettext >= 0.18.2
- libssh2 >= 1.2.8 is required only for sftp vfs
Expand Down Expand Up @@ -367,8 +367,8 @@ get glib from

ftp://ftp.gnome.org/pub/gnome/sources/glib/

Minimal version of glib: 2.30.0
Recommended version: 2.30.x and higher.
Minimal version of glib: 2.32.0
Recommended version: 2.32.x and higher.

Newer versions may work, but haven't been tested.

Expand Down
1 change: 1 addition & 0 deletions lib/charsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ load_codepages_list_from_file (GPtrArray ** list, const char *fname)
if (*list == NULL)
{
*list = g_ptr_array_sized_new (16);
g_ptr_array_set_free_func (*list, free_codepage_desc);
g_ptr_array_add (*list, new_codepage_desc (id, p));
}
else
Expand Down
21 changes: 0 additions & 21 deletions lib/glibcompat.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,8 @@ g_clear_list (GList ** list_ptr, GDestroyNotify destroy)
}
}

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

#endif /* ! GLIB_CHECK_VERSION (2, 63, 3) */

#if ! GLIB_CHECK_VERSION (2, 32, 0)
/**
* g_queue_free_full:
* @queue: a pointer to a #GQueue
* @free_func: the function to be called to free each element's data
*
* Convenience method, which frees all the memory used by a #GQueue,
* and calls the specified destroy function on every element's data.
*
* Since: 2.32
*/
void
g_queue_free_full (GQueue * queue, GDestroyNotify free_func)
{
g_queue_foreach (queue, (GFunc) free_func, NULL);
g_queue_free (queue);
}
#endif /* ! GLIB_CHECK_VERSION (2, 32, 0) */

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

#if ! GLIB_CHECK_VERSION (2, 60, 0)
Expand Down
4 changes: 0 additions & 4 deletions lib/glibcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ void g_clear_slist (GSList ** slist_ptr, GDestroyNotify destroy);
void g_clear_list (GList ** list_ptr, GDestroyNotify destroy);
#endif /* ! GLIB_CHECK_VERSION (2, 63, 3) */

#if ! GLIB_CHECK_VERSION (2, 32, 0)
void g_queue_free_full (GQueue * queue, GDestroyNotify free_func);
#endif /* ! GLIB_CHECK_VERSION (2, 32, 0) */

#if ! GLIB_CHECK_VERSION (2, 60, 0)
void g_queue_clear_full (GQueue * queue, GDestroyNotify free_func);
#endif /* ! GLIB_CHECK_VERSION (2, 60, 0) */
Expand Down
2 changes: 2 additions & 0 deletions lib/mcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ vfs_path_t *mc_config_get_full_vpath (const char *config_name);

/* read history to the mc_config, but don't save config to file */
GList *mc_config_history_get (const char *name);
/* read recent item from the history */
char *mc_config_history_get_recent_item (const char *name);
/* load history from the mc_config */
GList *mc_config_history_load (mc_config_t * cfg, const char *name);
/* save history to the mc_config, but don't save config to file */
Expand Down
36 changes: 31 additions & 5 deletions lib/mcconfig/history.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Widgets for the Midnight Commander
Configure module for the Midnight Commander
Copyright (C) 1994-2023
Free Software Foundation, Inc.
Expand All @@ -10,7 +10,7 @@
Jakub Jelinek, 1995
Andrej Borsenkow, 1996
Norbert Warmuth, 1997
Andrew Borodin <[email protected]>, 2009-2019
Andrew Borodin <[email protected]>, 2009-2023
This file is part of the Midnight Commander.
Expand Down Expand Up @@ -65,7 +65,7 @@ int num_history_items_recorded = 60;
/* --------------------------------------------------------------------------------------------- */

/**
* Load the history from the ${XDG_CACHE_HOME}/mc/history file.
* Load the history from the ${XDG_DATA_HOME}/mc/history file.
* It is called with the widgets history name and returns the GList list.
*/

Expand Down Expand Up @@ -94,6 +94,33 @@ mc_config_history_get (const char *name)

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

/**
* Get the recent item of a history from the ${XDG_DATA_HOME}/mc/history file.
*
* TODO: get rid of load the entire history to get the only top item.
*/

char *
mc_config_history_get_recent_item (const char *name)
{
GList *history;
char *item = NULL;

history = mc_config_history_get (name);
if (history != NULL)
{
/* FIXME: can history->data be NULL? */
item = (char *) history->data;
history->data = NULL;
history = g_list_first (history);
g_list_free_full (history, g_free);
}

return item;
}

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

/**
* Load history from the mc_config
*/
Expand Down Expand Up @@ -177,8 +204,7 @@ mc_config_history_save (mc_config_t * cfg, const char *name, GList * h)
for (i = 0; (i < num_history_items_recorded - 1) && (h->prev != NULL); i++)
h = g_list_previous (h);

if (name != NULL)
mc_config_del_group (cfg, name);
mc_config_del_group (cfg, name);

/* create charset conversion handler to convert strings
from system codepage to UTF-8 */
Expand Down
49 changes: 23 additions & 26 deletions lib/skin/colors.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ int mc_skin_color__cache[MC_SKIN_COLOR_CACHE_COUNT];
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */

static mc_skin_color_t *
static tty_color_pair_t *
mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
{
gchar kname[BUF_TINY];
mc_skin_color_t *mc_skin_color;
tty_color_pair_t *mc_skin_color;

if (group == NULL || key == NULL)
return NULL;
Expand All @@ -62,7 +62,7 @@ mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gch
mc_skin = &mc_skin__default;

g_snprintf (kname, sizeof (kname), "%s.%s", group, key);
mc_skin_color = (mc_skin_color_t *) g_hash_table_lookup (mc_skin->colors, (gpointer) kname);
mc_skin_color = (tty_color_pair_t *) g_hash_table_lookup (mc_skin->colors, (gpointer) kname);

return mc_skin_color;
}
Expand All @@ -89,7 +89,7 @@ mc_skin_color_remove_from_hash (mc_skin_t * mc_skin, const gchar * group, const

static void
mc_skin_color_add_to_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key,
mc_skin_color_t * mc_skin_color)
tty_color_pair_t * mc_skin_color)
{
gchar *kname;

Expand All @@ -105,10 +105,10 @@ mc_skin_color_add_to_hash (mc_skin_t * mc_skin, const gchar * group, const gchar

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

static mc_skin_color_t *
static tty_color_pair_t *
mc_skin_color_get_with_defaults (const gchar * group, const gchar * name)
{
mc_skin_color_t *mc_skin_color;
tty_color_pair_t *mc_skin_color;

mc_skin_color = mc_skin_color_get_from_hash (NULL, group, name);
if (mc_skin_color != NULL)
Expand Down Expand Up @@ -179,12 +179,12 @@ mc_skin_color_look_up_alias (mc_skin_t * mc_skin, gchar * str)

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

static mc_skin_color_t *
static tty_color_pair_t *
mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
{
gsize items_count;
gchar **values;
mc_skin_color_t *mc_skin_color, *tmp;
tty_color_pair_t *mc_skin_color, *tmp;

values = mc_config_get_string_list (mc_skin->config, group, key, &items_count);
if (values == NULL || values[0] == NULL)
Expand All @@ -193,29 +193,27 @@ mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const
return NULL;
}

mc_skin_color = g_try_new0 (mc_skin_color_t, 1);
mc_skin_color = g_try_new0 (tty_color_pair_t, 1);
if (mc_skin_color == NULL)
{
g_strfreev (values);
return NULL;
}

tmp = mc_skin_color_get_with_defaults (group, "_default_");
mc_skin_color->fgcolor = (items_count > 0 && values[0][0]) ?
mc_skin_color->fg = (items_count > 0 && values[0][0]) ?
mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[0]))) :
(tmp != NULL) ? g_strdup (tmp->fgcolor) : NULL;
mc_skin_color->bgcolor = (items_count > 1 && values[1][0]) ?
(tmp != NULL) ? g_strdup (tmp->fg) : NULL;
mc_skin_color->bg = (items_count > 1 && values[1][0]) ?
mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[1]))) :
(tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL;
(tmp != NULL) ? g_strdup (tmp->bg) : NULL;
mc_skin_color->attrs = (items_count > 2 && values[2][0]) ?
mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[2]))) :
(tmp != NULL) ? g_strdup (tmp->attrs) : NULL;

g_strfreev (values);

mc_skin_color->pair_index =
tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor,
mc_skin_color->attrs, FALSE);
mc_skin_color->pair_index = tty_try_alloc_color_pair (mc_skin_color, FALSE);

return mc_skin_color;
}
Expand All @@ -225,16 +223,15 @@ mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const
static void
mc_skin_color_set_default_for_terminal (mc_skin_t * mc_skin)
{
mc_skin_color_t *mc_skin_color;
mc_skin_color = g_try_new0 (mc_skin_color_t, 1);
tty_color_pair_t *mc_skin_color;

mc_skin_color = g_try_new0 (tty_color_pair_t, 1);
if (mc_skin_color != NULL)
{
mc_skin_color->fgcolor = g_strdup ("default");
mc_skin_color->bgcolor = g_strdup ("default");
mc_skin_color->fg = g_strdup ("default");
mc_skin_color->bg = g_strdup ("default");
mc_skin_color->attrs = NULL;
mc_skin_color->pair_index =
tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor,
mc_skin_color->attrs, FALSE);
mc_skin_color->pair_index = tty_try_alloc_color_pair (mc_skin_color, FALSE);
mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color);
}
}
Expand Down Expand Up @@ -363,7 +360,7 @@ mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
gboolean ret = FALSE;
gsize items_count;
gchar **groups, **orig_groups;
mc_skin_color_t *mc_skin_color;
tty_color_pair_t *mc_skin_color;

mc_skin_color_check_bw_mode (mc_skin);

Expand All @@ -377,7 +374,7 @@ mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
if (mc_skin_color == NULL)
goto ret;

tty_color_set_defaults (mc_skin_color->fgcolor, mc_skin_color->bgcolor, mc_skin_color->attrs);
tty_color_set_defaults (mc_skin_color);
mc_skin_color_add_to_hash (mc_skin, "core", "_default_", mc_skin_color);

for (groups = orig_groups; *groups != NULL; groups++)
Expand Down Expand Up @@ -412,7 +409,7 @@ mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
int
mc_skin_color_get (const gchar * group, const gchar * name)
{
mc_skin_color_t *mc_skin_color;
tty_color_pair_t *mc_skin_color;

mc_skin_color = mc_skin_color_get_with_defaults (group, name);

Expand Down
10 changes: 5 additions & 5 deletions lib/skin/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ static gboolean mc_skin_is_init = FALSE;
static void
mc_skin_hash_destroy_value (gpointer data)
{
mc_skin_color_t *mc_skin_color = (mc_skin_color_t *) data;
g_free (mc_skin_color->fgcolor);
g_free (mc_skin_color->bgcolor);
tty_color_pair_t *mc_skin_color = (tty_color_pair_t *) data;

g_free (mc_skin_color->fg);
g_free (mc_skin_color->bg);
g_free (mc_skin_color->attrs);
g_free (mc_skin_color);
}
Expand Down Expand Up @@ -180,8 +181,7 @@ mc_skin_init (const gchar * skin_override, GError ** mcerror)
void
mc_skin_deinit (void)
{
tty_color_free_all_tmp ();
tty_color_free_all_non_tmp ();
tty_color_free_all ();

MC_PTR_FREE (mc_skin__default.name);
g_hash_table_destroy (mc_skin__default.colors);
Expand Down
8 changes: 0 additions & 8 deletions lib/skin/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@

/*** structures declarations (and typedefs of structures)*****************************************/

typedef struct mc_skin_color_struct
{
gchar *fgcolor;
gchar *bgcolor;
gchar *attrs;
int pair_index;
} mc_skin_color_t;

/*** global variables defined in .c file *********************************************************/

/*** declarations of public functions ************************************************************/
Expand Down
Loading

0 comments on commit 1d5931a

Please sign in to comment.