Merge branch '3598_wcast_qual'

* 3598_wcast_qual: (27 commits)
  src/setup.c: cleanup -Wcast-qual warning.
  src/clipboard.c: cleanup Wcast-qual warning.
  src/viewer/search.c: cleanup some -Wcast-qual warning.
  src/vfs/extfs.c: cleanup -Wcast-qual warnings.
  src/filemanager/find.c: cleanup -Wcast-qual warning.
  src/filemanager/file.c: cleanup -Wcast-qual warning.
  src/filemanager/file.c: cleanup -Wcast-qual warning.
  src/filemanager/panel.c: cleanup -Wcast-qual warning.
  src/editor/syntax.c: cleanup -Wcast-qual warnings.
  src/editor/editcmd.c: cleanup some -Wcast-qual warnings.
  src/editor/choosesyntax.c: cleanup -Wcast-qual warning.
  src/diffviewer/ydiff.c: cleanup -Wcast-qual warning.
  (dview_get_utf): apply const qualifier to str argument.
  lib/charsets.[ch]: clarify usage of const qualifier.
  lib/widget/input_complete.c: cleanup -Wcast-qual warning.
  lib/widget/input.c: cleanup -Wcast-qual warning.
  lib/widget/dialog.c: cleanup -Wcast-qual warning.
  lib/widget/buttonbar.c: cleanup -Wcast-qual warning.
  lib/vfs/path.c: cleanup some -Wcast-qual warning.
  lib/tty/tty-ncurses.c: cleanup -Wcast-qual warning.
  ...
This commit is contained in:
Andrew Borodin 2016-04-16 10:24:58 +03:00
commit 9d0f6e584e
36 changed files with 134 additions and 127 deletions

View File

@ -354,7 +354,7 @@ convert_to_display (char *str)
/* --------------------------------------------------------------------------------------------- */
GString *
str_convert_to_display (char *str)
str_convert_to_display (const char *str)
{
return str_nconvert_to_display (str, -1);
@ -363,7 +363,7 @@ str_convert_to_display (char *str)
/* --------------------------------------------------------------------------------------------- */
GString *
str_nconvert_to_display (char *str, int len)
str_nconvert_to_display (const char *str, int len)
{
GString *buff;
GIConv conv;
@ -400,7 +400,7 @@ convert_from_input (char *str)
/* --------------------------------------------------------------------------------------------- */
GString *
str_convert_to_input (char *str)
str_convert_to_input (const char *str)
{
return str_nconvert_to_input (str, -1);
}
@ -408,7 +408,7 @@ str_convert_to_input (char *str)
/* --------------------------------------------------------------------------------------------- */
GString *
str_nconvert_to_input (char *str, int len)
str_nconvert_to_input (const char *str, int len)
{
GString *buff;
GIConv conv;
@ -466,7 +466,7 @@ convert_from_utf_to_current (const char *str)
/* --------------------------------------------------------------------------------------------- */
unsigned char
convert_from_utf_to_current_c (const int input_char, GIConv conv)
convert_from_utf_to_current_c (int input_char, GIConv conv)
{
unsigned char str[UTF8_CHAR_LEN + 1];
unsigned char buf_ch[UTF8_CHAR_LEN + 1];
@ -498,7 +498,7 @@ convert_from_utf_to_current_c (const int input_char, GIConv conv)
/* --------------------------------------------------------------------------------------------- */
int
convert_from_8bit_to_utf_c (const char input_char, GIConv conv)
convert_from_8bit_to_utf_c (char input_char, GIConv conv)
{
unsigned char str[2];
unsigned char buf_ch[UTF8_CHAR_LEN + 1];
@ -530,7 +530,7 @@ convert_from_8bit_to_utf_c (const char input_char, GIConv conv)
/* --------------------------------------------------------------------------------------------- */
int
convert_from_8bit_to_utf_c2 (const char input_char)
convert_from_8bit_to_utf_c2 (char input_char)
{
unsigned char str[2];
int ch = '.';

View File

@ -50,27 +50,27 @@ unsigned char convert_from_utf_to_current (const char *str);
* param input_char, gunichar
* return char in needle codepage (by global int mc_global.source_codepage)
*/
unsigned char convert_from_utf_to_current_c (const int input_char, GIConv conv);
unsigned char convert_from_utf_to_current_c (int input_char, GIConv conv);
/*
* Converter from selected codepage 8-bit
* param char input_char, GIConv converter
* return int utf char
*/
int convert_from_8bit_to_utf_c (const char input_char, GIConv conv);
int convert_from_8bit_to_utf_c (char input_char, GIConv conv);
/*
* Converter from display codepage 8-bit to utf-8
* param char input_char, GIConv converter
* return int utf char
*/
int convert_from_8bit_to_utf_c2 (const char input_char);
int convert_from_8bit_to_utf_c2 (char input_char);
GString *str_convert_to_input (char *str);
GString *str_nconvert_to_input (char *str, int len);
GString *str_convert_to_input (const char *str);
GString *str_nconvert_to_input (const char *str, int len);
GString *str_convert_to_display (char *str);
GString *str_nconvert_to_display (char *str, int len);
GString *str_convert_to_display (const char *str);
GString *str_nconvert_to_display (const char *str, int len);
/*** inline functions ****************************************************************************/

View File

@ -289,6 +289,8 @@ mc_config_init_config_paths (GError ** mcerror)
char *dir;
#if MC_HOMEDIR_XDG == 0
char *defined_userconf_dir;
#else
const char *cdir;
#endif
mc_return_if_error (mcerror);
@ -316,9 +318,9 @@ mc_config_init_config_paths (GError ** mcerror)
}
else
{
dir = (char *) g_get_user_config_dir ();
if (dir != NULL && *dir != '\0')
mc_config_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, mcerror);
cdir = g_get_user_config_dir ();
if (cdir != NULL && *cdir != '\0')
mc_config_str = mc_config_init_one_config_path (cdir, MC_USERCONF_DIR, mcerror);
else
{
dir = g_build_filename (homedir, ".config", (char *) NULL);
@ -326,9 +328,9 @@ mc_config_init_config_paths (GError ** mcerror)
g_free (dir);
}
dir = (char *) g_get_user_cache_dir ();
if (dir != NULL && *dir != '\0')
mc_cache_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, mcerror);
cdir = g_get_user_cache_dir ();
if (cdir != NULL && *cdir != '\0')
mc_cache_str = mc_config_init_one_config_path (cdir, MC_USERCONF_DIR, mcerror);
else
{
dir = g_build_filename (homedir, ".cache", (char *) NULL);
@ -336,9 +338,9 @@ mc_config_init_config_paths (GError ** mcerror)
g_free (dir);
}
dir = (char *) g_get_user_data_dir ();
if (dir != NULL && *dir != '\0')
mc_data_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, mcerror);
cdir = g_get_user_data_dir ();
if (cdir != NULL && *cdir != '\0')
mc_data_str = mc_config_init_one_config_path (cdir, MC_USERCONF_DIR, mcerror);
else
{
dir = g_build_filename (homedir, ".local", "share", (char *) NULL);

View File

@ -97,7 +97,8 @@ gchar *
mc_search__get_one_symbol (const char *charset, const char *str, gsize str_len,
gboolean * just_letters)
{
gchar *converted_str, *next_char;
gchar *converted_str;
const gchar *next_char;
gsize tmp_len;
#ifdef HAVE_CHARSET
@ -114,7 +115,7 @@ mc_search__get_one_symbol (const char *charset, const char *str, gsize str_len,
converted_str = g_strndup (str, str_len);
#endif
next_char = (char *) str_cget_next_char (converted_str);
next_char = str_cget_next_char (converted_str);
tmp_len = next_char - converted_str;

View File

@ -927,9 +927,8 @@ mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
*/
while (TRUE)
{
char current_chr;
const char current_chr = ((const char *) user_data)[current_pos];
current_chr = ((char *) user_data)[current_pos];
if (current_chr == '\0')
break;
@ -940,7 +939,7 @@ mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data,
}
/* use virtual_pos as index of start of current chunk */
g_string_append_len (lc_mc_search->regex_buffer, (char *) user_data + virtual_pos,
g_string_append_len (lc_mc_search->regex_buffer, (const char *) user_data + virtual_pos,
current_pos - virtual_pos);
virtual_pos = current_pos;
}

View File

@ -58,14 +58,16 @@ mc_skin_get_list_from_dir (const gchar * base_dir, GPtrArray * list)
if (dir != NULL)
{
while ((name = (gchar *) g_dir_read_name (dir)) != NULL)
const gchar *cname;
while ((cname = g_dir_read_name (dir)) != NULL)
{
gchar *sname;
size_t slen;
unsigned int i;
slen = strlen (name);
sname = g_strndup (name, slen);
slen = strlen (cname);
sname = g_strndup (cname, slen);
if (slen > 4 && strcmp (sname + slen - 4, ".ini") == 0)
sname[slen - 4] = '\0';
@ -89,10 +91,7 @@ mc_skin_get_list_from_dir (const gchar * base_dir, GPtrArray * list)
static int
string_array_comparator (gconstpointer a, gconstpointer b)
{
char *aa = *(char **) a;
char *bb = *(char **) b;
return strcmp (aa, bb);
return strcmp (*(char *const *) a, *(char *const *) b);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -277,7 +277,7 @@ str_8bit_vfs_convert_to (GIConv coder, const char *string, int size, GString * b
if (coder == str_cnv_not_convert)
g_string_append_len (buffer, string, size);
else
result = str_nconvert (coder, (char *) string, size, buffer);
result = str_nconvert (coder, string, size, buffer);
return result;
}

View File

@ -427,7 +427,7 @@ str_utf8_vfs_convert_to (GIConv coder, const char *string, int size, GString * b
if (coder == str_cnv_not_convert)
g_string_append_len (buffer, string, size);
else
result = str_nconvert (coder, (char *) string, size, buffer);
result = str_nconvert (coder, string, size, buffer);
return result;
}

View File

@ -1208,8 +1208,8 @@ s_dispose (SelectList * sel)
static int
key_code_comparator_by_name (const void *p1, const void *p2)
{
const key_code_name_t *n1 = *(const key_code_name_t **) p1;
const key_code_name_t *n2 = *(const key_code_name_t **) p2;
const key_code_name_t *n1 = *(const key_code_name_t * const *) p1;
const key_code_name_t *n2 = *(const key_code_name_t * const *) p2;
return g_ascii_strcasecmp (n1->name, n2->name);
}
@ -1219,8 +1219,8 @@ key_code_comparator_by_name (const void *p1, const void *p2)
static int
key_code_comparator_by_code (const void *p1, const void *p2)
{
const key_code_name_t *n1 = *(const key_code_name_t **) p1;
const key_code_name_t *n2 = *(const key_code_name_t **) p2;
const key_code_name_t *n1 = *(const key_code_name_t * const *) p1;
const key_code_name_t *n2 = *(const key_code_name_t * const *) p2;
return n1->code - n2->code;
}
@ -1259,7 +1259,7 @@ lookup_keyname (const char *name, int *idx)
{
const key_code_name_t key = { 0, name, NULL, NULL };
const key_code_name_t *keyp = &key;
key_code_name_t **res;
const key_code_name_t **res;
if (name[1] == '\0')
{
@ -1274,7 +1274,7 @@ lookup_keyname (const char *name, int *idx)
if (res != NULL)
{
*idx = (int) (res - (key_code_name_t **) key_conv_tab_sorted);
*idx = (int) (res - key_conv_tab_sorted);
return (*res)->code;
}
}
@ -1292,7 +1292,7 @@ lookup_keycode (const long code, int *idx)
{
const key_code_name_t key = { code, NULL, NULL, NULL };
const key_code_name_t *keyp = &key;
key_code_name_t **res;
const key_code_name_t **res;
sort_key_conv_tab (KEY_SORTBYCODE);
@ -1301,7 +1301,7 @@ lookup_keycode (const long code, int *idx)
if (res != NULL)
{
*idx = (int) (res - (key_code_name_t **) key_conv_tab_sorted);
*idx = (int) (res - key_conv_tab_sorted);
return TRUE;
}
}
@ -1464,6 +1464,7 @@ long
lookup_key (const char *name, char **label)
{
char **lc_keys, **p;
char *cname;
int k = -1;
int key = 0;
int lc_index = -1;
@ -1475,9 +1476,9 @@ lookup_key (const char *name, char **label)
if (name == NULL)
return 0;
name = g_strstrip (g_strdup (name));
lc_keys = g_strsplit_set (name, "-+ ", -1);
g_free ((char *) name);
cname = g_strstrip (g_strdup (name));
lc_keys = g_strsplit_set (cname, "-+ ", -1);
g_free (cname);
for (p = lc_keys; p != NULL && *p != NULL; p++)
{

View File

@ -649,7 +649,7 @@ char *
tty_tgetstr (const char *cap)
{
char *unused = NULL;
return tgetstr ((char *) cap, &unused);
return tgetstr (cap, &unused);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -805,11 +805,11 @@ vfs_path_elements_count (const vfs_path_t * vpath)
*/
void
vfs_path_add_element (const vfs_path_t * vpath, const vfs_path_element_t * path_element)
vfs_path_add_element (vfs_path_t * vpath, const vfs_path_element_t * path_element)
{
g_array_append_val (vpath->path, path_element);
g_free (vpath->str);
((vfs_path_t *) vpath)->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE);
vpath->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -74,7 +74,7 @@ size_t vfs_path_tokens_count (const vfs_path_t *);
char *vfs_path_tokens_get (const vfs_path_t * vpath, ssize_t start_position, ssize_t length);
vfs_path_t *vfs_path_vtokens_get (const vfs_path_t * vpath, ssize_t start_position, ssize_t length);
void vfs_path_add_element (const vfs_path_t * vpath, const vfs_path_element_t * path_element);
void vfs_path_add_element (vfs_path_t * vpath, const vfs_path_element_t * path_element);
const vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t * path, int element_index);
vfs_path_element_t *vfs_path_element_clone (const vfs_path_element_t * element);
void vfs_path_element_free (vfs_path_element_t * element);

View File

@ -261,8 +261,8 @@ buttonbar_new (gboolean visible)
/* --------------------------------------------------------------------------------------------- */
void
buttonbar_set_label (WButtonBar * bb, int idx, const char *text,
const global_keymap_t * keymap, const Widget * receiver)
buttonbar_set_label (WButtonBar * bb, int idx, const char *text, const global_keymap_t * keymap,
Widget * receiver)
{
if ((bb != NULL) && (idx >= 1) && (idx <= BUTTONBAR_LABELS_NUM))
{

View File

@ -38,7 +38,7 @@ typedef struct WButtonBar
WButtonBar *buttonbar_new (gboolean visible);
void buttonbar_set_label (WButtonBar * bb, int idx, const char *text,
const global_keymap_t * keymap, const Widget * receiver);
const global_keymap_t * keymap, Widget * receiver);
WButtonBar *find_buttonbar (const WDialog * h);
/*** inline functions ****************************************************************************/

View File

@ -201,8 +201,8 @@ dlg_unfocus (WDialog * h)
static int
dlg_find_widget_callback (const void *a, const void *b)
{
const Widget *w = WIDGET (a);
widget_cb_fn f = (widget_cb_fn) b;
const Widget *w = CONST_WIDGET (a);
const widget_cb_fn f = b;
return (w->callback == f) ? 0 : 1;
}
@ -595,7 +595,7 @@ frontend_dlg_run (WDialog * h)
static int
dlg_find_widget_by_id (gconstpointer a, gconstpointer b)
{
Widget *w = WIDGET (a);
const Widget *w = CONST_WIDGET (a);
unsigned long id = GPOINTER_TO_UINT (b);
return w->id == id ? 0 : 1;

View File

@ -91,7 +91,7 @@ get_history_length (const GList * history)
{
size_t len = 0;
for (; history != NULL; history = g_list_previous (history))
for (; history != NULL; history = (const GList *) g_list_previous (history))
len++;
return len;

View File

@ -685,7 +685,7 @@ command_completion_function (const char *_text, int state, input_complete_t flag
static int
match_compare (const void *a, const void *b)
{
return strcmp (*(char **) a, *(char **) b);
return strcmp (*(char *const *) a, *(char *const *) b);
}
/* --------------------------------------------------------------------------------------------- */
@ -799,7 +799,7 @@ completion_matches (const char *text, CompletionFunction entry_function, input_c
static gboolean
check_is_cd (const char *text, int lc_start, input_complete_t flags)
{
char *p, *q;
const char *p, *q;
SHOW_C_CTX ("check_is_cd");
@ -807,10 +807,10 @@ check_is_cd (const char *text, int lc_start, input_complete_t flags)
return FALSE;
/* Skip initial spaces */
p = (char *) text;
q = (char *) text + lc_start;
p = text;
q = text + lc_start;
while (p < q && p[0] != '\0' && str_isspace (p))
str_next_char (&p);
str_cnext_char (&p);
/* Check if the command is "cd" and the cursor is after it */
return (p[0] == 'c' && p[1] == 'd' && str_isspace (p + 2) && p + 2 < q);

View File

@ -281,7 +281,7 @@ widget_erase (Widget * w)
gboolean
widget_is_active (const void *w)
{
return (w == WIDGET (w)->owner->current->data);
return (w == CONST_WIDGET (w)->owner->current->data);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -12,8 +12,9 @@
/*** typedefs(not structures) and defined constants **********************************************/
#define WIDGET(x) ((Widget *)(x))
#define CONST_WIDGET(x) ((const Widget *)(x))
#define widget_move(w, _y, _x) tty_gotoyx (WIDGET(w)->y + (_y), WIDGET(w)->x + (_x))
#define widget_move(w, _y, _x) tty_gotoyx (CONST_WIDGET(w)->y + (_y), CONST_WIDGET(w)->x + (_x))
/* Sets/clear the specified flag in the options field */
#define widget_want_cursor(w,i) widget_set_options(w, W_WANT_CURSOR, i)
#define widget_want_hotkey(w,i) widget_set_options(w, W_WANT_HOTKEY, i)

View File

@ -197,7 +197,7 @@ clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name
{
ssize_t ret;
ret = mc_write (file, (char *) text, str_len);
ret = mc_write (file, text, str_len);
(void) ret;
}
mc_close (file);

View File

@ -581,7 +581,7 @@ dview_get_byte (char *str, gboolean * result)
*/
static int
dview_get_utf (char *str, int *char_length, gboolean * result)
dview_get_utf (const char *str, int *char_length, gboolean * result)
{
int res = -1;
gunichar ch;
@ -1915,7 +1915,7 @@ get_line_numbers (const GArray * a, size_t pos, int *linenum, int *lineofs)
/* --------------------------------------------------------------------------------------------- */
static int
calc_nwidth (const GArray ** const a)
calc_nwidth (const GArray * const *a)
{
int l1, o1;
int l2, o2;
@ -2795,7 +2795,7 @@ dview_redo (WDiff * dview)
int old;
old = dview->display_numbers;
dview->display_numbers = calc_nwidth ((const GArray **) dview->a);
dview->display_numbers = calc_nwidth ((const GArray * const *) dview->a);
dview->new_frame = (old != dview->display_numbers);
}
dview_reread (dview);
@ -3043,7 +3043,7 @@ dview_load_options (WDiff * dview)
dview->display_symbols = 1;
show_numbers = mc_config_get_bool (mc_main_config, "DiffView", "show_numbers", FALSE);
if (show_numbers)
dview->display_numbers = calc_nwidth ((const GArray ** const) dview->a);
dview->display_numbers = calc_nwidth ((const GArray * const *) dview->a);
tab_size = mc_config_get_int (mc_main_config, "DiffView", "tab_size", 8);
if (tab_size > 0 && tab_size < 9)
dview->tab_size = tab_size;
@ -3126,7 +3126,7 @@ dview_execute_cmd (WDiff * dview, long command)
dview->new_frame = TRUE;
break;
case CK_ShowNumbers:
dview->display_numbers ^= calc_nwidth ((const GArray ** const) dview->a);
dview->display_numbers ^= calc_nwidth ((const GArray * const *) dview->a);
dview->new_frame = TRUE;
break;
case CK_SplitFull:

View File

@ -61,7 +61,7 @@
static int
pstrcmp (const void *p1, const void *p2)
{
return strcmp (*(char **) p1, *(char **) p2);
return strcmp (*(char *const *) p1, *(char *const *) p2);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -909,7 +909,7 @@ editcmd_find (edit_search_status_msg_t * esm, gsize * len)
/* --------------------------------------------------------------------------------------------- */
static char *
edit_replace_cmd__conv_to_display (char *str)
edit_replace_cmd__conv_to_display (const char *str)
{
#ifdef HAVE_CHARSET
GString *tmp;
@ -1487,7 +1487,7 @@ edit_syntax_onoff_cb (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor ((const Widget *) data))
if (edit_widget_is_editor (CONST_WIDGET (data)))
{
WEdit *edit = (WEdit *) data;
@ -1511,7 +1511,7 @@ edit_redraw_page_cb (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor ((const Widget *) data))
if (edit_widget_is_editor (CONST_WIDGET (data)))
((WEdit *) data)->force |= REDRAW_PAGE;
}
@ -2244,7 +2244,7 @@ edit_close_cmd (WEdit * edit)
del_widget (edit);
if (edit_widget_is_editor (WIDGET (h->current->data)))
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
edit = (WEdit *) h->current->data;
else
{
@ -2532,8 +2532,8 @@ edit_replace_cmd (WEdit * edit, int again)
{
char *tmp_inp1, *tmp_inp2;
disp1 = edit_replace_cmd__conv_to_display (saved1 ? saved1 : (char *) "");
disp2 = edit_replace_cmd__conv_to_display (saved2 ? saved2 : (char *) "");
disp1 = edit_replace_cmd__conv_to_display (saved1 ? saved1 : "");
disp2 = edit_replace_cmd__conv_to_display (saved2 ? saved2 : "");
edit_push_undo_action (edit, KEY_PRESS + edit->start_display);
@ -2744,7 +2744,7 @@ edit_replace_cmd (WEdit * edit, int again)
mc_search_cbret_t
edit_search_cmd_callback (const void *user_data, gsize char_offset, int *current_char)
{
WEdit *edit = ((edit_search_status_msg_t *) user_data)->edit;
WEdit *edit = ((const edit_search_status_msg_t *) user_data)->edit;
*current_char = edit_buffer_get_byte (&edit->buffer, (off_t) char_offset);
return MC_SEARCH_CB_OK;

View File

@ -346,7 +346,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean c
char *
editcmd_dialog_completion_show (const WEdit * edit, int max_len, GString ** compl, int num_compl)
{
const Widget *we = WIDGET (edit);
const Widget *we = CONST_WIDGET (edit);
int start_x, start_y, offset, i;
char *curr = NULL;
WDialog *compl_dlg;

View File

@ -348,7 +348,7 @@ edit_status_window (WEdit * edit)
static inline void
edit_draw_frame (const WEdit * edit, int color, gboolean active)
{
const Widget *w = (const Widget *) edit;
const Widget *w = CONST_WIDGET (edit);
/* draw a frame around edit area */
tty_setcolor (color);
@ -374,7 +374,7 @@ edit_draw_frame (const WEdit * edit, int color, gboolean active)
static inline void
edit_draw_window_icons (const WEdit * edit, int color)
{
const Widget *w = WIDGET (edit);
const Widget *w = CONST_WIDGET (edit);
char tmp[17];
tty_setcolor (color);

View File

@ -84,7 +84,7 @@ edit_reset_over_col (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor ((const Widget *) data))
if (edit_widget_is_editor (CONST_WIDGET (data)))
((WEdit *) data)->over_col = 0;
}
@ -102,9 +102,10 @@ edit_reload_syntax (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor (WIDGET (data)))
if (edit_widget_is_editor (CONST_WIDGET (data)))
{
WEdit *edit = (WEdit *) data;
edit_load_syntax (edit, NULL, edit->syntax_type);
}
}

View File

@ -332,7 +332,7 @@ edit_window_list (const WDialog * h)
listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]");
for (w = h->widgets; w != NULL; w = g_list_next (w))
if (edit_widget_is_editor (WIDGET (w->data)))
if (edit_widget_is_editor (CONST_WIDGET (w->data)))
{
WEdit *e = (WEdit *) w->data;
char *fname;
@ -427,7 +427,7 @@ edit_dialog_command_execute (WDialog * h, long command)
break;
case CK_Close:
/* if there are no opened files anymore, close MC editor */
if (edit_widget_is_editor (WIDGET (h->current->data)) &&
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)) &&
edit_close_cmd ((WEdit *) h->current->data) && find_editor (h) == NULL)
dlg_stop (h);
break;
@ -476,7 +476,7 @@ edit_dialog_command_execute (WDialog * h, long command)
break;
case CK_WindowMove:
case CK_WindowResize:
if (edit_widget_is_editor (WIDGET (h->current->data)))
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
edit_handle_move_resize ((WEdit *) h->current->data, command);
break;
case CK_WindowList:
@ -643,7 +643,7 @@ edit_quit (WDialog * h)
h->state = DLG_ACTIVE; /* don't stop the dialog before final decision */
for (l = h->widgets; l != NULL; l = g_list_next (l))
if (edit_widget_is_editor (WIDGET (l->data)))
if (edit_widget_is_editor (CONST_WIDGET (l->data)))
{
e = (WEdit *) l->data;
@ -890,7 +890,8 @@ edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
/* Try find top fullscreen window */
for (l = h->widgets; l != NULL; l = g_list_next (l))
if (edit_widget_is_editor (WIDGET (l->data)) && ((WEdit *) l->data)->fullscreen)
if (edit_widget_is_editor (CONST_WIDGET (l->data))
&& ((WEdit *) l->data)->fullscreen)
top = l;
/* Handle fullscreen/close buttons in the top line */
@ -1266,7 +1267,7 @@ edit_get_file_name (const WEdit * edit)
WEdit *
find_editor (const WDialog * h)
{
if (edit_widget_is_editor (WIDGET (h->current->data)))
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
return (WEdit *) h->current->data;
return (WEdit *) find_widget_type (h, edit_callback);
}

View File

@ -263,7 +263,7 @@ compare_word_to_right (const WEdit * edit, off_t i, const char *text,
if ((line_start != 0 && c != '\n') || (whole_left != NULL && strchr (whole_left, c) != NULL))
return -1;
for (p = (unsigned char *) text, q = p + strlen ((char *) p); p < q; p++, i++)
for (p = (const unsigned char *) text, q = p + strlen ((const char *) p); p < q; p++, i++)
{
switch (*p)
{
@ -295,7 +295,7 @@ compare_word_to_right (const WEdit * edit, off_t i, const char *text,
if (*p == *text && p[1] == '\0') /* handle eg '+' and @+@ keywords properly */
break;
}
if (j != 0 && strchr ((char *) p + 1, c) != NULL) /* c exists further down, so it will get matched later */
if (j != 0 && strchr ((const char *) p + 1, c) != NULL) /* c exists further down, so it will get matched later */
break;
if (c == '\n' || c == '\t' || c == ' ' ||
(whole_right != NULL && strchr (whole_right, c) == NULL))
@ -443,7 +443,7 @@ apply_rules_going_right (WEdit * edit, off_t i)
p = r->keyword_first_chars;
if (p != NULL)
while (*(p = xx_strchr (edit, (unsigned char *) p + 1, c)) != '\0')
while (*(p = xx_strchr (edit, (const unsigned char *) p + 1, c)) != '\0')
{
syntax_keyword_t *k;
int count;
@ -544,7 +544,7 @@ apply_rules_going_right (WEdit * edit, off_t i)
r = CONTEXT_RULE (g_ptr_array_index (edit->rules, _rule.context));
p = r->keyword_first_chars;
while (*(p = xx_strchr (edit, (unsigned char *) p + 1, c)) != '\0')
while (*(p = xx_strchr (edit, (const unsigned char *) p + 1, c)) != '\0')
{
syntax_keyword_t *k;
int count;

View File

@ -805,7 +805,7 @@ panel_listing_box (WPanel * panel, int num, char **userp, char **minip, int *use
const panel_field_t *
sort_box (dir_sort_options_t * op, const panel_field_t * sort_field)
{
const char **sort_orders_names;
char **sort_orders_names;
gsize i;
gsize sort_names_num = 0;
int sort_idx = 0;
@ -824,7 +824,7 @@ sort_box (dir_sort_options_t * op, const panel_field_t * sort_field)
quick_widget_t quick_widgets[] = {
/* *INDENT-OFF* */
QUICK_START_COLUMNS,
QUICK_RADIO (sort_names_num, sort_orders_names, &sort_idx, NULL),
QUICK_RADIO (sort_names_num, (const char **) sort_orders_names, &sort_idx, NULL),
QUICK_NEXT_COLUMN,
QUICK_CHECKBOX (N_("Executable &first"), &op->exec_first, NULL),
QUICK_CHECKBOX (N_("Cas&e sensitive"), &op->case_sensitive, NULL),
@ -848,7 +848,7 @@ sort_box (dir_sort_options_t * op, const panel_field_t * sort_field)
result = sort_field;
}
g_strfreev ((gchar **) sort_orders_names);
g_strfreev (sort_orders_names);
return result;
}
@ -1139,7 +1139,7 @@ configure_vfs (void)
char *
cd_dialog (void)
{
const Widget *w = WIDGET (current_panel);
const Widget *w = CONST_WIDGET (current_panel);
char *my_str;
quick_widget_t quick_widgets[] = {

View File

@ -228,7 +228,7 @@ static char *
transform_source (file_op_context_t * ctx, const vfs_path_t * source_vpath)
{
char *s, *q;
char *fnsource;
const char *fnsource;
s = g_strdup (vfs_path_as_str (source_vpath));
@ -238,7 +238,7 @@ transform_source (file_op_context_t * ctx, const vfs_path_t * source_vpath)
if (*q == '\n')
*q = ' ';
fnsource = (char *) x_basename (s);
fnsource = x_basename (s);
if (mc_search_run (ctx->search_handle, fnsource, 0, strlen (fnsource), NULL))
{
@ -293,7 +293,7 @@ is_in_linklist (const GSList * lp, const vfs_path_t * vpath, const struct stat *
class = vfs_path_get_last_path_vfs (vpath);
for (; lp != NULL; lp = g_slist_next (lp))
for (; lp != NULL; lp = (const GSList *) g_slist_next (lp))
{
const struct link *lnk = (const struct link *) lp->data;
@ -1423,10 +1423,10 @@ panel_operate_generate_prompt (const WPanel * panel, FileOperation operation,
* "Delete %d files/directories?"
*/
sp = (char *) (src_stat != NULL ? one_format : many_format);
cp = (src_stat != NULL ? one_format : many_format);
/* 1. Substitute %o */
format_string = str_replace_all (sp, "%o", op_names1[(int) operation]);
format_string = str_replace_all (cp, "%o", op_names1[(int) operation]);
/* 2. Substitute %n */
cp = operation == OP_DELETE ? "\n" : " ";

View File

@ -853,7 +853,7 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
/* --------------------------------------------------------------------------------------------- */
static inline void
push_directory (const vfs_path_t * dir)
push_directory (vfs_path_t * dir)
{
g_queue_push_head (&dir_queue, (void *) dir);
}
@ -1228,7 +1228,7 @@ find_rotate_dash (const WDialog * h, gboolean show)
{
static size_t pos = 0;
static const char rotating_dash[4] = "|/-\\";
const Widget *w = WIDGET (h);
const Widget *w = CONST_WIDGET (h);
if (!verbose)
return;
@ -1458,7 +1458,7 @@ view_edit_currently_selected_file (gboolean unparsed_view, gboolean edit)
static void
find_calc_button_locations (const WDialog * h, gboolean all_buttons)
{
const int cols = WIDGET (h)->cols;
const int cols = CONST_WIDGET (h)->cols;
int l1, l2;
@ -1489,7 +1489,7 @@ find_relocate_buttons (const WDialog * h, gboolean all_buttons)
find_calc_button_locations (h, all_buttons);
for (i = 0; i < fbuts_num; i++)
fbuts[i].button->x = WIDGET (h)->x + fbuts[i].x;
fbuts[i].button->x = CONST_WIDGET (h)->x + fbuts[i].x;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -405,7 +405,7 @@ static int
panel_lines (const WPanel * p)
{
/* 3 lines are: top frame, column header, botton frame */
return (WIDGET (p)->lines - 3 - (panels_options.show_mini_info ? 2 : 0));
return (CONST_WIDGET (p)->lines - 3 - (panels_options.show_mini_info ? 2 : 0));
}
/* --------------------------------------------------------------------------------------------- */
@ -1066,9 +1066,10 @@ paint_dir (WPanel * panel)
static void
display_total_marked_size (const WPanel * panel, int y, int x, gboolean size_only)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
char buffer[BUF_SMALL], b_bytes[BUF_SMALL], *buf;
char buffer[BUF_SMALL], b_bytes[BUF_SMALL];
const char *buf;
int cols;
if (panel->marked <= 0)
@ -1090,7 +1091,7 @@ display_total_marked_size (const WPanel * panel, int y, int x, gboolean size_onl
b_bytes, panel->marked);
/* don't forget spaces around buffer content */
buf = (char *) str_trunc (buf, cols - 4);
buf = str_trunc (buf, cols - 4);
if (x < 0)
/* center in panel */
@ -1112,7 +1113,7 @@ mini_info_separator (const WPanel * panel)
{
if (panels_options.show_mini_info)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
int y;
y = panel_lines (panel) + 2;
@ -1155,7 +1156,7 @@ show_free_space (const WPanel * panel)
if (myfs_stats.avail != 0 || myfs_stats.total != 0)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
char buffer1[6], buffer2[6], tmp[BUF_SMALL];
size_trunc_len (buffer1, sizeof (buffer1) - 1, myfs_stats.avail, 1,
@ -1256,7 +1257,7 @@ panel_get_encoding_info_str (const WPanel * panel)
static void
show_dir (const WPanel * panel)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
gchar *tmp;
@ -1554,7 +1555,7 @@ panel_get_title_without_hotkey (const char *title)
static void
panel_print_header (const WPanel * panel)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
int y, x;
int i;
@ -4852,7 +4853,7 @@ panel_get_num_of_sortable_fields (void)
/* --------------------------------------------------------------------------------------------- */
const char **
char **
panel_get_sortable_fields (gsize * array_size)
{
char **ret;
@ -4873,7 +4874,7 @@ panel_get_sortable_fields (gsize * array_size)
if (panel_fields[i].is_user_choice)
ret[lc_index++] = g_strdup (_(panel_fields[i].title_hotkey));
return (const char **) ret;
return ret;
}
/* --------------------------------------------------------------------------------------------- */
@ -4940,7 +4941,7 @@ panel_get_num_of_user_possible_fields (void)
/* --------------------------------------------------------------------------------------------- */
const char **
char **
panel_get_user_possible_fields (gsize * array_size)
{
char **ret;
@ -4961,7 +4962,7 @@ panel_get_user_possible_fields (gsize * array_size)
if (panel_fields[i].use_in_user_format)
ret[lc_index++] = g_strdup (_(panel_fields[i].title_hotkey));
return (const char **) ret;
return ret;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -180,12 +180,12 @@ void do_file_mark (WPanel * panel, int idx, int val);
gboolean do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
gsize panel_get_num_of_sortable_fields (void);
const char **panel_get_sortable_fields (gsize *);
char **panel_get_sortable_fields (gsize *);
const panel_field_t *panel_get_field_by_id (const char *);
const panel_field_t *panel_get_field_by_title (const char *);
const panel_field_t *panel_get_field_by_title_hotkey (const char *);
gsize panel_get_num_of_user_possible_fields (void);
const char **panel_get_user_possible_fields (gsize *);
char **panel_get_user_possible_fields (gsize *);
void panel_set_cwd (WPanel * panel, const vfs_path_t * vpath);
void panel_set_lwd (WPanel * panel, const vfs_path_t * vpath);

View File

@ -998,6 +998,7 @@ load_setup (void)
#ifdef HAVE_CHARSET
char *buffer;
const char *cbuffer;
load_codepages_list ();
#endif /* HAVE_CHARSET */
@ -1118,9 +1119,9 @@ load_setup (void)
is_autodetect_codeset_enabled = TRUE;
g_free (init_translation_table (mc_global.source_codepage, mc_global.display_codepage));
buffer = (char *) get_codepage_id (mc_global.display_codepage);
if (buffer != NULL)
mc_global.utf8_display = str_isutf8 (buffer);
cbuffer = get_codepage_id (mc_global.display_codepage);
if (cbuffer != NULL)
mc_global.utf8_display = str_isutf8 (cbuffer);
#endif /* HAVE_CHARSET */
#ifdef HAVE_ASPELL

View File

@ -246,7 +246,7 @@ extfs_find_entry_int (struct entry *dir, const char *name, GSList * list,
if (g_path_is_absolute (name))
{
/* Handle absolute paths */
name = (char *) g_path_skip_root (name);
name = g_path_skip_root (name);
dir = dir->inode->archive->root_entry;
}

View File

@ -186,7 +186,7 @@ mcview_search_show_result (WView * view, size_t match_len)
mc_search_cbret_t
mcview_search_cmd_callback (const void *user_data, gsize char_offset, int *current_char)
{
WView *view = ((mcview_search_status_msg_t *) user_data)->view;
WView *view = ((const mcview_search_status_msg_t *) user_data)->view;
/* view_read_continue (view, &view->search_onechar_info); *//* AB:FIXME */
if (!view->text_nroff_mode)