Commit Graph

16185 Commits

Author SHA1 Message Date
Andrew Borodin
7d8ea93d0b Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2025-01-01 13:21:02 +03:00
Andrew Borodin
b2f69534ce maint/update-years.sh: add command to restore script permissions.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2025-01-01 13:18:53 +03:00
Andrew Borodin
5fe1f3fce0 (check_dir_is_empty): handle the return value of mc_opendir().
Show error message if mc_opendir() returns NULL.

  * (erase_dir_iff_empty): sync with modified check_dir_is_empty().
  * (erase_dir): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2025-01-01 13:07:44 +03:00
Andrew Borodin
878491238f viewer: type accuracy related to the WView::locked flag.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-28 10:54:17 +03:00
Andrew Borodin
c1effaf564 mcedit: type accuracy.
Use bit fields as integers not as booleans.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-28 10:52:16 +03:00
Andrew Borodin
9ad0e22988 mcedit: reset WEdit::locked flag at file unlock. 2024-12-28 10:30:17 +03:00
Andrew Borodin
5c5b52a898 WEdit: remove unused member max_column.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-28 10:23:44 +03:00
Andrew Borodin
2980010b53 search: change types of start and end search positions from gsize to off_t.
editor: related changes.
viewer: likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-26 11:06:13 +03:00
Andrew Borodin
fcecbf003c mcedit (editsearch): minor refactoring.
* (edit_do_search): refactor check of search options.
  * (edit_replace_cmd): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-25 20:38:50 +03:00
Andrew Borodin
de999cd76d (edit_search_show_error): rename from edit_show_search_error.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-25 10:29:54 +03:00
Andrew Borodin
f94d15d143 mcedit: move definition of edit_search_options_t to editsearch.c.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-25 07:54:55 +03:00
Andrew Borodin
e06fc107ed src/vfs/tar/tar.c: fix typo.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-12-23 14:19:30 +03:00
Andrew Borodin
3475da785f (size_trunc_len): fix Undefined Binary Operator Result.
lib/util.c:493:28: warning: The left operand of '!=' is a garbage value due to array index out of bounds [clang-analyzer-core.UndefinedBinaryOperatorResult]
  493 |     for (j = units; sfx[j] != NULL; j++)
      |                     ~~~~~~ ^

 - verify and limit input 'units' value

Found by Clang-19 Static Analyzer.

Reported-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <vmail.ru>
2024-12-22 11:39:28 +03:00
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