Commit Graph

6539 Commits

Author SHA1 Message Date
Andrew Borodin
0780ef2970 Refactoring of file and directory delete routines.
* (file_progress_show_deleting): take 'vfs_path_t *' instead of 'char *'.
  * (try_erase_dir): likewise.
  * (erase_file): sync with new file_progress_show_deleting().
  * (recursive_erase): sync with new file_progress_show_deleting() and
    try_erase_dir().
  * (erase_dir_iff_empty): likewise.
  * (erase_dir): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
4e9f4b97cb (user_menu_cmd): port to GPtrArray.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
bb4e152c59 (extract_line): optionally return the lengh of the line.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
bb5b35be9e (user_menu_cmd): refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
5288f994c4 (user_file_menu_cmd): move to src/usermenu.h and make inline.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-05 15:05:58 +03:00
Andrew Borodin
f4ef5c64a4 (edit_draw_this_line): fix printable character recognition in 8-bit locales when displaying UTF-8
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
ffd6fd11f7 ydiff: fix -Wdiscarded-qualifiers warning
```
../../../src/diffviewer/ydiff.c:613:17: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  613 |         next_ch = g_utf8_next_char (str);
```

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
f84099512e extfs helpers: remove usage of local, instead use subshell to isolate variables
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-05 11:49:26 +02:00
Yury V. Zaytsev
50976cec62 shell: replace which with command -v for speed and POSIX compatibility
https://stackoverflow.com/a/677212/5132088

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-09-11 08:45:25 +02:00
Yury V. Zaytsev
d081bc68aa main: remove O_EXCL for wd-file since creation is now managed by wrapper
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-09-03 07:39:25 +02:00
Gabriel Vlasiu
66bfefbf1a Ticket #4580: mceditor: segfault on new file creation.
(edit_init): fix NULL dereference.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-08-29 21:04:40 +03:00
Yury V. Zaytsev
876555035a Ticket #4576: fix visual glitches by avoiding g_module_close on NULL while loading libaspell
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-08-25 17:35:54 +02:00
Andrew Borodin
5e64cc637f (file_op_context_create_ui): apply callback to the "Abort" button
...to keep the file progress dialog visible.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-08-20 22:01:52 +03:00
Johannes Altmanninger
c249980ed3 subshell: ensure compatibility with fish 3.8
The upcoming fish 3.8 will add a feature flag to officially deprecate
"%self," see

8d71eef1da

Unfortunately this can cause mc+fish to break for users who configured
fish with "set -U fish_features all" which opts into any new feature
flag, thus disabling %self expansion.

Prevent this potential breakage by using the recommended "$fish_pid",
which was introduced in fish 3.0.0 (December 2018).

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-08-07 09:50:28 +02:00
Yury V. Zaytsev
5b335920aa Ticket #3960: remove mmap support in file comparison
It's not working on AIX, but more importantly doesn't offer any benefits in
terms of speed, and we have a fallback anyways.

https://lists.gnu.org/archive/html/autoconf/2024-07/msg00006.html

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-07-30 21:11:21 +02:00
Yury V. Zaytsev
0749b6d2d3 aspell: fix -Wdeprecated-declarations for g_module_build_path
```
../../../src/editor/spell.c:177:26: warning: 'g_module_build_path' is deprecated [-Wdeprecated-declarations]
    spell_module_fname = g_module_build_path (NULL, "libaspell");
                         ^
/opt/homebrew/Cellar/glib/2.80.4/include/glib-2.0/gmodule.h:141:1: note: 'g_module_build_path' has been explicitly marked deprecated here
GMODULE_DEPRECATED_IN_2_76
```

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-07-28 21:46:26 +02:00
slowpeek
db77fd5a0c Ticket #4559: extfs: u7z: bug with nested dirs in mkdir action.
The -w option sets the working directory for the temporary archive 7-zip
builds when modifying an existing one. The option cant be used to set
the base path inside an archive when adding something into it.

When adding something to a 7z archive by its absolute path, 7zip only
uses the last part of the path by default. E.g. `7z a 1.7z
/tmp/a/b/date.txt` would add date.txt to the root dir inside the
archive. If we wanted the file to be under `a/b/` inside the archive as
well, it should be `7z a 1.7z /tmp/a`.

Closes MidnightCommander/mc#202.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-07-28 14:53:57 +03:00
Yury V. Zaytsev
0cfccd5882 filemanager: use correct type for results of read in mmap fallback
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-07-28 10:00:52 +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
Andrew Borodin
cc34729f45 Ticket #4563: support reget in file move operation.
* (file_op_context_new): change default value of file_op_context_t::do_reget.
  * (overwrite_query_dialog): show the "Reget" button in query dialog for
    move operation.
  * (copy_file_file): keep non-default value of file_op_context_t::do_reget
    that was set before.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-07-27 12:19:08 +03:00
Andrew Borodin
e9258fcc6c Ticket #4562: mcedit: don't apply macros to the pasted text.
(edit_callback): use bracketed_pasting_in_progress variable to detect
if text is being pasted. If yes, paste text as is without macro
expanaison.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-07-21 19:57:00 +03:00
Andrew Borodin
ffdb057e5b Ticket #4561: tar: fix segault on copy fiiles from archive.
* (tar_read_header): canonicalize path name after decoding of all
    headers occupied with long file/directory name.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-07-15 21:42:11 +03:00
Andrew Borodin
e4c80b5d13 Ticket #4560: extfs: fix segfault om enter to deleted archive.
* (extfs_open_and_read_archive): fix NULL dereference if
    extfs_open_archive() doesn't create an error.
  * (extfs_open_archive): create an error message when mc_open() returns -1.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-07-11 21:06:35 +03:00
Koichi Murase
61675a90a8 Ticket #4549: subshell: call execl with argv[0] being the actual path to Bash.
We currently call Bash with argv[0] being just the fixed string
"bash", but this confuses Bash when it initializes the shell variable
BASH, which are expected to be the absolute file path to the current
Bash image.  This patch fixes argv[0] to be the actual path that mc
uses to start Bash.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-20 21:02:55 +03:00
Yury V. Zaytsev
61b22eb606 warnings: mute unused variable warning
../../../src/viewer/datasource.c: In function ‘mcview_set_byte’:
../../../src/viewer/datasource.c:270:38: error: unused parameter ‘offset’ [-Werror=unused-parameter]
  270 | mcview_set_byte (WView * view, off_t offset, byte b)
      |                                ~~~~~~^~~~~~

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-06-03 21:06:19 +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
b3c6bea510 Remove src/editor/.gitignore.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03: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
ce299bbee9 clang: fix -Wconstant-conversion warning
../../../src/filemanager/filegui.c:1413:35: warning: implicit conversion from 'int' to 'mode_t' (aka 'unsigned short') changes value from 262143 to 65535 [-Wconstant-conversion]
                ctx->umask_kill = 0777777;
                                ~ ^~~~~~~

../../../src/filemanager/fileopctx.c:81:23: warning: implicit conversion from 'int' to 'mode_t' (aka 'unsigned short') changes value from 262143 to 65535 [-Wconstant-conversion]
    ctx->umask_kill = 0777777;
                    ~ ^~~~~~~

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
de06f36ccf clang: fix -Wpointer-sign warning
../../../../src/vfs/sftpfs/connection.c:787:22: warning: passing 'unsigned char *const' to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
        if (strncmp (prompts[i].text, "Password: ", prompts[i].length) == 0)
                     ^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/string.h:84:26: note: passing argument to parameter '__s1' here
int      strncmp(const char *__s1, const char *__s2, size_t __n);
                             ^

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
Yury V. Zaytsev
b76569d5ee buildsys: fix build on macOS with libssh2 present via homebrew
Path to libssh2 headers was missing from CPPFLAGS resulting into FTBFS.

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
Andrew Borodin
34e78a2127 src/filemanager/find.c: remove unneeded intialization of local variables.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:12 +03:00
Andrew Borodin
3972b7d502 (do_find): minor refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:12 +03:00
Andrew Borodin
615eda6e9e src/filemanager/find.c: ret rid of string duplication.
* (add_to_list_take): new function: listbox_add_item_take() wrapper.
  * (insert_file): use add_to_list_take().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:12 +03:00
Andrew Borodin
5dd087421e (search_content): reduce variable scope.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
44e4b7f8b9 (do_find): fix coding style.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
6f7b4131c6 (panel_operate): remove intermediate variable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
12d117ea60 extfs: lslR: remove unneeded escape of space.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Artem Babii
4c998ac636 sftpfs: expand %h
Properly parse %h hostname token, which is widely used in HostName directive within
~/.ssh/config:

Host testing*
  HostName %h.eu.example.com

Host staging*
  HostName %h.us.example.net

# this host will be expanded to `testing-1.eu.example.com`
% mc sftp://username@testing-1

Closes MidnightCommander/mc#197.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
f6afcb7076 (copy_file_file): handle "Abort" button
...when can't get extended attributes.

Clarify f6f7c8c1ce.

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
822ef80f5b (spell_available): refactoing.
Simplify detection of aspell functions availability.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
9098dacb8a mecedit: spell: reduce functions scope.
* (aspell_check): make static.
  * (aspell_suggest): likewise.
  * (aspell_array_clean): likewise.
  * (aspell_get_lang_list): likewise.
  * (aspell_get_lang): likewise.
  * (aspell_set_lang): likewise.
  * (aspell_add_to_dict): likewise.
  * (spell_dialog_spell_suggest_show): likewise.

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
127f975657 (search_content): minor refactoring of file opening.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:40:02 +03:00
Andrew Borodin
e113055175 Constify argument in panel field format functions.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:40:02 +03:00