* added new color pair EDITOR_RIGHT_MARGIN_COLOR
* show right margin. Used EDITOR_RIGHT_MARGIN_COLOR color for drawing text beyond rigth edge.
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
valgrind log snippet: (from here http://pavlinux.ru/vgmc.log)
> ==26750== HEAP SUMMARY:
> ==26750== in use at exit: 0 bytes in 0 blocks
> ==26750== ==26749== Invalid free() / delete / delete[]
> ==26749== at 0x4A06DD8: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==26749== by 0x48B5F9: edit_read_syntax_rules (syntax.c:766)
> ==26749== by 0x48CDA7: edit_read_syntax_file (syntax.c:1140)
> ==26749== by 0x48D06D: edit_load_syntax (syntax.c:1219)
> ==26749== by 0x4762F6: edit_init (edit.c:834)
> ==26749== by 0x4858FC: edit_file (editwidget.c:241)
> ==26749== by 0x44D017: do_edit_at_line (cmd.c:304)
> ==26749== by 0x44D098: do_edit (cmd.c:324)
> ==26749== by 0x44D10E: edit_cmd (cmd.c:331)
> ==26749== by 0x46C2E4: midnight_execute_cmd (main.c:1193)
> ==26749== by 0x46CD41: midnight_callback (main.c:1690)
> ==26749== by 0x4353F4: buttonbar_call (widget.c:2654)
> ==26749== Address 0x60f8e10 is 0 bytes inside a block of size 30 free'd
> ==26749== at 0x4A06DD8: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==26749== by 0x48B32C: open_include_file (syntax.c:705)
> ==26749== by 0x48B6E8: edit_read_syntax_rules (syntax.c:784)
> ==26749== by 0x48CDA7: edit_read_syntax_file (syntax.c:1140)
> ==26749== by 0x48D06D: edit_load_syntax (syntax.c:1219)
> ==26749== by 0x4762F6: edit_init (edit.c:834)
> ==26749== by 0x4858FC: edit_file (editwidget.c:241)
> ==26749== by 0x44D017: do_edit_at_line (cmd.c:304)
> ==26749== by 0x44D098: do_edit (cmd.c:324)
> ==26749== by 0x44D10E: edit_cmd (cmd.c:331)
> ==26749== by 0x46C2E4: midnight_execute_cmd (main.c:1193)
> ==26749== by 0x46CD41: midnight_callback (main.c:1690)
We see doublefree memory corruption here, introduced by spurious 'g_free(error_file_name)'
of changeset:0c17219b2ab5cb5fe2e73f8d7cc9c11c755a3ae4 (syntax.c file)
The rest of code seems to store real syntax file name there.
Making code the same as part above: don't free 'error_file_name'
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
g_new(), g_new0(), g_malloc(), g_malloc0() and g_realloc() functions
never return NULL and call abort() on fail. So check result of these
functions is useless. g_try_new(), g_try_new0(), g_try_malloc(),
g_try_malloc0() and g_try_realloc() functions are used instead.
Some minor optimization and code formatting are also performed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
../../mc/edit/editcmd.c:2519:50: error: field precision should have type 'int', but argument has type 'gsize' (aka 'unsigned long') [-Wformat]
match_expr = g_strdup_printf ("(^|\\s+|\\b)%.*s[^\\s\\.=\\+\\[\\]\\(\\)\\,\\;\\:\\\"\\'\\-\\?\\/\\|\\\\\\{\\}\\*\\&\\^\\%%\\$#@\\!]+", word_len, bufpos);
^ ~~~~~~~~
../../mc/edit/editcmd.c:2700:38: error: field precision should have type 'int', but argument has type 'gsize' (aka 'unsigned long') [-Wformat]
match_expr = g_strdup_printf ("%.*s", word_len, bufpos);
^ ~~~~~~~~
2 diagnostics generated.
make[2]: *** [editcmd.o] Error 1
make[2]: Target `all' not remade because of errors.
../../../mc/src/mcconfig/common.c:71:74: error: format string is not a string literal (potentially insecure) [-Wformat-security]
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
^~~~~~~~~~~~~~~
../../../mc/src/mcconfig/common.c:83:74: error: format string is not a string literal (potentially insecure) [-Wformat-security]
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
^~~~~~~~~~~~~~~
2 diagnostics generated.
make[3]: *** [libmcconfig_la-common.lo] Error 1
make[3]: Target `all' not remade because of errors.
../../mc/src/main.c:2165:41: error: format string is not a string literal (potentially insecure) [-Wformat-security]
message (D_ERROR, _("Warning"), error->message);
^~~~~~~~~~~~~~
1 diagnostic generated.
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
Removed unneeded goto, return, #ifdef.
Type accuracy.
Indentation.
Minor optimization.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>
Since button bar is a part of editor dialog, its initialization
was moved from WIDGET_INIT stage to DLG_INIT one.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Now these functions will return newly allocated string in any case.
As third-side effect, fixed memory leak with '--disable-charset' configure option.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
fixed: drawing CJK character as '...'.
Sometimes the CJK character gets replaced by three inverse dots.
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
fixed: 'eval_marks' for correct vertical block delete.
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
fixed edit_block_delete, edit_delete_column_of_text for correct delete vertical block
fixed cursor position after delete block
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
fixed: cursor placement and movements in non-ascii (cyrillic) UTF-8 files
in 8-bit (KOI8-R) locales
fixed incorrect width calculation in 7-bit codeset
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
Minor optimization of edit_move_forward3() function.
Also fixed build with --disable-charset option.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Refactoring of uneeded goto in user_menu() function in editor.
Thanks to Vit Rosin for originl patch.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
fixed: cursor positioning after non-printeble char (in 8-bit encoding)
added: char convertion for correct cursor movement
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
Added two parameters:
* Widget *sender -- to recognize the wiget that have sent message;
* void *data -- to pass any user-defined data to the dialog.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
First step: renamed type of dialog command execution function.
Made execution function more flexible: added parameters for
sender and receiver widgets and user data.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>