Commit Graph

16172 Commits

Author SHA1 Message Date
Andreas Mohr
a4063fc316 (quick_create_labeled_input): fix potential leak of memory.
/tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/quick.c:150:9: warning: Potential leak of memory pointed to by 'label.quick_widget' [clang-analyzer-unix.Malloc]
  150 |         return;
      |         ^

Found by Clang-19 Static Analyzer.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-22 11:38:32 +03:00
Andrew Borodin
470b79b5aa (listbox_drawscroll:) fix division by zero warning.
Make Static Analyzer happy.

lib/widget/listbox.c:119:51: warning: Division by zero [clang-analyzer-core.DivideZero]
  119 |         line = 1 + ((l->current * (w->lines - 2)) / length);

Found by Clang-19 Static Analyzer.

Reported-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-22 11:38:24 +03:00
Andreas Mohr
5edf6d6ab7 (edit_dialog_search_show): fix uninitialized value and null pointer dereference.
Make Static Analyzer happy.

/tmp/portage/app-misc/mc-9999/work/mc-9999/src/editor/editsearch.c:124:38: warning: Array access (from variable 'search_text') results in a null pointer dereference [clang-analyzer-core.NullDereference]
  124 |     if (dialog_result == B_CANCEL || search_text[0] == '\0')
      |                                      ^

src/editor/editsearch.c:126:9: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
  126 |         g_free (search_text);
      |         ^

Found by Clang-19 Static Analyzer.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-22 10:48:39 +03:00
Andreas Mohr
888db5c041 mcedit: fix uninitialized value function call.
Make Static Analyzer happy.

src/editor/editcmd.c:412:17: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
  412 |         fname = tilde_expand (filename_res);
      |                 ^

src/editor/editcmd.c:1928:9: warning: 2nd function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
 1928 |         pipe_mail (&edit->buffer, mail_to, mail_subject, mail_cc);
      |         ^                         ~~~~~~~

Found by Clang-19 Static Analyzer.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-22 10:48:39 +03:00
Andreas Mohr
d4025f674d (configure_box): fix uninitialized value function call.
Make Static Analyzer happy.

src/filemanager/boxes.c:623:9: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
  623 |         g_free (time_out_new);
      |         ^       ~~~~~~~~~~~~

Found by Clang-19 Static Analyzer.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-22 10:48:39 +03:00
Andreas Mohr
8c36ec2ad6 (quick_dialog_skip): fix undefined behavior.
quick.c:432:28: runtime error: member access within null pointer of type 'Widget' (aka 'struct Widget')
   #0 in quick_dialog_skip lib/widget/quick.c:432:28
   #1 in file_mask_dialog src/filemanager/filegui.c:1462:19
   #2 in do_confirm_copy_move src/filemanager/file.c:1977:11
   #3 in panel_operate src/filemanager/file.c:3536:16
   #4 in copy_cmd src/filemanager/./cmd.h:111:5
   #5 in midnight_execute_cmd src/filemanager/filemanager.c:1177:9
   #6 in midnight_callback src/filemanager/filemanager.c
   #7 in send_message lib/widget/../../lib/widget/widget-common.h:255:15
   #8 in buttonbar_call lib/widget/buttonbar.c:157:15
   #9 in buttonbar_callback lib/widget/buttonbar.c:174:42
   #10 in send_message lib/widget/../../lib/widget/widget-common.h:255:15
   #11 in group_handle_hotkey lib/widget/group.c:566:23
   #12 in group_default_callback lib/widget/group.c:640:16
   #13 in dlg_default_callback lib/widget/dialog.c:370:16
   #14 in midnight_callback src/filemanager/filemanager.c:1615:16
   #15 in send_message lib/widget/../../lib/widget/widget-common.h:255:15
   #16 in group_handle_key lib/widget/group.c:503:15
   #17 in group_default_callback lib/widget/group.c:637:16
   #18 in dlg_key_event lib/widget/dialog.c:252:19
   #19 in dlg_process_event lib/widget/dialog.c:539:9
   #20 in frontend_dlg_run lib/widget/dialog.c:321:9
   #21 in dlg_run lib/widget/dialog.c:573:5
   #22 in do_nc src/filemanager/filemanager.c:1826:16
   #23 in main src/main.c:469:21
   #24 in <null> <null>
   #25 in __libc_start_main <null>
   #26 in _start <null>

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior quick.c:432:28.

Found by Clang-19 Static Analyzer.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-22 10:48:39 +03:00
Andreas Mohr
24243984bd Fix garbage return value warning.
Make Static Analyzer happy.

Bug Group   Bug Type              File                     Function/Method       Line
Logic error Garbage return value  src/filemanager/boxes.c  cd_box                1236
Logic error Garbage return value  lib/widget/wtools.c      fg_input_dialog_help  198

Found by Clang-19 Static Analyzer.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-22 10:48:39 +03:00
Andrew Borodin
87eca47039 (ftpfs_open_socket): fix handling of errno if connect() fails.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-22 10:48:31 +03:00
Andreas Mohr
e439bd5555 (shell_free_archive): fix Glib g_string_free assertion.
Fix confusing extra output like ticket #4611
(mc:72268): GLib-CRITICAL : ... g_string_free: assertion 'string != NULL' failed.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-17 21:15:22 +03:00
Andreas Mohr
9ef2cb4efd Cleanup cppcheck warnings.
Make cppcheck happy.

lib/search/regex.c:888:85: error: Uninitialized variable: *error [uninitvar]
        if (pcre2_jit_compile (mc_search_cond->regex_handle, PCRE2_JIT_COMPLETE) && *error != '\0')
                                                                                    ^
src/vfs/sftpfs/dir.c:95:26: warning: Uninitialized variable: handle [uninitvar]
    sftpfs_dir->handle = handle;
                         ^
Found by cppcheck-2.16.0

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
6de5e620eb (mcview_eol): refactor, fix coding style.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
b5610b24ec (mcview_bol): refactor, fix coding style.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andreas Mohr
053108afd2 (widget_focus): fix -Wanalyzer-deref-before-check warning
widget-common.c: In function 'widget_focus':
widget-common.c:123:12: error: check of '*g.current' for NULL after already dereferencing it []8;;https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Static-Analyzer-Options.html#index-Wanalyzer-deref-before-check-Werror=analyzer-deref-before-check]8;;]
  123 |         if (g->current == NULL || !widget_get_state (WIDGET (g->current->data), WST_FOCUSED))
      |            ^
  'widget_focus': event 1
    |
    |  116 |     if (g == NULL)
    |      |        ^
    |      |        |
    |      |        (1) following 'false' branch (when 'g' is non-NULL)...
    |
  'widget_focus': event 2
    |
    |  119 |     if (WIDGET (g->current->data) != w)
    |      |                 ~^~~~~~~~~
    |      |                  |
    |      |                  (2) ...to here
../../lib/widget/widget-common.h:15:31: note: in definition of macro 'WIDGET'
    |   15 | #define WIDGET(x) ((Widget *)(x))
    |      |                               ^
    |
  'widget_focus': event 3
    |
    |widget-common.c:119:27:
    |  119 |     if (WIDGET (g->current->data) != w)
../../lib/widget/widget-common.h:15:31: note: in definition of macro 'WIDGET'
    |   15 | #define WIDGET(x) ((Widget *)(x))
    |      |                               ^
    |
  'widget_focus': events 4-6
    |
    |widget-common.c:119:8:
    |  119 |     if (WIDGET (g->current->data) != w)
    |      |        ^
    |      |        |
    |      |        (4) following 'true' branch...
    |  120 |     {
    |  121 |         widget_do_focus (WIDGET (g->current->data), FALSE);
    |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |         |
    |      |         (5) ...to here
    |  122 |         /* Test if focus lost was allowed and focus has really been loose */
    |  123 |         if (g->current == NULL || !widget_get_state (WIDGET (g->current->data), WST_FOCUSED))
    |      |            ~
    |      |            |
    |      |            (6) pointer '*g.current' is checked for NULL here but it was already dereferenced at (3)
    |

Found by gcc-14 analyzer

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andreas Mohr
3b86f15a68 Remove unused macros.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
2f176afe7d (subshell_chdir): move to src/subshell/common.c, make public.
(do_subshell_chdir): make static.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
218bff6be9 mcedit: remove get_sys_error() macro that does nothing.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
1c580e874c mcedit: use message() instead of edit_error_dialog().
(edit_error_dialog): isn't used anymore. Remove.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
7b2b78722d (edit_show_search_error): use message().
(edit_query_dialog): isn't used anymore. Remove.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
37a0540423 (learn_button): clarify title and message of dialog window.
Change title to "Warning". Move previous title to the message body.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
009efde431 Join create_message() and do_create_message().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
71199a290f Make message box with button.
* (bg_message): use query_dialog() instead of fg_message().
  * (message): likewise.
  * (fg_message): isn't used anymore. Remove.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:21 +03:00
Andrew Borodin
4f47b16ba8 (mcview_do_search): use message().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:06:19 +03:00
Andrew Borodin
1eb6c94c9b configure.ac: indentation: replace tabs by spaces.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:03:37 +03:00
Yury V. Zaytsev
013b2fddc8 doc: centralized the list of dependencies, removed outdated docs
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-15 14:03:35 +03:00
Andrew Borodin
ce15d50cde doc/INSTALL: add uClibc, musl and clang.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 14:00:41 +03:00
Artem S. Tashkinov
83a5d34a64 filehighlight: update to close MidnightCommander/mc#208
- Add awb: https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_Wideband
- Add y4m: RAW video format, https://wiki.multimedia.cx/index.php/YUV4MPEG2
- Add tga: https://en.wikipedia.org/wiki/Truevision_TGA

Signed-off-by: Artem S. Tashkinov <birdie-github@users.noreply.github.com>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-15 14:00:41 +03:00
Yury V. Zaytsev
81a7a5bc92 shell: use backticks for compability with Solaris /bin/sh
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-15 14:00:41 +03:00
Kirill Rekhov
6f60924c83 Ticket #4602: fix typo in mc.emacs.keymap.
Closes MidnightCommander/mc#207.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-15 14:00:41 +03:00
Andrew Borodin
c547894788 Ticket #4572: code cleanup before 4.8.33 release.
(compare_files): fix coding style.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-15 14:00:41 +03:00
Andrew Borodin
511d4d853b Merge branch '4587_mcview_search_bol'
* 4587_mcview_search_bol:
  (mcview_moveto_bottom): fix search start and stop positions.
  mcview: fix regex search.
  mcview: minor refactoring.
  Ticket #4587: mcviewer: fix BOL regex search.
2024-12-15 13:48:22 +03:00
Andrew Borodin
a83a6f4acf (mcview_moveto_bottom): fix search start and stop positions.
After move to the end of file, set the start positions to EOL
to make backward search starting directly from EOL.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-15 13:46:57 +03:00
Andrew Borodin
4861ccb19a mcview: fix regex search.
Sync regex search way with mcedit: handle BOL (^) metacharacter.

  * (WView::search_line_type): new member.
  * (mcview_search_init): init WView::search_line_type.
  * (mcview_find): sync with edit_find().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-15 13:46:57 +03:00
Andrew Borodin
a3825e1b29 mcview: minor refactoring.
* (mcview_search): move to search.c.
  * (mcview_do_search): make static.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-15 13:46:57 +03:00
Andrew Borodin
c943b931d7 Ticket #4587: mcviewer: fix BOL regex search.
Refactoring.

* (mc_search_line_t): rename from edit_search_line_t and move to
lib/search.h.
* (mc_search_get_line_type): rename from edit_get_search_line_type()
and move to lib/search/regex.c.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-15 13:46:52 +03:00
Andrew Borodin
7950ae8b24 Merge branch '4613_check_eta_overflow'
* 4613_check_eta_overflow:
  Ticket #4613: check for ETA overflow.
2024-12-14 09:20:47 +03:00
Jakob Kastelic
27c01b8942 Ticket #4613: check for ETA overflow.
(file_eta_prepare_for_show): check if 'eta_secs' is too large to display
as integer. If yes, display "--".

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-13 19:51:52 +03:00
Yury V. Zaytsev
7fc6dfc16b Merge branch '4609_rust_crate'
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-06 22:20:34 +03:00
Yury V. Zaytsev
63a51cdcd7 Ticket #4609: treat Rust crates as tar.gz archives
534ce68621/src/cargo/ops/cargo_package.rs (L185)

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-12-06 16:13:02 +03:00
Andrew Borodin
c2eb73bb2c Merge branch '4608_mcdiff_segfault'
* 4608_mcdiff_segfault:
  Ticket #4608: mcdiff: segmentation fault on empty files merge.
2024-12-05 20:59:44 +03:00
Andrew Borodin
8548796e75 Ticket #4608: mcdiff: segmentation fault on empty files merge.
(get_current_hunk): immediately return if hunk list is empty.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-04 21:02:21 +03:00
Andrew Borodin
f85f7fec29 Merge branch '3205_eta'
* 3205_eta: (29 commits)
  Update po/*.po files.
  doc: update EN and RU man pages.
  Calculate pauses in file operations.
  File copy/move: make ETA accurate.
  (calc_copy_file_progress): clarify calculation of BPSes and ETAs.
  (panel_operate): use intermediate variable for better indentation.
  (copy_file_file): clarify handling of mc_open() errors.
  (copy_file_file): fix handling of mc_open() error.
  (calc_copy_file_progress): rename from copy_file_file_display_progress().
  (file_progress_show_total): add 'tv_current' argument.
  (file_progress_show_total): use 'copied_bytes' to show numeric value.
  (file_progress_show_count): remove 'done' and 'total' arguments.
  (erase_dir_iff_empty): remove 'count' argument.
  (file_op_context_t): rename members.
  (copy_file_file): reduce variable scope, change order of progress update.
  (file_op_context_t): reorder members.
  Move content of src/filemanager/fileopctx.[ch] to src/filemanager/filegui.[ch].
  (file_op_total_context_t): remove. All members were moved to file_op_context_t.
  (file_op_total_context_t): rename members.
  (copy_file_file_display_progress): remove dead code.
  ...
2024-11-13 19:38:42 +03:00
Andrew Borodin
883aec7625 Update po/*.po files.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:02 +03:00
Andrew Borodin
c3fa92d89a doc: update EN and RU man pages. 2024-11-13 19:38:01 +03:00
Andrew Borodin
5047d4d114 Calculate pauses in file operations.
Calculate BPS and ETA, taking into account pauses due to query
dialog boxes.

  * (file_op_context_t): new 'pauses' member.
  * (file_error): pass file operation context to calculate pause.
  * (real_warn_same_file): likewise.
  * (real_do_file_error): likewise.
  * (real_query_recursive): calculate pause.
  * (overwrite_query_dialog): likewise.
  * (file_progress_show_total): use ctx->pauses to show time of
    operation.
  * (calc_copy_file_progress): calculate use ctx->pauses to calculate ETA.
  * (warn_same_file):
  * (check_same_file):
  * (check_hardlinks):
  * (make_symlink):
  * (do_file_error):
  * (files_error):
  * (try_remove_file):
  * (move_file_file):
  * (try_erase_dir):
  * (do_move_dir_dir):
  * (copy_file_file):
  * (copy_dir_dir):
  * (panel_operate):
  * (tree_move): related changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:01 +03:00
Andrew Borodin
1e35ae3adb File copy/move: make ETA accurate.
* (progress_update_one): update total progress bytes counter. Update
    progress info in the progress window only if file was processed
    successfully. Don't check buttons here.
  * (move_file_file): update progress info if file move wasn't aborted.
  * (copy_file_file): update progress info if stat() or open() failed
    (file size is unknown, but file counter shoud be updated). Modify
    caclulation and display of byte counters.
  * (panel_operate): simplify files processing loop. Remove action that
    already done via operate_one_file() call.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:01 +03:00
Andrew Borodin
ff1a404bb3 (calc_copy_file_progress): clarify calculation of BPSes and ETAs.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:01 +03:00
Andrew Borodin
07ea52d767 (panel_operate): use intermediate variable for better indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:00 +03:00
Andrew Borodin
e2ca50418d (copy_file_file): clarify handling of mc_open() errors.
Handle mc_open() errors in the same way as mc_fstat().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:00 +03:00
Andrew Borodin
25fb677b87 (copy_file_file): fix handling of mc_open() error.
In case of FILE_IGNORE, immediately stop processing of file.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:00 +03:00
Andrew Borodin
e6e329bc8c (calc_copy_file_progress): rename from copy_file_file_display_progress().
Refactoring, reuse variable.

(file_op_context_t): remove 'bps_time' member. It's unused anymore.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:37:59 +03:00