In mcedit user menu the %f macro should match the file name opened in
mcedit not the file name is selected in the panel.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Broken in 178628e67f.
(mcview_do_search): do search in last chunk if data source is the
growing buffer only.
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>
If the file is not compressed and DECOMP is empty, it should be replaced
by *nothing*, not an empty argument. Broken in the following commit:
becc0d01d0
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
* (mcview_dialog_goto): do read data from pipe in case of
MC_VIEW_GOTO_OFFSET_DEC and MC_VIEW_GOTO_OFFSET_HEX.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Goto decimal/hexadecimal offset doesn't grow the file if necessary,
rather stops at an earlier offset.
Goto percent doesn't work either. It's trickier because no matter what
the percent value is, it'd need to read the entire contents.
Goto line number works as expected.
* (mcview_dialog_goto): read all data from pipe in case of
MC_VIEW_GOTO_PERCENT.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(mcview_do_search):
* In main search loop: don't break in case of MC_SEARCH_E_NOTFOUND
error. Make next iteration until buffer can be grown.
* Make search in the last data chunk.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
struct stat in libc for Linux kernel contains few fields more since 14+
years [1]. From bits/stat.h:
```
struct timespec st_atim; /* Time of last access. */
struct timespec st_mtim; /* Time of last modification. */
struct timespec st_ctim; /* Time of last status change. */
# define st_atime st_atim.tv_sec /* Backward compatibility. */
# define st_mtime st_mtim.tv_sec
# define st_ctime st_ctim.tv_sec
```
The conventional fields became an alias.
POSIX.1-2008 made struct stat st_[acm]tim mandatory [2].
OS takes care to initialize struct stat properly [3]. By not using an OS
syscall or a libc wrapper to fill struct stat, we have to take care of
initializing all fields (or at least those being used later) explicitly.
[1]: https://www.sourceware.org/ml/libc-alpha/2002-12/msg00011.html
[2]: https://www.sourceware.org/ml/libc-alpha/2009-11/msg00102.html
[3]: https://www.sourceware.org/ml/libc-alpha/2002-12/msg00013.html
Fixes: file timestamps not preserved (https://mail.gnome.org/archives/mc-devel/2017-April/msg00000.html)
Reported-By: Nerijus Baliunas <nerijus@users.sourceforge.net>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
How to reproduce:
1. Create two tar files with empty dir:
$ mkdir -p dir/dir1; mkdir dir/dir2; touch dir/dir1/file
$ tar cf normal.tar dir/
$ tar cf incremental.tar -g incremental.snap dir/
2. Press Enter to enter to normal.tar.
Result: normal.tar contains dir/dir2, incremental.tar doesn't.
Expected result: incremental.tar contains dir/dir2.
This patch also fixes Ticket #3709: Wrong directories owner for tar
--numeric-owner -g.
How to reproduce:
As root:
# mkdir -p TEST/TEST2
# echo aaa > TEST/TEST2/aaa.txt
# chown 10000:10000 TEST
# chown 10001:10001 TEST/TEST2
# chown 10002:10002 TEST/TEST2/aaa.txt
# tar --numeric-owner -zcf test1.tar.gz TEST
# tar --numeric-owner -g test.inc -zcf test2.tar.gz TEST
and now view these tarballs with long view. Directories of test2.tar.gz
have owner root instead of 10000 or 10001, but if you untar them using
tar -xvf directories owners are correct
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>