Skip to content

Commit

Permalink
Merge branch '4524_cleanup'
Browse files Browse the repository at this point in the history
* 4524_cleanup: (40 commits)
  Update po/*.po files.
  (link_t): remove unused member linkcount.
  src/filemanager/file.c: fix comment.
  src/filemanager/file.c: rename structure: link -> link_t.
  (fetch_hosts): refactoring.
  hostname complition: refactoring: use GPtrArray.
  (load_codepages_list_from_file): use g_ptr_array_new_full().
  src/selcodepage.c: fix coding style.
  (tree_move): fix coding style.
  (info_show_info): don't create VFS path if EXT2 attributes aren't supported.
  file_op_context_t: remove op_preserve member.
  (shell_execute): fix coding style.
  (tar_seek_archive): improve diagnostic for truncated archive.
  Move OS-specific stuff from lib/global.h to lib/unixcompat.h.
  Merge lib/utilunix.h into lib/util.h.
  Merge lib/strescape.h into lib/strutil.h. Rename functions.
  Set the default IO size to 256KiB.
  (find_cmd): add intermediate variable to simplify formatting.
  mceditor: massive use of edit_arg_t as function argument.
  mceditor: new APIs.
  ...
  • Loading branch information
aborodin committed Apr 7, 2024
2 parents 7b3c427 + d7cd645 commit cfedd65
Show file tree
Hide file tree
Showing 130 changed files with 3,525 additions and 1,376 deletions.
10 changes: 9 additions & 1 deletion doc/man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ if USE_NLS
SUBDIRS = $(DOC_LINGUAS)
endif

man_MANS = mc.1 mcedit.1 mcview.1 mcdiff.1
man_MANS = mc.1 mcview.1

if USE_INTERNAL_EDIT
man_MANS += mcedit.1
endif

if USE_DIFF
man_MANS += mcdiff.1
endif

CLEANFILES = $(man_MANS)

Expand Down
16 changes: 10 additions & 6 deletions doc/man/date-of-man-include.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ mc.1: $(srcdir)/mc.1.in
MAN_FILE='$(srcdir)/mc.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mc.1.in' > '$@'

mcdiff.1: $(srcdir)/mcdiff.1.in
MAN_FILE='$(srcdir)/mcdiff.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mcdiff.1.in' > '$@'
mcview.1: $(srcdir)/mcview.1.in
MAN_FILE='$(srcdir)/mcview.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mcview.1.in' > '$@'

if USE_INTERNAL_EDIT
mcedit.1: $(srcdir)/mcedit.1.in
MAN_FILE='$(srcdir)/mcedit.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mcedit.1.in' > '$@'
endif

mcview.1: $(srcdir)/mcview.1.in
MAN_FILE='$(srcdir)/mcview.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mcview.1.in' > '$@'
if USE_DIFF
mcdiff.1: $(srcdir)/mcdiff.1.in
MAN_FILE='$(srcdir)/mcdiff.1.in'; MAN_DATE=$$($(MAN_DATE_CMD)); \
$(SED) $(SED_PARAMETERS) '$(srcdir)/mcdiff.1.in' > '$@'
endif
3 changes: 1 addition & 2 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ SUBLIB_includes = \
mcconfig.h \
search.h \
skin.h \
strescape.h \
strutil.h \
widget.h
SRC_mc_utils = \
utilunix.c utilunix.h \
utilunix.c \
unixcompat.h \
util.c util.h
Expand Down
3 changes: 1 addition & 2 deletions lib/charsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,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);
*list = g_ptr_array_new_full (16, free_codepage_desc);
g_ptr_array_add (*list, new_codepage_desc (id, p));
}
else
Expand Down
4 changes: 2 additions & 2 deletions lib/filehighlight/ini-file-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "lib/global.h"
#include "lib/fileloc.h"
#include "lib/strescape.h"
#include "lib/strutil.h"
#include "lib/skin.h"
#include "lib/util.h" /* exist_file() */

Expand Down Expand Up @@ -154,7 +154,7 @@ mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
{
char *esc_ext;

esc_ext = strutils_regex_escape (*exts);
esc_ext = str_regex_escape (*exts);
if (buf->len != 0)
g_string_append_c (buf, '|');
g_string_append (buf, esc_ext);
Expand Down
75 changes: 75 additions & 0 deletions lib/glibcompat.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,87 @@

/*** file scope variables ************************************************************************/

/* --------------------------------------------------------------------------------------------- */
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */

#if ! GLIB_CHECK_VERSION (2, 54, 0)
/**
* g_direct_equal:
* @v1: (nullable): a key
* @v2: (nullable): a key to compare with @v1
*
* Compares two #gpointer arguments and returns %TRUE if they are equal.
* It can be passed to g_hash_table_new() as the @key_equal_func
* parameter, when using opaque pointers compared by pointer value as
* keys in a #GHashTable.
*
* This equality function is also appropriate for keys that are integers
* stored in pointers, such as `GINT_TO_POINTER (n)`.
*
* Returns: %TRUE if the two keys match.
*/

static gboolean
g_direct_equal (gconstpointer v1, gconstpointer v2)
{
return v1 == v2;
}
#endif /* ! GLIB_CHECK_VERSION (2, 54, 0) */

/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */

#if ! GLIB_CHECK_VERSION (2, 54, 0)
/**
* g_ptr_array_find_with_equal_func: (skip)
* @haystack: pointer array to be searched
* @needle: pointer to look for
* @equal_func: (nullable): the function to call for each element, which should
* return %TRUE when the desired element is found; or %NULL to use pointer
* equality
* @index_: (optional) (out): return location for the index of
* the element, if found
*
* Checks whether @needle exists in @haystack, using the given @equal_func.
* If the element is found, %TRUE is returned and the element^A^A^As index is
* returned in @index_ (if non-%NULL). Otherwise, %FALSE is returned and @index_
* is undefined. If @needle exists multiple times in @haystack, the index of
* the first instance is returned.
*
* @equal_func is called with the element from the array as its first parameter,
* and @needle as its second parameter. If @equal_func is %NULL, pointer
* equality is used.
*
* Returns: %TRUE if @needle is one of the elements of @haystack
* Since: 2.54
*/
gboolean
g_ptr_array_find_with_equal_func (GPtrArray * haystack, gconstpointer needle, GEqualFunc equal_func,
guint * index_)
{
guint i;

g_return_val_if_fail (haystack != NULL, FALSE);

if (equal_func == NULL)
equal_func = g_direct_equal;

for (i = 0; i < haystack->len; i++)
if (equal_func (g_ptr_array_index (haystack, i), needle))
{
if (index_ != NULL)
*index_ = i;
return TRUE;
}

return FALSE;
}
#endif /* ! GLIB_CHECK_VERSION (2, 54, 0) */

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

#if ! GLIB_CHECK_VERSION (2, 63, 3)
/**
* g_clear_slist: (skip)
Expand Down
5 changes: 5 additions & 0 deletions lib/glibcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

/*** declarations of public functions ************************************************************/

#if ! GLIB_CHECK_VERSION (2, 54, 0)
gboolean g_ptr_array_find_with_equal_func (GPtrArray * haystack, gconstpointer needle,
GEqualFunc equal_func, guint * index_);
#endif /* ! GLIB_CHECK_VERSION (2, 54, 0) */

#if ! GLIB_CHECK_VERSION (2, 63, 3)
void g_clear_slist (GSList ** slist_ptr, GDestroyNotify destroy);
void g_clear_list (GList ** list_ptr, GDestroyNotify destroy);
Expand Down
97 changes: 11 additions & 86 deletions lib/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,17 @@
#ifndef MC_GLOBAL_H
#define MC_GLOBAL_H

#if defined(HAVE_STRING_H)
#include <string.h>
/* An ANSI string.h and pre-ANSI memory.h might conflict */
#elif defined(HAVE_MEMORY_H)
#include <memory.h>
#else
#include <strings.h>
/* memory and strings.h conflict on other systems */
#endif /* !STDC_HEADERS & !HAVE_STRING_H */

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif

/* for O_* macros */
#include <fcntl.h>
#include <glib.h>
#include "glibcompat.h"

/* for sig_atomic_t */
#include <signal.h>
#include "unixcompat.h"

#ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
#define MC_FALLTHROUGH __attribute__((fallthrough))
#else
#define MC_FALLTHROUGH
#endif
#include "fs.h"
#include "shell.h"
#include "mcconfig.h"

/*** typedefs(not structures) and defined constants **********************************************/

/* The O_BINARY definition was taken from gettext */
#if !defined O_BINARY && defined _O_BINARY
/* For MSC-compatible compilers. */
#define O_BINARY _O_BINARY
#endif
#ifdef __BEOS__
/* BeOS 5 has O_BINARY, but is has no effect. */
#undef O_BINARY
#endif
/* On reasonable systems, binary I/O is the default. */
#ifndef O_BINARY
#define O_BINARY 0
#endif

/* Replacement for O_NONBLOCK */
#ifndef O_NONBLOCK
#ifdef O_NDELAY /* SYSV */
#define O_NONBLOCK O_NDELAY
#else /* BSD */
#define O_NONBLOCK FNDELAY
#endif /* !O_NDELAY */
#endif /* !O_NONBLOCK */

#if defined(__QNX__) && !defined(__QNXNTO__)
/* exec*() from <process.h> */
#include <unix.h>
#endif

#include <glib.h>
#include "glibcompat.h"

/* Solaris9 doesn't have PRIXMAX */
#ifndef PRIXMAX
#define PRIXMAX PRIxMAX
#endif

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) gettext (String)
Expand All @@ -90,9 +37,11 @@
#define N_(String) (String)
#endif /* !ENABLE_NLS */

#include "fs.h"
#include "shell.h"
#include "mcconfig.h"
#ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
#define MC_FALLTHROUGH __attribute__((fallthrough))
#else
#define MC_FALLTHROUGH
#endif

#ifdef USE_MAINTAINER_MODE
#include "lib/logging.h"
Expand All @@ -109,32 +58,8 @@
#define BUF_SMALL 128
#define BUF_TINY 64

/* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
#ifdef ESC_CHAR
#undef ESC_CHAR
#endif
/* AIX compiler doesn't understand '\e' */
#define ESC_CHAR '\033'
#define ESC_STR "\033"

/* OS specific defines */
#define PATH_SEP '/'
#define PATH_SEP_STR "/"
#define IS_PATH_SEP(c) ((c) == PATH_SEP)
#define PATH_ENV_SEP ':'
#define TMPDIR_DEFAULT "/tmp"
#define SCRIPT_SUFFIX ""
#define get_default_editor() "vi"
#define OS_SORT_CASE_SENSITIVE_DEFAULT TRUE
#define UTF8_CHAR_LEN 6

/* struct stat members */
#ifdef __APPLE__
#define st_atim st_atimespec
#define st_ctim st_ctimespec
#define st_mtim st_mtimespec
#endif

/* Used to distinguish between a normal MC termination and */
/* one caused by typing 'exit' or 'logout' in the subshell */
#define SUBSHELL_EXIT 128
Expand Down
2 changes: 1 addition & 1 deletion lib/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

#include "lib/global.h"
#include "lib/vfs/vfs.h"
#include "lib/util.h" /* tilde_expand() */
#include "lib/util.h"
#include "lib/lock.h"
#include "lib/widget.h" /* query_dialog() */

Expand Down
11 changes: 5 additions & 6 deletions lib/search/glob.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "lib/global.h"
#include "lib/strutil.h"
#include "lib/search.h"
#include "lib/strescape.h"

#include "internal.h"

Expand Down Expand Up @@ -62,36 +61,36 @@ mc_search__glob_translate_to_regex (const GString * astr)
switch (str[loop])
{
case '*':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (!str_is_char_escaped (str, &(str[loop])))
{
g_string_append (buff, inside_group ? ".*" : "(.*)");
continue;
}
break;
case '?':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (!str_is_char_escaped (str, &(str[loop])))
{
g_string_append (buff, inside_group ? "." : "(.)");
continue;
}
break;
case ',':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (!str_is_char_escaped (str, &(str[loop])))
{
g_string_append_c (buff, inside_group ? '|' : ',');
continue;
}
break;
case '{':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (!str_is_char_escaped (str, &(str[loop])))
{
g_string_append_c (buff, '(');
inside_group = TRUE;
continue;
}
break;
case '}':
if (!strutils_is_char_escaped (str, &(str[loop])))
if (!str_is_char_escaped (str, &(str[loop])))
{
g_string_append_c (buff, ')');
inside_group = FALSE;
Expand Down
1 change: 0 additions & 1 deletion lib/search/hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "lib/global.h"
#include "lib/strutil.h"
#include "lib/search.h"
#include "lib/strescape.h"

#include "internal.h"

Expand Down
Loading

0 comments on commit cfedd65

Please sign in to comment.