Remove all G_LIKELY macros inside g_return_if_fail() statements as this is redundant.

Remove many other G_LIKELY/G_UNLIKELY macros which doesn't make much sense to keep the code more readable.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3708 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2009-04-15 22:47:33 +00:00
parent ba4002e502
commit a95a59a42f
31 changed files with 638 additions and 657 deletions

View File

@ -3,6 +3,18 @@
* src/keyfile.c, src/keyfile.h, src/project.c:
Fix duplicating the recent files and projects lists when closing
a project.
* src/build.c, src/callbacks.c, src/dialogs.c, src/document.c,
src/editor.c, src/encodings.c, src/filetypes.c,
src/geanymenubuttonaction.c, src/geanyobject.c, src/geanywraplabel.c,
src/highlighting.c, src/keybindings.c, src/keyfile.c, src/main.c,
src/msgwindow.c, src/navqueue.c, src/notebook.c, src/plugins.c,
src/prefs.c, src/queue.c, src/sciwrappers.c, src/socket.c,
src/symbols.c, src/templates.c, src/toolbar.c, src/tools.c,
src/treeviews.c, src/ui_utils.c, src/utils.c, src/vte.c:
Remove all G_LIKELY macros inside g_return_if_fail() statements as
this is redundant.
Remove many other G_LIKELY/G_UNLIKELY macros which doesn't make much
sense to keep the code more readable.
2009-04-09 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

View File

@ -1570,12 +1570,11 @@ void build_menu_update(GeanyDocument *doc)
BuildMenuItems *menu_items;
static GtkWidget *menubar_build_menu = NULL;
if (G_UNLIKELY(menubar_build_menu == NULL)) /* cache the build menu pointer */
if (menubar_build_menu == NULL) /* cache the build menu pointer */
menubar_build_menu = ui_lookup_widget(main_widgets.window, "menu_build1");
if (doc == NULL)
doc = document_get_current();
if (G_UNLIKELY(doc == NULL) ||
(FILETYPE_ID(doc->file_type) == GEANY_FILETYPES_NONE && doc->file_name == NULL))
if (doc == NULL || (FILETYPE_ID(doc->file_type) == GEANY_FILETYPES_NONE && doc->file_name == NULL))
{
gtk_widget_set_sensitive(menubar_build_menu, FALSE);
gtk_menu_item_remove_submenu(GTK_MENU_ITEM(menubar_build_menu));
@ -1588,7 +1587,7 @@ void build_menu_update(GeanyDocument *doc)
gtk_widget_set_sensitive(menubar_build_menu, TRUE);
ft = doc->file_type;
g_return_if_fail(G_LIKELY(ft != NULL));
g_return_if_fail(ft != NULL);
menu_items = build_get_menu_items(ft->id);
/* Note: don't remove the submenu first because it can now cause an X hang if
@ -1596,7 +1595,7 @@ void build_menu_update(GeanyDocument *doc)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_build_menu),
menu_items->menu);
have_path = G_LIKELY(doc->file_name != NULL);
have_path = doc->file_name != NULL;
can_make = have_path && build_info.pid <= (GPid) 1;
@ -1853,7 +1852,7 @@ show_make_custom(void)
{
static GtkWidget *dialog = NULL; /* keep dialog for combo history */
if (G_UNLIKELY(! dialog))
if (! dialog)
dialog = dialogs_show_input(_("Make Custom Target"),
_("Enter custom options here, all entered text is passed to the make command."),
build_info.custom_target, TRUE, &on_make_custom_input_response);
@ -2055,7 +2054,7 @@ void build_init()
widgets.build_action = toolbar_get_action_by_name("Build");
toolmenu = geany_menu_button_action_get_menu(GEANY_MENU_BUTTON_ACTION(widgets.build_action));
if (G_UNLIKELY(toolmenu != NULL))
if (toolmenu != NULL)
{
/* build the code */
item = ui_image_menu_item_new(GEANY_STOCK_BUILD, _("_Build"));

View File

@ -95,7 +95,7 @@ static gboolean check_no_unsaved(void)
for (i = 0; i < documents_array->len; i++)
{
if (documents[i]->is_valid && G_UNLIKELY(documents[i]->changed))
if (documents[i]->is_valid && documents[i]->changed)
{
return FALSE;
}
@ -179,9 +179,9 @@ on_save1_activate (GtkMenuItem *menuitem,
gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL) && G_LIKELY(cur_page >= 0))
if (doc != NULL && cur_page >= 0)
{
if (G_UNLIKELY(doc->file_name == NULL))
if (doc->file_name == NULL)
dialogs_show_save_as();
else
document_save_file(doc, FALSE);
@ -207,8 +207,9 @@ on_save_all1_activate (GtkMenuItem *menuitem,
for (i = 0; i < max; i++)
{
doc = document_get_from_page(i);
if (! doc->changed) continue;
if (G_UNLIKELY(doc->file_name == NULL))
if (! doc->changed)
continue;
if (doc->file_name == NULL)
{
/* display unnamed document */
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
@ -237,8 +238,9 @@ on_close1_activate (GtkMenuItem *menuitem,
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc))
document_close(doc);
g_return_if_fail(doc != NULL);
document_close(doc);
}
@ -282,7 +284,9 @@ on_undo1_activate (GtkMenuItem *menuitem,
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL) && document_can_undo(doc))
g_return_if_fail(doc != NULL);
if (document_can_undo(doc))
{
sci_cancel(doc->editor->sci);
document_undo(doc);
@ -296,7 +300,9 @@ on_redo1_activate (GtkMenuItem *menuitem,
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL) && document_can_redo(doc))
g_return_if_fail(doc != NULL);
if (document_can_redo(doc))
{
sci_cancel(doc->editor->sci);
document_redo(doc);
@ -314,7 +320,7 @@ on_cut1_activate (GtkMenuItem *menuitem,
if (GTK_IS_EDITABLE(focusw))
gtk_editable_cut_clipboard(GTK_EDITABLE(focusw));
else
if (IS_SCINTILLA(focusw) && G_LIKELY(doc != NULL))
if (IS_SCINTILLA(focusw) && doc != NULL)
sci_cut(doc->editor->sci);
else
if (GTK_IS_TEXT_VIEW(focusw))
@ -336,7 +342,7 @@ on_copy1_activate (GtkMenuItem *menuitem,
if (GTK_IS_EDITABLE(focusw))
gtk_editable_copy_clipboard(GTK_EDITABLE(focusw));
else
if (IS_SCINTILLA(focusw) && G_LIKELY(doc != NULL))
if (IS_SCINTILLA(focusw) && doc != NULL)
sci_copy(doc->editor->sci);
else
if (GTK_IS_TEXT_VIEW(focusw))
@ -358,7 +364,7 @@ on_paste1_activate (GtkMenuItem *menuitem,
if (GTK_IS_EDITABLE(focusw))
gtk_editable_paste_clipboard(GTK_EDITABLE(focusw));
else
if (IS_SCINTILLA(focusw) && G_LIKELY(doc != NULL))
if (IS_SCINTILLA(focusw) && doc != NULL)
{
sci_paste(doc->editor->sci);
}
@ -383,7 +389,7 @@ on_delete1_activate (GtkMenuItem *menuitem,
if (GTK_IS_EDITABLE(focusw))
gtk_editable_delete_selection(GTK_EDITABLE(focusw));
else
if (IS_SCINTILLA(focusw) && G_LIKELY(doc != NULL) && sci_has_selection(doc->editor->sci))
if (IS_SCINTILLA(focusw) && doc != NULL && sci_has_selection(doc->editor->sci))
sci_clear(doc->editor->sci);
else
if (GTK_IS_TEXT_VIEW(focusw))
@ -449,11 +455,12 @@ on_reload_as_activate (GtkMenuItem *menuitem,
gint i = GPOINTER_TO_INT(user_data);
gchar *charset = NULL;
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(doc->file_name == NULL))
return;
g_return_if_fail(doc != NULL);
g_return_if_fail(doc->file_name != NULL);
if (i >= 0)
{
if (G_UNLIKELY(i >= GEANY_ENCODINGS_MAX) || G_UNLIKELY(encodings[i].charset == NULL))
if (i >= GEANY_ENCODINGS_MAX || encodings[i].charset == NULL)
return;
charset = encodings[i].charset;
}
@ -634,13 +641,12 @@ on_zoom_in1_activate (GtkMenuItem *menuitem,
GeanyDocument *doc = document_get_current();
static gint done = 1;
if (G_LIKELY(doc != NULL))
{
if (done++ % 3 == 0)
sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin,
g_return_if_fail(doc != NULL);
if (done++ % 3 == 0)
sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin,
(sci_get_zoom(doc->editor->sci) / 2));
sci_zoom_in(doc->editor->sci);
}
sci_zoom_in(doc->editor->sci);
}
/* zoom out from menu bar and popup menu */
@ -649,12 +655,12 @@ on_zoom_out1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (doc != NULL)
{
if (sci_get_zoom(doc->editor->sci) == 0)
g_return_if_fail(doc != NULL);
if (sci_get_zoom(doc->editor->sci) == 0)
sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, 0);
sci_zoom_out(doc->editor->sci);
}
sci_zoom_out(doc->editor->sci);
}
@ -663,11 +669,11 @@ on_normal_size1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
{
sci_zoom_off(doc->editor->sci);
sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, 0);
}
g_return_if_fail(doc != NULL);
sci_zoom_off(doc->editor->sci);
sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, 0);
}
@ -721,7 +727,7 @@ on_notebook1_switch_page_after (GtkNotebook *notebook,
else
doc = document_get_from_page(page_num);
if (G_LIKELY(doc != NULL))
if (doc != NULL)
{
treeviews_select_openfiles_item(doc);
document_set_text_changed(doc, doc->changed); /* also sets window title and status bar */
@ -769,9 +775,12 @@ void
on_crlf_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (ignore_callback || G_UNLIKELY(doc == NULL))
GeanyDocument *doc;
if (ignore_callback)
return;
doc = document_get_current();
g_return_if_fail(doc != NULL);
sci_convert_eols(doc->editor->sci, SC_EOL_CRLF);
sci_set_eol_mode(doc->editor->sci, SC_EOL_CRLF);
}
@ -781,9 +790,12 @@ void
on_lf_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (ignore_callback || G_UNLIKELY(doc == NULL))
GeanyDocument *doc;
if (ignore_callback)
return;
doc = document_get_current();
g_return_if_fail(doc != NULL);
sci_convert_eols(doc->editor->sci, SC_EOL_LF);
sci_set_eol_mode(doc->editor->sci, SC_EOL_LF);
}
@ -793,9 +805,12 @@ void
on_cr_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (ignore_callback || G_UNLIKELY(doc == NULL))
GeanyDocument *doc;
if (ignore_callback)
return;
doc = document_get_current();
g_return_if_fail(doc != NULL);
sci_convert_eols(doc->editor->sci, SC_EOL_CR);
sci_set_eol_mode(doc->editor->sci, SC_EOL_CR);
}
@ -807,8 +822,9 @@ on_replace_tabs_activate (GtkMenuItem *menuitem,
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
editor_replace_tabs(doc->editor);
g_return_if_fail(doc != NULL);
editor_replace_tabs(doc->editor);
}
@ -858,8 +874,7 @@ void on_toggle_case1_activate(GtkMenuItem *menuitem, gpointer user_data)
gchar *text;
gboolean keep_sel = TRUE;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
sci = doc->editor->sci;
if (! sci_has_selection(sci))
@ -1008,8 +1023,9 @@ on_line_wrapping1_toggled (GtkCheckMenuItem *checkmenuitem,
if (! ignore_callback)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
editor_set_line_wrapping(doc->editor, ! doc->editor->line_wrapping);
g_return_if_fail(doc != NULL);
editor_set_line_wrapping(doc->editor, ! doc->editor->line_wrapping);
}
}
@ -1021,8 +1037,8 @@ on_set_file_readonly1_toggled (GtkCheckMenuItem *checkmenuitem,
if (! ignore_callback)
{
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
doc->readonly = ! doc->readonly;
sci_set_readonly(doc->editor->sci, doc->readonly);
ui_update_tab_status(doc);
@ -1038,8 +1054,9 @@ on_use_auto_indentation1_toggled (GtkCheckMenuItem *checkmenuitem,
if (! ignore_callback)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
doc->editor->auto_indent = ! doc->editor->auto_indent;
g_return_if_fail(doc != NULL);
doc->editor->auto_indent = ! doc->editor->auto_indent;
}
}
@ -1050,8 +1067,7 @@ static void find_usage(gboolean in_session)
gchar *search_text;
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
if (sci_has_selection(doc->editor->sci))
{ /* take selected text if there is a selection */
@ -1094,7 +1110,7 @@ on_goto_tag_activate (GtkMenuItem *menuitem,
GTK_MENU_ITEM(ui_lookup_widget(main_widgets.editor_menu, "goto_tag_definition1")));
GeanyDocument *doc = document_get_current();
g_return_if_fail(G_LIKELY(doc != NULL));
g_return_if_fail(doc != NULL);
sci_set_current_position(doc->editor->sci, editor_info.click_pos, FALSE);
symbols_goto_tag(editor_info.current_word, definition);
@ -1117,8 +1133,7 @@ on_show_color_chooser1_activate (GtkMenuItem *menuitem,
GeanyDocument *doc = document_get_current();
gint pos;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
pos = sci_get_current_position(doc->editor->sci);
editor_find_current_word(doc->editor, pos, colour, sizeof colour, GEANY_WORDCHARS"#");
@ -1146,7 +1161,7 @@ static void find_again(gboolean change_direction)
{
GeanyDocument *doc = document_get_current();
g_return_if_fail(G_LIKELY(doc != NULL));
g_return_if_fail(doc != NULL);
if (search_data.text)
{
@ -1227,11 +1242,10 @@ on_go_to_line_activate (GtkMenuItem *menuitem,
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
{
if (! editor_goto_line(doc->editor, (gint) val - 1))
utils_beep();
}
g_return_if_fail(doc != NULL);
if (! editor_goto_line(doc->editor, (gint) val - 1))
utils_beep();
}
}
@ -1241,12 +1255,10 @@ on_toolbutton_goto_entry_activate(GtkAction *action, const gchar *text, gpointer
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
{
gint line = atoi(text);
if (! editor_goto_line(doc->editor, line - 1))
utils_beep();
}
g_return_if_fail(doc != NULL);
if (! editor_goto_line(doc->editor, atoi(text) - 1))
utils_beep();
}
@ -1317,7 +1329,7 @@ on_comments_function_activate (GtkMenuItem *menuitem,
const gchar *cur_tag = NULL;
gint line = -1, pos = 0;
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(doc->file_type == NULL))
if (doc == NULL || doc->file_type == NULL)
{
ui_set_statusbar(FALSE,
_("Please set the filetype for the current file before using this function."));
@ -1342,7 +1354,7 @@ on_comments_multiline_activate (GtkMenuItem *menuitem,
{
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(doc->file_type == NULL))
if (doc == NULL || doc->file_type == NULL)
{
ui_set_statusbar(FALSE,
_("Please set the filetype for the current file before using this function."));
@ -1362,8 +1374,7 @@ on_comments_gpl_activate (GtkMenuItem *menuitem,
GeanyDocument *doc = document_get_current();
gchar *text;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
text = templates_get_template_licence(FILETYPE_ID(doc->file_type), GEANY_TEMPLATE_GPL);
@ -1382,8 +1393,7 @@ on_comments_bsd_activate (GtkMenuItem *menuitem,
GeanyDocument *doc = document_get_current();
gchar *text;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
text = templates_get_template_licence(FILETYPE_ID(doc->file_type), GEANY_TEMPLATE_BSD);
@ -1402,8 +1412,7 @@ on_comments_changelog_activate (GtkMenuItem *menuitem,
GeanyDocument *doc = document_get_current();
gchar *text;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
text = templates_get_template_changelog();
sci_insert_text(doc->editor->sci, 0, text);
@ -1424,7 +1433,7 @@ on_comments_fileheader_activate (GtkMenuItem *menuitem,
gchar *fname;
GeanyFiletype *ft;
g_return_if_fail(G_LIKELY(doc != NULL));
g_return_if_fail(doc != NULL);
ft = doc->file_type;
fname = doc->file_name;
@ -1451,8 +1460,7 @@ on_insert_date_activate (GtkMenuItem *menuitem,
gchar *format;
gchar *time_str;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
if (utils_str_equal(_("dd.mm.yyyy"), (gchar*) user_data))
format = "%d.%m.%Y";
@ -1484,7 +1492,7 @@ on_insert_date_activate (GtkMenuItem *menuitem,
}
time_str = utils_get_date_time(format, NULL);
if (G_UNLIKELY(time_str != NULL))
if (time_str != NULL)
{
verify_click_pos(doc); /* make sure that the click_pos is valid */
@ -1509,8 +1517,8 @@ on_insert_include_activate (GtkMenuItem *menuitem,
gint pos = -1;
gchar *text;
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(user_data == NULL))
return;
g_return_if_fail(doc != NULL);
g_return_if_fail(user_data != NULL);
verify_click_pos(doc); /* make sure that the click_pos is valid */
@ -1526,7 +1534,7 @@ on_insert_include_activate (GtkMenuItem *menuitem,
sci_insert_text(doc->editor->sci, editor_info.click_pos, text);
g_free(text);
if (G_LIKELY(pos >= 0))
if (pos >= 0)
sci_goto_pos(doc->editor->sci, pos, FALSE);
}
@ -1536,6 +1544,8 @@ on_file_properties_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
g_return_if_fail(doc != NULL);
dialogs_show_file_properties(doc);
}
@ -1545,8 +1555,9 @@ on_menu_fold_all1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
editor_fold_all(doc->editor);
g_return_if_fail(doc != NULL);
editor_fold_all(doc->editor);
}
@ -1555,8 +1566,9 @@ on_menu_unfold_all1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
editor_unfold_all(doc->editor);
g_return_if_fail(doc != NULL);
editor_unfold_all(doc->editor);
}
@ -1573,9 +1585,9 @@ on_menu_remove_indicators1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
g_return_if_fail(doc != NULL);
if (G_LIKELY(doc != NULL))
editor_indicator_clear(doc->editor, GEANY_INDICATOR_ERROR);
editor_indicator_clear(doc->editor, GEANY_INDICATOR_ERROR);
}
@ -1586,11 +1598,11 @@ on_encoding_change (GtkMenuItem *menuitem,
GeanyDocument *doc = document_get_current();
guint i = GPOINTER_TO_INT(user_data);
if (ignore_callback || G_UNLIKELY(doc == NULL) || G_UNLIKELY(encodings[i].charset == NULL) ||
if (ignore_callback || doc == NULL || encodings[i].charset == NULL ||
utils_str_equal(encodings[i].charset, doc->encoding))
return;
if (G_UNLIKELY(doc->readonly))
if (doc->readonly)
{
utils_beep();
return;
@ -1606,8 +1618,9 @@ on_print1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
printing_print_doc(doc);
g_return_if_fail(doc != NULL);
printing_print_doc(doc);
}
@ -1616,9 +1629,9 @@ on_menu_select_all1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
g_return_if_fail(doc != NULL);
if (G_LIKELY(doc != NULL))
sci_select_all(doc->editor->sci);
sci_select_all(doc->editor->sci);
}
@ -1658,9 +1671,8 @@ on_menu_write_unicode_bom1_toggled (GtkCheckMenuItem *checkmenuitem,
{
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
return;
if (G_UNLIKELY(doc->readonly))
g_return_if_fail(doc != NULL);
if (doc->readonly)
{
utils_beep();
return;
@ -1680,8 +1692,9 @@ on_menu_comment_line1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
editor_do_comment(doc->editor, -1, FALSE, FALSE);
g_return_if_fail(doc != NULL);
editor_do_comment(doc->editor, -1, FALSE, FALSE);
}
@ -1690,8 +1703,9 @@ on_menu_uncomment_line1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
editor_do_uncomment(doc->editor, -1, FALSE);
g_return_if_fail(doc != NULL);
editor_do_uncomment(doc->editor, -1, FALSE);
}
@ -1701,8 +1715,9 @@ on_menu_toggle_line_commentation1_activate
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
editor_do_comment_toggle(doc->editor);
g_return_if_fail(doc != NULL);
editor_do_comment_toggle(doc->editor);
}
@ -1731,8 +1746,7 @@ on_menu_increase_indent1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
if (sci_get_lines_selected(doc->editor->sci) > 1)
{
@ -1750,8 +1764,7 @@ on_menu_decrease_indent1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
if (sci_get_lines_selected(doc->editor->sci) > 1)
{
@ -1868,7 +1881,7 @@ on_menu_project1_activate (GtkMenuItem *menuitem,
static GtkWidget *item_close = NULL;
static GtkWidget *item_properties = NULL;
if (G_UNLIKELY(item_close == NULL))
if (item_close == NULL)
{
item_close = ui_lookup_widget(main_widgets.window, "project_close1");
item_properties = ui_lookup_widget(main_widgets.window, "project_properties1");
@ -1886,8 +1899,7 @@ on_menu_open_selected_file1_activate (GtkMenuItem *menuitem,
GeanyDocument *doc = document_get_current();
gchar *sel = NULL;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
sel = editor_get_default_selection(doc->editor, TRUE, GEANY_WORDCHARS"./-");
@ -1929,9 +1941,7 @@ on_remove_markers1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
sci_marker_delete_all(doc->editor->sci, 0); /* delete the yellow tag marker */
sci_marker_delete_all(doc->editor->sci, 1); /* delete user markers */
@ -1955,8 +1965,7 @@ on_context_action1_activate (GtkMenuItem *menuitem,
GError *error = NULL;
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
if (sci_has_selection(doc->editor->sci))
{ /* take selected text if there is a selection */
@ -2078,11 +2087,14 @@ gboolean on_motion_event(GtkWidget *widget, GdkEventMotion *event, gpointer user
static void set_indent_type(GeanyIndentType type)
{
GeanyDocument *doc = document_get_current();
GeanyDocument *doc;
if (G_UNLIKELY(doc == NULL) || ignore_callback)
if (ignore_callback)
return;
doc = document_get_current();
g_return_if_fail(doc != NULL);
editor_set_indent_type(doc->editor, type);
ui_update_statusbar(doc, -1);
}
@ -2122,7 +2134,7 @@ on_strip_trailing_spaces1_activate (GtkMenuItem *menuitem,
return;
doc = document_get_current();
g_return_if_fail(G_LIKELY(doc != NULL));
g_return_if_fail(doc != NULL);
editor_strip_trailing_spaces(doc->editor);
}
@ -2165,7 +2177,7 @@ on_line_breaking1_activate (GtkMenuItem *menuitem,
return;
doc = document_get_current();
g_return_if_fail(G_LIKELY(doc != NULL));
g_return_if_fail(doc != NULL);
doc->editor->line_breaking = !doc->editor->line_breaking;
}
@ -2176,8 +2188,9 @@ on_replace_spaces_activate (GtkMenuItem *menuitem,
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
editor_replace_spaces(doc->editor);
g_return_if_fail(doc != NULL);
editor_replace_spaces(doc->editor);
}
@ -2210,7 +2223,7 @@ on_close_other_documents1_activate (GtkMenuItem *menuitem,
{
doc = documents[i];
if (G_UNLIKELY(doc == cur_doc) || ! doc->is_valid)
if (doc == cur_doc || ! doc->is_valid)
continue;
if (! document_close(doc))

View File

@ -141,7 +141,7 @@ on_file_open_selection_changed (GtkFileChooser *filechooser,
gchar *filename = gtk_file_chooser_get_filename(filechooser);
gboolean is_on = gtk_file_chooser_get_show_hidden(filechooser);
if (G_LIKELY(filename))
if (filename)
{
/* try to get the UTF-8 equivalent for the filename, fallback to filename if error */
gchar *utf8_filename = utils_get_utf8_from_locale(filename);
@ -268,7 +268,7 @@ void dialogs_show_open_file()
/* We use the same file selection widget each time, so first of all we create it
* if it hasn't already been created. */
if (G_UNLIKELY(ui_widgets.open_filesel == NULL))
if (ui_widgets.open_filesel == NULL)
create_open_file_dialog();
if (initdir != NULL)
@ -704,7 +704,7 @@ gboolean dialogs_show_unsaved_file(GeanyDocument *doc)
document_get_notebook_page(doc));
main_status.quitting = old_quitting_state;
if (G_LIKELY(doc->file_name != NULL))
if (doc->file_name != NULL)
{
short_fn = g_path_get_basename(doc->file_name);
}
@ -959,9 +959,9 @@ gboolean dialogs_show_input_numeric(const gchar *title, const gchar *label_text,
GtkWidget *dialog, *label, *spin, *vbox;
gboolean res = FALSE;
g_return_val_if_fail(G_LIKELY(title != NULL), FALSE);
g_return_val_if_fail(G_LIKELY(label_text != NULL), FALSE);
g_return_val_if_fail(G_LIKELY(value != NULL), FALSE);
g_return_val_if_fail(title != NULL, FALSE);
g_return_val_if_fail(label_text != NULL, FALSE);
g_return_val_if_fail(value != NULL, FALSE);
dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(main_widgets.window),
GTK_DIALOG_DESTROY_WITH_PARENT,
@ -1023,7 +1023,7 @@ void dialogs_show_file_properties(GeanyDocument *doc)
# define S_IXOTH 0
#endif
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(doc->file_name == NULL))
if (doc == NULL || doc->file_name == NULL)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("An error occurred or file information could not be retrieved (e.g. from a new file)."));

View File

@ -131,7 +131,7 @@ GeanyDocument* document_find_by_real_path(const gchar *realname)
{
guint i;
if (G_UNLIKELY(! realname))
if (! realname)
return NULL; /* file doesn't exist on disk */
for (i = 0; i < documents_array->len; i++)
@ -178,8 +178,7 @@ GeanyDocument *document_find_by_filename(const gchar *utf8_filename)
GeanyDocument *doc;
gchar *realname;
if (G_UNLIKELY(! utf8_filename))
return NULL;
g_return_val_if_fail(utf8_filename != NULL, NULL);
/* First search GeanyDocument::file_name, so we can find documents with a
* filename set but not saved on disk, like vcdiff produces */
@ -208,8 +207,7 @@ GeanyDocument *document_find_by_sci(ScintillaObject *sci)
{
guint i;
if (G_UNLIKELY(sci == NULL))
return NULL;
g_return_val_if_fail(sci != NULL, NULL);
for (i = 0; i < documents_array->len; i++)
{
@ -223,8 +221,7 @@ GeanyDocument *document_find_by_sci(ScintillaObject *sci)
/* returns the index of the notebook page for the document. */
gint document_get_notebook_page(GeanyDocument *doc)
{
if (G_UNLIKELY(doc == NULL))
return -1;
g_return_val_if_fail(doc != NULL, -1);
return gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook),
GTK_WIDGET(doc->editor->sci));
@ -242,7 +239,7 @@ GeanyDocument *document_get_from_page(guint page_num)
{
ScintillaObject *sci;
if (G_UNLIKELY(page_num >= documents_array->len))
if (page_num >= documents_array->len)
return NULL;
sci = (ScintillaObject*)gtk_notebook_get_nth_page(
@ -261,7 +258,7 @@ GeanyDocument *document_get_current(void)
{
gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
if (G_UNLIKELY(cur_page == -1))
if (cur_page == -1)
return NULL;
else
{
@ -290,7 +287,7 @@ void document_update_tab_label(GeanyDocument *doc)
gchar *base_name;
GtkWidget *parent;
g_return_if_fail(G_LIKELY(doc != NULL));
g_return_if_fail(doc != NULL);
base_name = g_path_get_basename(DOC_FILENAME(doc));
/* we need to use the event box for the tooltip, labels don't get the necessary events */
@ -315,12 +312,11 @@ void document_update_tab_label(GeanyDocument *doc)
**/
void document_set_text_changed(GeanyDocument *doc, gboolean changed)
{
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
doc->changed = changed;
if (G_LIKELY(! main_status.quitting))
if (! main_status.quitting)
{
ui_update_tab_status(doc);
ui_save_buttons_toggle(changed);
@ -397,7 +393,7 @@ static void queue_colourise(GeanyDocument *doc)
/* Set the file status to 'changed' after a single 'created' event. */
static gboolean monitor_finish_pending_create(gpointer doc)
{
g_return_val_if_fail(G_LIKELY(doc != NULL), FALSE);
g_return_val_if_fail(doc != NULL, FALSE);
((GeanyDocument *)doc)->priv->file_disk_status = FILE_CHANGED;
ui_update_tab_status(doc);
@ -409,7 +405,7 @@ static gboolean monitor_finish_pending_create(gpointer doc)
/* Resets the 'ignore' file status after a reload action. */
static gboolean monitor_reset_ignore(gpointer doc)
{
g_return_val_if_fail(G_LIKELY(doc != NULL), FALSE);
g_return_val_if_fail(doc != NULL, FALSE);
((GeanyDocument *)doc)->priv->file_disk_status = FILE_OK;
ui_update_tab_status(doc);
@ -421,7 +417,7 @@ static gboolean monitor_reset_ignore(gpointer doc)
static void monitor_file_changed_cb(G_GNUC_UNUSED GFileMonitor *monitor, G_GNUC_UNUSED GFile *file,
G_GNUC_UNUSED GFile *other_file, GFileMonitorEvent event, GeanyDocument *doc)
{
g_return_if_fail(G_LIKELY(doc != NULL));
g_return_if_fail(doc != NULL);
if (file_prefs.disk_check_timeout == 0)
return;
@ -494,7 +490,7 @@ static void monitor_file_changed_cb(G_GNUC_UNUSED GFileMonitor *monitor, G_GNUC_
void document_stop_file_monitoring(GeanyDocument *doc)
{
g_return_if_fail(G_LIKELY(doc != NULL));
g_return_if_fail(doc != NULL);
if (doc->priv->monitor != NULL)
{
@ -506,7 +502,7 @@ void document_stop_file_monitoring(GeanyDocument *doc)
static void monitor_file_setup(GeanyDocument *doc)
{
g_return_if_fail(G_LIKELY(doc != NULL));
g_return_if_fail(doc != NULL);
/* Disable file monitoring completely for remote files (i.e. remote GIO files) as GFileMonitor
* doesn't work at all for remote files and legacy polling is too slow. */
if (! doc->priv->is_remote)
@ -604,7 +600,7 @@ static GeanyDocument *document_create(const gchar *utf8_filename)
**/
gboolean document_close(GeanyDocument *doc)
{
g_return_val_if_fail(G_LIKELY(doc), FALSE);
g_return_val_if_fail(doc, FALSE);
return document_remove_page(document_get_notebook_page(doc));
}
@ -712,7 +708,7 @@ GeanyDocument *document_new_file(const gchar *utf8_filename, GeanyFiletype *ft,
{
GeanyDocument *doc = document_create(utf8_filename);
g_assert(G_LIKELY(doc != NULL));
g_assert(doc != NULL);
sci_set_undo_collection(doc->editor->sci, FALSE); /* avoid creation of an undo action */
if (text)
@ -814,7 +810,7 @@ handle_forced_encoding(FileData *filedata, const gchar *forced_enc)
{
gchar *converted_text = encodings_convert_to_utf8_from_charset(
filedata->data, filedata->size, forced_enc, FALSE);
if (G_LIKELY(converted_text == NULL))
if (converted_text == NULL)
{
return FALSE;
}
@ -836,8 +832,8 @@ handle_forced_encoding(FileData *filedata, const gchar *forced_enc)
static gboolean
handle_encoding(FileData *filedata, GeanyEncodingIndex enc_idx)
{
g_return_val_if_fail(G_LIKELY(filedata->enc == NULL), FALSE);
g_return_val_if_fail(G_LIKELY(filedata->bom == FALSE), FALSE);
g_return_val_if_fail(filedata->enc == NULL, FALSE);
g_return_val_if_fail(filedata->bom == FALSE, FALSE);
if (filedata->size == 0)
{
@ -857,7 +853,7 @@ handle_encoding(FileData *filedata, GeanyEncodingIndex enc_idx)
{
gchar *converted_text = encodings_convert_to_utf8_from_charset(
filedata->data, filedata->size, filedata->enc, FALSE);
if (G_LIKELY(converted_text != NULL))
if (converted_text != NULL)
{
g_free(filedata->data);
filedata->data = converted_text;
@ -887,7 +883,7 @@ handle_encoding(FileData *filedata, GeanyEncodingIndex enc_idx)
gchar *converted_text = encodings_convert_to_utf8(filedata->data,
filedata->size, &filedata->enc);
if (G_UNLIKELY(converted_text == NULL))
if (converted_text == NULL)
{
return FALSE;
}
@ -1160,7 +1156,7 @@ static gboolean auto_update_tag_list(gpointer data)
{
GeanyDocument *doc = data;
if (G_UNLIKELY(! doc) || G_UNLIKELY(! doc->is_valid) || G_UNLIKELY(doc->tm_file == NULL))
if (! doc || ! doc->is_valid || doc->tm_file == NULL)
return FALSE;
if (gtk_window_get_focus(GTK_WINDOW(main_widgets.window)) != GTK_WIDGET(doc->editor->sci))
@ -1197,7 +1193,7 @@ GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename
else
{
/* filename must not be NULL when opening a file */
if (G_UNLIKELY(filename == NULL))
if (filename == NULL)
{
ui_set_statusbar(FALSE, _("Invalid filename"));
return NULL;
@ -1242,7 +1238,7 @@ GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename
if (! reload)
{
doc = document_create(utf8_filename);
g_return_val_if_fail(G_LIKELY(doc != NULL), NULL); /* really should not happen */
g_return_val_if_fail(doc != NULL, NULL); /* really should not happen */
/* file exists on disk, set real_path */
setptr(doc->real_path, tm_get_real_path(locale_filename));
@ -1342,8 +1338,7 @@ void document_open_file_list(const gchar *data, gssize length)
gchar *filename;
gchar **list;
if (G_UNLIKELY(data == NULL))
return;
g_return_if_fail(data != NULL);
if (length < 0)
length = strlen(data);
@ -1405,8 +1400,7 @@ gboolean document_reload_file(GeanyDocument *doc, const gchar *forced_enc)
gint pos = 0;
GeanyDocument *new_doc;
if (G_UNLIKELY(doc == NULL))
return FALSE;
g_return_val_if_fail(doc != NULL, FALSE);
/* try to set the cursor to the position before reloading */
pos = sci_get_current_position(doc->editor->sci);
@ -1430,7 +1424,7 @@ static gboolean document_update_timestamp(GeanyDocument *doc, const gchar *local
#if ! defined(HAVE_GIO) || ! defined(USE_GIO_FILEMON)
struct stat st;
g_return_val_if_fail(G_LIKELY(doc != NULL), FALSE);
g_return_val_if_fail(doc != NULL, FALSE);
/* stat the file to get the timestamp, otherwise on Windows the actual
* timestamp can be ahead of time(NULL) */
@ -1479,8 +1473,8 @@ static void replace_header_filename(GeanyDocument *doc)
gchar *filename;
struct TextToFind ttf;
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(doc->file_type == NULL))
return;
g_return_if_fail(doc != NULL);
g_return_if_fail(doc->file_type != NULL);
filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", (doc->file_type)->extension, NULL);
filename = g_path_get_basename(doc->file_name);
@ -1524,7 +1518,7 @@ void document_rename_file(GeanyDocument *doc, const gchar *new_filename)
document_stop_file_monitoring(doc);
result = g_rename(old_locale_filename, new_locale_filename);
if (G_UNLIKELY(result != 0))
if (result != 0)
{
dialogs_show_msgbox_with_secondary(GTK_MESSAGE_ERROR,
_("Error renaming file."), g_strerror(errno));
@ -1549,7 +1543,7 @@ gboolean document_save_file_as(GeanyDocument *doc, const gchar *utf8_fname)
{
gboolean ret;
g_return_val_if_fail(G_LIKELY(doc != NULL), FALSE);
g_return_val_if_fail(doc != NULL, FALSE);
if (utf8_fname != NULL)
setptr(doc->file_name, g_strdup(utf8_fname));
@ -1579,7 +1573,7 @@ gboolean document_save_file_as(GeanyDocument *doc, const gchar *utf8_fname)
monitor_file_setup(doc);
doc->priv->file_disk_status = FILE_IGNORE;
if (G_LIKELY(ret))
if (ret)
ui_add_recent_file(doc->file_name);
return ret;
}
@ -1592,14 +1586,14 @@ static gsize save_convert_to_encoding(GeanyDocument *doc, gchar **data, gsize *l
gsize bytes_read;
gsize conv_len;
g_return_val_if_fail(G_LIKELY(data != NULL) || G_LIKELY(*data == NULL), FALSE);
g_return_val_if_fail(G_LIKELY(len != NULL), FALSE);
g_return_val_if_fail(data != NULL || *data == NULL, FALSE);
g_return_val_if_fail(len != NULL, FALSE);
/* try to convert it from UTF-8 to original encoding */
conv_file_contents = g_convert(*data, *len - 1, doc->encoding, "UTF-8",
&bytes_read, &conv_len, &conv_error);
if (G_UNLIKELY(conv_error != NULL))
if (conv_error != NULL)
{
gchar *text = g_strdup_printf(
_("An error occurred while converting the file from UTF-8 in \"%s\". The file remains unsaved."),
@ -1656,7 +1650,7 @@ static gint write_data_to_disk(GeanyDocument *doc, const gchar *locale_filename,
gint bytes_written;
gint err = 0;
g_return_val_if_fail(G_LIKELY(data != NULL), EINVAL);
g_return_val_if_fail(data != NULL, EINVAL);
fp = g_fopen(locale_filename, "wb");
if (G_UNLIKELY(fp == NULL))
@ -1700,8 +1694,7 @@ gboolean document_save_file(GeanyDocument *doc, gboolean force)
gint err;
gchar *locale_filename;
if (G_UNLIKELY(doc == NULL))
return FALSE;
g_return_val_if_fail(doc != NULL, FALSE);
/* the "changed" flag should exclude the "readonly" flag, but check it anyway for safety */
if (! force && ! ui_prefs.allow_always_save && (! doc->changed || doc->readonly))
@ -1781,7 +1774,7 @@ gboolean document_save_file(GeanyDocument *doc, gboolean force)
store_saved_encoding(doc);
/* ignore the following things if we are quitting */
if (G_LIKELY(! main_status.quitting))
if (! main_status.quitting)
{
sci_set_savepoint(doc->editor->sci);
@ -1815,10 +1808,9 @@ gboolean document_search_bar_find(GeanyDocument *doc, const gchar *text, gint fl
gint start_pos, search_pos;
struct TextToFind ttf;
g_return_val_if_fail(G_LIKELY(text != NULL), FALSE);
if (G_UNLIKELY(doc == NULL))
return FALSE;
if (G_UNLIKELY(! *text))
g_return_val_if_fail(text != NULL, FALSE);
g_return_val_if_fail(doc != NULL, FALSE);
if (! *text)
return TRUE;
start_pos = (inc) ? sci_get_selection_start(doc->editor->sci) :
@ -1877,8 +1869,8 @@ gint document_find_text(GeanyDocument *doc, const gchar *text, gint flags, gbool
{
gint selection_end, selection_start, search_pos;
g_return_val_if_fail(G_LIKELY(doc != NULL) && G_LIKELY(text != NULL), -1);
if (G_UNLIKELY(! *text))
g_return_val_if_fail(doc != NULL && text != NULL, -1);
if (! *text)
return -1;
/* Sci doesn't support searching backwards with a regex */
@ -1949,10 +1941,9 @@ gint document_replace_text(GeanyDocument *doc, const gchar *find_text, const gch
{
gint selection_end, selection_start, search_pos;
g_return_val_if_fail(G_LIKELY(doc != NULL) && G_LIKELY(find_text != NULL) &&
G_LIKELY(replace_text != NULL), -1);
g_return_val_if_fail(doc != NULL && find_text != NULL && replace_text != NULL, -1);
if (G_UNLIKELY(! *find_text))
if (! *find_text)
return -1;
/* Sci doesn't support searching backwards with a regex */
@ -2050,10 +2041,9 @@ document_replace_range(GeanyDocument *doc, const gchar *find_text, const gchar *
if (new_range_end != NULL)
*new_range_end = -1;
g_return_val_if_fail(G_LIKELY(doc != NULL) && G_LIKELY(find_text != NULL) &&
G_LIKELY(replace_text != NULL), 0);
g_return_val_if_fail(doc != NULL && find_text != NULL && replace_text != NULL, 0);
if (G_UNLIKELY(! *find_text) || doc->readonly)
if (! *find_text || doc->readonly)
return 0;
sci = doc->editor->sci;
@ -2127,10 +2117,9 @@ void document_replace_sel(GeanyDocument *doc, const gchar *find_text, const gcha
gint max_column = 0, count = 0;
gboolean replaced = FALSE;
g_return_if_fail(G_LIKELY(doc != NULL) && G_LIKELY(find_text != NULL) &&
G_LIKELY(replace_text != NULL));
g_return_if_fail(doc != NULL && find_text != NULL && replace_text != NULL);
if (G_UNLIKELY(! *find_text))
if (! *find_text)
return;
selection_start = sci_get_selection_start(doc->editor->sci);
@ -2228,10 +2217,9 @@ gboolean document_replace_all(GeanyDocument *doc, const gchar *find_text, const
gint flags, gboolean escaped_chars)
{
gint len, count;
g_return_val_if_fail(G_LIKELY(doc != NULL) && G_LIKELY(find_text != NULL) &&
G_LIKELY(replace_text != NULL), FALSE);
g_return_val_if_fail(doc != NULL && find_text != NULL && replace_text != NULL, FALSE);
if (G_UNLIKELY(! *find_text))
if (! *find_text)
return FALSE;
len = sci_get_length(doc->editor->sci);
@ -2271,16 +2259,15 @@ void document_update_tag_list(GeanyDocument *doc, gboolean update)
gboolean success = FALSE;
/* if the filetype doesn't have a tag parser or it is a new file */
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(doc->file_type == NULL) ||
G_UNLIKELY(app->tm_workspace == NULL) ||
! filetype_has_tags(doc->file_type) || G_UNLIKELY(! doc->file_name))
if (doc == NULL || doc->file_type == NULL || app->tm_workspace == NULL ||
! filetype_has_tags(doc->file_type) || ! doc->file_name)
{
/* set the default (empty) tag list */
treeviews_update_tag_list(doc, FALSE);
return;
}
if (G_UNLIKELY(doc->tm_file == NULL))
if (doc->tm_file == NULL)
{
gchar *locale_filename = utils_get_locale_from_utf8(doc->file_name);
@ -2320,7 +2307,7 @@ static gboolean get_project_typenames(const GString **types, gint lang)
static GString *last_typenames = NULL;
GString *s = NULL;
if (G_LIKELY(app->tm_workspace))
if (app->tm_workspace)
{
GPtrArray *tags_array = app->tm_workspace->work_object.tags_array;
@ -2360,7 +2347,7 @@ static gboolean update_type_keywords(GeanyDocument *doc, gint lang)
const GString *s;
ScintillaObject *sci;
g_return_val_if_fail(G_LIKELY(doc != NULL), FALSE);
g_return_val_if_fail(doc != NULL, FALSE);
sci = doc->editor->sci;
switch (FILETYPE_ID(doc->file_type))
@ -2377,7 +2364,7 @@ static gboolean update_type_keywords(GeanyDocument *doc, gint lang)
}
sci = doc->editor->sci;
if (G_UNLIKELY(sci != NULL) && editor_lexer_get_type_keyword_idx(sci_get_lexer(sci)) == -1)
if (sci != NULL && editor_lexer_get_type_keyword_idx(sci_get_lexer(sci)) == -1)
return FALSE;
if (! get_project_typenames(&s, lang))
@ -2391,7 +2378,7 @@ static gboolean update_type_keywords(GeanyDocument *doc, gint lang)
}
return FALSE;
}
g_return_val_if_fail(G_LIKELY(s != NULL), FALSE);
g_return_val_if_fail(s != NULL, FALSE);
for (n = 0; n < documents_array->len; n++)
{
@ -2419,7 +2406,7 @@ void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type)
{
gboolean ft_changed;
if (G_UNLIKELY(type == NULL) || G_UNLIKELY(doc == NULL))
if (type == NULL || doc == NULL)
return;
geany_debug("%s : %s (%s)",
@ -2461,7 +2448,7 @@ void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type)
**/
void document_set_encoding(GeanyDocument *doc, const gchar *new_encoding)
{
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(new_encoding == NULL) ||
if (doc == NULL || new_encoding == NULL ||
utils_str_equal(new_encoding, doc->encoding))
return;
@ -2522,8 +2509,7 @@ void document_undo_add(GeanyDocument *doc, guint type, gpointer data)
{
undo_action *action;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
action = g_new0(undo_action, 1);
action->type = type;
@ -2538,8 +2524,7 @@ void document_undo_add(GeanyDocument *doc, guint type, gpointer data)
gboolean document_can_undo(GeanyDocument *doc)
{
if (G_UNLIKELY(doc == NULL))
return FALSE;
g_return_val_if_fail(doc != NULL, FALSE);
if (g_trash_stack_height(&doc->priv->undo_actions) > 0 || sci_can_undo(doc->editor->sci))
return TRUE;
@ -2562,8 +2547,7 @@ void document_undo(GeanyDocument *doc)
{
undo_action *action;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
action = g_trash_stack_pop(&doc->priv->undo_actions);
@ -2619,8 +2603,7 @@ void document_undo(GeanyDocument *doc)
gboolean document_can_redo(GeanyDocument *doc)
{
if (G_UNLIKELY(doc == NULL))
return FALSE;
g_return_val_if_fail(doc != NULL, FALSE);
if (g_trash_stack_height(&doc->priv->redo_actions) > 0 || sci_can_redo(doc->editor->sci))
return TRUE;
@ -2633,8 +2616,7 @@ void document_redo(GeanyDocument *doc)
{
undo_action *action;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
action = g_trash_stack_pop(&doc->priv->redo_actions);
@ -2691,8 +2673,7 @@ static void document_redo_add(GeanyDocument *doc, guint type, gpointer data)
{
undo_action *action;
if G_UNLIKELY((doc == NULL))
return;
g_return_if_fail(doc != NULL);
action = g_new0(undo_action, 1);
action->type = type;
@ -2724,8 +2705,7 @@ const GdkColor *document_get_status_color(GeanyDocument *doc)
/*static GdkColor orange = {0, 0xFFFF, 0x7FFF, 0};*/
GdkColor *color = NULL;
if (G_UNLIKELY(doc == NULL))
return NULL;
g_return_val_if_fail(doc != NULL, NULL);
if (doc->changed)
color = &red;
@ -2752,8 +2732,7 @@ const GdkColor *document_get_status_color(GeanyDocument *doc)
*/
GeanyDocument *document_index(gint idx)
{
return (G_LIKELY(idx >= 0) && G_LIKELY(idx < (gint) documents_array->len)) ?
documents[idx] : NULL;
return (idx >= 0 && idx < (gint) documents_array->len) ? documents[idx] : NULL;
}
@ -2764,7 +2743,7 @@ GeanyDocument *document_clone(GeanyDocument *old_doc, const gchar *utf8_filename
gchar *text;
GeanyDocument *doc;
g_return_val_if_fail(G_LIKELY(old_doc != NULL), NULL);
g_return_val_if_fail(old_doc != NULL, NULL);
len = sci_get_length(old_doc->editor->sci) + 1;
text = (gchar*) g_malloc(len);

View File

@ -598,7 +598,7 @@ static gboolean reshow_calltip(gpointer data)
{
SCNotification *nt = data;
g_return_val_if_fail(G_LIKELY(calltip.sci != NULL), FALSE);
g_return_val_if_fail(calltip.sci != NULL, FALSE);
SSM(calltip.sci, SCI_CALLTIPCANCEL, 0, 0);
/* we use the position where the calltip was previously started as SCI_GETCURRENTPOS
@ -644,7 +644,7 @@ void editor_sci_notify_cb(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gint sc
GeanyEditor *editor = data;
gboolean retval;
g_return_if_fail(G_LIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
g_signal_emit_by_name(geany_object, "editor-notify", editor, scnt, &retval);
}
@ -797,7 +797,7 @@ static gint get_tab_width(const GeanyIndentPrefs *indent_prefs)
static gchar *
get_whitespace(const GeanyIndentPrefs *iprefs, gint width)
{
g_return_val_if_fail(G_LIKELY(width >= 0), NULL);
g_return_val_if_fail(width >= 0, NULL);
if (width == 0)
return g_strdup("");
@ -847,7 +847,7 @@ editor_get_indent_prefs(GeanyEditor *editor)
iprefs = *get_default_indent_prefs();
if (G_UNLIKELY(editor == NULL))
if (editor == NULL)
return &iprefs;
iprefs.type = editor->indent_type;
@ -998,7 +998,7 @@ static gint get_indent_size_after_line(GeanyEditor *editor, gint line)
gint size;
const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
g_return_val_if_fail(G_LIKELY(line >= 0), 0);
g_return_val_if_fail(line >= 0, 0);
size = sci_get_line_indentation(sci, line);
@ -1020,7 +1020,7 @@ static void insert_indent_after_line(GeanyEditor *editor, gint line)
gint size = get_indent_size_after_line(editor, line);
const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
if (G_LIKELY(size > 0))
if (size > 0)
{
gchar *text;
@ -1123,7 +1123,7 @@ static void close_block(GeanyEditor *editor, gint pos)
if (iprefs->auto_indent_mode < GEANY_AUTOINDENT_CURRENTCHARS)
return;
g_return_if_fail(G_LIKELY(editor != NULL) && G_LIKELY(editor->document->file_type != NULL));
g_return_if_fail(editor != NULL && editor->document->file_type != NULL);
sci = editor->sci;
doc = editor->document;
@ -1196,8 +1196,7 @@ static void read_current_word(GeanyEditor *editor, gint pos, gchar *word, size_t
gchar *chunk;
ScintillaObject *sci;
if (G_UNLIKELY(editor == NULL))
return;
g_return_if_fail(editor != NULL);
sci = editor->sci;
if (pos == -1)
@ -1270,7 +1269,7 @@ gchar *editor_get_word_at_pos(GeanyEditor *editor, gint pos, const gchar *wordch
{
static gchar cword[GEANY_MAX_WORD_LENGTH];
g_return_val_if_fail(G_LIKELY(editor != NULL), FALSE);
g_return_val_if_fail(editor != NULL, FALSE);
read_current_word(editor, pos, cword, sizeof(cword), wordchars, FALSE);
@ -1367,7 +1366,7 @@ static gchar *find_calltip(const gchar *word, GeanyFiletype *ft)
GString *str = NULL;
guint i;
g_return_val_if_fail(G_LIKELY(ft) && G_LIKELY(word) && G_LIKELY(*word), NULL);
g_return_val_if_fail(ft && word && *word, NULL);
tags = tm_workspace_find(word, arg_types | tm_tag_class_t, attrs, FALSE, ft->lang);
if (tags->len == 0)
@ -1452,8 +1451,9 @@ gboolean editor_show_calltip(GeanyEditor *editor, gint pos)
gchar *str;
ScintillaObject *sci;
if (G_UNLIKELY(editor == NULL) || G_UNLIKELY(editor->document->file_type == NULL))
return FALSE;
g_return_val_if_fail(editor != NULL, FALSE);
g_return_val_if_fail(editor->document->file_type != NULL, FALSE);
sci = editor->sci;
lexer = SSM(sci, SCI_GETLEXER, 0, 0);
@ -1466,7 +1466,7 @@ gboolean editor_show_calltip(GeanyEditor *editor, gint pos)
orig_pos = pos;
pos = (lexer == SCLEX_LATEX) ? find_previous_brace(sci, pos) :
find_start_bracket(sci, pos);
if (G_UNLIKELY(pos == -1))
if (pos == -1)
return FALSE;
}
@ -1500,7 +1500,7 @@ gchar *editor_get_calltip_text(GeanyEditor *editor, const TMTag *tag)
{
GString *str;
g_return_val_if_fail(G_LIKELY(editor != NULL), NULL);
g_return_val_if_fail(editor != NULL, NULL);
str = g_string_new(NULL);
if (append_calltip(str, tag, FILETYPE_ID(editor->document->file_type)))
@ -1531,9 +1531,9 @@ autocomplete_html(ScintillaObject *sci, const gchar *root, gsize rootlen)
words = g_string_sized_new(500);
for (i = 0; ; i++)
{
if (G_UNLIKELY(entities[i] == NULL))
if (entities[i] == NULL)
break;
else if (G_UNLIKELY(entities[i][0] == '#'))
else if (entities[i][0] == '#')
continue;
if (! strncmp(entities[i], root, rootlen))
@ -1559,8 +1559,7 @@ autocomplete_tags(GeanyEditor *editor, const gchar *root, gsize rootlen)
ScintillaObject *sci;
GeanyDocument *doc;
g_return_val_if_fail(G_LIKELY(editor != NULL) &&
G_LIKELY(editor->document->file_type != NULL), FALSE);
g_return_val_if_fail(editor != NULL && editor->document->file_type != NULL, FALSE);
sci = editor->sci;
doc = editor->document;
@ -1573,7 +1572,7 @@ autocomplete_tags(GeanyEditor *editor, const gchar *root, gsize rootlen)
for (j = 0; j < tags->len; ++j)
{
if (G_LIKELY(j > 0))
if (j > 0)
g_string_append_c(words, '\n');
if (j == editor_prefs.autocompletion_max_entries)
@ -1623,9 +1622,9 @@ gboolean editor_start_auto_complete(GeanyEditor *editor, gint pos, gboolean forc
if (! editor_prefs.auto_complete_symbols && ! force)
return FALSE;
g_return_val_if_fail(G_LIKELY(editor != NULL), FALSE);
g_return_val_if_fail(editor != NULL, FALSE);
if (G_UNLIKELY(editor->document->file_type == NULL))
if (editor->document->file_type == NULL)
return FALSE;
/* If we are at the beginning of the document, we skip autocompletion as we can't determine the
@ -1684,7 +1683,7 @@ void editor_auto_latex(GeanyEditor *editor, gint pos)
{
ScintillaObject *sci;
g_return_if_fail(G_LIKELY(editor != NULL) && G_LIKELY(editor->document->file_type != NULL));
g_return_if_fail(editor != NULL && editor->document->file_type != NULL);
sci = editor->sci;
@ -1797,8 +1796,8 @@ void snippets_replace_specials(gpointer key, gpointer value, gpointer user_data)
{
gchar *needle;
if (G_UNLIKELY(key == NULL) || G_UNLIKELY(value == NULL))
return;
g_return_if_fail(key != NULL);
g_return_if_fail(value != NULL);
needle = g_strconcat("%", (gchar*) key, "%", NULL);
@ -1868,7 +1867,7 @@ static void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gin
GString *buf;
const gchar cur_marker[] = "__GEANY_CURSOR_MARKER__";
g_return_if_fail(G_LIKELY(text));
g_return_if_fail(text);
buf = g_string_new(text);
@ -1922,7 +1921,7 @@ static void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gin
* Can, and should, be optimized to give better results */
void snippet_goto_next_cursor(ScintillaObject *sci, gint current_pos)
{
if (G_LIKELY(snippet_queue))
if (snippet_queue)
{
gpointer offset;
@ -2089,8 +2088,7 @@ gboolean editor_complete_snippet(GeanyEditor *editor, gint pos)
const gchar *word;
ScintillaObject *sci;
if (G_UNLIKELY(editor == NULL))
return FALSE;
g_return_val_if_fail(editor != NULL, FALSE);
sci = editor->sci;
/* return if we are editing an existing line (chars on right of cursor) */
@ -2125,11 +2123,11 @@ void editor_show_macro_list(GeanyEditor *editor)
{
GString *words;
if (G_UNLIKELY(editor == NULL) || G_UNLIKELY(editor->document->file_type == NULL))
if (editor == NULL || editor->document->file_type == NULL)
return;
words = symbols_get_macro_list(editor->document->file_type->lang);
if (G_UNLIKELY(words == NULL))
if (words == NULL)
return;
SSM(editor->sci, SCI_USERLISTSHOW, 1, (sptr_t) words->str);
@ -2310,7 +2308,7 @@ static void real_comment_multiline(GeanyEditor *editor, gint line_start, gint la
gchar *str_begin, *str_end, *co, *cc;
gint line_len;
g_return_if_fail(G_LIKELY(editor != NULL) && G_LIKELY(editor->document->file_type != NULL));
g_return_if_fail(editor != NULL && editor->document->file_type != NULL);
eol = editor_get_eol_char(editor);
co = editor->document->file_type->comment_open;
@ -2335,7 +2333,7 @@ static void real_uncomment_multiline(GeanyEditor *editor)
gchar *linebuf;
GeanyDocument *doc;
g_return_if_fail(G_LIKELY(editor != NULL) && G_LIKELY(editor->document->file_type != NULL));
g_return_if_fail(editor != NULL && editor->document->file_type != NULL);
doc = editor->document;
/* remove comment open chars */
@ -2380,8 +2378,7 @@ gint editor_do_uncomment(GeanyEditor *editor, gint line, gboolean toggle)
gboolean break_loop = FALSE, single_line = FALSE;
GeanyFiletype *ft;
g_return_val_if_fail(G_LIKELY(editor != NULL) &&
G_LIKELY(editor->document->file_type != NULL), 0);
g_return_val_if_fail(editor != NULL && editor->document->file_type != NULL, 0);
if (line < 0)
{ /* use selection or current line */
@ -2412,11 +2409,11 @@ gint editor_do_uncomment(GeanyEditor *editor, gint line, gboolean toggle)
co = ft->comment_open;
cc = ft->comment_close;
if (G_UNLIKELY(co == NULL))
if (co == NULL)
return 0;
co_len = strlen(co);
if (G_UNLIKELY(co_len == 0))
if (co_len == 0)
return 0;
SSM(editor->sci, SCI_BEGINUNDOACTION, 0, 0);
@ -2535,7 +2532,7 @@ void editor_do_comment_toggle(GeanyEditor *editor)
gsize tm_len = strlen(editor_prefs.comment_toggle_mark);
GeanyFiletype *ft;
g_return_if_fail(G_LIKELY(editor != NULL) && G_LIKELY(editor->document->file_type != NULL));
g_return_if_fail(editor != NULL && editor->document->file_type != NULL);
sel_start = sci_get_selection_start(editor->sci);
sel_end = sci_get_selection_end(editor->sci);
@ -2559,11 +2556,11 @@ void editor_do_comment_toggle(GeanyEditor *editor)
co = ft->comment_open;
cc = ft->comment_close;
if (G_UNLIKELY(co == NULL))
if (co == NULL)
return;
co_len = strlen(co);
if (G_UNLIKELY(co_len == 0))
if (co_len == 0)
return;
SSM(editor->sci, SCI_BEGINUNDOACTION, 0, 0);
@ -2703,7 +2700,7 @@ void editor_do_comment(GeanyEditor *editor, gint line, gboolean allow_empty_line
gboolean break_loop = FALSE, single_line = FALSE;
GeanyFiletype *ft;
g_return_if_fail(G_LIKELY(editor != NULL) && G_LIKELY(editor->document->file_type != NULL));
g_return_if_fail(editor != NULL && editor->document->file_type != NULL);
if (line < 0)
{ /* use selection or current line */
@ -2734,11 +2731,11 @@ void editor_do_comment(GeanyEditor *editor, gint line, gboolean allow_empty_line
co = ft->comment_open;
cc = ft->comment_close;
if (G_UNLIKELY(co == NULL))
if (co == NULL)
return;
co_len = strlen(co);
if (G_UNLIKELY(co_len == 0))
if (co_len == 0)
return;
SSM(editor->sci, SCI_BEGINUNDOACTION, 0, 0);
@ -3263,9 +3260,8 @@ void editor_insert_multiline_comment(GeanyEditor *editor)
gboolean have_multiline_comment = FALSE;
GeanyDocument *doc;
g_return_if_fail(G_LIKELY(editor != NULL) &&
G_LIKELY(editor->document->file_type != NULL) &&
G_LIKELY(editor->document->file_type->comment_open != NULL));
g_return_if_fail(editor != NULL &&
editor->document->file_type != NULL && editor->document->file_type->comment_open != NULL);
doc = editor->document;
@ -3323,8 +3319,7 @@ void editor_scroll_to_line(GeanyEditor *editor, gint line, gfloat percent_of_vie
gint vis1, los, delta;
GtkWidget *wid;
if (G_UNLIKELY(editor == NULL))
return;
g_return_if_fail(editor != NULL);
wid = GTK_WIDGET(editor->sci);
@ -3352,8 +3347,7 @@ void editor_insert_alternative_whitespace(GeanyEditor *editor)
gchar *text;
GeanyIndentPrefs iprefs = *editor_get_indent_prefs(editor);
if (G_UNLIKELY(editor == NULL))
return;
g_return_if_fail(editor != NULL);
switch (iprefs.type)
{
@ -3377,7 +3371,7 @@ void editor_select_word(GeanyEditor *editor)
gint start;
gint end;
g_return_if_fail(G_LIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
pos = SSM(editor->sci, SCI_GETCURRENTPOS, 0, 0);
start = SSM(editor->sci, SCI_WORDSTARTPOSITION, pos, TRUE);
@ -3403,7 +3397,7 @@ void editor_select_lines(GeanyEditor *editor, gboolean extra_line)
{
gint start, end, line;
g_return_if_fail(G_LIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
start = sci_get_selection_start(editor->sci);
end = sci_get_selection_end(editor->sci);
@ -3477,7 +3471,7 @@ void editor_select_paragraph(GeanyEditor *editor)
{
gint pos_start, pos_end, line_start, line_found;
g_return_if_fail(G_LIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
line_start = SSM(editor->sci, SCI_LINEFROMPOSITION,
SSM(editor->sci, SCI_GETCURRENTPOS, 0, 0), 0);
@ -3536,7 +3530,7 @@ void editor_smart_line_indentation(GeanyEditor *editor, gint pos)
gint first_sel_start, first_sel_end;
ScintillaObject *sci;
g_return_if_fail(G_LIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
sci = editor->sci;
@ -3580,7 +3574,7 @@ void editor_indentation_by_one_space(GeanyEditor *editor, gint pos, gboolean dec
gint i, first_line, last_line, line_start, indentation_end, count = 0;
gint sel_start, sel_end, first_line_offset = 0;
g_return_if_fail(G_LIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
sel_start = sci_get_selection_start(editor->sci);
sel_end = sci_get_selection_end(editor->sci);
@ -3654,8 +3648,7 @@ gchar *editor_get_default_selection(GeanyEditor *editor, gboolean use_current_wo
{
gchar *s = NULL;
if (G_UNLIKELY(editor == NULL))
return NULL;
g_return_val_if_fail(editor != NULL, NULL);
if (sci_get_lines_selected(editor->sci) == 1)
{
@ -3683,8 +3676,7 @@ gboolean editor_line_in_view(GeanyEditor *editor, gint line)
{
gint vis1, los;
if (G_UNLIKELY(editor == NULL))
return FALSE;
g_return_val_if_fail(editor != NULL, FALSE);
/* If line is wrapped the result may occur on another virtual line than the first and may be
* still hidden, so increase the line number to check for the next document line */
@ -3705,8 +3697,7 @@ void editor_display_current_line(GeanyEditor *editor, gfloat percent_of_view)
{
gint line;
if (G_UNLIKELY(editor == NULL))
return;
g_return_if_fail(editor != NULL);
line = sci_get_current_line(editor->sci);
@ -3744,10 +3735,10 @@ void editor_indicator_clear(GeanyEditor *editor, gint indic)
{
glong last_pos;
g_return_if_fail(G_LIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
last_pos = sci_get_length(editor->sci);
if (G_LIKELY(last_pos > 0))
if (last_pos > 0)
{
sci_indicator_set(editor->sci, indic);
sci_indicator_clear(editor->sci, 0, last_pos);
@ -3771,8 +3762,7 @@ void editor_indicator_set_on_line(GeanyEditor *editor, gint indic, gint line)
guint i = 0, len;
gchar *linebuf;
if (G_UNLIKELY(editor == NULL))
return;
g_return_if_fail(editor != NULL);
start = sci_get_position_from_line(editor->sci, line);
end = sci_get_position_from_line(editor->sci, line + 1);
@ -3812,7 +3802,8 @@ void editor_indicator_set_on_line(GeanyEditor *editor, gint indic, gint line)
*/
void editor_indicator_set_on_range(GeanyEditor *editor, gint indic, gint start, gint end)
{
if (G_UNLIKELY(editor == NULL) || G_UNLIKELY(start >= end))
g_return_if_fail(editor != NULL);
if (start >= end)
return;
sci_indicator_set(editor->sci, indic);
@ -3824,7 +3815,7 @@ void editor_indicator_set_on_range(GeanyEditor *editor, gint indic, gint start,
* the replacement will also start with 0x... */
void editor_insert_color(GeanyEditor *editor, const gchar *colour)
{
g_return_if_fail(G_LIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
if (sci_has_selection(editor->sci))
{
@ -3853,7 +3844,7 @@ const gchar *editor_get_eol_char_name(GeanyEditor *editor)
{
gint mode = file_prefs.default_eol_character;
if (G_LIKELY(editor != NULL))
if (editor != NULL)
mode = sci_get_eol_mode(editor->sci);
switch (mode)
@ -3870,7 +3861,7 @@ gint editor_get_eol_char_len(GeanyEditor *editor)
{
gint mode = file_prefs.default_eol_character;
if (G_LIKELY(editor != NULL))
if (editor != NULL)
mode = sci_get_eol_mode(editor->sci);
switch (mode)
@ -3886,7 +3877,7 @@ const gchar *editor_get_eol_char(GeanyEditor *editor)
{
gint mode = file_prefs.default_eol_character;
if (G_LIKELY(editor != NULL))
if (editor != NULL)
mode = sci_get_eol_mode(editor->sci);
switch (mode)
@ -3902,7 +3893,7 @@ static void fold_all(GeanyEditor *editor, gboolean want_fold)
{
gint lines, first, i;
if (G_UNLIKELY(editor == NULL) || ! editor_prefs.folding)
if (editor == NULL || ! editor_prefs.folding)
return;
lines = sci_get_line_count(editor->sci);
@ -3940,8 +3931,7 @@ void editor_replace_tabs(GeanyEditor *editor)
gchar *tab_str;
struct TextToFind ttf;
if (G_UNLIKELY(editor == NULL))
return;
g_return_if_fail(editor != NULL);
sci_start_undo_action(editor->sci);
tab_len = sci_get_tab_width(editor->sci);
@ -3979,10 +3969,9 @@ void editor_replace_spaces(GeanyEditor *editor)
gint tab_len;
struct TextToFind ttf;
if (G_UNLIKELY(editor == NULL))
return;
g_return_if_fail(editor != NULL);
if (G_UNLIKELY(tab_len_f < 0.0))
if (tab_len_f < 0.0)
tab_len_f = sci_get_tab_width(editor->sci);
if (! dialogs_show_input_numeric(
@ -4059,11 +4048,11 @@ void editor_ensure_final_newline(GeanyEditor *editor)
gboolean append_newline = (max_lines == 1);
gint end_document = sci_get_position_from_line(editor->sci, max_lines);
if (G_LIKELY(max_lines > 1))
if (max_lines > 1)
{
append_newline = end_document > sci_get_position_from_line(editor->sci, max_lines - 1);
}
if (G_LIKELY(append_newline))
if (append_newline)
{
const gchar *eol = "\n";
switch (sci_get_eol_mode(editor->sci))
@ -4086,7 +4075,7 @@ void editor_set_font(GeanyEditor *editor, const gchar *font)
gchar *font_name;
PangoFontDescription *pfd;
g_return_if_fail(G_LIKELY(editor));
g_return_if_fail(editor);
pfd = pango_font_description_from_string(font);
size = pango_font_description_get_size(pfd) / PANGO_SCALE;
@ -4109,7 +4098,7 @@ void editor_set_font(GeanyEditor *editor, const gchar *font)
void editor_set_line_wrapping(GeanyEditor *editor, gboolean wrap)
{
g_return_if_fail(G_LIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
editor->line_wrapping = wrap;
sci_set_lines_wrapped(editor->sci, wrap);
@ -4147,8 +4136,8 @@ gboolean editor_goto_line(GeanyEditor *editor, gint line)
{
gint pos;
g_return_val_if_fail(G_LIKELY(editor), FALSE);
if (G_UNLIKELY(line < 0) || G_UNLIKELY(line >= sci_get_line_count(editor->sci)))
g_return_val_if_fail(editor, FALSE);
if (line < 0 || line >= sci_get_line_count(editor->sci))
return FALSE;
pos = sci_get_position_from_line(editor->sci, line);
@ -4162,7 +4151,7 @@ gboolean editor_goto_pos(GeanyEditor *editor, gint pos, gboolean mark)
{
gint page_num;
g_return_val_if_fail(G_LIKELY(editor), FALSE);
g_return_val_if_fail(editor, FALSE);
if (G_UNLIKELY(pos < 0))
return FALSE;
@ -4193,12 +4182,12 @@ on_editor_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_d
/* Handle scroll events if Alt is pressed and scroll whole pages instead of a
* few lines only, maybe this could/should be done in Scintilla directly */
if (G_UNLIKELY(event->state & GDK_MOD1_MASK))
if (event->state & GDK_MOD1_MASK)
{
sci_send_command(editor->sci, (event->direction == GDK_SCROLL_DOWN) ? SCI_PAGEDOWN : SCI_PAGEUP);
return TRUE;
}
else if (G_UNLIKELY(event->state & GDK_SHIFT_MASK))
else if (event->state & GDK_SHIFT_MASK)
{
gint amount = (event->direction == GDK_SCROLL_DOWN) ? 8 : -8;
@ -4462,7 +4451,7 @@ void editor_apply_update_prefs(GeanyEditor *editor)
{
ScintillaObject *sci;
g_return_if_fail(G_UNLIKELY(editor != NULL));
g_return_if_fail(editor != NULL);
sci = editor->sci;

View File

@ -150,7 +150,7 @@ GeanyEncodingIndex encodings_get_idx_from_charset(const gchar *charset)
{
gint i;
if (G_UNLIKELY(charset == NULL))
if (charset == NULL)
return GEANY_ENCODING_UTF_8;
i = 0;
@ -169,7 +169,7 @@ const GeanyEncoding *encodings_get_from_charset(const gchar *charset)
{
gint i;
if (G_UNLIKELY(charset == NULL))
if (charset == NULL)
return &encodings[GEANY_ENCODING_UTF_8];
i = 0;
@ -187,7 +187,7 @@ const GeanyEncoding *encodings_get_from_charset(const gchar *charset)
const GeanyEncoding *encodings_get_from_index(gint idx)
{
g_return_val_if_fail(G_LIKELY(idx >= 0) && G_LIKELY(idx < GEANY_ENCODINGS_MAX), NULL);
g_return_val_if_fail(idx >= 0 && idx < GEANY_ENCODINGS_MAX, NULL);
return &encodings[idx];
}
@ -206,7 +206,7 @@ const GeanyEncoding *encodings_get_from_index(gint idx)
**/
const gchar* encodings_get_charset_from_index(gint idx)
{
g_return_val_if_fail(G_LIKELY(idx >= 0) && G_LIKELY(idx < GEANY_ENCODINGS_MAX), NULL);
g_return_val_if_fail(idx >= 0 && idx < GEANY_ENCODINGS_MAX, NULL);
return encodings[idx].charset;
}
@ -214,9 +214,9 @@ const gchar* encodings_get_charset_from_index(gint idx)
gchar *encodings_to_string(const GeanyEncoding* enc)
{
g_return_val_if_fail(G_LIKELY(enc != NULL), NULL);
g_return_val_if_fail(G_LIKELY(enc->name != NULL), NULL);
g_return_val_if_fail(G_LIKELY(enc->charset != NULL), NULL);
g_return_val_if_fail(enc != NULL, NULL);
g_return_val_if_fail(enc->name != NULL, NULL);
g_return_val_if_fail(enc->charset != NULL, NULL);
return g_strdup_printf("%s (%s)", enc->name, enc->charset);
}
@ -224,8 +224,8 @@ gchar *encodings_to_string(const GeanyEncoding* enc)
const gchar *encodings_get_charset(const GeanyEncoding* enc)
{
g_return_val_if_fail(G_LIKELY(enc != NULL), NULL);
g_return_val_if_fail(G_LIKELY(enc->charset != NULL), NULL);
g_return_val_if_fail(enc != NULL, NULL);
g_return_val_if_fail(enc->charset != NULL, NULL);
return enc->charset;
}
@ -237,7 +237,7 @@ void encodings_select_radio_item(const gchar *charset)
{
gint i;
g_return_if_fail(G_LIKELY(charset != NULL));
g_return_if_fail(charset != NULL);
i = 0;
while (i < GEANY_ENCODINGS_MAX)
@ -246,7 +246,7 @@ void encodings_select_radio_item(const gchar *charset)
break;
i++;
}
if (G_UNLIKELY(i == GEANY_ENCODINGS_MAX))
if (i == GEANY_ENCODINGS_MAX)
i = GEANY_ENCODING_UTF_8; /* fallback to UTF-8 */
/* ignore_callback has to be set by the caller */
@ -263,7 +263,7 @@ void encodings_select_radio_item(const gchar *charset)
static void regex_compile(regex_t *preg, const gchar *pattern)
{
gint retval = regcomp(preg, pattern, REG_EXTENDED | REG_ICASE);
if (G_UNLIKELY(retval != 0))
if (retval != 0)
{
gchar errmsg[512];
regerror(retval, preg, errmsg, 512);
@ -304,7 +304,7 @@ static gchar *regex_match(regex_t *preg, const gchar *buffer, gsize size)
void encodings_finalize(void)
{
#ifdef HAVE_REGCOMP
if (G_LIKELY(pregs_loaded))
if (pregs_loaded)
{
guint i, len;
len = G_N_ELEMENTS(pregs);
@ -331,7 +331,7 @@ void encodings_init(void)
init_encodings();
#ifdef HAVE_REGCOMP
if (G_UNLIKELY(! pregs_loaded))
if (! pregs_loaded)
{
regex_compile(&pregs[0], PATTERN_HTMLMETA);
regex_compile(&pregs[1], PATTERN_CODING);
@ -448,8 +448,8 @@ gchar *encodings_convert_to_utf8_from_charset(const gchar *buffer, gsize size,
gchar* converted_contents = NULL;
gsize bytes_written;
g_return_val_if_fail(G_LIKELY(buffer != NULL), NULL);
g_return_val_if_fail(G_LIKELY(charset != NULL), NULL);
g_return_val_if_fail(buffer != NULL, NULL);
g_return_val_if_fail(charset != NULL, NULL);
converted_contents = g_convert(buffer, size, "UTF-8", charset, NULL,
&bytes_written, &conv_error);
@ -630,7 +630,7 @@ GeanyEncodingIndex encodings_scan_unicode_bom(const gchar *string, gsize len, gu
gboolean encodings_is_unicode_charset(const gchar *string)
{
if (G_LIKELY(string != NULL) &&
if (string != NULL &&
(strncmp(string, "UTF", 3) == 0 || strncmp(string, "UCS", 3) == 0))
{
return TRUE;

View File

@ -611,8 +611,8 @@ static gint cmp_filetype(gconstpointer pft1, gconstpointer pft2)
* and set the filetype::id field. */
static void filetype_add(GeanyFiletype *ft)
{
g_return_if_fail(G_LIKELY(ft));
g_return_if_fail(G_LIKELY(ft->name));
g_return_if_fail(ft);
g_return_if_fail(ft->name);
ft->id = filetypes_array->len; /* len will be the index for filetype_array */
g_ptr_array_add(filetypes_array, ft);
@ -627,8 +627,8 @@ void filetypes_init_types()
{
filetype_id ft_id;
g_return_if_fail(G_LIKELY(filetypes_array == NULL));
g_return_if_fail(G_LIKELY(filetypes_hash == NULL));
g_return_if_fail(filetypes_array == NULL);
g_return_if_fail(filetypes_hash == NULL);
filetypes_array = g_ptr_array_sized_new(GEANY_MAX_BUILT_IN_FILETYPES);
filetypes_hash = g_hash_table_new(g_str_hash, g_str_equal);
@ -902,7 +902,7 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file
if (ft != NULL)
return ft;
if (G_UNLIKELY(utf8_filename == NULL))
if (utf8_filename == NULL)
return filetypes[GEANY_FILETYPES_NONE];
return filetypes_detect_from_extension(utf8_filename);
@ -915,7 +915,7 @@ GeanyFiletype *filetypes_detect_from_document(GeanyDocument *doc)
GeanyFiletype *ft;
gchar *line;
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return filetypes[GEANY_FILETYPES_NONE];
line = sci_get_line(doc->editor->sci, 0);
@ -943,7 +943,7 @@ GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename)
f = g_fopen(locale_name, "r");
g_free(locale_name);
if (G_LIKELY(f != NULL))
if (f != NULL)
{
if (fgets(line, sizeof(line), f) != NULL)
{
@ -962,7 +962,7 @@ void filetypes_select_radio_item(const GeanyFiletype *ft)
/* ignore_callback has to be set by the caller */
g_return_if_fail(ignore_callback);
if (G_UNLIKELY(ft == NULL))
if (ft == NULL)
ft = filetypes[GEANY_FILETYPES_NONE];
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ft->priv->menu_item), TRUE);
@ -974,7 +974,7 @@ on_filetype_change (GtkMenuItem *menuitem,
gpointer user_data)
{
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(ignore_callback) || G_UNLIKELY(doc == NULL))
if (ignore_callback || doc == NULL)
return;
document_set_filetype(doc, (GeanyFiletype*)user_data);
@ -999,7 +999,7 @@ static void create_radio_menu_item(GtkWidget *menu, GeanyFiletype *ftype)
/* Remove a filetype pointer from the list of available filetypes. */
static void filetype_remove(GeanyFiletype *ft)
{
g_return_if_fail(G_LIKELY(ft));
g_return_if_fail(ft);
g_ptr_array_remove(filetypes_array, ft);
@ -1027,7 +1027,7 @@ static void filetype_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
GeanyFiletype *ft = data;
g_return_if_fail(G_LIKELY(ft != NULL));
g_return_if_fail(ft != NULL);
g_free(ft->name);
g_free(ft->title);
@ -1051,8 +1051,8 @@ static void filetype_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
/* frees the array and all related pointers */
void filetypes_free_types(void)
{
g_return_if_fail(G_LIKELY(filetypes_array != NULL));
g_return_if_fail(G_LIKELY(filetypes_hash != NULL));
g_return_if_fail(filetypes_array != NULL);
g_return_if_fail(filetypes_hash != NULL);
g_ptr_array_foreach(filetypes_array, filetype_free, NULL);
g_ptr_array_free(filetypes_array, TRUE);
@ -1176,7 +1176,7 @@ void filetypes_load_config(gint ft_id, gboolean reload)
GKeyFile *config, *config_home;
GeanyFiletypePrivate *pft;
g_return_if_fail(G_LIKELY(ft_id >= 0) && G_LIKELY(ft_id < (gint) filetypes_array->len));
g_return_if_fail(ft_id >= 0 && ft_id < (gint) filetypes_array->len);
pft = filetypes[ft_id]->priv;
@ -1245,7 +1245,7 @@ void filetypes_save_commands(void)
GKeyFile *config_home;
gchar *fname, *ext, *data;
if (G_LIKELY(! bp->modified))
if (! bp->modified)
continue;
ext = filetypes_get_conf_extension(i);
@ -1303,7 +1303,7 @@ GtkFileFilter *filetypes_create_file_filter(const GeanyFiletype *ft)
gint i;
const gchar *title;
g_return_val_if_fail(G_LIKELY(ft != NULL), NULL);
g_return_val_if_fail(ft != NULL, NULL);
new_filter = gtk_file_filter_new();
title = ft->id == GEANY_FILETYPES_NONE ? _("All files") : ft->title;
@ -1321,7 +1321,7 @@ GtkFileFilter *filetypes_create_file_filter(const GeanyFiletype *ft)
/* Indicates whether there is a tag parser for the filetype or not. */
gboolean filetype_has_tags(GeanyFiletype *ft)
{
g_return_val_if_fail(G_LIKELY(ft != NULL), FALSE);
g_return_val_if_fail(ft != NULL, FALSE);
return ft->lang >= 0;
}
@ -1389,9 +1389,9 @@ gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
if (!NZV(ft->error_regex_string))
return FALSE;
if (G_UNLIKELY(!ft->priv->error_regex_compiled))
if (!ft->priv->error_regex_compiled)
compile_regex(ft, regex);
if (G_UNLIKELY(!ft->priv->error_regex_compiled)) /* regex error */
if (!ft->priv->error_regex_compiled) /* regex error */
return FALSE;
if (regexec(regex, message, G_N_ELEMENTS(pmatch), pmatch, 0) != 0)
@ -1478,8 +1478,7 @@ void filetypes_read_extensions(void)
*/
GeanyFiletype *filetypes_index(gint idx)
{
return (G_LIKELY(idx >= 0) && G_LIKELY(idx < (gint) filetypes_array->len)) ?
filetypes[idx] : NULL;
return (idx >= 0 && idx < (gint) filetypes_array->len) ? filetypes[idx] : NULL;
}

View File

@ -68,7 +68,7 @@ static void menu_filled_cb(GtkContainer *container, GtkWidget *widget, gpointer
{
GeanyMenubuttonActionPrivate *priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(data);
if (G_UNLIKELY(! priv->menu_added))
if (! priv->menu_added)
{
gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(priv->button), priv->menu);
priv->menu_added = TRUE;
@ -161,7 +161,7 @@ GtkWidget *geany_menu_button_action_get_menu(GeanyMenubuttonAction *action)
{
GeanyMenubuttonActionPrivate *priv;
g_return_val_if_fail(G_LIKELY(action != NULL), NULL);
g_return_val_if_fail(action != NULL, NULL);
priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(action);

View File

@ -66,7 +66,7 @@ static void geany_cclosure_marshal_VOID__STRING_INT_POINTER(GClosure *closure, G
register GCClosure* cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail(G_LIKELY(n_param_vals == 4));
g_return_if_fail(n_param_vals == 4);
if (G_CCLOSURE_SWAP_DATA(closure))
{
@ -112,8 +112,8 @@ static void geany_cclosure_marshal_BOOL__POINTER_POINTER( GClosure *closure, GVa
register gpointer data1, data2;
gboolean v_return;
g_return_if_fail(G_LIKELY(return_value != NULL));
g_return_if_fail(G_LIKELY(n_param_values == 3));
g_return_if_fail(return_value != NULL);
g_return_if_fail(n_param_values == 3);
if (G_CCLOSURE_SWAP_DATA(closure))
{

View File

@ -84,7 +84,7 @@ static void geany_wrap_label_set_wrap_width(GtkWidget *widget, gsize width)
{
GeanyWrapLabelPrivate *priv;
if (G_UNLIKELY(width == 0))
if (width == 0)
return;
/*

View File

@ -121,7 +121,7 @@ static void get_keyfile_keywords(GKeyFile *config, GKeyFile *configh, const gcha
{
gchar *result;
if (G_UNLIKELY(config == NULL) || G_UNLIKELY(configh == NULL) || G_UNLIKELY(section == NULL))
if (config == NULL || configh == NULL || section == NULL)
{
style_sets[index].keywords[pos] = g_strdup(default_value);
return;
@ -131,7 +131,7 @@ static void get_keyfile_keywords(GKeyFile *config, GKeyFile *configh, const gcha
if (result == NULL)
result = g_key_file_get_string(config, section, key, NULL);
if (G_UNLIKELY(result == NULL))
if (result == NULL)
{
style_sets[index].keywords[pos] = g_strdup(default_value);
}
@ -146,7 +146,7 @@ static void get_keyfile_wordchars(GKeyFile *config, GKeyFile *configh, gchar **w
{
gchar *result;
if (G_UNLIKELY(config == NULL) || G_UNLIKELY(configh == NULL))
if (config == NULL || configh == NULL)
{
*wordchars = g_strdup(GEANY_WORDCHARS);
return;
@ -155,7 +155,7 @@ static void get_keyfile_wordchars(GKeyFile *config, GKeyFile *configh, gchar **w
result = g_key_file_get_string(configh, "settings", "wordchars", NULL);
if (result == NULL) result = g_key_file_get_string(config, "settings", "wordchars", NULL);
if (G_UNLIKELY(result == NULL))
if (result == NULL)
{
*wordchars = g_strdup(GEANY_WORDCHARS);
}
@ -179,11 +179,11 @@ static void get_keyfile_style(GKeyFile *config, GKeyFile *configh,
gchar **list;
gsize len;
g_return_if_fail(G_LIKELY(config));
g_return_if_fail(G_LIKELY(configh));
g_return_if_fail(G_LIKELY(key_name));
g_return_if_fail(G_LIKELY(default_style));
g_return_if_fail(G_LIKELY(style));
g_return_if_fail(config);
g_return_if_fail(configh);
g_return_if_fail(key_name);
g_return_if_fail(default_style);
g_return_if_fail(style);
list = g_key_file_get_string_list(configh, "styling", key_name, &len, NULL);
if (list == NULL)
@ -219,10 +219,10 @@ static void get_keyfile_hex(GKeyFile *config, GKeyFile *configh,
gchar **list;
gsize len;
g_return_if_fail(G_LIKELY(config));
g_return_if_fail(G_LIKELY(configh));
g_return_if_fail(G_LIKELY(section));
g_return_if_fail(G_LIKELY(key));
g_return_if_fail(config);
g_return_if_fail(configh);
g_return_if_fail(section);
g_return_if_fail(key);
list = g_key_file_get_string_list(configh, section, key, &len, NULL);
if (list == NULL)
@ -260,10 +260,10 @@ static void get_keyfile_int(GKeyFile *config, GKeyFile *configh, const gchar *se
gchar *end1, *end2;
gsize len;
g_return_if_fail(G_LIKELY(config));
g_return_if_fail(G_LIKELY(configh));
g_return_if_fail(G_LIKELY(section));
g_return_if_fail(G_LIKELY(key));
g_return_if_fail(config);
g_return_if_fail(configh);
g_return_if_fail(section);
g_return_if_fail(key);
list = g_key_file_get_string_list(configh, section, key, &len, NULL);
if (list == NULL)
@ -305,18 +305,18 @@ static guint invert(guint icolour)
static GeanyLexerStyle *get_style(guint ft_id, guint styling_index)
{
g_assert(G_LIKELY(ft_id < GEANY_MAX_BUILT_IN_FILETYPES));
g_assert(ft_id < GEANY_MAX_BUILT_IN_FILETYPES);
if (G_UNLIKELY(ft_id == GEANY_FILETYPES_NONE))
{
g_assert(G_LIKELY(styling_index < GCS_MAX));
g_assert(styling_index < GCS_MAX);
return &common_style_set.styling[styling_index];
}
else
{
StyleSet *set = &style_sets[ft_id];
g_assert(G_LIKELY(styling_index < set->count));
g_assert(styling_index < set->count);
return &set->styling[styling_index];
}
}
@ -354,11 +354,11 @@ static GString *get_global_typenames(gint lang)
{
GString *s = NULL;
if (G_LIKELY(app->tm_workspace))
if (app->tm_workspace)
{
GPtrArray *tags_array = app->tm_workspace->global_tags;
if (G_LIKELY(tags_array))
if (tags_array)
{
s = symbols_find_tags_as_string(tags_array, TM_GLOBAL_TYPE_MASK, lang);
}
@ -372,7 +372,7 @@ get_keyfile_whitespace_chars(GKeyFile *config, GKeyFile *configh)
{
gchar *result;
if (G_UNLIKELY(config == NULL) || G_UNLIKELY(configh == NULL))
if (config == NULL || configh == NULL)
{
result = NULL;
}
@ -392,7 +392,7 @@ static void styleset_common_init(gint ft_id, GKeyFile *config, GKeyFile *config_
{
static gboolean common_style_set_valid = FALSE;
if (G_LIKELY(common_style_set_valid))
if (common_style_set_valid)
return;
common_style_set_valid = TRUE; /* ensure filetypes.common is only loaded once */
@ -646,7 +646,7 @@ static void assign_global_and_user_keywords(ScintillaObject *sci,
static void
apply_filetype_properties(ScintillaObject *sci, gint lexer, filetype_id ft_id)
{
g_assert(G_LIKELY(ft_id != GEANY_FILETYPES_NONE));
g_assert(ft_id != GEANY_FILETYPES_NONE);
SSM(sci, SCI_SETLEXER, lexer, 0);
@ -3523,7 +3523,7 @@ void highlighting_set_styles(ScintillaObject *sci, gint filetype_idx)
* @see Scintilla messages @c SCI_STYLEGETFORE, etc, for use with ScintillaFuncs::send_message(). */
const GeanyLexerStyle *highlighting_get_style(gint ft_id, gint style_id)
{
if (G_UNLIKELY(ft_id < 0) || G_UNLIKELY(ft_id > GEANY_MAX_BUILT_IN_FILETYPES))
if (ft_id < 0 || ft_id > GEANY_MAX_BUILT_IN_FILETYPES)
return NULL;
/* ensure filetype loaded */

View File

@ -126,7 +126,7 @@ void keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
{
GeanyKeyBinding *kb;
g_assert(G_LIKELY(key_id < group->count));
g_assert(key_id < group->count);
kb = &group->keys[key_id];
@ -526,7 +526,7 @@ static gboolean on_idle_close(gpointer data)
static void on_document_close(GObject *obj, GeanyDocument *doc)
{
if (G_LIKELY(! main_status.quitting))
if (! main_status.quitting)
{
g_queue_remove_all(mru_docs, doc);
g_idle_add(on_idle_close, NULL);
@ -558,7 +558,7 @@ void keybindings_init(void)
static void apply_kb_accel(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_data)
{
if (G_LIKELY(kb->key != 0) && kb->menu_item)
if (kb->key != 0 && kb->menu_item)
{
gtk_widget_add_accelerator(kb->menu_item, "activate", kb_accel_group,
kb->key, kb->mods, GTK_ACCEL_VISIBLE);
@ -595,7 +595,7 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
GdkModifierType mods;
val = g_key_file_get_string(config, group->name, kb->name, NULL);
if (G_LIKELY(val != NULL))
if (val != NULL)
{
gtk_accelerator_parse(val, &key, &mods);
kb->key = key;
@ -637,7 +637,7 @@ static void add_menu_accel(GeanyKeyGroup *group, guint kb_id,
{
GeanyKeyBinding *kb = &group->keys[kb_id];
if (G_LIKELY(kb->key != 0))
if (kb->key != 0)
gtk_widget_add_accelerator(menuitem, "activate", accel_group,
kb->key, kb->mods, GTK_ACCEL_VISIBLE);
}
@ -751,7 +751,7 @@ static void fill_shortcut_labels_treeview(GtkWidget *tree)
{
group = g_ptr_array_index(keybinding_groups, g);
if (G_LIKELY(g > 0))
if (g > 0)
{
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, -1);
@ -856,7 +856,7 @@ static void on_dialog_response(GtkWidget *dialog, gint response, gpointer user_d
void keybindings_show_shortcuts(void)
{
if (G_UNLIKELY(key_dialog))
if (key_dialog)
gtk_widget_destroy(key_dialog); /* in case the key_dialog is still visible */
key_dialog = create_dialog();
@ -912,7 +912,7 @@ static gboolean check_snippet_completion(GeanyDocument *doc, guint keyval, guint
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
/* keybinding only valid when scintilla widget has focus */
if (G_LIKELY(doc != NULL) && focusw == GTK_WIDGET(doc->editor->sci))
if (doc != NULL && focusw == GTK_WIDGET(doc->editor->sci))
{
ScintillaObject *sci = doc->editor->sci;
gint pos = sci_get_current_position(sci);
@ -960,10 +960,10 @@ static gboolean check_menu_key(GeanyDocument *doc, guint keyval, guint state, gu
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
static GtkWidget *scribble = NULL;
if (G_UNLIKELY(scribble == NULL))
if (scribble == NULL)
scribble = ui_lookup_widget(main_widgets.window, "textview_scribble");
if (G_LIKELY(doc != NULL))
if (doc != NULL)
{
if (focusw == doc->priv->tag_tree)
{
@ -1150,12 +1150,12 @@ GeanyKeyBinding *keybindings_lookup_item(guint group_id, guint key_id)
{
GeanyKeyGroup *group;
g_return_val_if_fail(G_LIKELY(group_id < keybinding_groups->len), NULL);
g_return_val_if_fail(group_id < keybinding_groups->len, NULL);
group = g_ptr_array_index(keybinding_groups, group_id);
g_return_val_if_fail(G_LIKELY(group), NULL);
g_return_val_if_fail(G_LIKELY(key_id < group->count), NULL);
g_return_val_if_fail(group, NULL);
g_return_val_if_fail(key_id < group->count, NULL);
return &group->keys[key_id];
}
@ -1169,10 +1169,10 @@ void keybindings_send_command(guint group_id, guint key_id)
{
GeanyKeyBinding *kb;
g_return_if_fail(G_LIKELY(group_id < GEANY_KEY_GROUP_COUNT)); /* can't use this for plugin groups */
g_return_if_fail(group_id < GEANY_KEY_GROUP_COUNT); /* can't use this for plugin groups */
kb = keybindings_lookup_item(group_id, key_id);
if (G_LIKELY(kb))
if (kb)
kb->callback(key_id);
}
@ -1330,11 +1330,11 @@ static void cb_func_build_action(guint key_id)
BuildMenuItems *menu_items;
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return;
ft = doc->file_type;
if (G_UNLIKELY(! ft))
if (! ft)
return;
menu_items = build_get_menu_items(ft->id);
@ -1385,7 +1385,7 @@ static gboolean read_current_word(GeanyDocument *doc)
{
gint pos;
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return FALSE;
pos = sci_get_current_position(doc->editor->sci);
@ -1428,7 +1428,7 @@ static void cb_func_switch_action(guint key_id)
case GEANY_KEYS_FOCUS_EDITOR:
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
if (doc != NULL)
gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));
break;
}
@ -1553,7 +1553,7 @@ static gboolean on_switch_timeout(G_GNUC_UNUSED gpointer data)
if (switch_dialog_cancelled)
return FALSE;
if (G_UNLIKELY(! switch_dialog))
if (! switch_dialog)
switch_dialog = create_switch_dialog();
geany_wrap_label_set_text(GTK_LABEL(switch_dialog_label),
@ -1600,7 +1600,7 @@ static void cb_func_move_tab(guint key_id)
gint cur_page = gtk_notebook_get_current_page(nb);
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return;
sci = GTK_WIDGET(doc->editor->sci);
@ -1634,7 +1634,7 @@ static void goto_matching_brace(GeanyDocument *doc)
{
gint pos, new_pos;
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return;
pos = sci_get_current_position(doc->editor->sci);
@ -1654,7 +1654,7 @@ static void cb_func_clipboard(guint key_id)
{
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return;
switch (key_id)
@ -1684,7 +1684,7 @@ static void cb_func_goto_action(guint key_id)
gint cur_line;
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return;
cur_line = sci_get_current_line(doc->editor->sci);
@ -1793,7 +1793,7 @@ static void cb_func_editor_action(guint key_id)
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
/* edit keybindings only valid when scintilla widget has focus */
if (G_UNLIKELY(doc == NULL) || focusw != GTK_WIDGET(doc->editor->sci))
if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
return;
switch (key_id)
@ -1869,7 +1869,7 @@ static void cb_func_format_action(guint key_id)
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
/* keybindings only valid when scintilla widget has focus */
if (G_UNLIKELY(doc == NULL) || focusw != GTK_WIDGET(doc->editor->sci))
if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
return;
switch (key_id)
@ -1928,7 +1928,7 @@ static void cb_func_select_action(guint key_id)
static GtkWidget *scribble_widget = NULL;
/* special case for Select All in the scribble widget */
if (G_UNLIKELY(scribble_widget == NULL)) /* lookup the scribble widget only once */
if (scribble_widget == NULL) /* lookup the scribble widget only once */
scribble_widget = ui_lookup_widget(main_widgets.window, "textview_scribble");
if (key_id == GEANY_KEYS_SELECT_ALL && focusw == scribble_widget)
{
@ -1938,7 +1938,7 @@ static void cb_func_select_action(guint key_id)
doc = document_get_current();
/* keybindings only valid when scintilla widget has focus */
if (G_UNLIKELY(doc == NULL) || focusw != GTK_WIDGET(doc->editor->sci))
if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
return;
switch (key_id)
@ -1962,7 +1962,7 @@ static void cb_func_select_action(guint key_id)
static void cb_func_document_action(guint key_id)
{
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return;
switch (key_id)
@ -2008,7 +2008,7 @@ static void cb_func_insert_action(guint key_id)
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
/* keybindings only valid when scintilla widget has focus */
if (G_UNLIKELY(doc == NULL) || focusw != GTK_WIDGET(doc->editor->sci))
if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
return;
switch (key_id)

View File

@ -233,7 +233,7 @@ static gchar *get_session_file_string(GeanyDocument *doc)
gchar *locale_filename;
GeanyFiletype *ft = doc->file_type;
if (G_UNLIKELY(ft == NULL)) /* can happen when saving a new file when quitting */
if (ft == NULL) /* can happen when saving a new file when quitting */
ft = filetypes[GEANY_FILETYPES_NONE];
locale_filename = utils_get_locale_from_utf8(doc->file_name);
@ -275,7 +275,7 @@ void configuration_save_session_files(GKeyFile *config)
for (i = 0; i < max; i++)
{
doc = document_get_from_page(i);
if (G_LIKELY(doc != NULL) && G_LIKELY(doc->real_path != NULL))
if (doc != NULL && doc->real_path != NULL)
{
gchar *fname;
@ -566,11 +566,11 @@ void configuration_load_session_files(GKeyFile *config, gboolean read_recent_fil
session_files = g_ptr_array_new();
have_session_files = TRUE;
i = 0;
while (G_UNLIKELY(have_session_files))
while (have_session_files)
{
g_snprintf(entry, sizeof(entry), "FILE_NAME_%d", i);
tmp_array = g_key_file_get_string_list(config, "files", entry, NULL, &error);
if (G_UNLIKELY(! tmp_array) || G_UNLIKELY(error))
if (! tmp_array || error)
{
g_error_free(error);
error = NULL;
@ -670,7 +670,7 @@ static void load_dialog_prefs(GKeyFile *config)
if (tmp_string)
{
const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
if (G_LIKELY(enc != NULL))
if (enc != NULL)
file_prefs.default_open_encoding = enc->idx;
else
file_prefs.default_open_encoding = -1;
@ -799,7 +799,7 @@ static void load_ui_prefs(GKeyFile *config)
_("Type here what you want, use it as a notice/scratch board"));
geo = g_key_file_get_integer_list(config, PACKAGE, "geometry", NULL, &error);
if (G_UNLIKELY(error))
if (error)
{
ui_prefs.geometry[0] = -1;
g_error_free(error);
@ -821,7 +821,7 @@ static void load_ui_prefs(GKeyFile *config)
{
for (i = 2; i < 4; i++)
{
if (G_UNLIKELY(ui_prefs.geometry[i] < -1))
if (ui_prefs.geometry[i] < -1)
ui_prefs.geometry[i] = -1;
}
}
@ -924,7 +924,7 @@ static gboolean open_session_file(gchar **tmp, guint len)
/* replace ':' back with ';' (see get_session_file_string for details) */
g_strdelimit((gchar*) utils_path_skip_root(locale_filename), ":", ';');
if (G_LIKELY(len > 8))
if (len > 8)
line_breaking = atoi(tmp[8]);
if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
@ -935,7 +935,7 @@ static gboolean open_session_file(gchar **tmp, guint len)
(enc_idx >= 0 && enc_idx < GEANY_ENCODINGS_MAX) ?
encodings[enc_idx].charset : NULL);
if (G_LIKELY(doc))
if (doc)
{
editor_set_indent_type(doc->editor, indent_type);
editor_set_line_wrapping(doc->editor, line_wrapping);
@ -971,7 +971,7 @@ void configuration_open_files(void)
gchar **tmp = g_ptr_array_index(session_files, i);
guint len;
if (G_LIKELY(tmp != NULL) && (len = g_strv_length(tmp)) >= 8)
if (tmp != NULL && (len = g_strv_length(tmp)) >= 8)
{
if (! open_session_file(tmp, len))
failure = TRUE;
@ -981,13 +981,13 @@ void configuration_open_files(void)
if (file_prefs.tab_order_ltr)
{
i++;
if (G_UNLIKELY(i >= (gint)session_files->len))
if (i >= (gint)session_files->len)
break;
}
else
{
i--;
if (G_UNLIKELY(i < 0))
if (i < 0)
break;
}
}
@ -995,7 +995,7 @@ void configuration_open_files(void)
g_ptr_array_free(session_files, TRUE);
session_files = NULL;
if (G_UNLIKELY(failure))
if (failure)
ui_set_statusbar(TRUE, _("Failed to load one or more session files."));
else if (session_notebook_page >= 0)
{
@ -1014,7 +1014,7 @@ void configuration_open_files(void)
* realisation of the main window */
void configuration_apply_settings(void)
{
if (G_LIKELY(scribble_text))
if (scribble_text)
{ /* update the scribble widget, because now it's realized */
gtk_text_buffer_set_text(
gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui_lookup_widget(main_widgets.window,

View File

@ -352,7 +352,7 @@ static void get_line_and_column_from_filename(gchar *filename, gint *line, gint
gboolean have_number = FALSE;
gsize len;
g_assert(G_LIKELY(*line == -1) && G_LIKELY(*column == -1));
g_assert(*line == -1 && *column == -1);
if (! NZV(filename))
return;
@ -499,7 +499,7 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
* so we grab that here and replace it with a no-op */
for (i = 1; i < (*argc); i++)
{
if (G_LIKELY((*argv)[i][0] != '+'))
if ((*argv)[i][0] != '+')
continue;
cl_options.goto_line = atoi((*argv)[i] + 1);
@ -513,14 +513,14 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
g_option_context_parse(context, argc, argv, &error);
g_option_context_free(context);
if (G_UNLIKELY(error != NULL))
if (error != NULL)
{
g_printerr("Geany: %s\n", error->message);
g_error_free(error);
exit(1);
}
if (G_UNLIKELY(show_version))
if (show_version)
{
printf(PACKAGE " %s ", main_get_version_string());
printf(_("(built on %s with GTK %d.%d.%d, GLib %d.%d.%d)"),
@ -531,7 +531,7 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
exit(0);
}
if (G_UNLIKELY(print_prefix))
if (print_prefix)
{
printf("%s\n", GEANY_PREFIX);
printf("%s\n", GEANY_DATADIR);
@ -563,14 +563,14 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
}
#ifdef GEANY_DEBUG
if (G_UNLIKELY(generate_datafiles))
if (generate_datafiles)
{
filetypes_init_types();
configuration_generate_data_files(); /* currently only filetype_extensions.conf */
exit(0);
}
#endif
if (G_UNLIKELY(generate_tags))
if (generate_tags)
{
gboolean ret;
@ -580,7 +580,7 @@ static void parse_command_line_options(gint *argc, gchar ***argv)
exit(ret);
}
if (G_UNLIKELY(ft_names))
if (ft_names)
{
print_filetypes();
exit(0);
@ -724,7 +724,7 @@ static gint setup_config_dir(void)
setptr(app->configdir, utils_get_locale_from_utf8(app->configdir));
mkdir_result = create_config_dir();
if (G_UNLIKELY(mkdir_result != 0))
if (mkdir_result != 0)
{
if (! dialogs_show_question(
_("Configuration directory could not be created (%s).\nThere could be some problems "
@ -759,11 +759,11 @@ gboolean main_handle_filename(const gchar *locale_filename)
gint line = -1, column = -1;
gchar *filename;
g_return_val_if_fail(G_LIKELY(locale_filename), FALSE);
g_return_val_if_fail(locale_filename, FALSE);
/* check whether the passed filename is an URI */
filename = utils_get_path_from_uri(locale_filename);
if (G_UNLIKELY(filename == NULL))
if (filename == NULL)
return FALSE;
get_line_and_column_from_filename(filename, &line, &column);
@ -776,7 +776,7 @@ gboolean main_handle_filename(const gchar *locale_filename)
{
doc = document_open_file(filename, FALSE, NULL, NULL);
/* add recent file manually if opening_session_files is set */
if (G_LIKELY(doc != NULL) && main_status.opening_session_files)
if (doc != NULL && main_status.opening_session_files)
ui_add_recent_file(doc->file_name);
g_free(filename);
return TRUE;
@ -786,7 +786,7 @@ gboolean main_handle_filename(const gchar *locale_filename)
gchar *utf8_filename = utils_get_utf8_from_locale(filename);
doc = document_new_file(utf8_filename, NULL, NULL);
if (G_LIKELY(doc != NULL))
if (doc != NULL)
ui_add_recent_file(doc->file_name);
g_free(utf8_filename);
g_free(filename);
@ -811,7 +811,7 @@ static gboolean open_cl_files(gint argc, gchar **argv)
/* It seems argv elements are encoded in CP1252 on a German Windows */
setptr(filename, g_locale_to_utf8(filename, -1, NULL, NULL, NULL));
#endif
if (G_LIKELY(filename) && ! main_handle_filename(filename))
if (filename && ! main_handle_filename(filename))
{
const gchar *msg = _("Could not find file '%s'.");
@ -829,7 +829,7 @@ static void load_session_project_file(void)
{
gchar *locale_filename;
g_return_if_fail(G_LIKELY(project_prefs.session_file != NULL));
g_return_if_fail(project_prefs.session_file != NULL);
locale_filename = utils_get_locale_from_utf8(project_prefs.session_file);

View File

@ -327,7 +327,7 @@ void msgwin_msg_add_string(gint msg_color, gint line, GeanyDocument *doc, const
* cut the string to a maximum of 1024 bytes and discard the rest */
/* TODO: find the real cause for the display problem / if it is GtkTreeView file a bug report */
len = strlen(string);
if (G_UNLIKELY(len > 1024))
if (len > 1024)
tmp = g_strndup(string, 1024);
else
tmp = g_strdup(string);
@ -475,7 +475,7 @@ static void on_compiler_treeview_copy_all_activate(GtkMenuItem *menuitem, gpoint
}
/* copy the string into the clipboard */
if (G_LIKELY(str->len > 0))
if (str->len > 0)
{
gtk_clipboard_set_text(
gtk_clipboard_get(gdk_atom_intern("CLIPBOARD", FALSE)),
@ -562,7 +562,7 @@ find_prev_build_dir(GtkTreePath *cur, GtkTreeModel *model, gchar **prefix)
{
gchar *string;
gtk_tree_model_get(model, &iter, 1, &string, -1);
if (G_LIKELY(string != NULL) && build_parse_make_dir(string, prefix))
if (string != NULL && build_parse_make_dir(string, prefix))
{
g_free(string);
return TRUE;
@ -598,7 +598,7 @@ gboolean msgwin_goto_compiler_file_line()
gdk_color_free(color);
gtk_tree_model_get(model, &iter, 1, &string, -1);
if (G_LIKELY(string != NULL))
if (string != NULL)
{
gint line;
gchar *filename, *dir;
@ -625,7 +625,7 @@ gboolean msgwin_goto_compiler_file_line()
if (doc == NULL) /* file not already open */
doc = document_open_file(filename, FALSE, NULL, NULL);
if (G_LIKELY(doc != NULL))
if (doc != NULL)
{
if (! doc->changed) /* if modified, line may be wrong */
editor_indicator_set_on_line(doc->editor, GEANY_INDICATOR_ERROR, line - 1);
@ -645,7 +645,7 @@ static void make_absolute(gchar **filename, const gchar *dir)
{
guint skip_dot_slash = 0; /* number of characters to skip at the beginning of the filename */
if (G_UNLIKELY(*filename == NULL))
if (*filename == NULL)
return;
/* skip some characters at the beginning of the filename, at the moment only "./"
@ -673,7 +673,7 @@ static void parse_file_line(ParseData *data, gchar **filename, gint *line)
*filename = NULL;
*line = -1;
g_return_if_fail(G_LIKELY(data->string != NULL));
g_return_if_fail(data->string != NULL);
fields = g_strsplit_set(data->string, data->pattern, data->min_fields);
@ -687,7 +687,7 @@ static void parse_file_line(ParseData *data, gchar **filename, gint *line)
*line = strtol(fields[data->line_idx], &end, 10);
/* if the line could not be read, line is 0 and an error occurred, so we leave */
if (G_UNLIKELY(fields[data->line_idx] == end))
if (fields[data->line_idx] == end)
{
g_strfreev(fields);
return;
@ -891,7 +891,7 @@ void msgwin_parse_compiler_error_line(const gchar *string, const gchar *dir,
if (dir == NULL)
dir = build_info.dir;
g_return_if_fail(G_LIKELY(dir != NULL));
g_return_if_fail(dir != NULL);
trimmed_string = g_strdup(string);
g_strchug(trimmed_string); /* remove possible leading whitespace */
@ -930,7 +930,7 @@ gboolean msgwin_goto_messages_file_line()
{
ret = navqueue_goto_line(old_doc, doc, line);
}
else if (line < 0 && G_LIKELY(string != NULL))
else if (line < 0 && string != NULL)
{
gchar *filename;
msgwin_parse_grep_line(string, &filename, &line);
@ -938,7 +938,7 @@ gboolean msgwin_goto_messages_file_line()
{
/* use document_open_file to find an already open file, or open it in place */
doc = document_open_file(filename, FALSE, NULL, NULL);
if (G_LIKELY(doc != NULL))
if (doc != NULL)
ret = navqueue_goto_line(old_doc, doc, line);
}
g_free(filename);
@ -961,7 +961,7 @@ static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *
*filename = NULL;
*line = -1;
if (G_UNLIKELY(string == NULL) || msgwindow.find_in_files_dir == NULL)
if (string == NULL || msgwindow.find_in_files_dir == NULL)
return;
/* conflict:3:conflicting types for `foo' */
@ -1087,7 +1087,7 @@ void msgwin_clear_tab(gint tabnum)
case MSG_STATUS: store = msgwindow.store_status; break;
default: return;
}
if (G_UNLIKELY(store == NULL))
if (store == NULL)
return;
gtk_list_store_clear(store);
}

View File

@ -149,8 +149,8 @@ gboolean navqueue_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint
{
gint pos;
g_return_val_if_fail(G_LIKELY(new_doc != NULL), FALSE);
g_return_val_if_fail(G_LIKELY(line >= 1), FALSE);
g_return_val_if_fail(new_doc != NULL, FALSE);
g_return_val_if_fail(line >= 1, FALSE);
pos = sci_get_position_from_line(new_doc->editor->sci, line - 1);
@ -163,7 +163,7 @@ gboolean navqueue_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint
}
/* now add new file position */
if (G_LIKELY(new_doc->file_name))
if (new_doc->file_name)
{
add_new_position(new_doc->file_name, pos);
}
@ -176,7 +176,7 @@ static gboolean goto_file_pos(const gchar *file, gint pos)
{
GeanyDocument *doc = document_find_by_filename(file);
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return FALSE;
return editor_goto_pos(doc->editor, pos, TRUE);
@ -245,7 +245,7 @@ void navqueue_remove_file(const gchar *filename)
{
GList *match;
if (G_UNLIKELY(filename == NULL))
if (filename == NULL)
return;
while ((match = g_queue_find_custom(navigation_queue, filename, find_by_filename)))

View File

@ -76,7 +76,7 @@ static gboolean focus_sci(GtkWidget *widget, GdkEventButton *event, gpointer use
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL) && G_LIKELY(event->button == 1))
if (doc != NULL && event->button == 1)
gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));
return FALSE;
@ -127,10 +127,10 @@ static gboolean is_position_on_tab_bar(GtkNotebook *notebook, GdkEventButton *ev
gdouble x, y;
page = gtk_notebook_get_nth_page(notebook, 0);
g_return_val_if_fail(G_LIKELY(page != NULL), FALSE);
g_return_val_if_fail(page != NULL, FALSE);
tab = gtk_notebook_get_tab_label(notebook, page);
g_return_val_if_fail(G_LIKELY(tab != NULL), FALSE);
g_return_val_if_fail(tab != NULL, FALSE);
tab_pos = gtk_notebook_get_tab_pos(notebook);
nb = GTK_WIDGET(notebook);
@ -478,7 +478,7 @@ gint notebook_new_tab(GeanyDocument *this)
gint tabnum;
GtkWidget *page;
g_return_val_if_fail(G_LIKELY(this != NULL), -1);
g_return_val_if_fail(this != NULL, -1);
page = GTK_WIDGET(this->editor->sci);

View File

@ -406,7 +406,7 @@ static Plugin *find_active_plugin_by_name(const gchar *filename)
{
GList *item;
g_return_val_if_fail(G_LIKELY(filename), FALSE);
g_return_val_if_fail(filename, FALSE);
for (item = active_plugin_list; item != NULL; item = g_list_next(item))
{
@ -443,7 +443,7 @@ plugin_check_version(GModule *module)
"release of Geany - recompile it.", g_module_name(module));
return FALSE;
}
if (G_UNLIKELY(result > 0))
if (result > 0)
{
geany_debug("Plugin \"%s\" requires a newer version of Geany (API >= v%d).",
g_module_name(module), result);
@ -528,33 +528,33 @@ plugin_init(Plugin *plugin)
/* set these symbols before plugin_init() is called */
g_module_symbol(plugin->module, "geany_plugin", (void *) &p_geany_plugin);
if (G_LIKELY(p_geany_plugin))
if (p_geany_plugin)
*p_geany_plugin = &plugin->public;
g_module_symbol(plugin->module, "plugin_info", (void *) &p_info);
if (G_LIKELY(p_info))
if (p_info)
*p_info = &plugin->info;
g_module_symbol(plugin->module, "geany_data", (void *) &p_geany_data);
if (G_LIKELY(p_geany_data))
if (p_geany_data)
*p_geany_data = &geany_data;
g_module_symbol(plugin->module, "geany_functions", (void *) &p_geany_functions);
if (G_LIKELY(p_geany_functions))
if (p_geany_functions)
*p_geany_functions = &geany_functions;
g_module_symbol(plugin->module, "plugin_fields", (void *) &plugin_fields);
if (plugin_fields)
*plugin_fields = &plugin->fields;
/* start the plugin */
g_return_if_fail(G_LIKELY(plugin->init));
g_return_if_fail(plugin->init);
plugin->init(&geany_data);
if (G_LIKELY(p_geany_plugin) && (*p_geany_plugin)->priv->resident)
if (p_geany_plugin && (*p_geany_plugin)->priv->resident)
g_module_make_resident(plugin->module);
/* store some function pointers for later use */
g_module_symbol(plugin->module, "plugin_configure", (void *) &plugin->configure);
g_module_symbol(plugin->module, "plugin_help", (void *) &plugin->help);
g_module_symbol(plugin->module, "plugin_cleanup", (void *) &plugin->cleanup);
if (G_UNLIKELY(plugin->cleanup == NULL))
if (plugin->cleanup == NULL)
{
if (app->debug_mode)
g_warning("Plugin '%s' has no plugin_cleanup() function - there may be memory leaks!",
@ -596,7 +596,7 @@ plugin_new(const gchar *fname, gboolean init_plugin, gboolean add_to_list)
GModule *module;
void (*plugin_set_info)(PluginInfo*);
g_return_val_if_fail(G_LIKELY(fname), NULL);
g_return_val_if_fail(fname, NULL);
g_return_val_if_fail(g_module_supported(), NULL);
/* find the plugin in the list of already loaded, active plugins and use it, otherwise
@ -617,7 +617,7 @@ plugin_new(const gchar *fname, gboolean init_plugin, gboolean add_to_list)
* Also without G_MODULE_BIND_LOCAL calling public functions e.g. the old info()
* function from a plugin will be shadowed. */
module = g_module_open(fname, G_MODULE_BIND_LOCAL);
if (G_UNLIKELY(! module))
if (! module)
{
geany_debug("Can't load plugin: %s", g_module_error());
return NULL;
@ -640,7 +640,7 @@ plugin_new(const gchar *fname, gboolean init_plugin, gboolean add_to_list)
}
g_module_symbol(module, "plugin_set_info", (void *) &plugin_set_info);
if (G_UNLIKELY(plugin_set_info == NULL))
if (plugin_set_info == NULL)
{
geany_debug("No plugin_set_info() defined for \"%s\" - ignoring plugin!", fname);
@ -665,7 +665,7 @@ plugin_new(const gchar *fname, gboolean init_plugin, gboolean add_to_list)
}
g_module_symbol(module, "plugin_init", (void *) &plugin->init);
if (G_UNLIKELY(plugin->init == NULL))
if (plugin->init == NULL)
{
geany_debug("Plugin '%s' has no plugin_init() function - ignoring plugin!",
plugin->info.name);
@ -717,7 +717,7 @@ plugin_cleanup(Plugin *plugin)
{
GtkWidget *widget;
if (G_LIKELY(plugin->cleanup))
if (plugin->cleanup)
plugin->cleanup();
remove_callbacks(plugin);
@ -736,8 +736,8 @@ plugin_cleanup(Plugin *plugin)
static void
plugin_free(Plugin *plugin)
{
g_return_if_fail(G_LIKELY(plugin));
g_return_if_fail(G_LIKELY(plugin->module));
g_return_if_fail(plugin);
g_return_if_fail(plugin->module);
if (is_active_plugin(plugin))
plugin_cleanup(plugin);
@ -788,7 +788,7 @@ load_plugins_from_path(const gchar *path)
for (item = list; item != NULL; item = g_slist_next(item))
{
tmp = strrchr(item->data, '.');
if (G_UNLIKELY(tmp == NULL) || utils_str_casecmp(tmp, "." PLUGIN_EXT) != 0)
if (tmp == NULL || utils_str_casecmp(tmp, "." PLUGIN_EXT) != 0)
continue;
fname = g_strconcat(path, G_DIR_SEPARATOR_S, item->data, NULL);
@ -1017,7 +1017,7 @@ void pm_selection_changed(GtkTreeSelection *selection, gpointer user_data)
{
gtk_tree_model_get(model, &iter, PLUGIN_COLUMN_PLUGIN, &p, -1);
if (G_LIKELY(p != NULL))
if (p != NULL)
{
gchar *text;
PluginInfo *pi;
@ -1053,8 +1053,7 @@ static void pm_plugin_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer
gtk_tree_model_get(GTK_TREE_MODEL(pm_widgets.store), &iter,
PLUGIN_COLUMN_CHECK, &old_state, PLUGIN_COLUMN_PLUGIN, &p, -1);
if (G_UNLIKELY(p == NULL))
return;
g_return_if_fail(p != NULL);
state = ! old_state; /* toggle the state */
/* save the filename of the plugin */
@ -1195,7 +1194,7 @@ void pm_on_plugin_button_clicked(GtkButton *button, gpointer user_data)
{
gtk_tree_model_get(model, &iter, PLUGIN_COLUMN_PLUGIN, &p, -1);
if (G_LIKELY(p != NULL))
if (p != NULL)
{
if (GPOINTER_TO_INT(user_data) == PM_BUTTON_CONFIGURE)
configure_plugin(p);
@ -1316,7 +1315,7 @@ void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item)
gint pos;
GeanyAutoSeparator *autosep;
g_return_if_fail(G_LIKELY(plugin));
g_return_if_fail(plugin);
autosep = &plugin->priv->toolbar_separator;
if (!autosep->widget)
@ -1334,7 +1333,7 @@ void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item)
else
{
pos = gtk_toolbar_get_item_index(toolbar, GTK_TOOL_ITEM(autosep->widget));
g_return_if_fail(G_LIKELY(pos >= 0));
g_return_if_fail(pos >= 0);
gtk_toolbar_insert(toolbar, item, pos);
}
/* hide the separator widget if there are no toolbar items showing for the plugin */
@ -1352,7 +1351,7 @@ void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item)
*/
void plugin_module_make_resident(GeanyPlugin *plugin)
{
g_return_if_fail(G_LIKELY(plugin));
g_return_if_fail(plugin);
plugin->priv->resident = TRUE;
}

View File

@ -170,7 +170,7 @@ static void init_keybindings(void)
GeanyKeyGroup *group;
GeanyKeyBinding *kb;
if (G_UNLIKELY(store == NULL))
if (store == NULL)
init_kb_tree();
for (g = 0; g < keybinding_groups->len; g++)
@ -1185,7 +1185,7 @@ static GeanyKeyBinding *lookup_kb_from_iter(G_GNUC_UNUSED GtkTreeModel *model, G
static void on_cell_edited(GtkCellRendererText *cellrenderertext, gchar *path, gchar *new_text, gpointer user_data)
{
if (G_LIKELY(path != NULL) && new_text != NULL)
if (path != NULL && new_text != NULL)
{
GtkTreeIter iter;
guint lkey;
@ -1222,7 +1222,7 @@ static gboolean on_keytype_dialog_response(GtkWidget *dialog, GdkEventKey *event
state = event->state & GEANY_KEYS_MODIFIER_MASK;
if (G_UNLIKELY(event->keyval == GDK_Escape))
if (event->keyval == GDK_Escape)
return FALSE; /* close the dialog, don't allow escape when detecting keybindings. */
str = gtk_accelerator_name(event->keyval, state);
@ -1281,7 +1281,7 @@ static gboolean find_child_iter(GtkTreeIter *parent, guint i, GtkTreeIter *iter)
while (TRUE) /* foreach child */
{
gtk_tree_model_get(model, iter, KB_TREE_INDEX, &idx, -1);
if (G_UNLIKELY(idx == i))
if (idx == i)
return TRUE;
if (! gtk_tree_model_iter_next(model, iter))
return FALSE; /* no more children */
@ -1313,7 +1313,7 @@ static gboolean find_duplicate(GeanyKeyBinding *search_kb,
gsize g, i;
/* allow duplicate if there is no key combination */
if (G_UNLIKELY(key == 0) && G_UNLIKELY(mods == 0))
if (key == 0 && mods == 0)
return FALSE;
for (g = 0; g < keybinding_groups->len; g++)
@ -1414,7 +1414,7 @@ static void on_prefs_print_page_header_toggled(GtkToggleButton *togglebutton, gp
void prefs_show_dialog(void)
{
if (G_UNLIKELY(ui_widgets.prefs_dialog == NULL))
if (ui_widgets.prefs_dialog == NULL)
{
GtkWidget *combo_new, *combo_open, *combo_eol;
GtkWidget *label;

View File

@ -54,7 +54,7 @@ void queue_append(GeanyQueue *queue_start, gpointer data)
{
GeanyQueue *temp, *next;
if (G_UNLIKELY(queue_start == NULL) || G_UNLIKELY(data == NULL))
if (queue_start == NULL || data == NULL)
return;
if (queue_start->data == NULL)
@ -81,7 +81,7 @@ GeanyQueue *queue_delete(GeanyQueue *queue_start, gpointer *data, const gboolean
{
GeanyQueue *ret;
if (G_UNLIKELY(NULL == queue_start))
if (NULL == queue_start)
return NULL;
if (data != NULL)
@ -110,7 +110,7 @@ static void queue_foreach_data_2(GeanyQueue *queue_start, ForeachFunc func, Gean
{
GeanyQueue *temp = param;
if (G_UNLIKELY(! queue_start) || G_UNLIKELY(! param))
if (! queue_start || ! param)
return;
do

View File

@ -153,7 +153,7 @@ void sci_convert_eols( ScintillaObject* sci, gint eolmode)
void sci_add_text(ScintillaObject* sci, const gchar* text)
{
if (G_LIKELY(text != NULL))
if (text != NULL)
{ /* if null text is passed to scintilla will segfault */
SSM( sci, SCI_ADDTEXT, strlen(text), (sptr_t) text);
}

View File

@ -126,7 +126,7 @@ void send_open_command(gint sock, gint argc, gchar **argv)
gint i;
gchar *filename;
g_return_if_fail(G_LIKELY(argc > 1));
g_return_if_fail(argc > 1);
geany_debug("using running instance of Geany");
if (cl_options.goto_line >= 0)
@ -154,7 +154,7 @@ void send_open_command(gint sock, gint argc, gchar **argv)
filename = main_get_argv_filename(argv[i]);
/* if the filename is valid or if a new file should be opened is check on the other side */
if (G_LIKELY(filename != NULL))
if (filename != NULL)
{
socket_fd_write_all(sock, filename, strlen(filename));
socket_fd_write_all(sock, "\n", 1);
@ -203,7 +203,7 @@ gint socket_init(gint argc, gchar **argv)
HWND hwnd;
socket_init_win32();
hmutex = CreateMutexA(NULL, FALSE, "Geany");
if (G_UNLIKELY(! hmutex))
if (! hmutex)
{
geany_debug("cannot create Mutex\n");
return -1;
@ -217,20 +217,20 @@ gint socket_init(gint argc, gchar **argv)
* and the only data is the configuration directory path.
* For now we use one port number, that is we support only one instance at all. */
sock = socket_fd_open_inet(REMOTE_CMD_PORT);
if (G_UNLIKELY(sock < 0))
if (sock < 0)
return 0;
return sock;
}
sock = socket_fd_connect_inet(REMOTE_CMD_PORT);
if (G_UNLIKELY(sock < 0))
if (sock < 0)
return -1;
#else
gchar *display_name = gdk_get_display();
gchar *hostname = utils_get_hostname();
gchar *p;
if (G_UNLIKELY(display_name == NULL))
if (display_name == NULL)
display_name = g_strdup("NODISPLAY");
/* these lines are taken from dcopc.c in kdelibs */
@ -239,7 +239,7 @@ gint socket_init(gint argc, gchar **argv)
while ((p = strchr(display_name, ':')) != NULL)
*p = '_';
if (G_UNLIKELY(socket_info.file_name == NULL))
if (socket_info.file_name == NULL)
socket_info.file_name = g_strdup_printf("%s%cgeany_socket_%s_%s",
app->configdir, G_DIR_SEPARATOR, hostname, display_name);
@ -275,12 +275,12 @@ gint socket_init(gint argc, gchar **argv)
gint socket_finalize(void)
{
if (G_UNLIKELY(socket_info.lock_socket < 0))
if (socket_info.lock_socket < 0)
return -1;
if (G_LIKELY(socket_info.lock_socket_tag > 0))
if (socket_info.lock_socket_tag > 0)
g_source_remove(socket_info.lock_socket_tag);
if (G_LIKELY(socket_info.read_ioc))
if (socket_info.read_ioc)
{
g_io_channel_shutdown(socket_info.read_ioc, FALSE, NULL);
g_io_channel_unref(socket_info.read_ioc);
@ -290,7 +290,7 @@ gint socket_finalize(void)
#ifdef G_OS_WIN32
WSACleanup();
#else
if (G_LIKELY(socket_info.file_name != NULL))
if (socket_info.file_name != NULL)
{
remove_socket_link_full(); /* deletes the socket file and the symlink */
g_free(socket_info.file_name);
@ -308,7 +308,7 @@ static gint socket_fd_connect_unix(const gchar *path)
struct sockaddr_un addr;
sock = socket(PF_UNIX, SOCK_STREAM, 0);
if (G_UNLIKELY(sock < 0))
if (sock < 0)
{
perror("fd_connect_unix(): socket");
return -1;
@ -337,7 +337,7 @@ static gint socket_fd_open_unix(const gchar *path)
sock = socket(PF_UNIX, SOCK_STREAM, 0);
if (G_UNLIKELY(sock < 0))
if (sock < 0)
{
perror("sock_open_unix(): socket");
return -1;
@ -503,7 +503,7 @@ static void handle_input_filename(const gchar *buf)
utf8_filename = g_strdup(buf);
locale_filename = utils_get_locale_from_utf8(utf8_filename);
if (G_LIKELY(locale_filename))
if (locale_filename)
main_handle_filename(locale_filename);
g_free(utf8_filename);
g_free(locale_filename);
@ -641,7 +641,7 @@ static gint socket_fd_check_io(gint fd, GIOCondition cond)
#ifdef G_OS_UNIX
/* checking for non-blocking mode */
flags = fcntl(fd, F_GETFL, 0);
if (G_UNLIKELY(flags < 0))
if (flags < 0)
{
perror("fcntl");
return 0;
@ -681,7 +681,7 @@ static gint socket_fd_write_all(gint fd, const gchar *buf, gint len)
while (len)
{
n = socket_fd_write(fd, buf, len);
if (G_UNLIKELY(n <= 0))
if (n <= 0)
return -1;
len -= n;
wrlen += n;

View File

@ -144,7 +144,7 @@ void symbols_global_tags_loaded(gint file_type_idx)
load_c_ignore_tags();
}
if (cl_options.ignore_global_tags || G_UNLIKELY(app->tm_workspace == NULL))
if (cl_options.ignore_global_tags || app->tm_workspace == NULL)
return;
load_user_tags(file_type_idx);
@ -171,7 +171,7 @@ void symbols_global_tags_loaded(gint file_type_idx)
}
tfi = &tag_file_info[tag_type];
if (G_UNLIKELY(! tfi->tags_loaded))
if (! tfi->tags_loaded)
{
gchar *fname = g_strconcat(app->datadir, G_DIR_SEPARATOR_S, tfi->tag_file, NULL);
gint tm_lang;
@ -193,7 +193,7 @@ static void html_tags_loaded(void)
return;
tfi = &tag_file_info[GTF_HTML_ENTITIES];
if (G_UNLIKELY(! tfi->tags_loaded))
if (! tfi->tags_loaded)
{
gchar *file = g_strconcat(app->datadir, G_DIR_SEPARATOR_S, tfi->tag_file, NULL);
@ -212,7 +212,7 @@ GString *symbols_find_tags_as_string(GPtrArray *tags_array, guint tag_types, gin
GPtrArray *typedefs;
gint tag_lang;
g_return_val_if_fail(G_LIKELY(tags_array != NULL), NULL);
g_return_val_if_fail(tags_array != NULL, NULL);
typedefs = tm_tags_extract(tags_array, tag_types);
@ -279,7 +279,7 @@ GString *symbols_get_macro_list(gint lang)
gint tag_lang;
TMTag *tag;
if (G_UNLIKELY(app->tm_workspace->work_objects == NULL))
if (app->tm_workspace->work_objects == NULL)
return NULL;
ftags = g_ptr_array_sized_new(50);
@ -330,7 +330,7 @@ static TMTag *
symbols_find_tm_tag(const GPtrArray *tags, const gchar *tag_name)
{
guint i;
g_return_val_if_fail(G_LIKELY(tags != NULL), NULL);
g_return_val_if_fail(tags != NULL, NULL);
for (i = 0; i < tags->len; ++i)
{
@ -369,10 +369,10 @@ static TMTag *find_workspace_tag(const gchar *tag_name, gint type)
guint j;
const GPtrArray *work_objects = NULL;
if (G_LIKELY(app->tm_workspace != NULL))
if (app->tm_workspace != NULL)
work_objects = app->tm_workspace->work_objects;
if (G_LIKELY(work_objects != NULL))
if (work_objects != NULL)
{
for (j = 0; j < work_objects->len; j++)
{
@ -390,7 +390,7 @@ static TMTag *find_workspace_tag(const gchar *tag_name, gint type)
const gchar **symbols_get_html_entities(void)
{
if (G_UNLIKELY(html_entities == NULL))
if (html_entities == NULL)
html_tags_loaded(); /* if not yet created, force creation of the array but shouldn't occur */
return (const gchar **) html_entities;
@ -439,9 +439,9 @@ static GList *get_tag_list(GeanyDocument *doc, guint tag_types)
TMTag *tag;
guint i;
g_return_val_if_fail(G_LIKELY(doc), NULL);
g_return_val_if_fail(doc, NULL);
if (G_UNLIKELY(! doc->tm_file) || G_UNLIKELY(! doc->tm_file->tags_array))
if (! doc->tm_file || ! doc->tm_file->tags_array)
return NULL;
for (i = 0; i < doc->tm_file->tags_array->len; ++i)
@ -524,7 +524,7 @@ tag_list_add_groups(GtkTreeStore *tree_store, ...)
va_list args;
GtkTreeIter *iter;
g_return_if_fail(G_LIKELY(top_level_iter_names));
g_return_if_fail(top_level_iter_names);
va_start(args, tree_store);
for (; iter = va_arg(args, GtkTreeIter*), iter != NULL;)
@ -538,7 +538,7 @@ tag_list_add_groups(GtkTreeStore *tree_store, ...)
icon = get_tag_icon(icon_name);
}
g_assert(G_LIKELY(title != NULL));
g_assert(title != NULL);
g_ptr_array_add(top_level_iter_names, title);
gtk_tree_store_append(tree_store, iter, NULL);
@ -559,7 +559,7 @@ static void add_top_level_items(GeanyDocument *doc)
filetype_id ft_id = doc->file_type->id;
GtkTreeStore *tag_store = doc->priv->tag_store;
if (G_UNLIKELY(top_level_iter_names == NULL))
if (top_level_iter_names == NULL)
top_level_iter_names = g_ptr_array_new();
else
g_ptr_array_set_size(top_level_iter_names, 0);
@ -884,10 +884,10 @@ static const gchar *get_symbol_name(GeanyDocument *doc, const TMTag *tag, gboole
else
utf8_name = tag->name;
if (G_UNLIKELY(utf8_name == NULL))
if (utf8_name == NULL)
return NULL;
if (G_UNLIKELY(! buffer))
if (! buffer)
buffer = g_string_new(NULL);
else
g_string_truncate(buffer, 0);
@ -926,7 +926,7 @@ static gchar *get_symbol_tooltip(GeanyDocument *doc, const TMTag *tag)
encodings_convert_to_utf8_from_charset(utf8_name, (gsize) -1, doc->encoding, TRUE));
}
if (G_LIKELY(utf8_name != NULL))
if (utf8_name != NULL)
setptr(utf8_name, g_markup_escape_text(utf8_name, -1));
return utf8_name;
@ -1211,10 +1211,10 @@ gboolean symbols_recreate_tag_list(GeanyDocument *doc, gint sort_mode)
{
GList *tags;
g_return_val_if_fail(G_LIKELY(doc != NULL), FALSE);
g_return_val_if_fail(doc != NULL, FALSE);
tags = get_tag_list(doc, tm_tag_max_t);
if (G_UNLIKELY(tags == NULL))
if (tags == NULL)
return FALSE;
/* Make sure the model stays with us after the tree view unrefs it */
@ -1232,7 +1232,7 @@ gboolean symbols_recreate_tag_list(GeanyDocument *doc, gint sort_mode)
hide_empty_rows(doc->priv->tag_store);
if (G_LIKELY(sort_mode == SYMBOLS_SORT_USE_PREVIOUS))
if (sort_mode == SYMBOLS_SORT_USE_PREVIOUS)
sort_mode = doc->priv->symbol_list_sort_mode;
sort_tree(doc->priv->tag_store, sort_mode == SYMBOLS_SORT_BY_NAME);
@ -1257,14 +1257,14 @@ static GeanyFiletype *detect_global_tags_filetype(const gchar *utf8_filename)
GeanyFiletype *ft = NULL;
tags_ext = strstr(shortname, ".tags");
if (G_LIKELY(tags_ext))
if (tags_ext)
{
*tags_ext = '\0'; /* remove .tags extension */
ft = filetypes_detect_from_extension(shortname);
}
g_free(shortname);
if (G_UNLIKELY(ft == NULL) || G_UNLIKELY(! filetype_has_tags(ft)))
if (ft == NULL || ! filetype_has_tags(ft))
return NULL;
return ft;
@ -1295,7 +1295,7 @@ int symbols_generate_global_tags(int argc, char **argv, gboolean want_preprocess
ft = detect_global_tags_filetype(utf8_fname);
g_free(utf8_fname);
if (G_UNLIKELY(ft == NULL))
if (ft == NULL)
{
g_printerr(_("Unknown filetype extension for \"%s\".\n"), tags_file);
return 1;
@ -1437,14 +1437,14 @@ static void load_user_tags(filetype_id ft_id)
const GList *node;
const GeanyFiletype *ft = filetypes[ft_id];
g_return_if_fail(G_LIKELY(ft_id > 0));
g_return_if_fail(G_LIKELY(ft_id < GEANY_MAX_BUILT_IN_FILETYPES));
g_return_if_fail(ft_id > 0);
g_return_if_fail(ft_id < GEANY_MAX_BUILT_IN_FILETYPES);
if (G_LIKELY(tags_loaded[ft_id]))
if (tags_loaded[ft_id])
return;
tags_loaded[ft_id] = TRUE; /* prevent reloading */
if (G_UNLIKELY(lang_hash == NULL))
if (lang_hash == NULL)
lang_hash = init_user_tags();
fnames = g_hash_table_lookup(lang_hash, ft);
@ -1486,7 +1486,7 @@ gboolean symbols_goto_tag(const gchar *name, gboolean definition)
if (tmtag == NULL)
tmtag = find_workspace_tag(name, type);
if (G_LIKELY(tmtag != NULL))
if (tmtag != NULL)
{
GeanyDocument *new_doc = document_find_by_real_path(
tmtag->atts.entry.file->work_object.file_name);
@ -1739,10 +1739,10 @@ static void on_symbol_tree_sort_clicked(GtkMenuItem *menuitem, gpointer user_dat
gint sort_mode = GPOINTER_TO_INT(user_data);
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(ignore_callback))
if (ignore_callback)
return;
if (G_LIKELY(doc != NULL))
if (doc != NULL)
doc->has_tags = symbols_recreate_tag_list(doc, sort_mode);
}
@ -1759,7 +1759,7 @@ static void on_symbol_tree_menu_show(GtkWidget *widget,
gtk_widget_set_sensitive(symbol_menu.expand_all, enable);
gtk_widget_set_sensitive(symbol_menu.collapse_all, enable);
if (G_UNLIKELY(! doc))
if (! doc)
return;
ignore_callback = TRUE;
@ -1778,10 +1778,10 @@ static void on_expand_collapse(GtkWidget *widget, gpointer user_data)
gboolean expand = utils_str_equal(user_data, GTK_STOCK_ADD);
GeanyDocument *doc = document_get_current();
if (G_UNLIKELY(! doc))
if (! doc)
return;
g_return_if_fail(G_LIKELY(doc->priv->tag_tree));
g_return_if_fail(doc->priv->tag_tree);
if (expand)
gtk_tree_view_expand_all(GTK_TREE_VIEW(doc->priv->tag_tree));

View File

@ -260,7 +260,7 @@ static gchar *replace_all(gchar *text, const gchar *year, const gchar *date, con
{
GString *str;
if (G_UNLIKELY(text == NULL))
if (text == NULL)
return NULL;
str = g_string_new(text);
@ -398,7 +398,7 @@ static gchar *get_template_from_file(const gchar *locale_fname, const gchar *doc
g_file_get_contents(locale_fname, &content, NULL, NULL);
if (G_LIKELY(content != NULL))
if (content != NULL)
{
gchar *file_header;
gchar *year = utils_get_date_time(template_prefs.year_format, NULL);
@ -446,7 +446,7 @@ static void add_file_item(gpointer data, gpointer user_data)
GtkWidget *tmp_menu, *tmp_button;
gchar *label;
g_return_if_fail(G_LIKELY(data));
g_return_if_fail(data);
label = utils_get_utf8_from_locale(data);
@ -492,7 +492,7 @@ static gboolean add_custom_template_items(void)
"files", NULL);
GSList *list = utils_get_file_list(path, NULL, NULL);
if (G_UNLIKELY(list == NULL))
if (list == NULL)
{
utils_mkdir(path, FALSE);
return FALSE;
@ -700,8 +700,7 @@ static gchar *make_comment_block(const gchar *comment_text, gint filetype_idx, g
gchar *templates_get_template_licence(gint filetype_idx, gint licence_type)
{
if (G_UNLIKELY(licence_type != GEANY_TEMPLATE_GPL) &&
G_UNLIKELY(licence_type != GEANY_TEMPLATE_BSD))
if (licence_type != GEANY_TEMPLATE_GPL && licence_type != GEANY_TEMPLATE_BSD)
return NULL;
return make_comment_block(templates[licence_type], filetype_idx, 8);
@ -818,7 +817,7 @@ void templates_free_templates(void)
g_free(ft_templates[i]);
}
/* destroy "New with template" sub menu items (in case we want to reload the templates) */
if (G_LIKELY(ui_widgets.new_file_menu != NULL))
if (ui_widgets.new_file_menu != NULL)
{
children = gtk_container_get_children(GTK_CONTAINER(ui_widgets.new_file_menu));
for (item = children; item != NULL; item = g_list_next(item))

View File

@ -112,7 +112,7 @@ GtkWidget *toolbar_get_widget_by_name(const gchar *name)
GtkWidget *widget;
gchar *path;
g_return_val_if_fail(G_LIKELY(name != NULL), NULL);
g_return_val_if_fail(name != NULL, NULL);
path = g_strconcat("/ui/GeanyToolbar/", name, NULL);
widget = gtk_ui_manager_get_widget(uim, path);
@ -135,7 +135,7 @@ GtkWidget *toolbar_get_widget_child_by_name(const gchar *name)
GtkAction *toolbar_get_action_by_name(const gchar *name)
{
g_return_val_if_fail(G_LIKELY(name != NULL), NULL);
g_return_val_if_fail(name != NULL, NULL);
return gtk_action_group_get_action(group, name);
}
@ -252,7 +252,7 @@ void toolbar_update_ui(void)
static GtkWidget *menubar_toolbar_separator = NULL;
GtkWidget *parent;
if (G_UNLIKELY(menubar == NULL))
if (menubar == NULL)
{ /* cache widget pointers */
hbox_menubar = ui_lookup_widget(main_widgets.window, "hbox_menubar");
menubar = ui_lookup_widget(main_widgets.window, "menubar1");
@ -266,7 +266,7 @@ void toolbar_update_ui(void)
if (toolbar_prefs.append_to_menu)
{
if (G_LIKELY(parent != NULL))
if (parent != NULL)
{
if (parent != hbox_menubar)
{ /* here we manually 'reparent' the toolbar, gtk_widget_reparent() doesn't
@ -287,7 +287,7 @@ void toolbar_update_ui(void)
{
GtkWidget *box = ui_lookup_widget(main_widgets.window, "vbox1");
if (G_LIKELY(parent != NULL))
if (parent != NULL)
{
if (parent != box)
{

View File

@ -237,7 +237,7 @@ void tools_execute_custom_command(GeanyDocument *doc, const gchar *command)
gint stdout_fd;
gint stderr_fd;
g_return_if_fail(G_LIKELY(doc != NULL) && G_LIKELY(command != NULL));
g_return_if_fail(doc != NULL && command != NULL);
if (! sci_has_selection(doc->editor->sci))
return;
@ -326,7 +326,7 @@ static void cc_show_dialog_custom_commands(void)
guint len = g_strv_length(ui_prefs.custom_commands);
for (i = 0; i < len; i++)
{
if (G_UNLIKELY(ui_prefs.custom_commands[i][0] == '\0'))
if (ui_prefs.custom_commands[i][0] == '\0')
continue; /* skip empty fields */
cc_add_command(&cc, i);
@ -402,8 +402,7 @@ static void cc_on_custom_command_menu_activate(GtkMenuItem *menuitem, gpointer u
gboolean enable;
GList *children;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
enable = sci_has_selection(doc->editor->sci) && (ui_prefs.custom_commands != NULL);
@ -427,8 +426,7 @@ static void cc_on_custom_command_activate(GtkMenuItem *menuitem, gpointer user_d
GeanyDocument *doc = document_get_current();
gint command_idx;
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
command_idx = GPOINTER_TO_INT(user_data);
@ -559,7 +557,7 @@ static void word_count(gchar *text, guint *chars, guint *lines, guint *words)
guint in_word = 0;
gunichar utext;
if (G_UNLIKELY(! text))
if (! text)
return; /* politely refuse to operate on NULL */
*chars = *words = *lines = 0;
@ -612,8 +610,7 @@ void tools_word_count(void)
gchar *text, *range;
doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
dialog = gtk_dialog_new_with_buttons(_("Word Count"), GTK_WINDOW(main_widgets.window),
GTK_DIALOG_DESTROY_WITH_PARENT,
@ -724,8 +721,7 @@ on_color_ok_button_clicked (GtkButton *button,
gchar *hex;
gtk_widget_hide(ui_widgets.open_colorsel);
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
gtk_color_selection_get_current_color(
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(ui_widgets.open_colorsel)->colorsel), &color);
@ -745,7 +741,7 @@ void tools_color_chooser(const gchar *color)
#else
gchar *c = (gchar*) color;
if (G_UNLIKELY(ui_widgets.open_colorsel == NULL))
if (ui_widgets.open_colorsel == NULL)
{
ui_widgets.open_colorsel = gtk_color_selection_dialog_new(_("Color Chooser"));
gtk_widget_set_name(ui_widgets.open_colorsel, "GeanyDialog");

View File

@ -163,7 +163,7 @@ void treeviews_update_tag_list(GeanyDocument *doc, gboolean update)
if (gtk_bin_get_child(GTK_BIN(tag_window)))
gtk_container_remove(GTK_CONTAINER(tag_window), gtk_bin_get_child(GTK_BIN(tag_window)));
if (G_UNLIKELY(tv.default_tag_tree == NULL))
if (tv.default_tag_tree == NULL)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW(tag_window);
GtkWidget *label;
@ -182,8 +182,7 @@ void treeviews_update_tag_list(GeanyDocument *doc, gboolean update)
}
/* show default empty tag tree if there are no tags */
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(doc->file_type == NULL) ||
! filetype_has_tags(doc->file_type))
if (doc == NULL || doc->file_type == NULL || ! filetype_has_tags(doc->file_type))
{
gtk_container_add(GTK_CONTAINER(tag_window), tv.default_tag_tree);
return;
@ -191,7 +190,7 @@ void treeviews_update_tag_list(GeanyDocument *doc, gboolean update)
if (update)
{ /* updating the tag list in the left tag window */
if (G_UNLIKELY(doc->priv->tag_tree == NULL))
if (doc->priv->tag_tree == NULL)
{
doc->priv->tag_store = gtk_tree_store_new(
SYMBOLS_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING);
@ -665,7 +664,7 @@ static void on_openfiles_tree_selection_changed(GtkTreeSelection *selection, gpo
if (gtk_tree_selection_get_selected(selection, &model, &iter) && ! ignore_callback)
{
gtk_tree_model_get(model, &iter, DOCUMENTS_DOCUMENT, &doc, -1);
if (G_UNLIKELY(! doc))
if (! doc)
return; /* parent */
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook),
@ -686,7 +685,7 @@ static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection)
const TMTag *tag;
gtk_tree_model_get(model, &iter, SYMBOLS_COLUMN_TAG, &tag, -1);
if (G_UNLIKELY(! tag))
if (! tag)
return FALSE;
line = tag->atts.entry.line;

View File

@ -97,7 +97,7 @@ static GtkWidget *progress_bar_create(void);
/* simple wrapper for gtk_widget_set_sensitive() to allow widget being NULL */
void ui_widget_set_sensitive(GtkWidget *widget, gboolean set)
{
if (G_LIKELY(widget != NULL))
if (widget != NULL)
gtk_widget_set_sensitive(widget, set);
}
@ -152,7 +152,7 @@ void ui_set_statusbar(gboolean log, const gchar *format, ...)
static GeanyFiletype *document_get_filetype(GeanyDocument *doc)
{
g_return_val_if_fail(G_LIKELY(doc), NULL);
g_return_val_if_fail(doc, NULL);
return filetypes[FILETYPE_ID(doc->file_type)];
}
@ -164,10 +164,10 @@ void ui_update_statusbar(GeanyDocument *doc, gint pos)
if (! interface_prefs.statusbar_visible)
return; /* just do nothing if statusbar is not visible */
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
doc = document_get_current();
if (G_UNLIKELY(doc != NULL))
if (doc != NULL)
{
static GString *stats_str = NULL;
const gchar sp[] = " ";
@ -264,11 +264,11 @@ void ui_set_window_title(GeanyDocument *doc)
str = g_string_new(NULL);
if (G_LIKELY(doc != NULL))
if (doc != NULL)
{
g_string_append(str, doc->changed ? "*" : "");
if (G_LIKELY(doc->file_name == NULL))
if (doc->file_name == NULL)
g_string_append(str, DOC_FILENAME(doc));
else
{
@ -299,7 +299,7 @@ void ui_set_editor_font(const gchar *font_name)
{
guint i;
g_return_if_fail(G_LIKELY(font_name != NULL));
g_return_if_fail(font_name != NULL);
/* do nothing if font has not changed */
if (interface_prefs.editor_font != NULL)
@ -341,7 +341,7 @@ void ui_update_popup_reundo_items(GeanyDocument *doc)
gboolean enable_redo;
guint i, len;
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
{
enable_undo = FALSE;
enable_redo = FALSE;
@ -420,13 +420,11 @@ void ui_update_insert_include_item(GeanyDocument *doc, gint item)
{
gboolean enable = FALSE;
if (G_UNLIKELY(doc == NULL) || G_UNLIKELY(doc->file_type == NULL))
if (doc == NULL || doc->file_type == NULL)
enable = FALSE;
else if (doc->file_type->id == GEANY_FILETYPES_C ||
doc->file_type->id == GEANY_FILETYPES_CPP)
{
else if (doc->file_type->id == GEANY_FILETYPES_C || doc->file_type->id == GEANY_FILETYPES_CPP)
enable = TRUE;
}
ui_widget_set_sensitive(widgets.menu_insert_include_items[item], enable);
}
@ -776,7 +774,7 @@ void ui_document_show_hide(GeanyDocument *doc)
if (doc == NULL)
doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
if (doc == NULL)
return;
ignore_callback = TRUE;
@ -837,7 +835,7 @@ void ui_set_search_entry_background(GtkWidget *widget, gboolean success)
static const GdkColor white = {0, 0xffff, 0xffff, 0xffff};
static gboolean old_value = TRUE;
g_return_if_fail(G_LIKELY(widget != NULL));
g_return_if_fail(widget != NULL);
/* update only if really needed */
if (old_value != success)
@ -1003,7 +1001,7 @@ static void add_recent_file(const gchar *utf8_filename, GeanyRecentFiles *grf)
{
GtkRecentManager *manager = gtk_recent_manager_get_default();
gchar *uri = g_filename_to_uri(utf8_filename, NULL, NULL);
if (G_LIKELY(uri != NULL))
if (uri != NULL)
{
gtk_recent_manager_add_item(manager, uri);
g_free(uri);
@ -1297,7 +1295,7 @@ ui_image_menu_item_new(const gchar *stock_id, const gchar *label)
static void entry_clear_icon_press_cb(GtkEntry *entry, gint icon_pos, GdkEvent *event, gpointer data)
{
if (event->button.button == 1 && G_LIKELY(icon_pos == 1))
if (event->button.button == 1 && icon_pos == 1)
{
gtk_entry_set_text(entry, "");
}
@ -1581,7 +1579,7 @@ static gchar *run_file_chooser(const gchar *title, GtkFileChooserAction action,
gtk_widget_set_name(dialog, "GeanyDialog");
locale_path = utils_get_locale_from_utf8(utf8_path);
if (G_LIKELY(action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER))
if (action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
if (g_path_is_absolute(locale_path) && g_file_test(locale_path, G_FILE_TEST_IS_DIR))
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_path);
@ -1613,7 +1611,7 @@ static void ui_path_box_open_clicked(GtkButton *button, gpointer user_data)
gchar *utf8_path;
/* TODO: extend for other actions */
g_return_if_fail(G_LIKELY(action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER));
g_return_if_fail(action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
if (title == NULL)
title = (action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER) ?
@ -1626,7 +1624,7 @@ static void ui_path_box_open_clicked(GtkButton *button, gpointer user_data)
utf8_path = run_file_chooser(title, action, gtk_entry_get_text(GTK_ENTRY(entry)));
#endif
if (G_LIKELY(utf8_path != NULL))
if (utf8_path != NULL)
{
gtk_entry_set_text(GTK_ENTRY(entry), utf8_path);
g_free(utf8_path);
@ -1816,7 +1814,7 @@ void ui_init(void)
static void auto_separator_update(GeanyAutoSeparator *autosep)
{
g_return_if_fail(G_LIKELY(autosep->ref_count >= 0));
g_return_if_fail(autosep->ref_count >= 0);
if (autosep->widget)
ui_widget_show_hide(autosep->widget, autosep->ref_count > 0);
@ -1908,8 +1906,8 @@ GtkWidget *ui_lookup_widget(GtkWidget *widget, const gchar *widget_name)
{
GtkWidget *parent, *found_widget;
g_return_val_if_fail(G_LIKELY(widget != NULL), NULL);
g_return_val_if_fail(G_LIKELY(widget_name != NULL), NULL);
g_return_val_if_fail(widget != NULL, NULL);
g_return_val_if_fail(widget_name != NULL, NULL);
for (;;)
{
@ -1917,7 +1915,7 @@ GtkWidget *ui_lookup_widget(GtkWidget *widget, const gchar *widget_name)
parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
else
parent = widget->parent;
if (G_UNLIKELY(parent == NULL))
if (parent == NULL)
parent = (GtkWidget*) g_object_get_data(G_OBJECT(widget), "GladeParentKey");
if (parent == NULL)
break;
@ -1976,7 +1974,7 @@ static gboolean progress_bar_pulse(gpointer data)
**/
void ui_progress_bar_start(const gchar *text)
{
g_return_if_fail(G_LIKELY(progress_bar_timer_id == (guint) -1));
g_return_if_fail(progress_bar_timer_id == (guint) -1);
if (! interface_prefs.statusbar_visible)
return;

View File

@ -73,12 +73,12 @@
void utils_open_browser(const gchar *uri)
{
#ifdef G_OS_WIN32
g_return_if_fail(G_LIKELY(uri != NULL));
g_return_if_fail(uri != NULL);
win32_open_browser(uri);
#else
gchar *cmdline;
g_return_if_fail(G_LIKELY(uri != NULL));
g_return_if_fail(uri != NULL);
cmdline = g_strconcat(tool_prefs.browser_cmd, " ", uri, NULL);
if (! g_spawn_command_line_async(cmdline, NULL))
@ -231,8 +231,8 @@ gint utils_write_file(const gchar *filename, const gchar *text)
{
GError *error = NULL;
g_return_val_if_fail(G_LIKELY(filename != NULL), ENOENT);
g_return_val_if_fail(G_LIKELY(text != NULL), EINVAL);
g_return_val_if_fail(filename != NULL, ENOENT);
g_return_val_if_fail(text != NULL, EINVAL);
if (! g_file_set_contents(filename, text, -1, &error))
{
@ -365,8 +365,8 @@ gint utils_str_casecmp(const gchar *s1, const gchar *s2)
gchar *tmp1, *tmp2;
gint result;
g_return_val_if_fail(G_LIKELY(s1 != NULL), 1);
g_return_val_if_fail(G_LIKELY(s2 != NULL), -1);
g_return_val_if_fail(s1 != NULL, 1);
g_return_val_if_fail(s2 != NULL, -1);
tmp1 = g_strdup(s1);
tmp2 = g_strdup(s2);
@ -377,12 +377,12 @@ gint utils_str_casecmp(const gchar *s1, const gchar *s2)
if (! g_utf8_validate(s2, -1, NULL))
setptr(tmp2, g_locale_to_utf8(s2, -1, NULL, NULL, NULL));
if (G_UNLIKELY(tmp1 == NULL))
if (tmp1 == NULL)
{
g_free(tmp2);
return 1;
}
if (G_UNLIKELY(tmp2 == NULL))
if (tmp2 == NULL)
{
g_free(tmp1);
return -1;
@ -413,8 +413,8 @@ gint utils_str_casecmp(const gchar *s1, const gchar *s2)
gboolean utils_str_equal(const gchar *a, const gchar *b)
{
/* (taken from libexo from os-cillation) */
if (G_UNLIKELY(a == NULL) && G_UNLIKELY(b == NULL)) return TRUE;
else if (G_UNLIKELY(a == NULL) || G_UNLIKELY(b == NULL)) return FALSE;
if (a == NULL && b == NULL) return TRUE;
else if (a == NULL || b == NULL) return FALSE;
while (*a == *b++)
if (*a++ == '\0')
@ -437,7 +437,7 @@ gchar *utils_remove_ext_from_filename(const gchar *filename)
gchar *result;
gint i;
g_return_val_if_fail(G_LIKELY(filename != NULL), NULL);
g_return_val_if_fail(filename != NULL, NULL);
last_dot = strrchr(filename, '.');
if (! last_dot)
@ -527,8 +527,7 @@ gchar *utils_str_replace(gchar *haystack, const gchar *needle, const gchar *repl
{
GString *str;
if (G_UNLIKELY(haystack == NULL))
return NULL;
g_return_val_if_fail(haystack != NULL, NULL);
str = g_string_new(haystack);
@ -545,7 +544,7 @@ gint utils_strpos(const gchar *haystack, const gchar *needle)
gint needle_length = strlen(needle);
gint i, j, pos = -1;
if (G_UNLIKELY(needle_length > haystack_length))
if (needle_length > haystack_length)
{
return -1;
}
@ -597,7 +596,7 @@ gchar *utils_get_date_time(const gchar *format, time_t *time_to_use)
gchar *locale_format;
gsize len;
g_return_val_if_fail(G_LIKELY(format != NULL), NULL);
g_return_val_if_fail(format != NULL, NULL);
if (! g_utf8_validate(format, -1, NULL))
{
@ -743,8 +742,7 @@ gchar *utils_get_hex_from_color(GdkColor *color)
{
gchar *buffer = g_malloc0(9);
if (G_UNLIKELY(color == NULL))
return NULL;
g_return_val_if_fail(color != NULL, NULL);
g_snprintf(buffer, 8, "#%02X%02X%02X",
(guint) (utils_scale_round(color->red / 256, 255)),
@ -762,12 +760,12 @@ gchar *utils_get_current_file_dir_utf8(void)
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
if (doc != NULL)
{
/* get current filename */
const gchar *cur_fname = doc->file_name;
if (G_LIKELY(cur_fname != NULL))
if (cur_fname != NULL)
{
/* get folder part from current filename */
return g_path_get_dirname(cur_fname); /* returns "." if no path */
@ -781,7 +779,8 @@ gchar *utils_get_current_file_dir_utf8(void)
/* very simple convenience function */
void utils_beep(void)
{
if (prefs.beep_on_errors) gdk_beep();
if (prefs.beep_on_errors)
gdk_beep();
}
@ -804,7 +803,7 @@ gchar *utils_make_human_readable_str(guint64 size, gulong block_size,
frac = 0;
val = size * block_size;
if (G_UNLIKELY(val == 0))
if (val == 0)
return g_strdup(u);
if (display_unit)
@ -854,9 +853,9 @@ gint utils_strtod(const gchar *source, gchar **end, gboolean with_route)
{
guint red, green, blue, offset = 0;
if (G_UNLIKELY(source == NULL))
return -1;
else if (with_route && (strlen(source) != 7 || source[0] != '#'))
g_return_val_if_fail(source != NULL, -1);
if (with_route && (strlen(source) != 7 || source[0] != '#'))
return -1;
else if (! with_route && (strlen(source) != 8 || source[0] != '0' ||
(source[1] != 'x' && source[1] != 'X')))
@ -937,12 +936,11 @@ gchar **utils_read_file_in_array(const gchar *filename)
gchar **result = NULL;
gchar *data;
if (G_UNLIKELY(filename == NULL))
return NULL;
g_return_val_if_fail(filename != NULL, NULL);
g_file_get_contents(filename, &data, NULL, NULL);
if (G_LIKELY(data != NULL))
if (data != NULL)
{
result = g_strsplit_set(data, "\r\n", -1);
g_free(data);
@ -959,11 +957,13 @@ gboolean utils_str_replace_escape(gchar *string)
gsize i, j, len;
guint unicodechar;
g_return_val_if_fail(string != NULL, FALSE);
j = 0;
len = strlen(string);
for (i = 0; i < len; i++)
{
if (G_UNLIKELY(string[i]=='\\'))
if (string[i]=='\\')
{
if (i++ >= strlen(string))
{
@ -1125,10 +1125,10 @@ gchar *utils_get_locale_from_utf8(const gchar *utf8_text)
#else
gchar *locale_text;
if (G_UNLIKELY(! utf8_text))
if (! utf8_text)
return NULL;
locale_text = g_locale_from_utf8(utf8_text, -1, NULL, NULL, NULL);
if (G_UNLIKELY(locale_text == NULL))
if (locale_text == NULL)
locale_text = g_strdup(utf8_text);
return locale_text;
#endif
@ -1153,10 +1153,10 @@ gchar *utils_get_utf8_from_locale(const gchar *locale_text)
#else
gchar *utf8_text;
if (G_UNLIKELY(! locale_text))
if (! locale_text)
return NULL;
utf8_text = g_locale_to_utf8(locale_text, -1, NULL, NULL, NULL);
if (G_UNLIKELY(utf8_text == NULL))
if (utf8_text == NULL)
utf8_text = g_strdup(locale_text);
return utf8_text;
#endif
@ -1178,7 +1178,7 @@ void utils_free_pointers(gsize arg_count, ...)
g_free(ptr);
}
ptr = va_arg(a, gpointer);
if (G_UNLIKELY(ptr))
if (ptr)
g_warning("Wrong arg_count!");
va_end(a);
}
@ -1195,8 +1195,7 @@ gchar **utils_strv_new(const gchar *first, ...)
gchar *str;
gchar **strv;
if (G_UNLIKELY(first == NULL))
return NULL;
g_return_val_if_fail(first != NULL, NULL);
strvlen = 1; /* for first argument */
@ -1236,7 +1235,7 @@ gint utils_mkdir(const gchar *path, gboolean create_parent_dirs)
gint mode = 0700;
gint result;
if (G_UNLIKELY(path == NULL) || strlen(path) == 0)
if (path == NULL || strlen(path) == 0)
return EFAULT;
result = (create_parent_dirs) ? g_mkdir_with_parents(path, mode) : g_mkdir(path, mode);
@ -1269,16 +1268,16 @@ GSList *utils_get_file_list(const gchar *path, guint *length, GError **error)
*error = NULL;
if (length)
*length = 0;
g_return_val_if_fail(G_LIKELY(path != NULL), NULL);
g_return_val_if_fail(path != NULL, NULL);
dir = g_dir_open(path, 0, error);
if (G_UNLIKELY(dir == NULL))
if (dir == NULL)
return NULL;
while (1)
{
const gchar *filename = g_dir_read_name(dir);
if (G_UNLIKELY(filename == NULL))
if (filename == NULL)
break;
list = g_slist_insert_sorted(list, g_strdup(filename), (GCompareFunc) utils_str_casecmp);
@ -1320,9 +1319,10 @@ static guint utils_string_replace_helper(GString *haystack, const gchar *needle,
guint ret = 0;
gssize pos;
if (G_UNLIKELY(haystack->len == 0))
g_return_val_if_fail(haystack != NULL, 0);
if (haystack->len == 0)
return FALSE;
g_return_val_if_fail(G_LIKELY(NZV(needle)), 0);
g_return_val_if_fail(NZV(needle), 0);
stack = haystack->str;
if (! (match = strstr(stack, needle)))
@ -1402,7 +1402,7 @@ const gchar *utils_get_default_dir_utf8(void)
static gboolean check_error(GError **error)
{
if (G_UNLIKELY(error != NULL) && G_UNLIKELY(*error != NULL))
if (error != NULL && *error != NULL)
{
/* imitate the GLib warning */
g_warning(
@ -1443,7 +1443,7 @@ gboolean utils_spawn_sync(const gchar *dir, gchar **argv, gchar **env, GSpawnFla
if (! check_error(error))
return FALSE;
if (G_UNLIKELY(argv == NULL))
if (argv == NULL)
{
*error = g_error_new(G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "argv must not be NULL");
return FALSE;
@ -1489,7 +1489,7 @@ gboolean utils_spawn_async(const gchar *dir, gchar **argv, gchar **env, GSpawnFl
if (! check_error(error))
return FALSE;
if (G_UNLIKELY(argv == NULL))
if (argv == NULL)
{
*error = g_error_new(G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "argv must not be NULL");
return FALSE;
@ -1513,7 +1513,7 @@ const gchar *utils_build_path(const gchar *first, ...)
const gchar *str;
va_list args;
if (G_UNLIKELY(! buffer))
if (! buffer)
buffer = g_string_new(first);
else
g_string_assign(buffer, first);
@ -1543,7 +1543,7 @@ gchar *utils_get_path_from_uri(const gchar *uri)
{
gchar *locale_filename;
g_return_val_if_fail(G_LIKELY(uri != NULL), NULL);
g_return_val_if_fail(uri != NULL, NULL);
if (! utils_is_uri(uri))
return g_strdup(uri);
@ -1575,7 +1575,7 @@ gchar *utils_get_path_from_uri(const gchar *uri)
gboolean utils_is_uri(const gchar *uri)
{
g_return_val_if_fail(G_LIKELY(uri != NULL), FALSE);
g_return_val_if_fail(uri != NULL, FALSE);
return (strstr(uri, "://") != NULL);
}
@ -1584,7 +1584,7 @@ gboolean utils_is_uri(const gchar *uri)
/* path should be in locale encoding */
gboolean utils_is_remote_path(const gchar *path)
{
g_return_val_if_fail(G_LIKELY(path != NULL), FALSE);
g_return_val_if_fail(path != NULL, FALSE);
/* if path is an URI and it doesn't start "file://", we take it as remote */
if (utils_is_uri(path) && strncmp(path, "file:", 5) != 0)

View File

@ -197,7 +197,7 @@ static gchar **vte_get_child_environment(void)
static void override_menu_key(void)
{
if (G_UNLIKELY(gtk_menu_key_accel == NULL)) /* for restoring the default value */
if (gtk_menu_key_accel == NULL) /* for restoring the default value */
g_object_get(G_OBJECT(gtk_settings_get_default()),
"gtk-menu-bar-accel", &gtk_menu_key_accel, NULL);
@ -241,7 +241,7 @@ void vte_init(void)
}
}
if (G_UNLIKELY(module == NULL))
if (module == NULL)
{
vte_info.have_vte = FALSE;
geany_debug("Could not load libvte.so, embedded terminal support disabled");
@ -395,7 +395,7 @@ static void vte_start(GtkWidget *widget)
static void vte_restart(GtkWidget *widget)
{
vte_get_working_directory(); /* try to keep the working directory when restarting the VTE */
if (G_LIKELY(pid > 0))
if (pid > 0)
{
kill(pid, SIGINT);
pid = 0;
@ -501,7 +501,7 @@ static void vte_popup_menu_clicked(GtkMenuItem *menuitem, gpointer user_data)
case POPUP_CHANGEPATH:
{
GeanyDocument *doc = document_get_current();
if (G_LIKELY(doc != NULL))
if (doc != NULL)
vte_cwd(doc->file_name, TRUE);
break;
}
@ -608,7 +608,7 @@ const gchar *vte_get_working_directory(void)
gchar *cwd;
gint length;
if (G_LIKELY(pid > 0))
if (pid > 0)
{
file = g_strdup_printf("/proc/%d/cwd", pid);
length = readlink(file, buffer, sizeof(buffer));
@ -622,7 +622,7 @@ const gchar *vte_get_working_directory(void)
else if (length == 0)
{
cwd = g_get_current_dir();
if (G_LIKELY(cwd != NULL))
if (cwd != NULL)
{
if (chdir(file) == 0)
{
@ -649,7 +649,7 @@ const gchar *vte_get_working_directory(void)
void vte_cwd(const gchar *filename, gboolean force)
{
if (vte_info.have_vte && (vc->follow_path || force) &&
G_LIKELY(filename != NULL) && g_path_is_absolute(filename))
filename != NULL && g_path_is_absolute(filename))
{
gchar *path;
@ -906,8 +906,7 @@ void vte_send_selection_to_vte(void)
gsize len;
doc = document_get_current();
if (G_UNLIKELY(doc == NULL))
return;
g_return_if_fail(doc != NULL);
if (sci_has_selection(doc->editor->sci))
{