Found by GCC 7.2.0
utilunix.c: In function 'my_systemv':
utilunix.c:455:13: error: this statement may fall through [-Werror=implicit-fallthrough=]
my_exit (127); /* Exec error */
^~~~~~~~~~~~~
utilunix.c:458:5: note: here
default:
^~~~~~~
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
When content of a large directory is being sorted by file names, a
significant amount of CPU time is spent in str_utf8_normalize() that is
called from str_utf8_create_key_gen().
For example, /usr/bin/ contains 5437 files on my Archlinux box. Running
mc /usr/bin/ /usr/bin/ takes approx. 75 000 000 CPU instructions to sort
file names, or 25% of total program run time. From these 75 000 000
instructions, 42 500 000 instruction are spent in str_utf8_normalize().
str_utf8_normalize() uses g_utf8_normalize() to do the work.
g_utf8_normalize() is a heavyweight function, that converts UTF-8 into
UCS-4, does the normalization and then converts UCS-4 back into UTF-8.
Since file names are composed of ASCII characters in most cases, we can
speed up str_utf8_normalize() by checking if the heavyweight Unicode
normalization is actually needed. Normalization of ASCII string is
no-op, so it is effectively "normalized" by just strdup().
With this patch, running mc /usr/bin/ /usr/bin/ requires just 37 000 000
instructions to sort the file names (down from 75 000 000) and 4 500 000
instuctions to do str_utf8_normalize() (down from 42 500 000).
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This patch was supposed to get committed as part of #3571 but this never
happened. We commit it now as we depend on its functionality for the next
commit.
Signed-off-by: Mooffie <mooffie@gmail.com>
Found by GCC 6.2.0.
color-internal.c:186:33: error: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'int' [-Werror=format=]
Signed-off-by: Andreas Mohr <and@gmx.li>
MC truncates timestamps during file copy and drops sub-second precision.
Make use of utimensat(), introduced in Linux kernel 2.6.22 (and since
2.6.26 compatible with POSIX-1.2008).
Signed-off-by: Andrey Gursky <andrey.gursky@e-mail.ua>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
We also improve the documentation of vfs_parse_filedate(), which does the
actual work.
Note that in the user-facing documentation (extfs/helpers/README) there are
two things we prefer *not* to mention about vfs_parse_filedate's ability:
* Accepting the format "MM-DD-YY hh:mm[:ss]", as this two-digit year is
more likely to confuse readers of such dates.
* Accepting '/', instead of '-', as the separator in MM-DD-YYYY. (Considering
that some scripts do use '/', maybe we should mention it?)
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This message is sent to widgets'owner when widget's focus state is
changed.
Find file dialog: fix initial draw of ignore directories input line.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
scanf("%x") knows to eat up this prefix[1][2], so we don't need to do this
ourselves.
[1] K&R's "The C Programming Language" documents "%x" as "hexadecimal
integer (with or without leading 0x or 0X)"
[2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/scanf.html
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Note: considering that this feature hasn't worked, we may consider removing it
entirely or partially (e.g., escaping) in order to simplify the code, as nobody
has grown used to it. It seems, based on the "hex mode" mentioned in the manual
page, that in the past there was no "normal" search in hex mode, and quoted
strings were the only easy way to look for text. This is no longer the case
nowadays.
Note: the characters in the quoted string are copied out as-is to the regexp.
No regexp-quoting is currently done. We may want to revisit this issue when we
work on ticket #3695.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
sscanf() returns EOF when it reaches the end of the string. Our code
erroneously interprets this as if a number was read. The fix: we test for an
explicit '1'.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Compiler with my_exit() 'noreturn' knowledge will complain about
never reachable break statement.
Reported by clang compiler.
(Maybe there is a better code sequence)
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
utilvfs.c: In function 'vfs_die':
utilvfs.c:354:1: warning: function might be candidate for attribute 'noreturn' [-Wsuggest-attribute=noreturn]
vfs_die (const char *m)
^~~~~~~
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
utilunix.c:360:1: error: function might be candidate for attribute 'noreturn' [-Wsuggest-attribute=noreturn]
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
serialize.c: In function 'mc_serialize_str':
serialize.c:116:34: error: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'size_t {aka long unsigned int}' [-Werror=format=]
return g_strdup_printf ("%c%zd" SRLZ_DELIM_S "%s", prefix, strlen (data), data);
^
serialize.c:130:19: error: format '%zd' expects argument of type 'signed size_t', but argument 5 has type 'size_t {aka long unsigned int}' [-Werror=format=]
#define FUNC_NAME "mc_serialize_str()"
^
serialize.c:175:22: note: in expansion of macro 'FUNC_NAME'
FUNC_NAME
^~~~~~~~~
serialize.c:130:19: error: format '%zd' expects argument of type 'signed size_t', but argument 6 has type 'size_t {aka long unsigned int}' [-Werror=format=]
#define FUNC_NAME "mc_serialize_str()"
^
serialize.c:175:22: note: in expansion of macro 'FUNC_NAME'
FUNC_NAME
^~~~~~~~~
serialize.c: In function 'mc_deserialize_config':
serialize.c:267:19: error: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'size_t {aka long unsigned int}' [-Werror=format=]
#define FUNC_NAME "mc_deserialize_config()"
^
serialize.c:269:35: note: in expansion of macro 'FUNC_NAME'
prepend_error_message (error, FUNC_NAME " at %zd", current_position + 1); \
^~~~~~~~~
serialize.c:301:17: note: in expansion of macro 'prepend_error_and_exit'
prepend_error_and_exit ();
^~~~~~~~~~~~~~~~~~~~~~
serialize.c:267:19: error: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'size_t {aka long unsigned int}' [-Werror=format=]
#define FUNC_NAME "mc_deserialize_config()"
^
serialize.c:269:35: note: in expansion of macro 'FUNC_NAME'
prepend_error_message (error, FUNC_NAME " at %zd", current_position + 1); \
^~~~~~~~~
serialize.c:313:17: note: in expansion of macro 'prepend_error_and_exit'
prepend_error_and_exit ();
^~~~~~~~~~~~~~~~~~~~~~
serialize.c:267:19: error: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'size_t {aka long unsigned int}' [-Werror=format=]
#define FUNC_NAME "mc_deserialize_config()"
^
serialize.c:269:35: note: in expansion of macro 'FUNC_NAME'
prepend_error_message (error, FUNC_NAME " at %zd", current_position + 1); \
^~~~~~~~~
serialize.c:325:17: note: in expansion of macro 'prepend_error_and_exit'
prepend_error_and_exit ();
^~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
hex.c: In function 'mc_search__hex_translate_to_regex':
hex.c:79:39: error: format '%x' expects argument of type 'unsigned int *', but argument 3 has type 'int *' [-Wformat=]
if (sscanf (tmp_str + loop, "%x%n", &val, &ptr))
^
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Additionally always put a space between number and unit which is
required by the norms.
It is important to note that really small buffers have to be bigger than it
appears because they store bytes and non-Latin scripts need more than one byte
with UTF-8 to encode them, e.g., the string "1023 МиБ" in Russian requires
11 bytes + null terminator.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
size_trunc() has been aligned to properly use either IEC or SI prefixes with
the unit B (byte). Additionally always put a space between number and unit
which is required by the norms.
Obsolete gettext message ids have been removed and some cleaned up for
duplicate words or leading spaces.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(widget_replace): if new widget cannot take focus, move focus to other widget
before widget replacement.
In our case, the focused file panel is replaced by Info one. Info panel
a) isn't selectable (it never takes focus) and b) uses CWD of current
panel. Therefore focus must be moved to other file panel to make it
current and correctly set up it's CWD before first draw of Info panel.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Add new WDialog APIs:
* dlg_set_current_widget_next
* dlg_set_current_widget_prev
* dlg_get_widget_next_of
* dlg_get_widget_prev_of
and use them:
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Send MSG_DRAW message immediately after MSG_FOCUS/MSG_UNFOCUS.
Thus, the MSG_DRAW message handler is the only place where widget
should be drawn. Widget should not draw itself in other message
handlers.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If menu is not active, it is not selectable also in order to disallow
select and focus the inactive menu.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
To ensure that nobody uses the 'homedir' variable in the future without
initializing it first, we make it private to the function, thereby effectively
removing it.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
We can conclude, by reading their GLib source[1], by their documentation,
and by looking at how popular programs use them[2], that the functions
g_get_user_{config,cache,data}_dir() don't return a NULL or empty string.
So the handling of this case can go.
[1] https://git.gnome.org/browse/glib/tree/glib/gutils.c
[2] E.g., google "g_get_user_data_dir".
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
glob.c:143:21: warning: implicit conversion loses integer precision: 'int' to 'char' [-Wconversion]
c = ++cnt;
~ ^~~~~
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
search.c: In function 'mc_search_set_error':
search.c:497:36: error: declaration of 'mc_search' shadows a global declaration [-Werror=shadow]
search.c:419:1: error: shadowed declaration is here [-Werror=shadow]
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
input_complete.c:383:42: error: variable 'p' may be uninitialized when used here [-Werror,-Wconditional-uninitialized]
temp = g_string_new_len (*env_p, p - *env_p);
^
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Move calls of disable_mouse() and disable_bracketed_paste()
to main() because init_mouse() and enable_bracketed_paste()
are called here.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The code that manipulates the ncurses backend into changing
the key combination to generate SIGINT from CTRL-c to CTRL-g does
so by accessing undocumented internal ncurses data structures.
This breaks compilation with netbsd-curses[0], and could also break
when the ncurses author decides to change internal structures in a
future release.
Fix it by using a portable approach that works everywhere using libc
primitives instead.
[0] https://github.com/sabotage-linux/netbsd-curses
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This occurs if the left panel is in long listing mode and the right
panel is in full listing mode:
When the left panel is active and you click on the right side of the
panel, the click event is directed to the (inactive) right panel instead
of the (active) left panel.
This occurs if the right panel is in long listing mode:
When the left panel is active and you click on the left panel, the click
event is always directed to the (inactive) right panel. It's impossible
to click anything on the left panel, if the right panel is in long
listing mode.
Thanks Seray Rosh <seray.rosh@web.de> for intial patch.
Initial commit: refactoring of widget selection.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* DLG_FULLSCREEN: move and rename to WPOS_FULLSCREEN.
* DLG_CENTER: move and rename to WPOS_CENTER.
* DLG_TRYUP: move and rename to WPOS_TRYUP.
* WDialog::fullscreen: remove, use WPOS_FULLSCREEN instead.
* WDialog::compact: new field. Use instead of DLG_COMPACT.
* WDialog:🎏 remove.
* dlg_flags_t: remove.
* dlg_create: add new agruments: pos_flags, compact. Remove
argument: flags.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The bug:
1. Go to the source directory for version 4.8.17.
2. Enter the command "ls -l misc/mc*". The output will show at least 7 files.
3. Start mc.
4. Press Meta-! to open the "Filtered View" dialogue box.
5. Enter the same command: "ls -l misc/mc*".
Result:
MC displays the following error:
"ls: cannot access misc/mc*: No such file or directory".
Fix:
(mc_popen): use popen(3) way: pass command to /bin/sh using the -c flag.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Since mc_search__run_regex() pften is called in various iterative
procedures, don't reallocate regex buffer every time and use already
allocated one before.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
As per #3629, use `LIBINTL` for `gettext.m4` versions >= 0.11.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
lib/strutil/xstrtol.c: prohibit monstrosities like "1bB".
Problem reported by Young Mo Kang in: http://bugs.gnu.org/23388.
(xstrtoumax): Allow trailing second suffixes like "B" only if the first
suffix needs a base.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
As other local functions use "text" as function parameter variable
to fix cppcheck warning:
[lib/widget/input_complete.c:569]: (error) Uninitialized variable: text
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Cleanup following cppcheck warnings:
[lib/utilunix.c:1109]: (style) Unused variable: link_path.
[lib/utilunix.c:1113]: (style) Variable 'readlinks' is assigned a value that is never used.
[lib/utilunix.c:1114]: (style) Unused variable: n.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Cleanup following cppcheck warnings:
[lib/vfs/direntry.c:121]: (style) Clarify calculation precedence for '&' and '?'.
[lib/vfs/direntry.c:386]: (style) Clarify calculation precedence for '&' and '?'.
[lib/vfs/direntry.c:391]: (style) Clarify calculation precedence for '&' and '?'.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Cleanup uninitialized warning with gcc compiler (gcc-4.4.7-4.el6).
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Make Solaris Studio 12.4 happy.
"dialog.c", line 1029: warning: argument #2 is incompatible with prototype:
prototype: pointer to const void
argument : pointer to function (...) returning enum (...)
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
m4.include/stat-size.m4, lib/stat-size.h: get these files from Gnulib.
src/filemanager/ioblksize.h: get this file from Coreutils.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
We now send mouse events to widgets in reverse Z-order, as done in common GUIs.
This makes it easy to implement "invisible" menubars correctly.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Decompose mouse event translation function: move mouse event handling
to separate function. This decomposition can be used for low-level
processing of high-level mouse events.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
On systems where 'mode_t' is smaller than 'int', doing 'va_arg (ap, mode_t)' is
wrong because of C's "default argument promotions". GCC 4 creates crashing code
in this case.
The "va_arg" page of Gnulib's manual describes the problem and a simple solution:
https://www.gnu.org/software/gnulib/manual/html_node/va_005farg.html
However, since that solution reportedly (see thread at next link) still causes
GCC to print warnings (for no good reason; perhaps this was fixed in newer
GCCs), we pick a solution that defines a PROMOTED_MODE_T at the configuration
stage:
https://lists.gnu.org/archive/html/bug-gnulib/2009-05/msg00231.html
(We take our 'mode_t.m4' from the most recent Gnulib source.)
(If any of the URLs above no longer works, simply search the web for the
mentioned words.)
Start step: simplify buttonbar and menu handling.
We make WButtonBar send the command directly to the target widget. This
lets us simplify the MSG_ACTION case in dialog handlers. The menu handling
too is simplified here.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Use real errno or set it to 0 when no meaningful error code exists
for current user error message.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Some error messages have no meaningful error code, don't display them.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
In non-unicode locales, search for non-latin symbols in any acharset was
case sensitive only. This bug was introduced in
1a1496fc0d.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
When listbox is updated, e.g. new file match add MSG_DRAW event is triggered
but currently listbox re-draw has no knowledge about right focus state.
Fix it by remember current focus state.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Accessing widget object (at g_array_index loop) which was freed
already (item->quick_widget->u.input.label before at loop).
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>