Commit Graph

6624 Commits

Author SHA1 Message Date
Andrew Borodin
b50470f067 Tricket #3761: mcedit: wrong deletion of marked column.
If mark column (Shitf+F3) and select the column from left to right, from
up to down, it can be properly deleted later with F8.
But if select it from right to left, from up to down, erasing with F8
keeps the first line of the selected block.

Solution: don't call eval_marks() several times while deleting vertical
block.

  * (edit_block_delete_cmd): calculate mark positions here and pass them...
  * (edit_block_delete): ...through here...
  * (edit_delete_column_of_text): ...to here.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:19:50 +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
Balló György
b750e70920 Ticket 4324: EXTFS: s3+: port to Python3.
Closes MidnightCommander/mc#149.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-10 17:42:41 +03:00
Andrew Borodin
95958bce85 (extfs_cmd): fix build of extfs command if localname is empty.
Fix d4e59aa022.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-04 21:00:53 +03:00
Roman 'gryf' Dobosz
9aa5974fdc Ticket #4511: update uc1541 unit of EXTFS VFS.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-28 21:08:28 +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
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
6735c4803a src/editor/edit.c: fix coding style.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
433f792b53 (edit_insert_file): change variable type from int to gboolean.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
719422746a (edit_user_menu): avoid inverse logic.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
6ad4f04626 mcedit: rename user_menu() to edit_user_menu().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
2949eabd33 mcedit: minor optimization.
* (edit_left_word_move): break the loop as fast as possible.
  * (edit_right_word_move): likewise.
  * (edit_left_delete_word): likewise.
  * (edit_right_delete_word): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
1fe2d902b8 (edit_cursor_to_eol): reduce variable scope.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
c3bc294bb3 (edit_execute_cmd): refactor loop.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
442af62c07 (insert_spaces_tab): refactor loop.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +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
Andrew Borodin
44b5accbf7 (expand_format): remove intermediate variable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
daaea80895 (strip_ext): refactor loop.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
657090aa1f tar: type accuracy.
* (oldgnu_get_sparse_info): change type for boolean variable from int
    to gboolean.
  * (star_get_sparse_info): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andreas Mohr
e87e0524a8 (oldgnu_get_sparse_info) fix conditional-uninitialized warning.
tar-sparse.c:563:55: warning: variable 'rc' may be uninitialized when used here [-Wconditional-uninitialized]
    for (ext_p = h->oldgnu_header.isextended ? 1 : 0; rc == add_ok && ext_p != 0;
                                                      ^~
tar-sparse.c:551:5: note: variable 'rc' is declared here
    enum oldgnu_add_status rc;
    ^

Found by clang-16.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
9a964edea9 (edit_print_string): refactor loop.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andreas Mohr
43a398d76f (do_background): fix leak of file descriptors.
background.c: In function 'do_background':
background.c:587:1: error: leak of file descriptor 'comm[0]' []8;;https://cwe.mitre.org/data/definitions/775.htmlCWE-775]8;;] []8;;https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html#index-Wanalyzer-fd-leak-Werror=analyzer-fd-leak]8;;]
  587 | }
      | ^
  'do_background': events 1-12
    |
    |  527 |     if (pipe (comm) == -1)
    |      |        ~^~~~~~~~~~~
    |      |        ||
    |      |        |(1) opened here as read-write
    |      |        |(2) when 'pipe' succeeds
    |      |        (3) following 'false' branch...
    |......
    |  530 |     if (pipe (back_comm) == -1)
    |      |     ~~ ~~~~~~~~~~~~~~~~~
    |      |     |  ||
    |      |     |  |(5) when 'pipe' succeeds
    |      |     |  (6) following 'false' branch...
    |      |     (4) ...to here
    |......
    |  538 |     pid = fork ();
    |      |     ~~~
    |      |     |
    |      |     (7) ...to here
    |  539 |     if (pid == -1)
    |      |        ~
    |      |        |
    |      |        (8) following 'false' branch (when 'pid != -1')...
    |......
    |  552 |     if (pid == 0)
    |      |     ~~ ~
    |      |     |  |
    |      |     |  (10) following 'true' branch (when 'pid == 0')...
    |      |     (9) ...to here
    |  553 |     {
    |  554 |         int nullfd;
    |      |         ~~~
    |      |         |
    |      |         (11) ...to here
    |......
    |  587 | }
    |      | ~
    |      | |
    |      | (12) 'comm[0]' leaks here
    |
background.c:587:1: error: leak of file descriptor 'back_comm[1]' []8;;https://cwe.mitre.org/data/definitions/775.htmlCWE-775]8;;] []8;;https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html#index-Wanalyzer-fd-leak-Werror=analyzer-fd-leak]8;;]
  587 | }
      | ^
  'do_background': events 1-12
    |
    |  527 |     if (pipe (comm) == -1)
    |      |        ~^~~~~~~~~~~
    |      |        ||
    |      |        |(1) when 'pipe' succeeds
    |      |        (2) following 'false' branch...
    |......
    |  530 |     if (pipe (back_comm) == -1)
    |      |     ~~ ~~~~~~~~~~~~~~~~~
    |      |     |  ||
    |      |     |  |(4) opened here as read-write
    |      |     |  |(5) when 'pipe' succeeds
    |      |     |  (6) following 'false' branch...
    |      |     (3) ...to here
    |......
    |  538 |     pid = fork ();
    |      |     ~~~
    |      |     |
    |      |     (7) ...to here
    |  539 |     if (pid == -1)
    |      |        ~
    |      |        |
    |      |        (8) following 'false' branch (when 'pid != -1')...
    |......
    |  552 |     if (pid == 0)
    |      |     ~~ ~
    |      |     |  |
    |      |     |  (10) following 'true' branch (when 'pid == 0')...
    |      |     (9) ...to here
    |  553 |     {
    |  554 |         int nullfd;
    |      |         ~~~
    |      |         |
    |      |         (11) ...to here
    |......
    |  587 | }
    |      | ~
    |      | |
    |      | (12) 'back_comm[1]' leaks here
    |
background.c:587:1: error: leak of file descriptor 'comm[1]' []8;;https://cwe.mitre.org/data/definitions/775.htmlCWE-775]8;;] []8;;https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html#index-Wanalyzer-fd-leak-Werror=analyzer-fd-leak]8;;]
  587 | }
      | ^
  'do_background': events 1-12
    |
    |  527 |     if (pipe (comm) == -1)
    |      |        ~^~~~~~~~~~~
    |      |        ||
    |      |        |(1) opened here as read-write
    |      |        |(2) when 'pipe' succeeds
    |      |        (3) following 'false' branch...
    |......
    |  530 |     if (pipe (back_comm) == -1)
    |      |     ~~ ~~~~~~~~~~~~~~~~~
    |      |     |  ||
    |      |     |  |(5) when 'pipe' succeeds
    |      |     |  (6) following 'false' branch...
    |      |     (4) ...to here
    |......
    |  538 |     pid = fork ();
    |      |     ~~~
    |      |     |
    |      |     (7) ...to here
    |  539 |     if (pid == -1)
    |      |        ~
    |      |        |
    |      |        (8) following 'false' branch (when 'pid != -1')...
    |......
    |  552 |     if (pid == 0)
    |      |     ~~ ~
    |      |     |  |
    |      |     |  (10) following 'false' branch (when 'pid != 0')...
    |      |     (9) ...to here
    |......
    |  583 |         ctx->pid = pid;
    |      |         ~~~
    |      |         |
    |      |         (11) ...to here
    |......
    |  587 | }
    |      | ~
    |      | |
    |      | (12) 'comm[1]' leaks here
    |
background.c:587:1: error: leak of file descriptor 'back_comm[0]' []8;;https://cwe.mitre.org/data/definitions/775.htmlCWE-775]8;;] []8;;https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html#index-Wanalyzer-fd-leak-Werror=analyzer-fd-leak]8;;]
  587 | }
      | ^
  'do_background': events 1-12
    |
    |  527 |     if (pipe (comm) == -1)
    |      |        ~^~~~~~~~~~~
    |      |        ||
    |      |        |(1) when 'pipe' succeeds
    |      |        (2) following 'false' branch...
    |......
    |  530 |     if (pipe (back_comm) == -1)
    |      |     ~~ ~~~~~~~~~~~~~~~~~
    |      |     |  ||
    |      |     |  |(4) opened here as read-write
    |      |     |  |(5) when 'pipe' succeeds
    |      |     |  (6) following 'false' branch...
    |      |     (3) ...to here
    |......
    |  538 |     pid = fork ();
    |      |     ~~~
    |      |     |
    |      |     (7) ...to here
    |  539 |     if (pid == -1)
    |      |        ~
    |      |        |
    |      |        (8) following 'false' branch (when 'pid != -1')...
    |......
    |  552 |     if (pid == 0)
    |      |     ~~ ~
    |      |     |  |
    |      |     |  (10) following 'false' branch (when 'pid != 0')...
    |      |     (9) ...to here
    |......
    |  583 |         ctx->pid = pid;
    |      |         ~~~
    |      |         |
    |      |         (11) ...to here
    |......
    |  587 | }
    |      | ~
    |      | |
    |      | (12) 'back_comm[0]' leaks here
    |

Found by gcc-13 (-fanalyzer-fd-leak).

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andreas Mohr
2c49acf868 tar (uintmax_from_header): remove unused function and macro.
Found by clang-16.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
1cada10e14 tar: parse in a more locale-independent way.
Use g_ascii_isspace() rather than isspace().

Sync with GNU tar 01f986b921d988ae51de6c937cc374b50a8b23b0.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
16d9f23161 tar: use single is_octal_digit function.
Sync with GNU tar 05fcfaafb648cb7e9bd01004593ce016b8fb1f32.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
4077522b2b (dff_reparse): get rif of code duplication.
Move diff displaying to separate function.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
e1ee8a4da2 ydiff.c: refactror loops: replace 'while' with 'for' where reasonably.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
6a10d8e932 (scan_diff): eliminate 'continue', use 'else' instead. 2023-11-06 21:06:14 +03:00
Andrew Borodin
c2e7bb9336 ydiff.c (fill_by_space): new helper function.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
b05c1731fc ydiff.c: rename functions.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
bee7d2aa39 ydiff.c: use g_array_set_clear_func().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
f373af88b7 (hdiff_multi): g_array_new() doesn't return NULL.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
c3bc39814e (redo_diff): g_array_new() doesn't return NULL.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
5cb55be2a3 (redo_diff): g_ptr_array_new() doesn't return NULL.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
92cc9b053d WDiff::display_symbols: change type from int to gboolean. Related changes.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
313b06034e ydiff.c: fix coding style.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:13 +03:00
Andrew Borodin
5d8399befb tty: refactoring of color pairs deallocation.
* (tty_color_free_all_tmp): rename to tty_color_free_temp and call
    g_hash_table_foreach_remove().
  * (tty_color_free_all_non_tmp): rename to tty_color_free_all and call
    g_hash_table_remove_all().
  * (tty_color_free_all): remove.
  * (tty_color_free_condition_cb): rename to tty_color_free_temp_cb and
    simplify.
  * (mc_skin_deinit): use changed API.
  * (edit_free_syntax_rules): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:13 +03:00
Andrew Borodin
2d6d8a477e tty: color-related API changes
* (tty_try_alloc_color_pair): remove.
  * (tty_try_alloc_color_pair2): rename to tty_try_alloc_color_pair,
  change arguments.
  * (tty_color_set_defaults): changes arguments.
  * (this_try_alloc_color_pair): likewise.
  * lib/skin/color.c: related changes.
  * src/editor/syntax.c: likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:13 +03:00
Michal Sojka
8303ccaec3 sftpfs: don't set preferred hostkey methods too restrictively.
This fixes "sftp: failure establishing SSH session (-5)" error that
may appear on some systems when using SFTP link feature. The error
appears even when connecting to the same host via the "ssh" command
works. Whether the error appears or not depends on the content of
~/.ssh/known_hosts file.

Problem description:

Midnight Commander uses ~/.ssh/known_hosts for two reasons. Obviously,
one reason is checking for hostkey match after the SSH handshake. The
second reason is to set preferences which host key the remote side
should send us during the SSH handshake. And this is the problematic
place.

Entries in ~/.ssh/known_hosts store host names either in plain text or
in a hashed form. libssh2 does not export host name hashes, only plain
text host names. When mc tries to find a matching entry to set hostkey
preferences, it cannot cannot reliably match the hashed host names.
Before this change, mc assumed that any entry with hashed host name
matches the connecting host and set hostkey preference to the type of
that key. In many cases, this was incorrect. For example, when the
first hashed entry in ~/.ssh/known_hosts appeared before the matching
non-hashed one, and its key type was ssh-rsa, which is disabled by
default since OpenSSH 8.8 (released 2021-09-26), then mc requested
only the ssh-rsa host key from the remote host. Since this host key is
likely disabled these days, no key was sent by the remote host and mc
reported error -5 (LIBSSH2_ERROR_KEX_FAILURE).

Solution:

In this commit, we fix the problem as follows:

1. When finding a matching known_hosts entry in order to set the
   preferred hostkey method, we ignore the entries with hashed host
   names. If we find no matching entry with the plain text host name,
   no preference is set, resulting in the server sending us whatever
   key it wants and our libssh2 supports it. Likely, that key will
   match an entry with hashed host name later during the host key
   check.

2. If, on the other hand, a matching plain text entry is found, we use
   its type as a preference, but newly, we add other methods as a
   fallback. If the matched entry has a server-supported key type, it
   will be used. If it is not supported by the server (e.g. the old
   ssh-rsa type), the added fallback ensures that the server sends us
   some host key, which will likely match an entry with hashed host
   name later during the host key check.

This solution is not ideal, but I think it's good enough. For example,
the following situation is not solved ideally (I think): The
known_hosts file contains a single entry for some server. It has a
hashed host name and key of type B. Since we ignore hashed entries,
the server can send its host key as type A, which is higher on the
preference list. To the user, it will appear as that she has never
connected to that server before. After accepting the new key, it will
be added to known_hosts and the problem disappears.

Ideal solution would IMHO be to create libssh2_knownhost_find()
function in libssh2. It would allow finding all matching entries (even
with hashed host names) in known_hosts. Midnight commander would then
use all key types of found entries as its preference.

Note: Since the code modified by this commit was inspired by code from
curl, curl has the same problem. See
https://github.com/libssh2/libssh2/issues/676#issuecomment-1741877207.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-10-22 18:03:44 +03:00
lnx
3c4941867a Ticket #4507: shell VFS: incorrect file names with cyrillic or diacritic symbols.
When using "Shell link", filenames with cyrillic or diacritic symbols
are displayed as chains of numbers.

The problem is due to Perl version. With Perl v5.36.0, there is no
S_ISLNK in POSIX.pm. With Perl v5.38.0, there is S_ISLNK in POSIX.pm,
so S_IMODE and S_IFMT are not imported from Fcntl due to condition
unless defined &S_ISLNK.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-10-15 16:21:31 +03:00
Andrew Borodin
6ca4ab4b4e Rename FISH VFS to SHELL one. 2023-10-15 16:04:39 +03:00
Andrew Borodin
3f42309a5d Ticket #4232: drop comatibility with native FISH protocol and FISH server.
Does anybody know any implementation of FISH server?

Should we keep the compatibility with unimplemented server?

Let's forget about the compatibility with FISH command formats. Let's
just send shell scripts with arguments that are convenient for us to the
remote host and get results of script work. The part of FISH protocol
relative to remote host answers will be used as is.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-10-15 16:04:38 +03:00
Andrew Borodin
0ed72610f2 Ticket #4499: reget: wrong timestamp when resuming copy operation.
(copy_file_file): always set the destination file timestamps to the
source file ones at the end of copy operation regardless of destination
file is complete or not.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-09-05 12:59:44 +03:00
Andrew Borodin
dfe3279a36 Ticket 4500: mcdiff: segfault when display of line numbers is enabled.
The bug was introduced in 00f84fbf24.

  * (dview_load_options): avoid NULL dereference: don't caclulate the
    width of line numbers field here because dview->a isn't created yet.
  * (dview_update): caclulate the width of line numbers field using an
    actual length of diff lines array.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-09-05 12:52:03 +03:00
Andrew Borodin
a4a5c97e1f Ticket #4494: tar: fix handling of hard links.
* tar.c: add typeflag values for regular file.
  * (tar_skip_member): set data offset here (and for regular file only)...
  * (tar_insert_entry): ...not here.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-27 16:21:19 +03:00
Andrew Borodin
9688e7d015 Ticket #4439: FTBFS on FreeBSD with ext2fs attribute support:
local.c:35:10: fatal error: 'e2p/e2p.h' file not found
         ^~~~~~~~~~~

  * m4.include/mc-ext2fs-attr.m4: add EXT2FS_CFLAGS E2P_CFLAGS to
    CPPFLAGS here...
  * src/filemanager/Makefile.am: ...not here.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-19 20:51:07 +03:00
Andrew Borodin
1f61ab0563 tar-sparse.c: turn -Werror=type-limits off here.
...to avoid following error:
comparison of unsigned expression < 0 is always false [-Werror=type-limits]

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-13 13:17:16 +03:00
Andrew Borodin
7e61d298b8 (pax_decode_header): fix the loop range.
The high boundary 'u' of loop was modified in the loop as a result of
decode_num().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-12 20:48:15 +03:00
Andrew Borodin
02dea0d65d (pax_decode_header): fix comparison of integer expressions of different signedness.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-12 20:48:07 +03:00
Andrew Borodin
38f41e4c82 (tar_free_inode): mark unused parameter.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-12 20:47:47 +03:00
Andrew Borodin
f1cf92f435 Indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:55 +03:00
Andrew Borodin
978ce6d0dd Use vfs_path_get_last_path_vfs() where it is resonable. 2023-08-04 21:04:55 +03:00
Andrew Borodin
e20d9acecb Use vfs_path_get_last_path_str() where it is resonable. 2023-08-04 21:04:55 +03:00
Andrew Borodin
b926c08ec9 sftpfs: refactoring: get rid of code duplication.
* (sftpfs_op_init): make public and use it...
  * (sftpfs_opendir): here,
  * (sftpfs_mkdir): here,
  * (sftpfs_rmdir): and here.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:55 +03:00
Andrew Borodin
ec98810986 (tree_move): get rid of gotos. 2023-08-04 21:04:55 +03:00
Andrew Borodin
e8e9d222a9 (tar_skip_member): fix NULL dereference.
Found by Coverity.
Coverity id #462418.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:55 +03:00
Andrew Borodin
37e7ee5a47 (edit_push_redo_action): reduce variable scope.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:55 +03:00
Andrew Borodin
a9f4626138 (edit_push_undo_action): reduce variable scope.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:55 +03:00
Andrew Borodin
8a0f00ae6f (edit_load_macro_cmd): reduce variable scope.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
e1c4e7f3cb (info_show_info): fix unused variable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
482e183190 (spell_dialog_lang_list_show): ret rid of string duplication.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
2e78166c23 src/editor/spell.c: refactoring: use GPtrArray instead of GArray for string arrays.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
583adea34e (edit_suggest_current_word): minor refactoring.
Do not duplcate an empty string.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
0869946de5 (str_nconvert_to_input): return NULL if input is NULL.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
464a2eeefc (str_nconvert_to_display): return NULL if input is NULL.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
6fecb7a9e8 (mc_args__convert_help_to_syscharset): return GString.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
0a9ecdeb98 Remove #include <errno.h> from files where errno is unused. 2023-08-04 21:04:54 +03:00
Andrew Borodin
f4ac2bb01f (cd_error_msg): new function to show the change directory error message.
Use it where needed.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
8cc71a7f65 src/viewer/nroff.c: remove unneeded include.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
044c035900 Use bit-field members of file_entry_t as integers explicitly.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
7f30f8c692 file_entry_t: rename members:
sort_key -> name_sort_key
  second_sort_key -> extension_sort_key

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
51400f132e (repaint_file): decomposition.
(repain_status): new function. Move draw of mini-status here from
repaint_file().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
94df2c8c8d src/filemanager/panel.c: refactor file color attributes.
* attributes: enum instead of defines.
 * (paint_dir): set attributes explicitly.
 * (unselect_item): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
fe121396ca WPanel: rename 'top_file' to 'top'.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
f29118dcec WPanel: rename 'selected' to 'current' and related changes.
Renames:
  WPanel::selected -> WPanel::current
  selection (macro) -> panel_current_entry()
  panel_selected_at_half() -> panel_current_at_half()
  move_selection() -> panel_move_current()
  do_select() -> panel_set_current()
  try_to_select() -> panel_set_current_by_name()
  mark_if_marking(): argument and intermal variables
  file attributes:
    SELECTED -> CURRENT
    MARKED_SELECTED -> MARKED_CURRENT

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
fac7922cd0 (do_try_to_select): move into try_to_select().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
6fb8b13207 Rename key-related APIs:
lookup_key() -> tty_keyname_to_keycode()
  lookup_key_by_code() -> tty_keycode_to_keyname()

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
35b5d8e2f2 WListbox: renames:
WListbox::pos -> WListbox::current
  listbox_select_entry() -> listbox_set_current()
  listbox_get_nth_item() -> listbox_get_nth_entry()

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
e6cb6591b3 (dlg_close): rename from dlg_stop().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:11 +03:00
Andrew Borodin
3616877462 (vfs_get_cwd): rename from _vfs_get_cwd(), simplify.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:11 +03:00
Andrew Borodin
9d28def848 (make_symlink): minor optimization.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:11 +03:00
Andrew Borodin
52572d5b80 (vfs_path_new): add argument to create relative path object.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:11 +03:00
Andrew Borodin
43fc63be8e src/filemanager/panel.c: fix indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:11 +03:00
Andrew Borodin
d82bfd8902 (do_external_panelize): constify argument.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:11 +03:00
Andrew Borodin
8b30eaee1c Ticket #4426: code clean up before 4.8.30 release.
(erase_dir_after_copy): don't call g_queue_is_empty() if erase_list is NULL.
erase_list is NULL in case of move an empty directory across filesystems.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:11 +03:00
Andrew Borodin
00f84fbf24 Ticket 3386: diffviewer: options are not applied on second run.
Fix: make full initialization before diff execution.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-07-29 19:43:32 +03:00
Roland Illig
b8d6485467 Ticket #4485: patchfs: be more specific in error message.
Closes MidnightCommander/mc#192.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-07-23 14:06:51 +03:00
Andrew Borodin
14bc2ac2f1 Ticket #4472: (ftpfs_parse_long_list_UNIX): don't ignore special files.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-06-04 12:02:24 +03:00
Andrew Borodin
25a445ed88 Ticket 1952: fix wrong timestamps "Jan 1, 1970" int tar archives.
(tar_insert_entry): assign timestamps after header decoding.
(tar_fill_stat): remove irrelevant #ifdef & #endif.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-05-28 19:23:44 +03:00
Evgeny Grin
cfe9ae814b Ticket #4464: FTBFS without ext2fs attributes support.
Closes MidnightCommander/mc#188.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-05-21 20:34:07 +03:00
Andrew Borodin
8d1427d183 tar: add support of extended headers.
Most of the code is taken from GNU tar.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-05-01 13:07:29 +03:00
Andrew Borodin
ffe6412c30 tar: prepare to support the POSIX extended headers.
Move required stuff to tar-internal.{ch} files.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-05-01 13:04:29 +03:00
Andrew Borodin
8223f82857 tar: refactoring of archive reading.
Make it close to GNU tar imlementation.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-05-01 13:02:57 +03:00
Andrew Borodin
4158824d70 (tar_read_header): move entry/inode creation to new function tar_insert_entry(). 2023-05-01 13:02:57 +03:00
Andrew Borodin
c35dfc3363 tar: use separate structure to store various file info.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-05-01 13:02:57 +03:00
Andrew Borodin
d4d0fe6019 (tar_read_header): minor optimization.
Calculate length of file and link name if that is really needed.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-05-01 13:02:42 +03:00
Andrew Borodin
d4ded63724 (tar_read_header): rename variable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-04-23 20:51:57 +03:00
Andrew Borodin
07a0aa352d (tar_find_next_block): rename from tar_get_next_block.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-04-23 20:51:57 +03:00
Andrew Borodin
3ed39fb883 src/vfs/tar/tar.c: remove period from error messages.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-04-23 20:51:56 +03:00
Andrew Borodin
3a9524979c (tar_read_header): rename variables.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-04-23 20:51:56 +03:00
Andrew Borodin
96ebde8d68 (tar_get_next_block): use file descriptor from archive descriptor.
(tar_skip_n_records): likewise.
(tar_read_header): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-04-23 20:51:56 +03:00
Andrew Borodin
74c16acf6a (tar_open_archive_int): return status of tar archive open
... instead of file descriptor.

(tar_open_archive): remove variable stored file descriptor. Use file
descriptor from archive descriptor.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-04-23 20:51:56 +03:00
Andrew Borodin
35e548b054 src/vfs/tar/tar.c: clarify support of OLDGNU format.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-04-23 20:51:56 +03:00
Andrew Borodin
d647914bfb (tar_decode_header): do not decode size here.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-04-23 20:51:56 +03:00
Andrew Borodin
78a25f7800 Ticket #1952: tar: support long file names in archive.
Initial changeset: tar.c: update code to be close to GNU tar.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-04-23 20:49:41 +03:00
Andrew Borodin
49624e473b Ticket #4450: support PCRE2 in the search engine.
* m4.include/ax_path_lib_pcre.m4: replace by recent version from GNU
Autoconf Archive.
  * m4.include/ax_check_pcre2.m4: get grom GNU Autoconf Archive.
  * m4.include/mc-check-search-type.m4: support both PCRE versions.
  * */*/Makefile.am: remove @CHECK_CFLAGS@ and @PCRE_LIBS@ ads they are
added via AX_PATH_LIB_PCRE and AX_CHECK_PCRE2.
  * lib/search.h, lib/search/: add support of PCRE2. Thanks broly <gagan@hotmail.com>
for the initial patch.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-25 10:07:41 +03:00
Andrew Borodin
a286f042d4 (edit_find_editor): rename from find_editor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
c157b048e5 Listbox window: rename functions.
create_listbox_window -> listbox_window_new
create_listbox_window_centered -> listbox_window_new_centered
run_listbox -> listbox_run
run_listbox_with_data -> listbox_run_with_data

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
d9383ba8b3 (buttonbar_find): rename from find_buttonbar.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
fd2d5b49ac Menu: rename functions.
menu_entry_create -> menu_entry_new
menu_separator_create -> menu_separator_new
create_menu -> menu_new
destroy_menu -> menu_free
find_menubar -> menubar_find

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
a242e8b91f (advanced_chown_cmd): use intermediate variables to make text more readable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
79c8a351ba Use mc_fgetflags() and mc_fsetflags() where needed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
2a6580127a VFS: mc_fgetflags, mc_fsetflags: new APIs.
(mc_fgetflags): fgetflags(3) VFS wrapper.
(mc_fsetflags): fsetflags(3) VFS wrapper.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
50f4717f45 Minor optimization of chown/chmod/chattr operations.
(try_chmod): create filename when required.
(try_chown): likewise.
(try_advanced_chown): likewise.
(try_chattr): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
6329771fc0 (operate_single_file): clarify creation of file operation UI.
Create UI to show confirmation dialog in case of foreground operation
regardless of ENABLE_BACKGROUND.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
8a951746b3 Collect all editor options to structure.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
d2b9454f4b Add EDIT and CONST_EDIT macros.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
683122482b usermenu: clarify compilation w/o internal editor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andreas Mohr
de1edb72f8 src/editor/spell.c: add missed #include.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
7257f794d2 Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):

/*** forward declarations (file scope functions) *************************************************/

/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);

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

static struct
{
    ...
    bcback_fn callback;
} fbuts[] =
{
    ...
    { B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
    ...
    { B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
    { B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin
e1ff8d94e4 (do_search): remove intermediate variable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
c7f9329dcb (do_search): get rid of string duplication.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
584fb9815c Change WDialog::data from void* to union{void*, int}
...to use data of type other than pointer w/o extra type cast.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
c5466cd494 Don't create an empty string in WLabel objects.
* (simple_status_msg_init_cb): pass NULL instead of "" to label_new()
    to get rid of an empty string duplication.
  * (advanced_chown_dlg_create): likewise.
  * (chown_dlg_create): likewise.
  * (dirsize_status_init_cb): likewise.
  * (file_op_context_create_ui): likewise.
  * (setup_gui): likewise.
  * (init_hotlist): likewise.
  * (init_learn): likewise.
  * (file_progress_show_source): pass NULL instead of "" to
    label_set_text() to get rid of an empty string duplication.
  * (file_progress_show_target): likewise.
  * (create_file_manager): pass NULL instead of 0 to label_new().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
e472f23c13 Don't NULLify objects by returned value of g_ptr_array_free().
g_ptr_array_free(obj, ...) returns a pointer (including NULL) to
obj->pdata, not to obj.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
000c1f18e6 src/vfs/tar/tar.c: reorder routines.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
ea93350506 (tar_decode_header): use offsetof().
Sync with GNU tar b8feb2b14247d76200fd53607d3613c82b6e5b81.

Access header->buffer + offsetof (struct posix_header, magic), instead
of header->header.magic, when reading or writing the OLDGNU_MAGIC
pattern. The code violates the C standard without this change, and GCC
warns about this if fortify checking is enabled. It's not a bug on
traditional (i.e., non-debugging) platforms, but it does violate the C
standard so it should be fixed. Problem originally reported by John
Emil Karlson in
<http://lists.gnu.org/archive/html/bug-tar/2010-04/msg00023.html>.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
4a17f02b21 (tar_skip_n_records): change type of n to off_t.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
4ae197e788 (tar_checksum): sync with GNU tar b5db9788306d45cd9432fda71236f07b8a214212.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
c4e20d3176 src/vfs/tar/tar.c: rename header read status and values.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
8ce58eab7b src/vfs/tar/tar.c: reorder includes; add <sys/stat.h>.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
a15b91b030 src/vfs/tar/tar.c: clean up.
Sync with GNU tar 33b63ebe94b8a2dc2cb8fb907d8b7c16591b05bc.

(struct extra_header): Removed unused structure.
(union block.extra_header): Removed unused member.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
8fdcbeed74 Move definition of file_entry_t to separate file.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
cf223bec27 Use g_ptr_array_new_with_free_func() where reasonably.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
273fbd2afe mceditor: editbuffer: use g_ptr_array_new_full() to create text buffers.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
29f513cf58 File operations: get file operation from the file operation context descriptor.
* (file_mask_dialog): get file operation from the file operation context
descriptor.
  * (do_confirm_copy_move): likewise.
  * (operate_single_file): likewise.
  * (operate_one_file): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
f25895280b (panel_operate): change type of save_cwd and save_dest to vfs_path_t
...to get rid of extra type conversions and memory allocations.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin
3364b5772c Ticket #4426: code clean up before 4.8.30 release.
(panel_do_set_filter): fix indentation.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Michal Sojka
d71a9cd43a Ticket #3121: don't clear subshell prompt during its reading.
When using zsh with starship.rs prompt generator, MC sometimes fails
to show the subshell prompt. This is not deterministic. Sometimes the
prompt is shown and sometimes it isn't.

The reason is that the shell prints the prompt in multiple chunks. The
first chunk contains the "real" prompt and the second is an escape
sequence for enabling bracketed paste mode. If both chunks are read by
MC in a single invocation of read_subshell_prompt(), the prompt is
shown correctly. If, however, read_subshell_prompt() reads each chunk
in separate invocations (because the second chunk is not ready during
the first invocation), the prompt is not shown. More precisely, only
the bracketed paste mode escape sequence is shown as a prompt in MC.

This can be demonstrated with the following commands:

    export SHELL=$(which zsh)
    export ZDOTDIR=/tmp/zshdotdir
    export STARSHIP_CONFIG=/tmp/starship-test.toml
    mkdir -p "$ZDOTDIR"
    echo 'eval "$(starship init zsh)"' > "$ZDOTDIR/.zshrc"
    echo 'format = "XXXX: $directory$character"' > "$STARSHIP_CONFIG"
    mc

In my case, the prompt is usualy shown after mc start and it
disappears after changing a directory in mc. In that case, the prompt
is read() in the following two chunks:

- 63 bytes: \xd\x1b[0m\x1b[27m\x1b[24m\x1b[J\xd\xaXXXX: \x1b[1;36mmc/.git\x1b[0m \x1b[1;32m\xe2\x9d\xaf\x1b[0m \x1b[K
- 8 bytes: \x1b[?2004h

To fix the problem, we remove clearing of the prompt string in
read_subshell_prompt(). It is sufficient that the prompt is cleared
when receiving '\n' and in feed_subshell().

Signed-off-by: Michal Sojka <michal.sojka@cvut.cz>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:27:25 +03:00
Andrew Borodin
7e04a57b87 Ticket #4408: incorrect redraw of overlapped file panels.
Revert "(panel_operate): update panel content before screen refresh."

This reverts commit 6623a9014f.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-12 10:14:13 +03:00
Andrew Borodin
b4bb352bfa Ticket #4235: fix find file with relative ignore directory.
If start directory of find files matches to the relative ignore
directory, nothing is found.

(do_search): the start directory is the first one in the directory
stack. Do not apply ignore_dir to it.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-05 19:51:50 +03:00
Pavel Roskin
44c299c784 Ticket #4446: mcedit: fix off-by-one error in paragraph formatting code.
The default margin is 72 characters, but the editor would keep 73 character
long lines without breaking them.

The visual length of strings was calculated incorrectly. The way "for" loop
was implemented, the byte length would be incremented before exiting the
loop. That would correspond to a character that doesn't fit the line.

Increment the byte length in a separate statement.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-20 21:36:37 +03:00
Andrew Borodin
e14ebea59f Ticket #4370: file panelization improvement.
Previously, both file panels share panelization results.
Now each file panel has own panelization buffer.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-19 19:00:59 +03:00
Andrew Borodin
cce50e5bff Ticket #4432: wrong sort order after swapping panels.
Revert "(swap_panels): swap panel sort modes too."

This reverts commit d07abec4c3.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-01 20:55:28 +03:00
Andrew Borodin
3937f97d96 Ticket #4437: (file_frmt_time): fix time format.
Change minutes and seconds delimiter: h:mm.ss -> h:mm:ss.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
08c2d4e276 (load_extension_file): make one-line long error messages multi-line.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Robert Yang
6123946251 extfs helpers: replace "perl -w" with "use warnings" (closes MidnightCommander/mc#174).
The shebang's max length is usually 128 as defined in
/usr/include/linux/binfmts.h:
  #define BINPRM_BUF_SIZE 128

To get around this, '/usr/bin/env perl' in place of @PERL@ can be used, but
'/usr/bin/env perl -w' doesn't work:

/usr/bin/env: perl -w: No such file or directory

So replace "perl -w" with "use warnings" to make it work.

The man2hlp.in already has "use warnings;", so just removing '-w' is OK.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2023-01-28 21:38:05 +03:00
Andrew Borodin
70599156db (do_find): use dir_list_append() to create file list for panelization.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andreas Mohr
606bd02945 (do_find): remove unused variable.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Kian-Meng Ang
5001232704 Fix various typos in the source code (closes MidnightCommander/mc#177).
Found via `codespell -S
po,doc,./misc/syntax,./src/vfs/extfs/helpers/README.it -L
parm,rouge,sav,ect,vie,te,dum,clen,wee,dynamc,childs,ths,fo,nin,unx,nd,iif,iterm,ser,makrs,wil`

Co-authored-by: Yury V. Zaytsev <yury@shurup.com>
Signed-off-by: Kian-Meng Ang <kianmeng@cpan.org>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2023-01-28 21:38:05 +03:00
Andrew Borodin
990200f6d3 (panel_destroy): don't free file list.
That is already done in panel_clean_dir().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
0b19bda4a1 (search_content): use g_get_monotonic_time() instead of g_get_real_time().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
58afbbe1ce (extfs_get_plugins): minor optimization.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
7cd8e513dd (edit_read_syntax_rules): trivial refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
dc7dd7ae03 mcedit (syntax): minor optimization.
Use GString for syntax keywords to calculate keyword length at once
when syntax file is being parsed.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
a01b391029 src/filemanager/panelize.c: use GSList to hold panelize entries.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
da4212c150 External panelize: rename functions:
external_panelize -> external_panelize_cmd
load_panelize -> external_panelize_load
save_panelize -> external_panelize_save
done_panelize -> external_panelize_free
init_panelize -> external_panelize_init
panelize_done -> external_panelize_done

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
177d1a780c External panelize: refactoring:
*  src/filemanager/panelize.[ch]: keep function related to the external
  panelize command only. Functions related to the panelized mode of file
  panel move to panel.[ch]. Clean up includes.

  * rename functions:
  cd_panelize_cmd -> panel_panelize_cd
  panelize_change_root -> panel_panelize_change_root
  panelize_absolutize_if_needed -> panel_panelize_absolutize_if_needed
  panelize_save_panel -> panel_panelize_save

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
57c61b7681 Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
c62d651ee3 Replace variable: global_profile_name -> mc_global_t::profile_name.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
e7d081565d (edit_read_syntax_file): rename variable and reduce scope.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
52ab57dca0 (sftpfs_read_known_hosts): display the unknown host key type in hex.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
9f6ef611f4 (ftpfs_setup_passive_epsv): join tests.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
e2521d2187 (do_subshell_chdir): trivial refactoring.
Change tests to place short branches before long ones.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
e42012d51e FISH: refactoring.
* fish_super_t::scr_env: change type to GString.
  * (fish_set_env): return GString, rename variable.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
ab897e4ca6 (vfs_path_element_build_pretty_path_str): return GString.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
b3dd7cfe60 (find_parameters): use vfs_path_len().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
f114af83c8 (edit_find_filter): refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
41ed8c13ee (edit_insert_stream): refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
7031508550 (command_completion_function): don't call canonicalize_pathname()
...because mc_build_filename() makes that.

(etags_set_definition_hash): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
328d27ccf1 Ticket #4426: code clean up before 4.8.30 release.
(sftpfs_cb_open): minor optimization.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
e254656c48 Ticket #4434: mc.ext.ini: 'Edit' command from 'Default' section is ingored.
(regex_command_for): execute the required action from the 'Default'
section if this action is not specified in the found section.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-23 20:27:01 +03:00
Andrew Borodin
b2ffac752f Ticket #4427: extfs: "Inconsistent archive" error for valid RPM.
(extfs_read_archive): fix condition to display message "Inconsistent archive".

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-15 10:47:19 +03:00
Andrew Borodin
9962abd701 (extfs_read_archive): show error message.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-07 09:27:54 +03:00
Jindrich Novy
69ed5696f2 Ticket #4422: extfs: segfault if archive contains file(s) in the parent directory.
zip archive can contain files outside archive root:

$ unzip -l tmp.zip
Archive:  tmp.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2023-01-04 19:43   a
        0  2023-01-04 19:43   b
        0  2023-01-04 19:43   ../c
        0  2023-01-04 19:43   ../../d
---------                     -------
        0                     4 files

Enter into such archive leads to a segfault.

(extfs_find_entry_int): fix possible NULL dereference. The result of this
fix is an impossibility to enter into such archive.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-07 09:27:24 +03:00
Andrew Borodin
3f882f50e0 Ticket #4413: mcedit: syntax definitions in user location don't work.
Fix location of all user's syntax related stuff. Now it is the
~/.local/share/mc/syntax/ directory.

Don't use the system configuration directory (/etc/mc) as a storage
of syntax definitions.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-12-18 14:20:36 +03:00
Andrew Borodin
1ac5c22517 Ticket #3121: empty subshell/command line prompt.
If subshell is initializing more than 1 second - we have no subshell.

(feed_subshell): change timeout to 10 secons. I belive that is more than
enough time to run subshell.

Thanks Alexandr Zamaraev (aka Tonal) <tonal.promsoft@gmail.com> and
antonio_so <sozonnik@gmail.com> for finding out the cause of the
problem.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-11-26 14:21:55 +03:00
Andrew Borodin
a72ede698e Ticket #3220: fix directory comparision in panelized panel.
Directory comparision expects only file names in both panels.
In panelized panel, files named can contain paths:

| boxes.c   | 43220|| 1/boxes.c   | 43220|
| boxes.h   | 1429 || 1/boxes.h   |  1429|
|           |      || boxes.c     | 43220|
|           |      || boxes.h     |  1429|

Even if boxes.c and 1/boxes.c files are the same, they are marked as
different because strings "boxes.c" and "1/boxes.c" are different.

The solution: for panelized panel, ignore path and use file name only
(like output of basename(3)) for comparision.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-11-14 20:59:05 +03:00
Andrew Borodin
30f9309b8a Ticket 4409: continue copy after interrupt.
(copy_file_file): add button "Continue copy" to query dialog "Incomplete
file was retrieved".
(file_ui_op_dlg_callback): callback for copy/move progess dialog.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-15 21:14:35 +03:00
Andrew Borodin
47b116b773 mc_search: refactoring.
(mc_search_t): use GString to keep original search string. Join search string
and charset to structure.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Andrew Borodin
f778c86e4d Revert "(extfs_open_archive): fix NULL dereferences."
This reverts commit 0df10f488b.

g_strconcat() accepts NULL after non-NULL arguments.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Andrew Borodin
116b6a616a (fish_dir_load): move ls -l output parser to separate function.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Ovsyannikov Sergey E
3e7424a95a FTP fixes.
* (parse_ls_line): fix get of file GID.
  * (ftpfs_parse_long_list_MLSD): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Ovsyannikov Sergey E
21c45e8a7a Cosmetics: add spaces around slash in statistics messages.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Andrew Borodin
bb3ace13f1 Enlarge subshell PTY buffer.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Andrew Borodin
a7833b5b2e (real_warn_same_file): truncate file names if required.
If file name is too long, message window is wider than screen.
Truncate file name to fit it in the screen.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Andrew Borodin
facf199f65 (fish_free_archive): check socket before close.
Find by Coverity.
Coverity id #313668.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Andrew Borodin
c441250beb mcviewer: move.c: fix coding style. 2022-10-10 21:07:40 +03:00
Andrew Borodin
fba3d47408 mcviewer: internal.h: fix coding style. 2022-10-10 21:07:40 +03:00
Andrew Borodin
72f5211327 (check_dir_is_empty): clarify description.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-09 14:02:19 +03:00
Andrew Borodin
d4d6cec52d Ticket #4364: FISH VFS: cannot remove non-empty directory.
Revert "(check_dir_is_empty): minor optimization."

This reverts commit 25e419ba08.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-02 11:13:17 +03:00
Andrew Borodin
d9eeec9a5a Port mc.ext to INI format.
Ticket #2773: 'include' keyword (for command class def) have no effect
if it was defined before 'Include' keyword (for command def).

Ticket #3742: update comment in mc.ext.ini.

doc: remove mc.ext.ini format description from manual page.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-09-25 14:55:00 +03:00
Andrew Borodin
1cb66b82bd (regex_command_for): move load of extension file to separate function.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-28 11:10:39 +03:00
Andrew Borodin
67ec86b570 Ticket #4141: allow compound (AND) conditions in mc.ext
...to disambiguate overloaded extensions

Initial commit:
  * rename macro for mc.ext file: MC_FILEBIND_FILE -> MC_EXT_FILE.
  * (ext_cmd): fix errorous usage of MC_LIB_EXT macro. Use MC_EXT_FILE
    instead.
  * (regex_command_for): likewise. Use already existing variable
    extension_file, remove variable filebind_filename.
  * MC_LIB_EXT: remove macro.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-28 11:10:39 +03:00
Michael Schuster
a1f22e104d Ticket #4401: Segmentation fault in mcviewer.
* (mcview_growbuf_read_until): the previous call to mcview_show_error()
   invalidates sp by freeing view->ds_stdio_pipe. Reintroduce the check
   that was removed in a68f2d1202 but take
   sp's invalidity into account.

 * (mc_pclose): add a NULL pointer check to play safe.

Signed-off-by: Michael Schuster <michael@schuster.ms>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-20 19:33:12 +03:00
Sergei Trofimovich
6b67d231a2 Ticket #4399: configure.ac: introduce PERL_FOR_BUILD
Most of mc uses of PERL is to embed path to the interpreter in VFS
helpers. There we can use path to perl for --host. But
`date-of-man-include.am` is the place where perl is used for --build.

On most systems both paths are expected to be /usr/bin/perl.
But on some systems paths might differ a bit. Most prominent
example is NixOS, where packages get installed into unique prefixes:

$ file /nix/store/...-perl-5.36.0/bin/perl \
       /nix/store/...-perl-powerpc64-unknown-linux-gnu-5.36.0/bin/perl
/nix/store/...-perl-5.36.0/bin/perl:
  ELF 64-bit LSB executable, x86-64, version 1 (SYSV), ...
/nix/store/...-perl-powerpc64-unknown-linux-gnu-5.36.0/bin/perl:
  ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, ...

This allows running both binaries via qemu-user if needed for tests.

The change introduces PERL_FOR_BUILD (similar to autoconf's CC_FOR_BUILD
and friends) to allow passing both PERLs when needed.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-20 08:26:24 +03:00
Andrew Borodin
ff26ce85f8 Ticket #4398: crash on quick view of archives.
* (extfs_cmd): make message null-terminated.
  * (sfs_vfmake): likewise.
  * (do_external_panelize): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-14 17:57:08 +03:00
Andrew Borodin
36abab7186 Clarify checks of input line content returned from quick dialog.
If quick dialog is finished with value other than B_CANCEL,
string value of input line isn't NULL.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-04 11:19:16 +03:00
Andrew Borodin
79645187c6 (input_get_ctext): mew API.
Use it instead of direct access to WInput's buffer.

(handle_cmdline_enter): additional minor refactoring.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-04 11:17:29 +03:00
Andrew Borodin
318315399b Ticket #4397: sort in editor without arguments stopped working.
* (input_get_text): never return NULL. If buffer is empty, return an
empty allocated string.
  * (input_push_history): use new input_get_text.
  * (find_parameters): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-04 11:09:42 +03:00
sxmboer2
cca4c46d05 (edit_delete_macro): do not resort macros after deleting one
...because g_array_remove_index() keeps the array sorted.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-07-27 19:22:05 +03:00
sxmboer2
01c3c56140 Ticket #4391: fix infinite loop when deleting an mceditor macro.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-07-27 19:22:05 +03:00
Andrew Borodin
6ea06c9845 Ticket #4381: missing selection of some files.
When files are selected keeping the right mouse button pressed,
some files are not selected.

  * Add new macros for mouse pointer location relative to file list.
  * (mark_if_marking): select/unselect all files between previous
    selected file and new one.
  * (panel_mouse_is_on_item): return clarified value of mouse pointer location.
  * (panel_mouse_callback): modify mouse drag event handling in accordance with
    the mouse pointer location relatively to the file list.

Also fixes ticket #4119: "Cannot scroll panel listing upwards using mouse".

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-07-27 19:10:16 +03:00
Andrew Borodin
cd47b158ac Ticket #4373: restore menu accelerator for "Sort order" item.
Menu according for "Sort order" item was changed in
d19b247c6d in order to fix shotrcut
conflict. Restore it back according to user requests.

óhange accelerator for "SFTP link" from S to N.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-07-11 19:44:43 +03:00
Andrew Borodin
debabe561a "file" utility: use -b option if available.
* configure.ac: test if "file" utility has -b option.
  * (regex_check_type): don't compare file names if "file -b" is used.
Reduce variable scope. Rename variable.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-26 20:03:47 +03:00
Andrew Borodin
0bb9c04720 Ticket #4377: file type check does not work with special character in filename.
Initial commit: clarify usage of "file" utility.

  * (get_popen_information): compile conditionally depending on USE_FILE_CMD
macro.
  * (get_file_type_local): likewise.
  * (get_file_encoding_local): likewise.
  * (regex_check_type): likewise.
  * (regex_command_for): ignore type method if file utiliti isn't used.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-26 19:57:37 +03:00
Andrew Borodin
1b93bae611 src/filemanager/dir.c: minor sort optimization.
Get rid of sort condition double check.

Condition

    ad == bd || panels_options.mix_all_files

was checked twice: first in sort_xxx(), then in sort_name() called in
sort_xxx().

Now this condition is checked in sort_xxx() only.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 12:19:47 +03:00
Andrew Borodin
c7af7f0bbd (edit_sort_cmd): clarify hint for Sort command.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 12:19:47 +03:00
Andrew Borodin
bae55d637a (ftpfs_setup_active): clarify handling of getnameinfo() errors.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 12:19:47 +03:00
Andrew Borodin
798f6e87b3 (ftpfs_initconn): clarify errno setup.
Handle errors of bind(), getsockname(), and listen() calls.
Return if one of these functions fails and setup errno to indicate the
cause of the error.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 12:19:47 +03:00
Andrew Borodin
03cef1bb6f ftpfs.c: variable ftpfs_errno is assigned but never used.
Use me->verrno directly instead.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 12:19:47 +03:00
Andrew Borodin
556cf2274d (ftpfs_dir_load): fix building of remote path.
Call of mc_build_filename(remote_path, ".") is pointless
because the path canonicalization is performed and trailing
"/." is removed.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 12:19:47 +03:00
Andrew Borodin
ebb328353e (vfs_s_subclass::dir_load): constify argument.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 12:19:44 +03:00
Andrew Borodin
5f746eea0c mceditor: minor refactoring of file load.
(edit_load_file_from_filename): make public, use it as main function to
load file and create editor window.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:56:32 +03:00
Andrew Borodin
12543835f9 (edit_init): change argument for coordinates.
Use WRect instead of four values.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:56:31 +03:00
Andrew Borodin
533b2076dd (edit_add_window): change argument for coordinates.
Use WRect instead of four values.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:55:06 +03:00
Andrew Borodin
caf41457c6 (widget_adjust_position): change argument for coordinates.
Use WRect instead of four values.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:55:06 +03:00
Andrew Borodin
390d614b5e (group_init): change argument for coordinates.
Use WRect instead of four values.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:55:06 +03:00
Andrew Borodin
ccdc909105 (widget_init): change argument for coordinates.
Use WRect instead of four values.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:55:03 +03:00
Andrew Borodin
2759d080cf Viewer: use WRect to hold position and size of various areas.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:52:14 +03:00
Andrew Borodin
aac258e44e (rect_grow): new API.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:50:19 +03:00
Andrew Borodin
5fae2313f3 Widget: use WRect to hold position and size.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:49:20 +03:00
Andrew Borodin
ed65694caa quick_dlg: use WRect to hold dialog position and size.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:37:04 +03:00
Andrew Borodin
bf0dd8efb1 WInput: use GString for buffer.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:28:51 +03:00
Andrew Borodin
f91d894f9b (input_get_text): new API.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:26:37 +03:00
Andrew Borodin
50f08e2194 (find_parameters): duplicate path when that is really needed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:23:37 +03:00
Andrew Borodin
88754d040f mcviewer: reimplement coordinate cache using GPtrArray.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:23:37 +03:00
Andrew Borodin
12d976eb6f src/viewer/coord_cache.c: clean up and minor refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:23:15 +03:00
Andrew Borodin
6f048314b1 (mcview_handle_key): fix variable name.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:22:46 +03:00
Andrew Borodin
03ae9ff24a Ticket #4357: code clean up before 4.8.29 release.
(set_prompt_string): use mc_g_string_dup().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:21:22 +03:00
Andrew Borodin
db109be8a2 Ticket #4374: fix file sort by version.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-05-23 20:56:31 +03:00
Andrew Borodin
81d57da867 Ticket #3670: ftp: reconnect if server terminated connection.
(ftpfs_init_data_socket): handle return value of
getpeername()/getsockname() and try to reconnect to FTP server
for 10 attempts in case of error.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-05-22 11:33:24 +03:00
Eric Roberts
4667618e68 Ticket #4372: fish commands don't work after window resize.
How to reproduce:
  start mc (with fish as your shell);
  resize mc window;
  type any command in the command prompt, for example, "ls";
  result: nothing happens;
  type the same command again;
  it works now, the second time.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-05-14 09:13:59 +03:00
Andrew Borodin
a92b6781b8 Load and save filter parameters.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-04-10 17:45:57 +03:00
Andrew Borodin
a705b67288 Implement more option for panel filter:
"Files only", "Case sensitive", and "Using shell patterns".

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-04-10 17:45:56 +03:00
Andrew Borodin
f20f5cc5cb Rename panel_select_flags_t -> select_flags_t.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-04-10 17:44:26 +03:00
Andrew Borodin
63e870867e Handle CK_Filter command in the file panel level.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-04-10 17:43:44 +03:00
Andrew Borodin
450993fff6 Add macros for select/unselect histories.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-04-10 17:43:44 +03:00
Andrew Borodin
45073a9d29 (panel_select_unselect_files_dialog): show error message if pattern is malformed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-04-10 17:43:42 +03:00
Andrew Borodin
733f7ce54b Ticket #1373: add more options to "Filter" dialog window.
The main idea is apply same options for file filter as for file
selection and use the same dialog window.

Initial commit: refactoring: move creation of the file selection dialog
to the separate function.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-04-10 17:42:39 +03:00
Andreas Mohr
1bdf814052 (mc_setup_by_args): reduce variable scope into #ifdef to fix coverity finding.
Found by Coverity.
Coverity id #331837

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:27 +03:00
Andrew Borodin
5b4ec9b033 (translate_file): refactoring.
Allocate buffer only if charset converter is created successfully.
g_string_free() returns NULL if second argument is TRUE. Use that to get
rig of 'if' statement.
Reduce variable scope.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:27 +03:00
Andrew Borodin
a6c142ed48 (get_random_hint): refactoring.
g_string_free() returns NULL if second argument is TRUE. Use that to get
rig of 'if' statement.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:27 +03:00
Andrew Borodin
4518885f93 (dir_list_load): rename argument: fltr -> filter.
(dir_list_reload): likewise.
(handle_dirent): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:27 +03:00
Andrew Borodin
2101026d4c (show_version): display version of libssh2.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:27 +03:00
Andrew Borodin
bb42ed706c (sftpfs_read_known_hosts): clarify displayed value of unknown host key type.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:27 +03:00
Andrew Borodin
f0924b954d (file_mask_dialog): refactoring: get rid of goto.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:27 +03:00
Andreas Mohr
2087ede32d (file_mask_dialog): NULLify variables before use in next iteration.
Found by Coverity.
Coverity id #331828
Coverity id #331850

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:27 +03:00
Andrew Borodin
9f53bf5617 Include <stddef.h> where ptrdiff_t is used.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-03-13 13:17:26 +03:00