g_strconcat expects 0 as last argument, but mhl_strmove is not.
When reverting this detail was overlooked. Returning 0 as last argument.
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
This pach fixes two issues (both appear only in escapy strings):
* tail cut of escapy string when '\\' is met
* head cut of escapy string when '\\' is met :]
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
This patch reintroduces fix firstly appeared in (and recently broken by mhl revert)
> commit e48cb7c89f
> Author: Sergei Trofimovich <st@anti-virus.by>
> Date: Fri Jan 30 09:31:28 2009 +0200
>
> mhl: added mhl_strmove() function (memmove semantics)
...
> Snippet of man strcpy:
> DESCRIPTION
> The strcpy() function copies the string pointed to by src, including the terminating
> null byte ('\0'), to the buffer pointed to by dest. ___The strings may not overlap___,
> and the destination string dest must be large enough to receive the copy.
> We used strcpy to move data chunk in memory: "./foo" -> "foo", etc.
>
> This patch introduces mhl_strmove and fixed canonicalize_pathname.
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
When we try to complete something what can't be stat()'ed,
we treated it like dir. Now we do not consider such candidates
for completion.
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
This commit will replace some *ptr = c; stuff with g_string_append_c(str,c);
in order to use glib here.
Signed-off-by: Patrick Winnertz <winnie@debian.org>
As we decided to fully switch back to glb we needed to rewrite this function in order to use
glib functions. This means in this case mostly that *ptr = c; ptr++; is replaced by something
like this: g_string_append(str,c); with str a GString*.
Signed-off-by: Patrick Winnertz <winnie@debian.org>
This commit moves the mhl_str_concat_dir_and_file back into src/util.c whitout changing atm the functionality.
Please note that this is an incomplete fix and needs to be partially enhanced in order to keep the full functionality with glib.
Signed-off-by: Patrick Winnertz <winnie@debian.org>
This removes the usage of stdbool.h in favour of mhl/tyes.h as we have to revert everything one by one
Signed-off-by: Patrick Winnertz <winnie@debian.org>
Enrico has accidentially removed the slang1.x support in mc-4.6 branch as
this is a structural change which clearly doesn't belong into mc-4.6.
Signed-off-by: Patrick Winnertz <winnie@debian.org>
./configure --enable-charset && make
charsets.c: In function 'load_codepages_list':
charsets.c:51: warning: implicit declaration of function 'mhl_str_dir_plus_file'
charsets.c:51: warning: assignment makes pointer from integer without a cast
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
* mc-4.6: (38 commits)
mhl: mhl_shell_unescape_buf(): fixed memory array OOB.
completion: fixed complete already escaped secuences.
completion: added changelog entry for solved #147
completion: fixed completion of escaped commands in commandline
Removed unused char*.
mhl: added mhl_strmove() function (memmove semantics)
completion: added escapes in command line on completion
complete: cleanup: #define to enum INPUT_COMPLETION_FLAGS
added a new parameter for completion flags to input_new
fish: cleanup: unboxed quoted strings when generate shell commands
introduced new type SHELL_ESCAPED_STR for more type safety
added mhl/types.h which defines bool enum, escape.h now using this type
Removed unused variable
Changes for use MHL.
Fixed bug with renamig/copying files with backshashes in names
Remove some testing stuff
Temporarry commit. Fixed completion in browse by directoryes.
Fixed some memory leaks.
Add $ and ` for escaping and reorder it according to the ascii values
Rewrite it to use g_string_append_c instead of some homebrew stuff
...
<winnie> ls -lQ /tmp/test
-rw-r--r-- 1 winnie winnie 0 30. Jan 13:05 "a"
-rw-r--r-- 1 winnie winnie 0 30. Jan 13:04 " test\"hallo"
-rw-r--r-- 1 winnie winnie 0 30. Jan 13:04 " test$hallo"
<winnie> and then cat /tmp/test/\ and ESC-tab in subshell...
unescape/escape sequences in command completion (it also solves
completiont of weirdweird escapy commands like ./<escapy-cmd><complete>, like:
$ ls -lQ
-rwxr-xr-x 1 slyfox slyfox 2037 Jan 15 21:18 " 'asd&&\"->build-glib1.sh"
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
* mc-4.6:
replaced buggy concat_dir_and_file() by mhl_str_dir_plus_file()
fixed out-of-tree-builds
Updated the NEWS file for 4.6.2 and added the bugnumbers behind the items in the list.
Update for OpenOffice and StarOffice viewer.
changelog: added entry for python syntax
syntax: python: keywords update (patch by NNemec) fixes#216
AC_USE_SYSTEM_EXTENSIONS macro requires autoconf >= 2.60
po/ru.po: In russian translation, there are some hotkey conficts in menu.
ChangeLog/NEWS: added entry for #181 ticket (copy to deleted dir)
Now a trailing slash will only be added in copy & move dialogs if the path itselfs
copy/move dialog: add trailing '/' to default destination path (fix#181)
fixed comments to /* ... */
Not only comment it out but removing it
Removed unneeded var to make build process a bit cleaner
Add code snipplet by il.smind which should fix issues with putty and
Conflicts:
ChangeLog
mhl/string.h
src/command.c
src/complete.c
src/file.c
src/util.c
valgrind detected an error in completion path:
==2962== Source and destination overlap in strcpy(0x459F068, 0x459F06A)
==2962== at 0x4026056: strcpy (mc_replace_strmem.c:268)
==2962== by 0x808F70B: canonicalize_pathname (string3.h:106)
==2962== by 0x805ECBA: filename_completion_function (complete.c:125)
==2962== by 0x805FB35: command_completion_function (complete.c:448)
==2962== by 0x805EA34: completion_matches (complete.c:552)
==2962== by 0x8060454: complete (complete.c:735)
==2962== by 0x809AAC4: handle_char (widget.c:1545)
==2962== by 0x807867E: midnight_callback (dialog.h:201)
==2962== by 0x8061B27: dlg_process_event (dialog.c:664)
==2962== by 0x8061ECE: run_dlg (dialog.c:786)
==2962== by 0x807996C: main (main.c:1674)
Snippet of man strcpy:
DESCRIPTION
The strcpy() function copies the string pointed to by src, including the terminating
null byte ('\0'), to the buffer pointed to by dest. ___The strings may not overlap___,
and the destination string dest must be large enough to receive the copy.
We used strcpy to move data chunk in memory: "./foo" -> "foo", etc.
This patch introduces mhl_strmove and fixed canonicalize_pathname.
Signed-off-by: Sergei Trofimovich <st@anti-virus.by>
* mc-4.6:
Now a trailing slash will only be added in copy & move dialogs if the path itselfs
copy/move dialog: add trailing '/' to default destination path (fix#181)
Problem:
When user tried to copy/move file (F5/F6) - he could run into trouble if
destination directory is removed (it can be removed by user from another mc session).
Operation is performed and(!) file is renamed.
So when when user issues 'cp /tmp/a.file /tmp/b' - he gets not expected /tmp/b/a.file,
but /tmp.b !
Solution:
Add trailing space for destination directory for non-local copy/move(F5/F6) operations.
So operation, given above will take form: 'cp /tmp/a.file /tmp/b/' disambiguating b
meaning.
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
mhl/escape.h:
add new function mhl_shell_is_char_escaped()
src/command.c; src/complete.c; src/file.c; src/util.c:
Changes for use MHL-functions.
src/util.h:
remove old escape-related declarations of functions
mc (mc over ssh on a putty console)
- to reproduce try this:
1) run 'putty'; login to remote host
2) run mc
3) press key '/' on keypad. You will see menu that is called when you press the F2
4) Go to 'Learn keys' (simple call dialog)
5) just exit from 'learn keys' dialog (without any changes)
6) 3) press key '/' on keypad again. You will see '/' symbol in command line.
experimental patch, completely different reading file, new cache structure,
shall view text in every encodings (remaped ctrl + t, new dialog need
localization).
1. to avoid backward reading, viewer keeps four following characters from
file: next, actual and two previous. This is enough to handle new lines
and nroff fortmatin correctly.
2. cache_line structure, that presents one line in file. cache_line stores,
where line starts and ends in file,number of line and width of line. Width
is at most equal to screen width, so longer lines are cached in more
cache_lines. This makes wrapping text very easy. Cache_lines are stored
in a linked list. file is loaded into cache_lines sequential, not whole at once.
It only provides navigation in file.
I found two problems in this solution:
1. slow first move to end in large files, because can not read files
backward. (loading in background may help)
2. it is slow with multibyte characters. I tried to eliminate calling iconv
to two, but it did not help (iconv is called on every byte). I think
caching some parts of file will be needed.
add support for filesystem, that use others encodings than mc (vfs). Now can be
encoding set only manually, but automatic detection is possible. Filename is
converted in mc_readdir and other function translate it back by vfs_translate
added menu etries encodnig in left and rigth menu (localization will be neede)
modified subshell.c to put subshell correct working directoy,
modified ext.c and execute.c to translate filename before running command
there could be one problem, vfs_translate_path does not use something like
path_magic function
rest of fixes in files cmc.c, main.c (xterm title), panelize.c, subshell.c,
tree.c, tty.c, user.c, util.c, win.c
now, basic mc's function should work well, editor and view are still broken.
like buttons use menu entries hotkey_t. But menus are staticly defined, so this
change is much bigger. All menu declaration must be edited. follow standard
changes in drawing and handling hotkeys.
now basic mc's functions works in utf-8, remain correct calculation of controls
width in dialogs, replace functions like tolower, toupper,isspace, ... width
functions from strutil or g_ascii variant.
like in input, added multibytes characters buffer for search in panel (ctrl+s)
drawing is simplier, because alignment do directly str_fit_to_term function
from strutil, changed time functions in util to work correctly in utf-8
experimental patch, completely different reading file, new cache structure,
shall view text in every encodings (remaped ctrl + t, new dialog need
localization).
1. to avoid backward reading, viewer keeps four following characters from
file: next, actual and two previous. This is enough to handle new lines
and nroff fortmatin correctly.
2. cache_line structure, that presents one line in file. cache_line stores,
where line starts and ends in file,number of line and width of line. Width
is at most equal to screen width, so longer lines are cached in more
cache_lines. This makes wrapping text very easy. Cache_lines are stored
in a linked list. file is loaded into cache_lines sequential, not whole at once.
It only provides navigation in file.
I found two problems in this solution:
1. slow first move to end in large files, because can not read files
backward. (loading in background may help)
2. it is slow with multibyte characters. I tried to eliminate calling iconv
to two, but it did not help (iconv is called on every byte). I think
caching some parts of file will be needed.
add support for filesystem, that use others encodings than mc (vfs). Now can be
encoding set only manually, but automatic detection is possible. Filename is
converted in mc_readdir and other function translate it back by vfs_translate
added menu etries encodnig in left and rigth menu (localization will be neede)
modified subshell.c to put subshell correct working directoy,
modified ext.c and execute.c to translate filename before running command
there could be one problem, vfs_translate_path does not use something like
path_magic function
rest of fixes in files cmc.c, main.c (xterm title), panelize.c, subshell.c,
tree.c, tty.c, user.c, util.c, win.c
now, basic mc's function should work well, editor and view are still broken.
changes in sorting strings (name, extension), for comparing are created keys
from strings and than their are compared instead of primary strings. (in
reality, keys are created only for case insensitive comparing, case
sensitive compare original strings). In utf-8 shall by keys faster than
compare strings directly. But this need ediding declaration of all sorts
functions.