Browse Source

Merge branch '4524_cleanup'

* 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.
  ...
Andrew Borodin 11 months ago
parent
commit
cfedd6598c
10 changed files with 120 additions and 106 deletions
  1. 9 1
      doc/man/Makefile.am
  2. 10 6
      doc/man/date-of-man-include.am
  3. 1 2
      lib/Makefile.am
  4. 1 2
      lib/charsets.c
  5. 2 2
      lib/filehighlight/ini-file-read.c
  6. 75 0
      lib/glibcompat.c
  7. 5 0
      lib/glibcompat.h
  8. 11 86
      lib/global.h
  9. 1 1
      lib/lock.c
  10. 5 6
      lib/search/glob.c

+ 9 - 1
doc/man/Makefile.am

@@ -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)
 

+ 10 - 6
doc/man/date-of-man-include.am

@@ -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

+ 1 - 2
lib/Makefile.am

@@ -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
 

+ 1 - 2
lib/charsets.c

@@ -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

+ 2 - 2
lib/filehighlight/ini-file-read.c

@@ -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() */
 
@@ -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);

+ 75 - 0
lib/glibcompat.c

@@ -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)

+ 5 - 0
lib/glibcompat.h

@@ -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);

+ 11 - 86
lib/global.h

@@ -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)
@@ -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"
@@ -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

+ 1 - 1
lib/lock.c

@@ -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() */
 

+ 5 - 6
lib/search/glob.c

@@ -29,7 +29,6 @@
 #include "lib/global.h"
 #include "lib/strutil.h"
 #include "lib/search.h"
-#include "lib/strescape.h"
 
 #include "internal.h"
 
@@ -62,28 +61,28 @@ 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;
@@ -91,7 +90,7 @@ mc_search__glob_translate_to_regex (const GString * astr)
             }
             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;

Some files were not shown because too many files changed in this diff