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>
* 3815_quickview_return:
TreeView should mute the command-line.
QuickView shouldn't consume all keys.
Factor out handle_cmdline_enter().
Ticket #3815: Factor out is_cmdline_mute().
Because it's a recipe for disaster to mix, for example, DEL for deleting a
directory and BACKSPACE for deleting the previous char.
Signed-off-by: Mooffie <mooffie@gmail.com>
The QuickView should return MSG_HANDLED, in its MSG_KEY, *only* for keys it has
indeed handled.
We move the "don't pass any chars to command line" responsibility to the main
dialog instead.
(We're reverting commit 8469c13f38 here.)
Signed-off-by: Mooffie <mooffie@gmail.com>
When change panel mode to listing one, in addition to reset of
panelization, reset panel filter too.
Optimization: get rid of double panel reload.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* 2942_panelize_absolutize:
do_panelize_cd() is missing call to panelize_absolutize_if_needed().
Introduce panelize_absolutize_if_needed(), plus documentation.
Fix assumptions of "dir.list->len == 0".
Ticket #2942: External panelize: opening a file with an absolute path fails.
Whenever we populate a panelized panel, we have to call
panelize_absolute_if_needed().
Note: do_panelize_cd() implements the "Restore last panelization" command
(see #3767).
Note: We move the `panel->is_panelized = TRUE` line to the bottom for stylistic
reason: to make it parallel to the other places where we have similar code. We
may factor out this common code in the future.
Signed-off-by: Mooffie <mooffie@gmail.com>
`dir.list->len` can't be zero because we're always checking it after a call to
dir_list_init(), which populated the list with "..".
Therefore any code that checks for zero is either superfluous or a bug.
As for the modifications in find.c:
- The bug caused us not to call panel_clean_dir(), and this caused:
- Memory leaks resulting from calling dir_list_init() without
dir_list_clean() first.
- The "total size" of selected files (for example) wasn't getting cleared.
- We remove the `if (list->len != 0)` around the
`current_panel->is_panelized = TRUE; ...` for several reasons:
- The code isn't called anyway if no files were found.
- Conceptually, there's no point in distinguishing an empty listing from an
empty panelized listing.
- It's the de-facto current behavior (as `list->len != 0` always)
Signed-off-by: Mooffie <mooffie@gmail.com>
We fix the detection of absolute paths in the panel's list. `list[0]` is "..",
so we need to inspect `list[1]`.
Signed-off-by: Mooffie <mooffie@gmail.com>
Before the patch: --help shows the same text for all tools, only "mc"
is replaced by tool name. For example, "mcedit --help" says:
Usage:
mcedit [OPTION...] [+number] [this_dir] [other_panel_dir]
+number - Set initial line number for the internal editor
which is wrong: mcedit does not take [this_dir] [other_panel_dir]
syntax, that's mc syntax.
After the patch, each tool has its own syntax string shown.
"Usage:" message for each tool is as follows now:
mc [OPTION...] [this_dir] [other_panel_dir]
mcedit [OPTION...] [+lineno] file1[:lineno] [file2[:lineno]...]
mcview [OPTION...] file
mcdiff [OPTION...] file1 file2
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>