Commit Graph

1937 Commits

Author SHA1 Message Date
Yury V. Zaytsev
ad96349c91 x11: fix -Wdeprecated-declarations for g_module_build_path
```
x11conn.c:140:5: warning: 'g_module_build_path' is deprecated [-Wdeprecated-declarations]
  140 |     x11_module_fname = g_module_build_path (NULL, "X11");
      |     ^~~~~~~~~~~~~~~~
```

Reported-by: David Martín <dhmartina@yahoo.es>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-08-15 21:09:08 +02:00
Yury V. Zaytsev
eb1375b65d vfs: implement support for all known stat formats and centralize handling
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-07-28 10:00:52 +02:00
Yury V. Zaytsev
c8e8f01faf utilvfs: concentrate timesbuf handling in one place
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-07-28 10:00:52 +02:00
Yury V. Zaytsev
77e5913c02 utilvfs: abstract mc_timesbuf_t handling with own mc_timespec_t type
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-07-28 10:00:52 +02:00
Yury V. Zaytsev
191108766f Ticket #4542: fix support of timestamps with nanosecond precision on macOS
utilvfs: isolate utime / utimensat calls in a helper function

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-07-28 10:00:52 +02:00
Yury V. Zaytsev
ab7ed3cf2c maint: fix typo in variable name (parse_ls_vga.c)
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-06-03 20:44:09 +02:00
Yury V. Zaytsev
335c5a78bb glibcompat: remove g_direct_equal shim
This function is present at least in glib-2.43.92:

../../lib/glibcompat.c:69:1: error: static declaration of 'g_direct_equal' follows non-static declaration
   69 | g_direct_equal (gconstpointer v1, gconstpointer v2)
      | ^~~~~~~~~~~~~~
In file included from /home/zaytsev/opt/glib/include/glib-2.0/glib.h:50,
                 from ../../lib/global.h:10,
                 from ../../lib/glibcompat.c:36:
/home/zaytsev/opt/glib/include/glib-2.0/glib/ghash.h:180:10: note: previous declaration of 'g_direct_equal' was here
  180 | gboolean g_direct_equal (gconstpointer  v1,
      |          ^~~~~~~~~~~~~~

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-06-03 16:18:12 +02:00
Yury V. Zaytsev
bda4e480d2 maint: fix typos in the code
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-06-03 16:18:04 +02:00
Andrew Borodin
6718b3ec26 Indentation using GNU indent-2.2.13.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Yury V. Zaytsev
40867e5740 clang: fix -Wimplicit-fallthrough warning
../../../lib/search/normal.c:75:9: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
        default:
        ^
../../../lib/search/normal.c:75:9: note: insert 'break;' to avoid fall-through
        default:
        ^
        break;

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Yury V. Zaytsev
04496c6fc1 clang: fix -Wconditional-uninitialized warnings
../../../src/filemanager/file.c:2402:61: warning: variable 'attrs' may be uninitialized when used here [-Wconditional-uninitialized]
                while (attrs_ok && mc_fsetflags (dst_vpath, attrs) != 0 && !ctx->skip_all)
                                                            ^~~~~
../../../src/filemanager/file.c:2266:24: note: initialize the variable 'attrs' to silence this warning
    unsigned long attrs;
                       ^
                        = 0

../../../src/filemanager/file.c:3227:38: warning: variable 'attrs' may be uninitialized when used here [-Wconditional-uninitialized]
            mc_fsetflags (dst_vpath, attrs);
                                     ^~~~~
../../../src/filemanager/file.c:2942:24: note: initialize the variable 'attrs' to silence this warning
    unsigned long attrs;
                       ^
                        = 0

../../../lib/strutil/tokenize.c:163:44: warning: variable 'delimopen' may be uninitialized when used here [-Wconditional-uninitialized]
        if (nestdelim != 0 && string[i] == delimopen)
                                           ^~~~~~~~~
../../../lib/strutil/tokenize.c:72:19: note: initialize the variable 'delimopen' to silence this warning
    char delimopen;
                  ^
                   = '\0'

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Andrew Borodin
a802f14c2e (path_trunc): optimization.
Get rid of double conversion of path: remove passwords using
vfs_path_from_str_flags (path, VPF_STRIP_PASSWORD).

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Andrew Borodin
5a67afc812 (vfs_path_build_url_params_str): minor refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Andrew Borodin
9e039f66d1 (vfs_path_from_str_uri_parser): fix coding style.
(vfs_path_to_str_flags): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Andrew Borodin
482feccca8 (mc_search__glob_translate_to_regex): reduce variable scope, refactor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:12 +03:00
Andrew Borodin
46ea5e2a99 Clarify handling of "#enc:".
* (vfs_canon): treate "#enc:" as a regular part of path in case of
    --disable-charset.
  * (realpath_test): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
8e55057fa3 (vfs_path_from_str_uri_parser): fixups.
Handle potential NULL argument.
Clarify detection of absolute path: handle a case when path starts
with #enc:.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
ab3e3339bb vfs_dirent: add new member d_len to get rid of d_name length calculation.
* (vfs_dirent_assign): set d_len up.
  * (mc_readdir): sync with new vfs_dirent: use d_len member.
  * (filename_completion_function): likewise.
  * (handle_dirent): likewise.
  * (find_ignore_dir_search): add 2nd argument to use length of
    directory name if it's known.
  * (do_search): sync with modified vfs_dirent and find_ignore_dir_search().
  * (NLENGTH): remove.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
f4183ed2f2 (filename_completion_function): use DIR_IS_DOT() macro.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
fc02bf666b (mc_g_string_append_c_len): new API that extends GString one.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
75ee44db20 Use listbox_add_item_take() in obvious cases.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
401cd4a16c (listbox_add_item_take): new WListbox API.
Add new item to a listbox taking ownerhip of item text
and avoid a string duplication.

(listbox_add_item): reimplement using listbox_add_item_take().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
e496af7a1c input complete: reimplement using GPtrArray.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:32 +03:00
Andrew Borodin
4eacf0f99b (insert_text): constify argument.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:40:02 +03:00
Andrew Borodin
2ee620f74f Ticket #4292: fix redundant back slashes for autocomplete.
Steps to reproduce:

1. Create file owth a space in the name:
  touch "a b"
There should no other files with name begins with "a" in the directory.
2. Press Shift-F4 to open editor
3. Press Shift-F2 to display dialog window "Save as..."
4. Press Esc+Tab to fill an input line

Result:
a\ b will appear in the edit field.
If you attempt to save the file, the back slash will be in the filename.

Expected result:
no any extra back slashes in the file name.

Soution: escape only '?', '*', and '&' symbols as described in the
manual page (see a11995e12b).

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-05-19 19:30:07 +03:00
Andrew Borodin
2fda4c6670 Ticket #4535: change name of temporary drirectory.
* (mc_tmpdir): use g_mkdtemp() to create temporary directory.
  Make it name unique to avoid conflicts with other software such as
  Distrobox container.
  * (main): temporary directory has unique name from now. Remove it at exit.
2024-05-13 21:48:35 +03:00
Andrew Borodin
e6ae50191b (fetch_hosts): refactoring.
Reduce variablle scope.
Refactor loops.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
4929248f30 hostname complition: refactoring: use GPtrArray. 2024-04-07 16:38:11 +03:00
Andrew Borodin
1c7da890bf (load_codepages_list_from_file): use g_ptr_array_new_full().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
1bae2c678f Move OS-specific stuff from lib/global.h to lib/unixcompat.h.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
a2f65852e3 Merge lib/utilunix.h into lib/util.h.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
aa38245e85 Merge lib/strescape.h into lib/strutil.h. Rename functions.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
9584973453 (mc_build_filenamev): refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:06:16 +03:00
Andrew Borodin
7af11660f8 Clean up irrelevant comments.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:01:47 +03:00
Andrew Borodin
44d8213f4e Ticket #4533: External editor does not work with arguments in $EDITOR
When using an external editor (i.e. "Use internal edit" in the Configure
Options is unchecked) the environment variable EDITOR is used. However,
if $EDITOR contains a command line argument after the executable name,
these arguments are not processed properly, and the editor might not be
started at all.

How to reproduce: (Precondition: vi is available on the system)
  1) On the command line, execute: export EDITOR="vi +" && mc
(the + argument should let vi start at the document's end instead of the
beginning).
  2) Go to the Options menu -> Configuration -> uncheck "Use internal
edit".
  3) Move the cursor to a file that is larger than a single screen (e.g.
ABOUT-NLS in mc's source directory).
  4) Press F4 to start the external editor.

Result: Nothing visible happens

Expected result: vi is opened showing the end of the file ABOUT-NLS

The bug: my_system_make_arg_array() doesn't perform full-feature
parsing of the comman line.

  * (str_tokenize): mew function based on history_tokenize_internal()
from GNU readline-8.2.
  * (str_tokenize_word): mew function based on history_tokenize_word()
from GNU readline-8.2.
  * (my_system_make_arg_array): reimplement using str_tokenize().
  * (my_systemv_flags): use modified my_system_make_arg_array().
  * (fork_child_tokens): new test for string tokenization.
  * (fork_child_tokens2): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-03-31 19:04:26 +03:00
Andrew Borodin
fe42478b97 Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-01-01 09:46:17 +03:00
Andrew Borodin
07db4c4fa3 Refactor learn keys.
* (learn_store_key):
  * (learn_key): use GString for key buffer.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
2d86b8889f Use g_string_new_take().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
247d092217 (str_utf8_offset_to_pos): change type of variable.
GString is pointless here.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
2e33fd4fad (mc_search_regex__get_max_num_of_replace_tokens): refactor loop.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
85b1cec81e lib/widget/input_complete.c: remove intermediate variables.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
94daff9071 (menubar_execute_cmd): move CK_Help handler to separate function menubar_help().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
20dd30ada3 (dlg_execute_cmd): move CK_Help handler to separate function dlg_help().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
1b3684e0e1 Ticket #4433: skins: add color for non-printable characters in editor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-10 17:47:07 +03:00
TobiasW
f78f9b2eda Ticket #4509: support for lzo/lzop compression format.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-26 17:27:11 +03:00
Andrew Borodin
7459861f58 (mc_config_history_save): remove check because condition is always true here.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
a74d638155 (mc_config_history_get_recent_item): new API.
* (edit_search_cmd): use mc_config_history_get_recent_item().
  * (mcview_continue_search_cmd): likewise.

mc_config_history_get_recent_item() is not implemented optimally yet.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
018687b12f Fix comments of history and panels.ini files location.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
6b274f7034 lib/mcconfig/history.c: fix comments.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
d4e59aa022 Refactoring: avoid create an empty strings.
* (name_quote): return NULL instead of an empty string.
  * (fake_name_quote): likewise.
  * (expand_format): likewise.
  * Related changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00