SF.net SVN: geany: [1376] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Fri Mar 9 13:52:26 UTC 2007


Revision: 1376
          http://svn.sourceforge.net/geany/?rev=1376&view=rev
Author:   eht16
Date:     2007-03-09 05:52:26 -0800 (Fri, 09 Mar 2007)

Log Message:
-----------
Fixed several compiler warnings (mainly shadowing local variables and unreachable code).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c
    trunk/src/encodings.c
    trunk/src/encodings.h
    trunk/src/highlighting.c
    trunk/src/msgwindow.c
    trunk/src/notebook.c
    trunk/src/project.c
    trunk/src/sci_cb.c
    trunk/src/search.c
    trunk/src/tools.c
    trunk/src/ui_utils.c
    trunk/src/utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/ChangeLog	2007-03-09 13:52:26 UTC (rev 1376)
@@ -1,3 +1,12 @@
+2007-03-09  Enrico Tröger  <enrico.troeger at 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 at btinternet.com>
 
  * src/interface.c, doc/geany.docbook, data/filetypes.*, geany.glade:

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/callbacks.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -1028,17 +1028,17 @@
 {
 	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 @@
 					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;
 

Modified: trunk/src/encodings.c
===================================================================
--- trunk/src/encodings.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/encodings.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -142,12 +142,12 @@
 }
 
 
-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];
 }
 
 

Modified: trunk/src/encodings.h
===================================================================
--- trunk/src/encodings.h	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/encodings.h	2007-03-09 13:52:26 UTC (rev 1376)
@@ -59,7 +59,7 @@
 
 
 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);

Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/highlighting.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -306,14 +306,14 @@
 }
 
 
-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 @@
 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 @@
 
 	// 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)

Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/msgwindow.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -129,7 +129,7 @@
 {
 	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 @@
 					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 @@
 {
 	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 @@
 					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);
 }
 
 

Modified: trunk/src/notebook.c
===================================================================
--- trunk/src/notebook.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/notebook.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -49,7 +49,7 @@
 
 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 @@
 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 @@
 
 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 @@
 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 @@
 
 		success = TRUE;
 	}
-	gtk_drag_finish(drag_context, success, FALSE, time);
+	gtk_drag_finish(drag_context, success, FALSE, event_time);
 }
 
 

Modified: trunk/src/project.c
===================================================================
--- trunk/src/project.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/project.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -526,11 +526,11 @@
 	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);

Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/sci_cb.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -389,8 +389,8 @@
 			}
 			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 @@
 		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;

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/search.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -875,8 +875,6 @@
 
 			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 @@
 			// 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);

Modified: trunk/src/tools.c
===================================================================
--- trunk/src/tools.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/tools.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -502,7 +502,7 @@
 };
 
 
-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 @@
 
 	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 @@
 		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 @@
 				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 @@
 		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 @@
 			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
 		}

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/ui_utils.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -136,25 +136,25 @@
 
 
 /* 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_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_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);

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2007-03-09 12:26:55 UTC (rev 1375)
+++ trunk/src/utils.c	2007-03-09 13:52:26 UTC (rev 1376)
@@ -161,8 +161,6 @@
 		case ']': return TRUE;
 		default:  return FALSE;
 	}
-
-	return FALSE;
 }
 
 
@@ -179,8 +177,6 @@
 		case '[':  return TRUE;
 		default:  return FALSE;
 	}
-
-	return FALSE;
 }
 
 
@@ -524,7 +520,7 @@
 	// 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)
 		{


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list