Fixed several compiler warnings (mainly shadowing local variables and unreachable code).
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1376 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
3888323376
commit
90b01daf35
@ -1,3 +1,12 @@
|
||||
2007-03-09 Enrico Tröger <enrico.troeger@uvena.de>
|
||||
|
||||
* src/callbacks.c, src/encodings.c, src/encodings.h, highlighting.c,
|
||||
src/msgwindow.c, src/notebook.c, src/project.c, src/sci_cb.c,
|
||||
src/search.c, src/tools.c, src/ui_utils.c, src/utils.c:
|
||||
Fixed several compiler warnings (mainly shadowing local variables
|
||||
and unreachable code).
|
||||
|
||||
|
||||
2007-03-09 Nick Treleaven <nick.treleaven@btinternet.com>
|
||||
|
||||
* src/interface.c, doc/geany.docbook, data/filetypes.*, geany.glade:
|
||||
|
@ -1028,17 +1028,17 @@ toolbar_popup_menu (GtkWidget *widget,
|
||||
{
|
||||
if (event->button == 3)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *w;
|
||||
|
||||
ignore_toolbar_toggle = TRUE;
|
||||
|
||||
switch (app->toolbar_icon_style)
|
||||
{
|
||||
case 0: widget = lookup_widget(app->toolbar_menu, "images_only2"); break;
|
||||
case 1: widget = lookup_widget(app->toolbar_menu, "text_only2"); break;
|
||||
default: widget = lookup_widget(app->toolbar_menu, "images_and_text2"); break;
|
||||
case 0: w = lookup_widget(app->toolbar_menu, "images_only2"); break;
|
||||
case 1: w = lookup_widget(app->toolbar_menu, "text_only2"); break;
|
||||
default: w = lookup_widget(app->toolbar_menu, "images_and_text2"); break;
|
||||
}
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), TRUE);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), TRUE);
|
||||
|
||||
switch (app->toolbar_icon_size)
|
||||
{
|
||||
@ -1046,7 +1046,7 @@ toolbar_popup_menu (GtkWidget *widget,
|
||||
widget = lookup_widget(app->toolbar_menu, "large_icons1"); break;
|
||||
default: widget = lookup_widget(app->toolbar_menu, "small_icons1"); break;
|
||||
}
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), TRUE);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), TRUE);
|
||||
|
||||
ignore_toolbar_toggle = FALSE;
|
||||
|
||||
|
@ -142,12 +142,12 @@ const GeanyEncoding *encodings_get_from_charset(const gchar *charset)
|
||||
}
|
||||
|
||||
|
||||
const GeanyEncoding *encodings_get_from_index(gint index)
|
||||
const GeanyEncoding *encodings_get_from_index(gint idx)
|
||||
{
|
||||
g_return_val_if_fail(index >= 0, NULL);
|
||||
g_return_val_if_fail(index < GEANY_ENCODINGS_MAX, NULL);
|
||||
g_return_val_if_fail(idx >= 0, NULL);
|
||||
g_return_val_if_fail(idx < GEANY_ENCODINGS_MAX, NULL);
|
||||
|
||||
return &encodings[index];
|
||||
return &encodings[idx];
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ typedef struct
|
||||
|
||||
|
||||
const GeanyEncoding* encodings_get_from_charset(const gchar *charset);
|
||||
const GeanyEncoding* encodings_get_from_index(gint index);
|
||||
const GeanyEncoding* encodings_get_from_index(gint idx);
|
||||
|
||||
gchar* encodings_to_string(const GeanyEncoding* enc);
|
||||
const gchar* encodings_get_charset(const GeanyEncoding* enc);
|
||||
|
@ -306,14 +306,14 @@ static guint invert(guint icolour)
|
||||
}
|
||||
|
||||
|
||||
static void set_sci_style(ScintillaObject *sci, gint style, gint filetype, gint styling_index)
|
||||
static void set_sci_style(ScintillaObject *sci, gint style, gint ft, gint styling_index)
|
||||
{
|
||||
Style *style_ptr;
|
||||
|
||||
if (filetype == GEANY_FILETYPES_ALL)
|
||||
if (ft == GEANY_FILETYPES_ALL)
|
||||
style_ptr = &common_style_set.styling[styling_index];
|
||||
else
|
||||
style_ptr = &style_sets[filetype].styling[styling_index];
|
||||
style_ptr = &style_sets[ft].styling[styling_index];
|
||||
|
||||
SSM(sci, SCI_STYLESETFORE, style, invert(style_ptr->foreground));
|
||||
SSM(sci, SCI_STYLESETBACK, style, invert(style_ptr->background));
|
||||
@ -571,15 +571,15 @@ void styleset_common(ScintillaObject *sci, gint style_bits)
|
||||
static void assign_global_and_user_keywords(ScintillaObject *sci, const gchar *user_words)
|
||||
{
|
||||
GString *s;
|
||||
|
||||
|
||||
s = get_global_typenames();
|
||||
if (s == NULL)
|
||||
s = g_string_sized_new(200);
|
||||
else
|
||||
g_string_append_c(s, ' '); // append a space as delimiter to the existing list of words
|
||||
|
||||
|
||||
g_string_append(s, user_words);
|
||||
|
||||
|
||||
SSM(sci, SCI_SETKEYWORDS, 1, (sptr_t) s->str);
|
||||
g_string_free(s, TRUE);
|
||||
}
|
||||
@ -716,7 +716,7 @@ void styleset_c(ScintillaObject *sci)
|
||||
|
||||
// assign global types, merge them with user defined keywords and set them
|
||||
assign_global_and_user_keywords(sci, style_sets[GEANY_FILETYPES_C].keywords[1]);
|
||||
|
||||
|
||||
styleset_c_like(sci, GEANY_FILETYPES_C);
|
||||
|
||||
if (style_sets[GEANY_FILETYPES_C].styling[20].foreground == 1)
|
||||
|
@ -129,7 +129,7 @@ static void prepare_msg_tree_view(void)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeSelection *select;
|
||||
GtkTreeSelection *selection;
|
||||
PangoFontDescription *pfd;
|
||||
|
||||
msgwindow.store_msg = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_STRING);
|
||||
@ -150,9 +150,9 @@ static void prepare_msg_tree_view(void)
|
||||
G_CALLBACK(on_msgwin_button_press_event), GINT_TO_POINTER(MSG_MESSAGE));
|
||||
|
||||
// selection handling
|
||||
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg));
|
||||
gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
|
||||
//g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(on_msg_tree_selection_changed), NULL);
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg));
|
||||
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
||||
//g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(on_msg_tree_selection_changed), NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ static void prepare_compiler_tree_view(void)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeSelection *select;
|
||||
GtkTreeSelection *selection;
|
||||
PangoFontDescription *pfd;
|
||||
|
||||
msgwindow.store_compiler = gtk_list_store_new(2, GDK_TYPE_COLOR, G_TYPE_STRING);
|
||||
@ -182,9 +182,9 @@ static void prepare_compiler_tree_view(void)
|
||||
G_CALLBACK(on_msgwin_button_press_event), GINT_TO_POINTER(MSG_COMPILER));
|
||||
|
||||
// selection handling
|
||||
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler));
|
||||
gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
|
||||
//g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(on_msg_tree_selection_changed), NULL);
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler));
|
||||
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
||||
//g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(on_msg_tree_selection_changed), NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ static GtkTargetEntry files_drop_targets[] = {
|
||||
|
||||
static gboolean
|
||||
notebook_drag_motion_cb(GtkWidget *widget, GdkDragContext *dc,
|
||||
gint x, gint y, guint time, gpointer user_data);
|
||||
gint x, gint y, guint event_time, gpointer user_data);
|
||||
|
||||
static void
|
||||
notebook_page_reordered_cb(GtkNotebook *notebook, GtkWidget *child, guint page_num,
|
||||
@ -64,7 +64,7 @@ notebook_motion_notify_event_cb(GtkWidget *widget, GdkEventMotion *event,
|
||||
static void
|
||||
on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
|
||||
gint x, gint y, GtkSelectionData *data, guint info,
|
||||
guint time, gpointer user_data);
|
||||
guint event_time, gpointer user_data);
|
||||
|
||||
static gint
|
||||
notebook_find_tab_num_at_pos(GtkNotebook *notebook, gint x, gint y);
|
||||
@ -188,15 +188,14 @@ notebook_page_reordered_cb(GtkNotebook *notebook, GtkWidget *child, guint page_n
|
||||
|
||||
static gboolean
|
||||
notebook_drag_motion_cb(GtkWidget *widget, GdkDragContext *dc,
|
||||
gint x, gint y, guint time, gpointer user_data)
|
||||
gint x, gint y, guint event_time, gpointer user_data)
|
||||
{
|
||||
GtkNotebook *notebook = GTK_NOTEBOOK(widget);
|
||||
static gint oldx, oldy; // for determining direction of mouse drag
|
||||
GtkNotebook *notebook = GTK_NOTEBOOK(widget);
|
||||
gint ndest = notebook_find_tab_num_at_pos(notebook, x, y);
|
||||
gint ncurr = gtk_notebook_get_current_page(notebook);
|
||||
|
||||
if (ndest >= 0)
|
||||
if (ndest != ncurr)
|
||||
if (ndest >= 0 && ndest != ncurr)
|
||||
{
|
||||
gboolean ok = FALSE;
|
||||
// prevent oscillation between non-homogeneous sized tabs
|
||||
@ -379,7 +378,7 @@ void notebook_remove_page(gint page_num)
|
||||
static void
|
||||
on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
|
||||
gint x, gint y, GtkSelectionData *data, guint target_type,
|
||||
guint time, gpointer user_data)
|
||||
guint event_time, gpointer user_data)
|
||||
{
|
||||
gboolean success = FALSE;
|
||||
|
||||
@ -394,7 +393,7 @@ on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
|
||||
|
||||
success = TRUE;
|
||||
}
|
||||
gtk_drag_finish(drag_context, success, FALSE, time);
|
||||
gtk_drag_finish(drag_context, success, FALSE, event_time);
|
||||
}
|
||||
|
||||
|
||||
|
@ -526,11 +526,11 @@ static void run_dialog(GtkWidget *dialog, GtkWidget *entry)
|
||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
||||
gchar *utf8_filename = utils_get_utf8_from_locale(filename);
|
||||
gchar *tmp_utf8_filename = utils_get_utf8_from_locale(filename);
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), utf8_filename);
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), tmp_utf8_filename);
|
||||
|
||||
g_free(utf8_filename);
|
||||
g_free(tmp_utf8_filename);
|
||||
g_free(filename);
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
|
@ -389,8 +389,8 @@ static void get_indent(ScintillaObject *sci, gint pos, gboolean use_this_line)
|
||||
}
|
||||
else
|
||||
{ // insert as many spaces as a tabulator would take
|
||||
gint i;
|
||||
for (i = 0; i < app->pref_editor_tab_width; i++)
|
||||
gint k;
|
||||
for (k = 0; k < app->pref_editor_tab_width; k++)
|
||||
indent[j++] = ' ';
|
||||
}
|
||||
|
||||
@ -1635,11 +1635,8 @@ void sci_cb_do_comment_toggle(gint idx)
|
||||
if (single_line)
|
||||
{
|
||||
gint a = (first_line_was_comment) ? - co_len : co_len;
|
||||
gint line_start;
|
||||
|
||||
// don't modify sel_start when the selection starts within indentation
|
||||
line_start = sci_get_position_from_line(doc_list[idx].sci,
|
||||
sci_get_line_from_position(doc_list[idx].sci, sel_start));
|
||||
get_indent(doc_list[idx].sci, sel_start, TRUE);
|
||||
if ((sel_start - line_start) <= (gint) strlen(indent))
|
||||
a = 0;
|
||||
|
@ -875,8 +875,6 @@ on_find_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
|
||||
case GEANY_RESPONSE_MARK:
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
|
||||
if (DOC_IDX_VALID(idx))
|
||||
search_mark(idx, search_data.text, search_data.flags);
|
||||
break;
|
||||
@ -990,11 +988,11 @@ on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
// replace in all documents following notebook tab order
|
||||
for (n = 0; (gint) n < gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)); n++)
|
||||
{
|
||||
gint idx = document_get_n_idx(n);
|
||||
gint ix = document_get_n_idx(n);
|
||||
|
||||
if (! doc_list[idx].is_valid) continue;
|
||||
if (! doc_list[ix].is_valid) continue;
|
||||
|
||||
if (document_replace_all(idx, find, replace, search_flags_re,
|
||||
if (document_replace_all(ix, find, replace, search_flags_re,
|
||||
search_replace_escape_re)) count++;
|
||||
}
|
||||
ui_set_statusbar(_("Replaced text in %u files."), count);
|
||||
|
16
src/tools.c
16
src/tools.c
@ -502,7 +502,7 @@ struct cc_dialog
|
||||
};
|
||||
|
||||
|
||||
static void cc_add_command(struct cc_dialog *cc, gint index)
|
||||
static void cc_add_command(struct cc_dialog *cc, gint idx)
|
||||
{
|
||||
GtkWidget *label, *entry, *hbox;
|
||||
gchar str[6];
|
||||
@ -513,7 +513,7 @@ static void cc_add_command(struct cc_dialog *cc, gint index)
|
||||
|
||||
entry = gtk_entry_new();
|
||||
if (index >= 0)
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), app->custom_commands[index]);
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), app->custom_commands[idx]);
|
||||
gtk_entry_set_max_length(GTK_ENTRY(entry), 255);
|
||||
gtk_entry_set_width_chars(GTK_ENTRY(entry), 30);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
||||
@ -537,7 +537,7 @@ static gboolean cc_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
|
||||
gint idx = GPOINTER_TO_INT(data);
|
||||
gchar *msg = NULL;
|
||||
GString *str = g_string_sized_new(256);
|
||||
GIOStatus rv;
|
||||
GIOStatus rv;
|
||||
GError *err = NULL;
|
||||
|
||||
do
|
||||
@ -555,8 +555,8 @@ static gboolean cc_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
|
||||
err = NULL;
|
||||
}
|
||||
} while (rv == G_IO_STATUS_NORMAL || rv == G_IO_STATUS_AGAIN);
|
||||
|
||||
if (rv == G_IO_STATUS_EOF)
|
||||
|
||||
if (rv == G_IO_STATUS_EOF)
|
||||
{ // Command completed successfully
|
||||
sci_replace_sel(doc_list[idx].sci, str->str);
|
||||
}
|
||||
@ -701,7 +701,7 @@ static void cc_show_dialog_custom_commands()
|
||||
GList *children = gtk_container_get_children(GTK_CONTAINER(cc.box));
|
||||
GList *tmp;
|
||||
GSList *result_list = NULL;
|
||||
gint i = 0;
|
||||
gint j = 0;
|
||||
gint len = 0;
|
||||
gchar **result = NULL;
|
||||
const gchar *text;
|
||||
@ -730,10 +730,10 @@ static void cc_show_dialog_custom_commands()
|
||||
result = g_new(gchar*, len + 1);
|
||||
while (result_list != NULL)
|
||||
{
|
||||
result[i] = (gchar*) result_list->data;
|
||||
result[j] = (gchar*) result_list->data;
|
||||
|
||||
result_list = result_list->next;
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
result[len] = NULL; // null-terminate the array
|
||||
}
|
||||
|
@ -136,25 +136,25 @@ void ui_update_statusbar(gint idx, gint pos)
|
||||
|
||||
|
||||
/* This sets the window title according to the current filename. */
|
||||
void ui_set_window_title(gint index)
|
||||
void ui_set_window_title(gint idx)
|
||||
{
|
||||
gchar *title;
|
||||
|
||||
if (index >= 0)
|
||||
if (idx >= 0)
|
||||
{
|
||||
if (doc_list[index].file_name == NULL)
|
||||
if (doc_list[idx].file_name == NULL)
|
||||
{
|
||||
title = g_strdup_printf("%s%s - Geany",
|
||||
doc_list[index].changed ? "*" : "",
|
||||
DOC_FILENAME(index));
|
||||
doc_list[idx].changed ? "*" : "",
|
||||
DOC_FILENAME(idx));
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *basename = g_path_get_basename(DOC_FILENAME(index));
|
||||
gchar *dirname = g_path_get_dirname(DOC_FILENAME(index));
|
||||
gchar *basename = g_path_get_basename(DOC_FILENAME(idx));
|
||||
gchar *dirname = g_path_get_dirname(DOC_FILENAME(idx));
|
||||
|
||||
title = g_strdup_printf("%s%s - %s - Geany",
|
||||
doc_list[index].changed ? "*" : "",
|
||||
doc_list[idx].changed ? "*" : "",
|
||||
basename, dirname ? dirname : "");
|
||||
g_free(basename);
|
||||
g_free(dirname);
|
||||
@ -215,20 +215,20 @@ void ui_set_fullscreen()
|
||||
}
|
||||
|
||||
|
||||
void ui_update_popup_reundo_items(gint index)
|
||||
void ui_update_popup_reundo_items(gint idx)
|
||||
{
|
||||
gboolean enable_undo;
|
||||
gboolean enable_redo;
|
||||
|
||||
if (index == -1)
|
||||
if (idx == -1)
|
||||
{
|
||||
enable_undo = FALSE;
|
||||
enable_redo = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
enable_undo = document_can_undo(index);
|
||||
enable_redo = document_can_redo(index);
|
||||
enable_undo = document_can_undo(idx);
|
||||
enable_redo = document_can_redo(idx);
|
||||
}
|
||||
|
||||
// index 0 is the popup menu, 1 is the menubar, 2 is the toolbar
|
||||
@ -242,13 +242,13 @@ void ui_update_popup_reundo_items(gint index)
|
||||
}
|
||||
|
||||
|
||||
void ui_update_popup_copy_items(gint index)
|
||||
void ui_update_popup_copy_items(gint idx)
|
||||
{
|
||||
gboolean enable;
|
||||
guint i;
|
||||
|
||||
if (index == -1) enable = FALSE;
|
||||
else enable = sci_can_copy(doc_list[index].sci);
|
||||
if (idx == -1) enable = FALSE;
|
||||
else enable = sci_can_copy(doc_list[idx].sci);
|
||||
|
||||
for(i = 0; i < (sizeof(app->popup_items)/sizeof(GtkWidget*)); i++)
|
||||
gtk_widget_set_sensitive(app->popup_items[i], enable);
|
||||
|
@ -161,8 +161,6 @@ gboolean utils_isbrace(gchar c)
|
||||
case ']': return TRUE;
|
||||
default: return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -179,8 +177,6 @@ gboolean utils_is_opening_brace(gchar c)
|
||||
case '[': return TRUE;
|
||||
default: return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -524,7 +520,7 @@ gint utils_get_current_function(gint idx, const gchar **tagname)
|
||||
// if the document has no changes, get the previous function name from TM
|
||||
if(! doc_list[idx].changed && tm_file != NULL && tm_file->tags_array != NULL)
|
||||
{
|
||||
TMTag *tag = TM_TAG(tm_get_current_function(tm_file->tags_array, line));
|
||||
const TMTag *tag = (const TMTag*) tm_get_current_function(tm_file->tags_array, line);
|
||||
|
||||
if (tag != NULL)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user