Merge branch '1656_lack_rights'

* 1656_lack_rights:
  Fix segfault in charset confirmation dialog at start of mc.
  Code cleanup for compile with new CFLAGS value.
  Added debug options for --enable-maintainer mode
  Ticket #1656: Incorrect processing of cases the lack of rights to save preferences.
This commit is contained in:
Slava Zanko 2009-10-28 13:38:18 +02:00
commit 09d8293043
26 changed files with 129 additions and 78 deletions

View File

@ -13,7 +13,6 @@ AM_INIT_AUTOMAKE(mc, ${VERSION} )
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE AM_MAINTAINER_MODE
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_USE_SYSTEM_EXTENSIONS AC_USE_SYSTEM_EXTENSIONS
@ -523,6 +522,12 @@ if test -z "$ac_env_CFLAGS_set"; then
fi fi
fi fi
if test x$USE_MAINTAINER_MODE = xyes; then
CFLAGS_WARNINGS="-Wall -Werror -Wwrite-strings -Wnested-externs -Wsign-compare -Wuninitialized"
CFLAGS_DEBUG="-g3 -O -ggdb"
CFLAGS="$CFLAGS $CFLAGS_WARNINGS $CFLAGS_DEBUG"
fi
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS) AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS) AC_SUBST(LDFLAGS)

View File

@ -718,7 +718,7 @@ edit_purge_widget (WEdit *edit)
} }
static void static void
edit_set_keymap (WEdit *edit) edit_set_keymap (void)
{ {
editor_map = default_editor_keymap; editor_map = default_editor_keymap;
if (editor_keymap && editor_keymap->len > 0) if (editor_keymap && editor_keymap->len > 0)
@ -839,7 +839,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename,
edit_move_to_line (edit, line - 1); edit_move_to_line (edit, line - 1);
} }
edit_set_keymap (edit); edit_set_keymap ();
return edit; return edit;
} }

View File

@ -428,7 +428,6 @@ menu_save_mode_cmd (void)
size_t i; size_t i;
size_t maxlen = 0; size_t maxlen = 0;
int dlg_x;
size_t w0, w1, b_len, w3; size_t w0, w1, b_len, w3;
assert (option_backup_ext != NULL); assert (option_backup_ext != NULL);
@ -438,7 +437,7 @@ menu_save_mode_cmd (void)
w1 = str_term_width1 (_(widgets[1].u.button.text)) + 5; /* default button */ w1 = str_term_width1 (_(widgets[1].u.button.text)) + 5; /* default button */
b_len = w0 + w1 + 3; b_len = w0 + w1 + 3;
maxlen = max (b_len, str_term_width1 (_(dialog.title)) + 2); maxlen = max (b_len, (size_t) str_term_width1 (_(dialog.title)) + 2);
w3 = 0; w3 = 0;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
@ -450,7 +449,7 @@ menu_save_mode_cmd (void)
maxlen = max (maxlen, w3 + 4); maxlen = max (maxlen, w3 + 4);
dialog.xlen = min (COLS, maxlen + 8); dialog.xlen = min ((size_t) COLS, maxlen + 8);
widgets[3].u.input.len = w3; widgets[3].u.input.len = w3;
widgets[1].relative_x = (dialog.xlen - b_len)/2; widgets[1].relative_x = (dialog.xlen - b_len)/2;

View File

@ -279,7 +279,7 @@ sort_box (const panel_field_t *sort_format, int *reverse, int *case_sensitive, i
{ {
int max_radio = 0, max_check = 0; int max_radio = 0, max_check = 0;
int ok_len, cancel_len; int ok_len, cancel_len;
int i; gsize i;
QuickWidget quick_widgets[] = QuickWidget quick_widgets[] =
{ {

View File

@ -1305,7 +1305,8 @@ dirsizes_cmd (void)
void void
save_setup_cmd (void) save_setup_cmd (void)
{ {
save_setup (); if (! save_setup ())
return;
message (D_NORMAL, _(" Setup "), _(" Setup saved to ~/%s"), message (D_NORMAL, _(" Setup "), _(" Setup saved to ~/%s"),
MC_USERCONF_DIR PATH_SEP_STR MC_CONFIG_FILE); MC_USERCONF_DIR PATH_SEP_STR MC_CONFIG_FILE);
} }

View File

@ -923,7 +923,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation,
i18n = TRUE; i18n = TRUE;
} }
fmd_xlen = max (FMDX, COLS * 2/3); fmd_xlen = max (FMDX, (size_t) COLS * 2/3);
/* buttons */ /* buttons */
for (i = 0; i <= 2 - OFFSET; i++) for (i = 0; i <= 2 - OFFSET; i++)
@ -950,7 +950,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation,
#endif #endif
b0_len = str_term_width1 (fmd_widgets[0].u.button.text) + 4; /* Cancel */ b0_len = str_term_width1 (fmd_widgets[0].u.button.text) + 4; /* Cancel */
len = b0_len + b1_len + b2_len; len = b0_len + b1_len + b2_len;
fmd_xlen = min (max (fmd_xlen, len + 6), COLS); fmd_xlen = min (max (fmd_xlen, len + 6), (size_t) COLS);
if (only_one) { if (only_one) {
int flen; int flen;
@ -961,7 +961,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation,
format, str_trunc ((const char *) text, i)); format, str_trunc ((const char *) text, i));
} else { } else {
g_snprintf (fmd_buf, sizeof (fmd_buf), format, *(const int *) text); g_snprintf (fmd_buf, sizeof (fmd_buf), format, *(const int *) text);
fmd_xlen = max (fmd_xlen, str_term_width1 (fmd_buf) + 6); fmd_xlen = max (fmd_xlen, (size_t) str_term_width1 (fmd_buf) + 6);
} }
for (i = sizeof (fmd_widgets) / sizeof (fmd_widgets[0]); i > 0; ) for (i = sizeof (fmd_widgets) / sizeof (fmd_widgets[0]); i > 0; )

View File

@ -49,6 +49,9 @@
inline static gboolean inline static gboolean
mc_fhl_is_file (file_entry * fe) mc_fhl_is_file (file_entry * fe)
{ {
#if S_ISREG == 0
(void) fe;
#endif
return S_ISREG (fe->st.st_mode); return S_ISREG (fe->st.st_mode);
} }
@ -61,12 +64,18 @@ mc_fhl_is_file_exec (file_entry * fe)
inline static gboolean inline static gboolean
mc_fhl_is_dir (file_entry * fe) mc_fhl_is_dir (file_entry * fe)
{ {
#if S_ISDIR == 0
(void) fe;
#endif
return S_ISDIR (fe->st.st_mode); return S_ISDIR (fe->st.st_mode);
} }
inline static gboolean inline static gboolean
mc_fhl_is_link (file_entry * fe) mc_fhl_is_link (file_entry * fe)
{ {
#if S_ISLNK == 0
(void) fe;
#endif
return S_ISLNK (fe->st.st_mode); return S_ISLNK (fe->st.st_mode);
} }
@ -85,30 +94,46 @@ mc_fhl_is_stale_link (file_entry * fe)
inline static gboolean inline static gboolean
mc_fhl_is_device_char (file_entry * fe) mc_fhl_is_device_char (file_entry * fe)
{ {
#if S_ISCHR == 0
(void) fe;
#endif
return S_ISCHR (fe->st.st_mode); return S_ISCHR (fe->st.st_mode);
} }
inline static gboolean inline static gboolean
mc_fhl_is_device_block (file_entry * fe) mc_fhl_is_device_block (file_entry * fe)
{ {
#if S_ISBLK == 0
(void) fe;
#endif
return S_ISBLK (fe->st.st_mode); return S_ISBLK (fe->st.st_mode);
} }
inline static gboolean inline static gboolean
mc_fhl_is_special_socket (file_entry * fe) mc_fhl_is_special_socket (file_entry * fe)
{ {
#if S_ISSOCK == 0
(void) fe;
#endif
return S_ISSOCK (fe->st.st_mode); return S_ISSOCK (fe->st.st_mode);
} }
inline static gboolean inline static gboolean
mc_fhl_is_special_fifo (file_entry * fe) mc_fhl_is_special_fifo (file_entry * fe)
{ {
#if S_ISFIFO == 0
(void) fe;
#endif
return S_ISFIFO (fe->st.st_mode); return S_ISFIFO (fe->st.st_mode);
} }
inline static gboolean inline static gboolean
mc_fhl_is_special_door (file_entry * fe) mc_fhl_is_special_door (file_entry * fe)
{ {
#if S_ISDOOR == 0
(void) fe;
#endif
return S_ISDOOR (fe->st.st_mode); return S_ISDOOR (fe->st.st_mode);
} }

View File

@ -150,7 +150,7 @@ static struct {
{ N_("&Edit - F4"), 13, 38 } { N_("&Edit - F4"), 13, 38 }
}; };
static char *in_contents = NULL; static const char *in_contents = NULL;
static char *in_start_dir = INPUT_LAST_TEXT; static char *in_start_dir = INPUT_LAST_TEXT;
static mc_search_t *search_file_handle = NULL; static mc_search_t *search_file_handle = NULL;
@ -441,7 +441,7 @@ find_parameters (char **start_dir, char **pattern, char **content)
/* keep empty Content field */ /* keep empty Content field */
/* if not empty, fill from history */ /* if not empty, fill from history */
*content = NULL; *content = NULL;
in_contents = ""; in_contents = "";
if (in_with->buffer[0] != '\0') { if (in_with->buffer[0] != '\0') {
*content = g_strdup (in_with->buffer); *content = g_strdup (in_with->buffer);
in_contents = INPUT_LAST_TEXT; in_contents = INPUT_LAST_TEXT;

View File

@ -1487,8 +1487,10 @@ load_hotlist (void)
} }
if (remove_old_list) { if (remove_old_list) {
GError *error = NULL;
clean_up_hotlist_groups ("Hotlist"); clean_up_hotlist_groups ("Hotlist");
mc_config_save_file (mc_main_config); if (! mc_config_save_file (mc_main_config, &error))
setup_save_config_show_error(mc_main_config->ini_path, &error);
} }
stat (hotlist_file_name, &stat_buf); stat (hotlist_file_name, &stat_buf);

View File

@ -548,7 +548,7 @@ void layout_cmd (void)
} }
if (result == B_EXIT){ if (result == B_EXIT){
save_layout (); save_layout ();
mc_config_save_file (mc_main_config); mc_config_save_file (mc_main_config, NULL);
} }
destroy_dlg (layout_dlg); destroy_dlg (layout_dlg);

View File

@ -334,7 +334,7 @@ learn_save (void)
* disk is much worse. * disk is much worse.
*/ */
if (profile_changed) if (profile_changed)
mc_config_save_file (mc_main_config); mc_config_save_file (mc_main_config, NULL);
g_free (section); g_free (section);
} }

View File

@ -23,6 +23,9 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> /* strerror() */
#include <errno.h> /* extern int errno */
#include "global.h" #include "global.h"
@ -45,7 +48,8 @@ mc_config_t *mc_panels_config;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static gboolean static gboolean
mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path) mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path,
GError **error)
{ {
gchar *data, *written_data; gchar *data, *written_data;
gsize len, total_written; gsize len, total_written;
@ -55,15 +59,17 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path)
data = g_key_file_to_data (mc_config->handle, &len, NULL); data = g_key_file_to_data (mc_config->handle, &len, NULL);
if (!exist_file (ini_path)) { if (!exist_file (ini_path)) {
ret = g_file_set_contents (ini_path, data, len, NULL); ret = g_file_set_contents (ini_path, data, len, error);
g_free (data); g_free (data);
return ret; return ret;
} }
mc_util_make_backup_if_possible (ini_path, "~"); mc_util_make_backup_if_possible (ini_path, "~");
fd = mc_open (ini_path, O_WRONLY | O_TRUNC | O_SYNC, 0); fd = mc_open (ini_path, O_WRONLY | O_TRUNC | O_SYNC, 0);
if (fd == -1) if (fd == -1) {
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
return FALSE; return FALSE;
}
for (written_data = data, total_written = len; for (written_data = data, total_written = len;
(cur_written = mc_write (fd, (const void *) written_data, total_written)) > 0; (cur_written = mc_write (fd, (const void *) written_data, total_written)) > 0;
@ -73,6 +79,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path)
if (cur_written == -1) { if (cur_written == -1) {
mc_util_restore_from_backup_if_possible (ini_path, "~"); mc_util_restore_from_backup_if_possible (ini_path, "~");
g_propagate_error (error, g_error_new (mc_main_error_quark() ,0, strerror(errno)));
return FALSE; return FALSE;
} }
@ -221,24 +228,24 @@ mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path)
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
gboolean gboolean
mc_config_save_file (mc_config_t * mc_config) mc_config_save_file (mc_config_t * mc_config, GError **error)
{ {
if (mc_config == NULL || mc_config->ini_path == NULL) { if (mc_config == NULL || mc_config->ini_path == NULL) {
return FALSE; return FALSE;
} }
return mc_config_new_or_override_file (mc_config, mc_config->ini_path); return mc_config_new_or_override_file (mc_config, mc_config->ini_path, error);
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
gboolean gboolean
mc_config_save_to_file (mc_config_t * mc_config, const gchar * ini_path) mc_config_save_to_file (mc_config_t * mc_config, const gchar * ini_path, GError **error)
{ {
if (mc_config == NULL) { if (mc_config == NULL) {
return FALSE; return FALSE;
} }
return mc_config_new_or_override_file (mc_config, ini_path); return mc_config_new_or_override_file (mc_config, ini_path, error);
} }

View File

@ -9,8 +9,7 @@
/*** structures declarations (and typedefs of structures)***************/ /*** structures declarations (and typedefs of structures)***************/
typedef struct mc_config_struct typedef struct mc_config_struct {
{
GKeyFile *handle; GKeyFile *handle;
gchar *ini_path; gchar *ini_path;
} mc_config_t; } mc_config_t;
@ -36,9 +35,10 @@ gboolean mc_config_has_group (mc_config_t *, const char *);
gboolean mc_config_read_file (mc_config_t *, const gchar *); gboolean mc_config_read_file (mc_config_t *, const gchar *);
gboolean mc_config_save_file (mc_config_t *); gboolean mc_config_save_file (mc_config_t * config, GError **error);
gboolean mc_config_save_to_file (mc_config_t *, const gchar *); gboolean mc_config_save_to_file (mc_config_t * config, const gchar * filename,
GError **error);
/* mcconfig/get.c: */ /* mcconfig/get.c: */
@ -46,54 +46,44 @@ gchar **mc_config_get_groups (mc_config_t *, gsize *);
gchar **mc_config_get_keys (mc_config_t *, const gchar *, gsize *); gchar **mc_config_get_keys (mc_config_t *, const gchar *, gsize *);
gchar *mc_config_get_string (mc_config_t *, const gchar *, const gchar *, gchar *mc_config_get_string (mc_config_t *, const gchar *, const gchar *, const gchar *);
const gchar *);
gchar *mc_config_get_string_raw (mc_config_t *, const gchar *, const gchar *, gchar *mc_config_get_string_raw (mc_config_t *, const gchar *, const gchar *, const gchar *);
const gchar *);
gboolean mc_config_get_bool (mc_config_t *, const gchar *, const gchar *, gboolean mc_config_get_bool (mc_config_t *, const gchar *, const gchar *, gboolean);
gboolean);
int mc_config_get_int (mc_config_t *, const gchar *, const gchar *, int); int mc_config_get_int (mc_config_t *, const gchar *, const gchar *, int);
gchar **mc_config_get_string_list (mc_config_t *, const gchar *, gchar **mc_config_get_string_list (mc_config_t *, const gchar *, const gchar *, gsize *);
const gchar *, gsize *);
gboolean *mc_config_get_bool_list (mc_config_t *, const gchar *, gboolean *mc_config_get_bool_list (mc_config_t *, const gchar *, const gchar *, gsize *);
const gchar *, gsize *);
int *mc_config_get_int_list (mc_config_t *, const gchar *, int *mc_config_get_int_list (mc_config_t *, const gchar *, const gchar *, gsize *);
const gchar *, gsize *);
/* mcconfig/set.c: */ /* mcconfig/set.c: */
void void
mc_config_direct_set_string (mc_config_t *, const gchar *, mc_config_direct_set_string (mc_config_t *, const gchar *, const gchar *, const gchar *);
const gchar *, const gchar *);
void void
mc_config_set_string (mc_config_t *, const gchar *, mc_config_set_string (mc_config_t *, const gchar *, const gchar *, const gchar *);
const gchar *, const gchar *);
void void
mc_config_set_bool (mc_config_t *, const gchar *, const gchar *, gboolean); mc_config_set_bool (mc_config_t *, const gchar *, const gchar *, gboolean);
void mc_config_set_int (mc_config_t *, const gchar *, const gchar *, int); void mc_config_set_int (mc_config_t *, const gchar *, const gchar *, int);
void void
mc_config_set_string_list (mc_config_t *, const gchar *, mc_config_set_string_list (mc_config_t *, const gchar *,
const gchar *, const gchar * const[], gsize); const gchar *, const gchar * const[], gsize);
void void
mc_config_set_bool_list (mc_config_t *, const gchar *, mc_config_set_bool_list (mc_config_t *, const gchar *, const gchar *, gboolean[], gsize);
const gchar *, gboolean[], gsize);
void void
mc_config_set_int_list (mc_config_t *, const gchar *, mc_config_set_int_list (mc_config_t *, const gchar *, const gchar *, int[], gsize);
const gchar *, int[], gsize);
/* mcconfig/dialog.c: */ /* mcconfig/dialog.c: */

View File

@ -134,7 +134,7 @@ menubar_paint_idx (WMenuBar *menubar, unsigned int idx, int color)
const int y = 2 + idx; const int y = 2 + idx;
int x = menu->start_x; int x = menu->start_x;
if (x + menu->max_entry_len + 4 > menubar->widget.cols) if (x + menu->max_entry_len + 4 > (gsize) menubar->widget.cols)
x = menubar->widget.cols - menu->max_entry_len - 4; x = menubar->widget.cols - menu->max_entry_len - 4;
if (entry == NULL) { if (entry == NULL) {
@ -185,7 +185,7 @@ menubar_draw_drop (WMenuBar *menubar)
int column = menu->start_x - 1; int column = menu->start_x - 1;
unsigned int i; unsigned int i;
if (column + menu->max_entry_len + 5 > menubar->widget.cols) if (column + menu->max_entry_len + 5 > (gsize) menubar->widget.cols)
column = menubar->widget.cols - menu->max_entry_len - 5; column = menubar->widget.cols - menu->max_entry_len - 5;
tty_setcolor (MENU_ENTRY_COLOR); tty_setcolor (MENU_ENTRY_COLOR);
@ -225,7 +225,7 @@ menubar_draw (WMenuBar *menubar)
/* Now each one of the entries */ /* Now each one of the entries */
for (i = menubar->menu; i != NULL; i = g_list_next (i)) { for (i = menubar->menu; i != NULL; i = g_list_next (i)) {
Menu *menu = i->data; Menu *menu = i->data;
gboolean is_selected = (menubar->selected == g_list_position (menubar->menu, i)); gboolean is_selected = (menubar->selected == (gsize) g_list_position (menubar->menu, i));
menubar_set_color (menubar, is_selected, FALSE); menubar_set_color (menubar, is_selected, FALSE);
widget_move (&menubar->widget, 0, menu->start_x); widget_move (&menubar->widget, 0, menu->start_x);
@ -605,7 +605,7 @@ menubar_event (Gpm_Event *event, void *data)
menubar_right (menubar); menubar_right (menubar);
else { else {
const unsigned int len = g_list_length (menubar->menu); const unsigned int len = g_list_length (menubar->menu);
int new_selection = 0; unsigned int new_selection = 0;
while ((new_selection < len) while ((new_selection < len)
&& (event->x > ((Menu *) g_list_nth_data (menubar->menu, && (event->x > ((Menu *) g_list_nth_data (menubar->menu,

View File

@ -62,7 +62,7 @@ typedef struct WMenuBar {
gboolean is_active; /* If the menubar is in use */ gboolean is_active; /* If the menubar is in use */
gboolean is_dropped; /* If the menubar has dropped */ gboolean is_dropped; /* If the menubar has dropped */
GList *menu; /* The actual menus */ GList *menu; /* The actual menus */
unsigned int selected; /* Selected menu on the top bar */ size_t selected; /* Selected menu on the top bar */
int previous_widget; /* Selected widget ID before activating menu */ int previous_widget; /* Selected widget ID before activating menu */
} WMenuBar; } WMenuBar;

View File

@ -244,7 +244,7 @@ void configure_box (void)
/* If they pressed the save button */ /* If they pressed the save button */
if (result == B_EXIT){ if (result == B_EXIT){
save_configure (); save_configure ();
mc_config_save_file (mc_main_config); mc_config_save_file (mc_main_config, NULL);
} }
destroy_dlg (conf_dlg); destroy_dlg (conf_dlg);

View File

@ -366,7 +366,7 @@ void save_panelize (void)
current->label, current->label,
current->command); current->command);
} }
mc_config_save_file (mc_main_config); mc_config_save_file (mc_main_config, NULL);
} }
void done_panelize (void) void done_panelize (void)

View File

@ -1158,11 +1158,10 @@ panel_update_cols (Widget *widget, int frame_size)
widget->x = origin; widget->x = origin;
} }
extern int saving_setup;
static char * static char *
panel_save_name (WPanel *panel) panel_save_name (WPanel *panel)
{ {
extern int saving_setup;
/* If the program is shuting down */ /* If the program is shuting down */
if ((midnight_shutdown && auto_save_setup) || saving_setup) if ((midnight_shutdown && auto_save_setup) || saving_setup)
return g_strdup (panel->panel_name); return g_strdup (panel->panel_name);
@ -1394,7 +1393,7 @@ panel_get_title_without_hotkey(const char *title)
hkey = strchr(translated_title, '&'); hkey = strchr(translated_title, '&');
if ((hkey != NULL) && (hkey[1] != '\0')) if ((hkey != NULL) && (hkey[1] != '\0'))
memmove(hkey, hkey+1,strlen(hkey)); memmove((void *) hkey, (void *) hkey+1,strlen(hkey));
return translated_title; return translated_title;
} }
@ -3372,7 +3371,7 @@ const panel_field_t *
panel_get_field_by_title(const char *name) panel_get_field_by_title(const char *name)
{ {
gsize index; gsize index;
gchar *title; gchar *title = NULL;
for(index=0; panel_fields[index].id != NULL; index ++) { for(index=0; panel_fields[index].id != NULL; index ++) {
title = panel_get_title_without_hotkey(panel_fields[index].title_hotkey); title = panel_get_title_without_hotkey(panel_fields[index].title_hotkey);

View File

@ -61,8 +61,7 @@ mc_search__recode_str (const char *str, gsize str_len,
gsize bytes_read; gsize bytes_read;
GIConv conv; GIConv conv;
if (charset_from == NULL || charset_to == NULL || !strcmp (charset_to, charset_from)) {
if (!strcmp (charset_to, charset_from)) {
*bytes_written = str_len; *bytes_written = str_len;
return g_strndup (str, str_len); return g_strndup (str, str_len);
} }

View File

@ -50,6 +50,7 @@
#include "file.h" /* safe_delete */ #include "file.h" /* safe_delete */
#include "keybind.h" /* lookup_action */ #include "keybind.h" /* lookup_action */
#include "fileloc.h" #include "fileloc.h"
#include "wtools.h"
#ifdef USE_VFS #ifdef USE_VFS
#include "../vfs/gc.h" #include "../vfs/gc.h"
@ -283,7 +284,7 @@ save_layout (void)
for (i = 0; layout [i].opt_name; i++){ for (i = 0; layout [i].opt_name; i++){
mc_config_set_int(mc_main_config, "Layout", layout [i].opt_name, *layout [i].opt_addr); mc_config_set_int(mc_main_config, "Layout", layout [i].opt_name, *layout [i].opt_addr);
} }
mc_config_save_to_file (mc_main_config, profile); mc_config_save_to_file (mc_main_config, profile, NULL);
g_free (profile); g_free (profile);
} }
@ -292,6 +293,7 @@ void
save_configure (void) save_configure (void)
{ {
char *profile; char *profile;
GError *error = NULL;
int i; int i;
profile = g_build_filename (home_dir, MC_USERCONF_DIR, MC_CONFIG_FILE, NULL); profile = g_build_filename (home_dir, MC_USERCONF_DIR, MC_CONFIG_FILE, NULL);
@ -304,7 +306,9 @@ save_configure (void)
for (i = 0; str_options[i].opt_name != NULL; i++) for (i = 0; str_options[i].opt_name != NULL; i++)
mc_config_set_string(mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name, *str_options[i].opt_addr); mc_config_set_string(mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name, *str_options[i].opt_addr);
mc_config_save_to_file (mc_main_config, profile); if (! mc_config_save_to_file (mc_main_config, profile, &error))
setup_save_config_show_error(profile, &error);
g_free (profile); g_free (profile);
} }
@ -348,13 +352,14 @@ save_panel_types (void)
mc_config_del_group (mc_panels_config, "Temporal:New Left Panel"); mc_config_del_group (mc_panels_config, "Temporal:New Left Panel");
mc_config_del_group (mc_panels_config, "Temporal:New Right Panel"); mc_config_del_group (mc_panels_config, "Temporal:New Right Panel");
mc_config_save_file (mc_panels_config); mc_config_save_file (mc_panels_config, NULL);
} }
void gboolean
save_setup (void) save_setup (void)
{ {
char *tmp_profile; char *tmp_profile;
gboolean ret;
saving_setup = 1; saving_setup = 1;
@ -383,9 +388,11 @@ save_setup (void)
get_codepage_id( source_codepage )); get_codepage_id( source_codepage ));
#endif /* HAVE_CHARSET */ #endif /* HAVE_CHARSET */
tmp_profile = g_build_filename (home_dir, MC_USERCONF_DIR, MC_CONFIG_FILE, NULL); tmp_profile = g_build_filename (home_dir, MC_USERCONF_DIR, MC_CONFIG_FILE, NULL);
mc_config_save_to_file (mc_main_config, tmp_profile); ret = mc_config_save_to_file (mc_main_config, tmp_profile, NULL);
g_free (tmp_profile); g_free (tmp_profile);
saving_setup = 0; saving_setup = 0;
return ret;
} }
void void
@ -504,7 +511,7 @@ setup__move_panels_config_into_separate_file(const char*profile)
curr_grp++; curr_grp++;
} }
mc_config_save_to_file (tmp_cfg, panels_profile_name); mc_config_save_to_file (tmp_cfg, panels_profile_name, NULL);
mc_config_deinit(tmp_cfg); mc_config_deinit(tmp_cfg);
tmp_cfg = mc_config_init(profile); tmp_cfg = mc_config_init(profile);
@ -526,7 +533,7 @@ setup__move_panels_config_into_separate_file(const char*profile)
curr_grp++; curr_grp++;
} }
g_strfreev(groups); g_strfreev(groups);
mc_config_save_file (tmp_cfg); mc_config_save_file (tmp_cfg, NULL);
mc_config_deinit(tmp_cfg); mc_config_deinit(tmp_cfg);
} }
@ -993,3 +1000,16 @@ load_keymap_defs (void)
mc_config_deinit (mc_global_keymap); mc_config_deinit (mc_global_keymap);
} }
} }
void
setup_save_config_show_error(const char *filename, GError **error)
{
if (error == NULL || *error == NULL)
return;
message (D_ERROR, MSG_ERROR, _("Cannot save file %s:\n%s"),
filename, (*error)->message);
g_error_free(*error);
*error = NULL;
}

View File

@ -12,7 +12,7 @@ char *setup_init (void);
void save_layout (void); void save_layout (void);
void save_configure (void); void save_configure (void);
void load_setup (void); void load_setup (void);
void save_setup (void); gboolean save_setup (void);
void done_setup (void); void done_setup (void);
void load_key_defs (void); void load_key_defs (void);
char *load_anon_passwd (void); char *load_anon_passwd (void);
@ -36,5 +36,6 @@ extern int mouse_close_dialog;
extern int reverse_files_only; extern int reverse_files_only;
extern int setup_copymove_persistent_attr; extern int setup_copymove_persistent_attr;
void setup_save_config_show_error(const char *filename, GError **error);
#endif #endif

View File

@ -182,11 +182,12 @@ mcview_display_nroff (mcview_t * view)
} }
col++; col++;
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
if (view->utf8) if (view->utf8) {
if (g_unichar_iswide(c)) if (g_unichar_iswide(c))
col++; col++;
else if (g_unichar_iszerowidth(c)) else if (g_unichar_iszerowidth(c))
col--; col--;
}
#endif #endif
tty_setcolor (NORMAL_COLOR); tty_setcolor (NORMAL_COLOR);
} }

View File

@ -68,7 +68,7 @@ mcview_display_text (mcview_t * view)
screen_dimen row, col; screen_dimen row, col;
off_t from; off_t from;
int cw = 1; int cw = 1;
int c, prev_ch; int c, prev_ch = 0;
gboolean read_res = TRUE; gboolean read_res = TRUE;
struct hexedit_change_node *curr = view->change_list; struct hexedit_change_node *curr = view->change_list;
@ -153,11 +153,12 @@ mcview_display_text (mcview_t * view)
} }
col++; col++;
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
if (view->utf8) if (view->utf8) {
if (g_unichar_iswide(c)) if (g_unichar_iswide(c))
col++; col++;
else if (g_unichar_iszerowidth(c)) else if (g_unichar_iszerowidth(c))
col--; col--;
}
#endif #endif
tty_setcolor (NORMAL_COLOR); tty_setcolor (NORMAL_COLOR);
} }

View File

@ -989,7 +989,7 @@ history_put (const char *input_name, GList *h)
} }
} }
mc_config_save_file (cfg); mc_config_save_file (cfg, NULL);
mc_config_deinit(cfg); mc_config_deinit(cfg);
g_free (profile); g_free (profile);
} }

View File

@ -288,11 +288,12 @@ smbfs_set_debug (int arg)
DEBUGLEVEL = arg; DEBUGLEVEL = arg;
} }
extern pstring debugf;
extern FILE *dbf;
void void
smbfs_set_debugf (const char *filename) smbfs_set_debugf (const char *filename)
{ {
extern pstring debugf;
extern FILE *dbf;
if (DEBUGLEVEL > 0) { if (DEBUGLEVEL > 0) {
FILE *outfile = fopen (filename, "w"); FILE *outfile = fopen (filename, "w");
if (outfile) { if (outfile) {

View File

@ -531,7 +531,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
} else { } else {
struct stat st; struct stat st;
struct vfs_s_entry *entry; struct vfs_s_entry *entry;
struct vfs_s_inode *inode, *parent; struct vfs_s_inode *inode = NULL, *parent;
long data_position; long data_position;
char *q; char *q;
int len; int len;