[geany/geany] 0998f1: Make code more readable by renaming poorly named macros NZV and NVL

Nick Treleaven git-noreply at xxxxx
Thu Aug 15 04:54:20 UTC 2013


Branch:      refs/heads/master
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Matthew Brush <matt at geany.org>
Date:        Thu, 15 Aug 2013 04:54:20 UTC
Commit:      0998f1c19c4a199c14920a3802172d820859be08
             https://github.com/geany/geany/commit/0998f1c19c4a199c14920a3802172d820859be08

Log Message:
-----------
Make code more readable by renaming poorly named macros NZV and NVL

Closes #159


Modified Paths:
--------------
    plugins/classbuilder.c
    plugins/export.c
    plugins/filebrowser.c
    plugins/htmlchars.c
    plugins/saveactions.c
    src/build.c
    src/callbacks.c
    src/dialogs.c
    src/editor.c
    src/filetypes.c
    src/highlighting.c
    src/keyfile.c
    src/main.c
    src/msgwindow.c
    src/plugins.c
    src/printing.c
    src/project.c
    src/search.c
    src/sidebar.c
    src/socket.c
    src/symbols.c
    src/templates.c
    src/toolbar.c
    src/tools.c
    src/ui_utils.c
    src/utils.c
    src/utils.h
    src/vte.c
    tagmanager/src/tm_symbol.c
    tagmanager/src/tm_tag.c
    tagmanager/src/tm_work_object.h

Modified: plugins/classbuilder.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -848,7 +848,7 @@ static gboolean create_class(CreateClassDialog *cc_dlg)
 		case GEANY_CLASS_TYPE_GTK:
 		{
 			class_info->namespace = g_strdup(gtk_entry_get_text(GTK_ENTRY(cc_dlg->class_namespace_entry)));
-			if (!NZV(class_info->namespace))
+			if (EMPTY(class_info->namespace))
 			{
 				class_info->namespace_up = g_strdup("");
 				class_info->namespace_low = g_strdup("");


Modified: plugins/export.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -247,7 +247,7 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
 		gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fname);
 
 		/* use default startup directory(if set) if no files are open */
-		if (NZV(default_open_path) && g_path_is_absolute(default_open_path))
+		if (!EMPTY(default_open_path) && g_path_is_absolute(default_open_path))
 		{
 			gchar *locale_path = utils_get_locale_from_utf8(default_open_path);
 			gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_path);


Modified: plugins/filebrowser.c
10 files changed, 5 insertions(+), 5 deletions(-)
===================================================================
@@ -186,7 +186,7 @@ static void add_item(const gchar *name)
 	const gchar *sep;
 	gboolean dir;
 
-	if (G_UNLIKELY(! NZV(name)))
+	if (G_UNLIKELY(EMPTY(name)))
 		return;
 
 	/* root directory doesn't need separator */
@@ -237,7 +237,7 @@ static void add_top_level_entry(void)
 	GtkTreeIter iter;
 	gchar *utf8_dir;
 
-	if (! NZV(g_path_skip_root(current_dir)))
+	if (EMPTY(g_path_skip_root(current_dir)))
 		return;	/* ignore 'C:\' or '/' */
 
 	utf8_dir = g_path_get_dirname(current_dir);
@@ -321,7 +321,7 @@ static gchar *get_default_dir(void)
 	else
 		dir = geany->prefs->default_open_path;
 
-	if (NZV(dir))
+	if (!EMPTY(dir))
 		return utils_get_locale_from_utf8(dir);
 
 	return g_get_current_dir();
@@ -762,7 +762,7 @@ static void on_path_entry_activate(GtkEntry *entry, gpointer user_data)
 {
 	gchar *new_dir = (gchar*) gtk_entry_get_text(entry);
 
-	if (NZV(new_dir))
+	if (!EMPTY(new_dir))
 	{
 		if (g_str_has_suffix(new_dir, ".."))
 		{
@@ -1006,7 +1006,7 @@ static void project_change_cb(G_GNUC_UNUSED GObject *obj, G_GNUC_UNUSED GKeyFile
 	gchar *new_dir;
 	GeanyProject *project = geany->app->project;
 
-	if (! fb_set_project_base_path || project == NULL || ! NZV(project->base_path))
+	if (! fb_set_project_base_path || project == NULL || EMPTY(project->base_path))
 		return;
 
 	/* TODO this is a copy of project_get_base_path(), add it to the plugin API */


Modified: plugins/htmlchars.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -587,7 +587,7 @@ static gboolean sc_insert(GtkTreeModel *model, GtkTreeIter *iter)
 		gint pos = sci_get_current_position(doc->editor->sci);
 
 		gtk_tree_model_get(model, iter, COLUMN_HTML_NAME, &str, -1);
-		if (NZV(str))
+		if (!EMPTY(str))
 		{
 			sci_insert_text(doc->editor->sci, pos, str);
 			g_free(str);


Modified: plugins/saveactions.c
10 files changed, 5 insertions(+), 5 deletions(-)
===================================================================
@@ -93,7 +93,7 @@ static gboolean backupcopy_set_backup_dir(const gchar *utf8_dir)
 {
 	gchar *tmp;
 
-	if (G_UNLIKELY(! NZV(utf8_dir)))
+	if (G_UNLIKELY(EMPTY(utf8_dir)))
 		return FALSE;
 
 	tmp = utils_get_locale_from_utf8(utf8_dir);
@@ -386,7 +386,7 @@ static void backupcopy_dir_button_clicked_cb(GtkButton *button, gpointer item)
 					GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
 
 	text = utils_get_locale_from_utf8(gtk_entry_get_text(GTK_ENTRY(item)));
-	if (NZV(text))
+	if (!EMPTY(text))
 		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), text);
 
 	/* run it */
@@ -458,7 +458,7 @@ static void configure_response_cb(GtkDialog *dialog, gint response, G_GNUC_UNUSE
 		SETPTR(backupcopy_time_fmt, g_strdup(text_time));
 		if (enable_backupcopy)
 		{
-			if (NZV(text_dir) && backupcopy_set_backup_dir(text_dir))
+			if (!EMPTY(text_dir) && backupcopy_set_backup_dir(text_dir))
 			{
 				g_key_file_set_string(config, "backupcopy", "backup_dir", text_dir);
 			}
@@ -665,7 +665,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
 
 		pref_widgets.backupcopy_entry_dir = entry_dir = gtk_entry_new();
 		gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry_dir);
-		if (NZV(backupcopy_backup_dir))
+		if (!EMPTY(backupcopy_backup_dir))
 			gtk_entry_set_text(GTK_ENTRY(entry_dir), backupcopy_backup_dir);
 
 		button = gtk_button_new();
@@ -688,7 +688,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
 
 		pref_widgets.backupcopy_entry_time = entry_time = gtk_entry_new();
 		gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry_time);
-		if (NZV(backupcopy_time_fmt))
+		if (!EMPTY(backupcopy_time_fmt))
 			gtk_entry_set_text(GTK_ENTRY(entry_time), backupcopy_time_fmt);
 		gtk_box_pack_start(GTK_BOX(inner_vbox), entry_time, FALSE, FALSE, 0);
 


Modified: src/build.c
38 files changed, 19 insertions(+), 19 deletions(-)
===================================================================
@@ -389,7 +389,7 @@ static GeanyBuildCommand *get_build_cmd(GeanyDocument *doc, guint grp, guint cmd
 
 
 #define return_nonblank_regex(src, ptr)\
-	if (NZV(ptr)) \
+	if (!EMPTY(ptr)) \
 		{ *fr = (src); return &(ptr); }
 
 
@@ -673,14 +673,14 @@ static void parse_build_output(const gchar **output, gint status)
 
 	for (x = 0; x < 2; x++)
 	{
-		if (NZV(output[x]))
+		if (!EMPTY(output[x]))
 		{
 			lines = g_strsplit_set(output[x], "\r\n", -1);
 			len = g_strv_length(lines);
 
 			for (i = 0; i < len; i++)
 			{
-				if (NZV(lines[i]))
+				if (!EMPTY(lines[i]))
 				{
 					line = lines[i];
 					while (*line != '\0')
@@ -781,7 +781,7 @@ static GPid build_spawn_cmd(GeanyDocument *doc, const gchar *cmd, const gchar *d
 	gint stderr_fd;
 #endif
 
-	if (!((doc != NULL && NZV(doc->file_name)) || NZV(dir)))
+	if (!((doc != NULL && !EMPTY(doc->file_name)) || !EMPTY(dir)))
 	{
 		geany_debug("Failed to run command with no working directory");
 		ui_set_statusbar(TRUE, _("Process failed, no working directory"));
@@ -804,7 +804,7 @@ static GPid build_spawn_cmd(GeanyDocument *doc, const gchar *cmd, const gchar *d
 #endif
 
 	utf8_cmd_string = utils_get_utf8_from_locale(cmd_string);
-	utf8_working_dir = NZV(dir) ? g_strdup(dir) : g_path_get_dirname(doc->file_name);
+	utf8_working_dir = !EMPTY(dir) ? g_strdup(dir) : g_path_get_dirname(doc->file_name);
 	working_dir = utils_get_locale_from_utf8(utf8_working_dir);
 
 	gtk_list_store_clear(msgwindow.store_compiler);
@@ -888,18 +888,18 @@ static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript,
 
 	cmd_string = build_replace_placeholder(doc, cmd->command);
 	cmd_working_dir =  cmd->working_dir;
-	if (! NZV(cmd_working_dir))
+	if (EMPTY(cmd_working_dir))
 		cmd_working_dir = "%d";
 	working_dir = build_replace_placeholder(doc, cmd_working_dir); /* in utf-8 */
 
 	/* only test whether working dir exists, don't change it or else Windows support will break
 	 * (gspawn-win32-helper.exe is used by GLib and must be in $PATH which means current working
 	 *  dir where geany.exe was started from, so we can't change it) */
-	if (!NZV(working_dir) || ! g_file_test(working_dir, G_FILE_TEST_EXISTS) ||
+	if (EMPTY(working_dir) || ! g_file_test(working_dir, G_FILE_TEST_EXISTS) ||
 		! g_file_test(working_dir, G_FILE_TEST_IS_DIR))
 	{
 		ui_set_statusbar(TRUE, _("Failed to change the working directory to \"%s\""),
-				NZV(working_dir) ? working_dir : "<NULL>" );
+				!EMPTY(working_dir) ? working_dir : "<NULL>" );
 		utils_free_pointers(2, cmd_string, working_dir, NULL);
 		return NULL;
 	}
@@ -928,7 +928,7 @@ static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript,
 	if (! result)
 	{
 		ui_set_statusbar(TRUE, _("Failed to execute \"%s\" (start-script could not be created: %s)"),
-			NZV(cmd_string) ? cmd_string : NULL, error->message);
+			!EMPTY(cmd_string) ? cmd_string : NULL, error->message);
 		g_error_free(error);
 	}
 
@@ -1073,7 +1073,7 @@ static void process_build_output_line(const gchar *str, gint color)
 
 	g_strchomp(msg);
 
-	if (! NZV(msg))
+	if (EMPTY(msg))
 	{
 		g_free(msg);
 		return;
@@ -1638,7 +1638,7 @@ void build_menu_update(GeanyDocument *doc)
 							(grp == GEANY_GBG_FT && bc != NULL && have_path && ! build_running) ||
 							(grp == GEANY_GBG_NON_FT && bc != NULL && ! build_running);
 						gtk_widget_set_sensitive(menu_item, cmd_sensitivity);
-						if (bc != NULL && NZV(label))
+						if (bc != NULL && !EMPTY(label))
 						{
 							geany_menu_item_set_label(menu_item, label);
 							gtk_widget_show_all(menu_item);
@@ -1666,7 +1666,7 @@ void build_menu_update(GeanyDocument *doc)
 						if (cmd == GBO_TO_CMD(GEANY_GBO_EXEC))
 							run_running = exec_running;
 						gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), image);
-						if (bc != NULL && NZV(label))
+						if (bc != NULL && !EMPTY(label))
 						{
 							geany_menu_item_set_label(menu_item, label);
 							gtk_widget_show_all(menu_item);
@@ -2268,7 +2268,7 @@ static gboolean read_regex(GtkWidget *regexentry, gchar **src, gchar **dst)
 
 	if (((src == NULL			/* originally there was no regex */
 		|| *src == NULL)		/* or it was NULL*/
-		&& NZV(reg))			/* and something was typed */
+		&& !EMPTY(reg))			/* and something was typed */
 		|| (src != NULL			/* originally there was a regex*/
 		&& (*src == NULL 		/* and either it was NULL */
 		|| strcmp(*src, reg) != 0)))	/* or it has been changed */
@@ -2524,7 +2524,7 @@ void build_load_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
 	/* set GeanyBuildCommand if it doesn't already exist and there is a command */
 /* TODO: rewrite as function */
 #define ASSIGNIF(type, id, string, value) \
-	if (NZV(value) && ! type[GBO_TO_CMD(id)].exists) { \
+	if (!EMPTY(value) && ! type[GBO_TO_CMD(id)].exists) { \
 		type[GBO_TO_CMD(id)].exists = TRUE; \
 		SETPTR(type[GBO_TO_CMD(id)].label, g_strdup(string)); \
 		SETPTR(type[GBO_TO_CMD(id)].command, (value)); \
@@ -2579,7 +2579,7 @@ void build_load_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
 			if (non_ft_pref[GBO_TO_CMD(GEANY_GBO_MAKE_OBJECT)].old)
 				SETPTR(non_ft_pref[GBO_TO_CMD(GEANY_GBO_MAKE_OBJECT)].working_dir, g_strdup("%d"));
 			value = g_key_file_get_string(config, "project", "run_cmd", NULL);
-			if (NZV(value))
+			if (!EMPTY(value))
 			{
 				if (exec_proj == NULL)
 					exec_proj = g_new0(GeanyBuildCommand, build_groups_count[GEANY_GBG_EXEC]);
@@ -2676,7 +2676,7 @@ static void foreach_project_filetype(gpointer data, gpointer user_data)
 
 	i += build_save_menu_grp(d->config, ft->projfilecmds, GEANY_GBG_FT, ft->name);
 	i += build_save_menu_grp(d->config, ft->projexeccmds, GEANY_GBG_EXEC, ft->name);
-	if (NZV(ft->projerror_regex_string))
+	if (!EMPTY(ft->projerror_regex_string))
 	{
 		g_key_file_set_string(d->config, build_grp_name, regkey, ft->projerror_regex_string);
 		i++;
@@ -2704,7 +2704,7 @@ void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
 				return;
 			build_save_menu_grp(config, ft->homefilecmds, GEANY_GBG_FT, NULL);
 			build_save_menu_grp(config, ft->homeexeccmds, GEANY_GBG_EXEC, NULL);
-			if (NZV(ft->homeerror_regex_string))
+			if (!EMPTY(ft->homeerror_regex_string))
 				g_key_file_set_string(config, build_grp_name, "error_regex", ft->homeerror_regex_string);
 			else
 				g_key_file_remove_key(config, build_grp_name, "error_regex", NULL);
@@ -2712,7 +2712,7 @@ void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
 		case GEANY_BCS_PREF:
 			build_save_menu_grp(config, non_ft_pref, GEANY_GBG_NON_FT, NULL);
 			build_save_menu_grp(config, exec_pref, GEANY_GBG_EXEC, NULL);
-			if (NZV(regex_pref))
+			if (!EMPTY(regex_pref))
 				g_key_file_set_string(config, build_grp_name, "error_regex", regex_pref);
 			else
 				g_key_file_remove_key(config, build_grp_name, "error_regex", NULL);
@@ -2721,7 +2721,7 @@ void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
 			pj = (GeanyProject*)ptr;
 			build_save_menu_grp(config, non_ft_proj, GEANY_GBG_NON_FT, NULL);
 			build_save_menu_grp(config, exec_proj, GEANY_GBG_EXEC, NULL);
-			if (NZV(regex_proj))
+			if (!EMPTY(regex_proj))
 				g_key_file_set_string(config, build_grp_name, "error_regex", regex_proj);
 			else
 				g_key_file_remove_key(config, build_grp_name, "error_regex", NULL);


Modified: src/callbacks.c
6 files changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -1646,7 +1646,7 @@ G_MODULE_EXPORT void on_menu_open_selected_file1_activate(GtkMenuItem *menuitem,
 			filename = g_build_path(G_DIR_SEPARATOR_S, path, sel, NULL);
 
 			if (! g_file_test(filename, G_FILE_TEST_EXISTS) &&
-				app->project != NULL && NZV(app->project->base_path))
+				app->project != NULL && !EMPTY(app->project->base_path))
 			{
 				/* try the project's base path */
 				SETPTR(path, project_get_base_path());
@@ -1713,7 +1713,7 @@ G_MODULE_EXPORT void on_context_action1_activate(GtkMenuItem *menuitem, gpointer
 
 	/* use the filetype specific command if available, fallback to global command otherwise */
 	if (doc->file_type != NULL &&
-		NZV(doc->file_type->context_action_cmd))
+		!EMPTY(doc->file_type->context_action_cmd))
 	{
 		command = g_strdup(doc->file_type->context_action_cmd);
 	}
@@ -1723,7 +1723,7 @@ G_MODULE_EXPORT void on_context_action1_activate(GtkMenuItem *menuitem, gpointer
 	}
 
 	/* substitute the wildcard %s and run the command if it is non empty */
-	if (G_LIKELY(NZV(command)))
+	if (G_LIKELY(!EMPTY(command)))
 	{
 		utils_str_replace_all(&command, "%s", word);
 


Modified: src/dialogs.c
12 files changed, 6 insertions(+), 6 deletions(-)
===================================================================
@@ -156,7 +156,7 @@ static void open_file_dialog_handle_response(GtkWidget *dialog, gint response)
 		}
 		g_slist_free(filelist);
 	}
-	if (app->project && NZV(app->project->base_path))
+	if (app->project && !EMPTY(app->project->base_path))
 		gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(dialog),
 			app->project->base_path, NULL);
 }
@@ -469,7 +469,7 @@ void dialogs_show_open_file(void)
 		if (initdir != NULL && g_path_is_absolute(initdir))
 				gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), initdir);
 
-		if (app->project && NZV(app->project->base_path))
+		if (app->project && !EMPTY(app->project->base_path))
 			gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(dialog),
 					app->project->base_path, NULL);
 
@@ -486,7 +486,7 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
 	GeanyDocument *doc = document_get_current();
 	gboolean success = FALSE;
 
-	g_return_val_if_fail(NZV(utf8_filename), FALSE);
+	g_return_val_if_fail(!EMPTY(utf8_filename), FALSE);
 
 	if (doc->file_name != NULL)
 	{
@@ -515,7 +515,7 @@ static gboolean save_as_dialog_handle_response(GtkWidget *dialog, gint response)
 	{
 		case GEANY_RESPONSE_RENAME:
 			/* rename doesn't check for empty filename or overwriting */
-			if (G_UNLIKELY(! NZV(new_filename)))
+			if (G_UNLIKELY(EMPTY(new_filename)))
 			{
 				utils_beep();
 				break;
@@ -628,7 +628,7 @@ static gboolean show_save_as_gtk(GeanyDocument *doc)
 		g_free(fname);
 	}
 
-	if (app->project && NZV(app->project->base_path))
+	if (app->project && !EMPTY(app->project->base_path))
 		gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(dialog),
 			app->project->base_path, NULL);
 
@@ -639,7 +639,7 @@ static gboolean show_save_as_gtk(GeanyDocument *doc)
 	}
 	while (! save_as_dialog_handle_response(dialog, resp));
 
-	if (app->project && NZV(app->project->base_path))
+	if (app->project && !EMPTY(app->project->base_path))
 		gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(dialog),
 			app->project->base_path, NULL);
 


Modified: src/editor.c
20 files changed, 10 insertions(+), 10 deletions(-)
===================================================================
@@ -647,7 +647,7 @@ static void show_tags_list(GeanyEditor *editor, const GPtrArray *tags, gsize roo
 			g_string_append(words, tag->name);
 
 			/* for now, tag types don't all follow C, so just look at arglist */
-			if (NZV(tag->atts.entry.arglist))
+			if (!EMPTY(tag->atts.entry.arglist))
 				g_string_append(words, "?2");
 			else
 				g_string_append(words, "?1");
@@ -1389,7 +1389,7 @@ static gint get_xml_indent(ScintillaObject *sci, gint line)
 			gchar *line_contents = sci_get_contents_range(sci, start, end + 1);
 			gchar *opened_tag_name = utils_find_open_xml_tag(line_contents, end + 1 - start);
 
-			if (NZV(opened_tag_name))
+			if (!EMPTY(opened_tag_name))
 			{
 				need_close = TRUE;
 				if (sci_get_lexer(sci) == SCLEX_HTML && utils_is_short_html_tag(opened_tag_name))
@@ -1823,7 +1823,7 @@ static gboolean append_calltip(GString *str, const TMTag *tag, filetype_id ft_id
 		g_string_append_c(str, ' ');
 		g_string_append(str, tag->atts.entry.arglist);
 
-		if (NZV(tag->atts.entry.var_type))
+		if (!EMPTY(tag->atts.entry.var_type))
 		{
 			g_string_append(str, " : ");
 			g_string_append(str, tag->atts.entry.var_type);
@@ -2593,7 +2593,7 @@ gboolean editor_complete_snippet(GeanyEditor *editor, gint pos)
 	word = editor_read_word_stem(editor, pos, wc);
 
 	/* prevent completion of "for " */
-	if (NZV(word) &&
+	if (!EMPTY(word) &&
 		! isspace(sci_get_char_at(sci, pos - 1))) /* pos points to the line end char so use pos -1 */
 	{
 		sci_start_undo_action(sci);	/* needed because we insert a space separately from construct */
@@ -2699,7 +2699,7 @@ static gboolean handle_xml(GeanyEditor *editor, gint pos, gchar ch)
 	{
 		/* ignore tag */
 	}
-	else if (NZV(str_found))
+	else if (!EMPTY(str_found))
 	{
 		insert_closing_tag(editor, pos, ch, str_found);
 		result = TRUE;
@@ -2979,7 +2979,7 @@ gint editor_do_uncomment(GeanyEditor *editor, gint line, gboolean toggle)
 		if (x < line_len && sel[x] != '\0')
 		{
 			/* use single line comment */
-			if (! NZV(cc))
+			if (EMPTY(cc))
 			{
 				single_line = TRUE;
 
@@ -3100,7 +3100,7 @@ void editor_do_comment_toggle(GeanyEditor *editor)
 		while (isspace(sel[x])) x++;
 
 		/* use single line comment */
-		if (! NZV(cc))
+		if (EMPTY(cc))
 		{
 			gboolean do_continue = FALSE;
 			single_line = TRUE;
@@ -3275,7 +3275,7 @@ void editor_do_comment(GeanyEditor *editor, gint line, gboolean allow_empty_line
 		if (allow_empty_lines || (x < line_len && sel[x] != '\0'))
 		{
 			/* use single line comment */
-			if (! NZV(cc))
+			if (EMPTY(cc))
 			{
 				gint start = line_start;
 				single_line = TRUE;
@@ -3542,7 +3542,7 @@ void editor_insert_multiline_comment(GeanyEditor *editor)
 
 	if (! filetype_get_comment_open_close(editor->document->file_type, FALSE, &co, &cc))
 		g_return_if_reached();
-	if (NZV(cc))
+	if (!EMPTY(cc))
 		have_multiline_comment = TRUE;
 
 	sci_start_undo_action(editor->sci);
@@ -4859,7 +4859,7 @@ static void on_document_save(GObject *obj, GeanyDocument *doc)
 {
 	gchar *f = g_build_filename(app->configdir, "snippets.conf", NULL);
 
-	g_return_if_fail(NZV(doc->real_path));
+	g_return_if_fail(!EMPTY(doc->real_path));
 
 	if (utils_str_equal(doc->real_path, f))
 	{


Modified: src/filetypes.c
14 files changed, 7 insertions(+), 7 deletions(-)
===================================================================
@@ -674,7 +674,7 @@ static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc)
 {
 	gchar *f;
 
-	g_return_if_fail(NZV(doc->real_path));
+	g_return_if_fail(!EMPTY(doc->real_path));
 
 	f = g_build_filename(app->configdir, "filetype_extensions.conf", NULL);
 	if (utils_str_equal(doc->real_path, f))
@@ -1216,7 +1216,7 @@ static void load_settings(guint ft_id, GKeyFile *config, GKeyFile *configh)
 		SETPTR(filetypes[ft_id]->comment_single, result);
 	}
 	/* import correctly filetypes that use old-style single comments */
-	else if (! NZV(filetypes[ft_id]->comment_close))
+	else if (EMPTY(filetypes[ft_id]->comment_close))
 	{
 		SETPTR(filetypes[ft_id]->comment_single, filetypes[ft_id]->comment_open);
 		filetypes[ft_id]->comment_open = NULL;
@@ -1529,7 +1529,7 @@ GeanyFiletype *filetypes_lookup_by_name(const gchar *name)
 {
 	GeanyFiletype *ft;
 
-	g_return_val_if_fail(NZV(name), NULL);
+	g_return_val_if_fail(!EMPTY(name), NULL);
 
 	ft = g_hash_table_lookup(filetypes_hash, name);
 	if (G_UNLIKELY(ft == NULL))
@@ -1577,7 +1577,7 @@ gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
 	*filename = NULL;
 	*line = -1;
 
-	if (G_UNLIKELY(! NZV(regstr)))
+	if (G_UNLIKELY(EMPTY(regstr)))
 		return FALSE;
 
 	if (!ft->priv->error_regex || regstr != ft->priv->last_error_pattern)
@@ -1803,7 +1803,7 @@ gboolean filetype_get_comment_open_close(const GeanyFiletype *ft, gboolean singl
 	if (single_first)
 	{
 		*co = ft->comment_single;
-		if (NZV(*co))
+		if (!EMPTY(*co))
 			*cc = NULL;
 		else
 		{
@@ -1814,7 +1814,7 @@ gboolean filetype_get_comment_open_close(const GeanyFiletype *ft, gboolean singl
 	else
 	{
 		*co = ft->comment_open;
-		if (NZV(*co))
+		if (!EMPTY(*co))
 			*cc = ft->comment_close;
 		else
 		{
@@ -1823,5 +1823,5 @@ gboolean filetype_get_comment_open_close(const GeanyFiletype *ft, gboolean singl
 		}
 	}
 
-	return NZV(*co);
+	return !EMPTY(*co);
 }


Modified: src/highlighting.c
8 files changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -225,7 +225,7 @@ static void parse_color(GKeyFile *kf, const gchar *str, gint *clr)
 
 	g_return_if_fail(clr != NULL);
 
-	if (G_UNLIKELY(! NZV(str)))
+	if (G_UNLIKELY(EMPTY(str)))
 		return;
 
 	named_color = g_key_file_get_string(kf, "named_colors", str, NULL);
@@ -554,7 +554,7 @@ static void load_named_styles(GKeyFile *config, GKeyFile *config_home)
 
 	named_style_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
 
-	if (NZV(scheme))
+	if (!EMPTY(scheme))
 	{
 		gchar *path, *path_home;
 
@@ -995,7 +995,7 @@ static void read_properties(GeanyFiletype *ft, GKeyFile *config, GKeyFile *confi
 
 static guint get_lexer_filetype(GeanyFiletype *ft)
 {
-	ft = NVL(ft->lexer_filetype, ft);
+	ft = FALLBACK(ft->lexer_filetype, ft);
 	return ft->id;
 }
 
@@ -1268,7 +1268,7 @@ static gchar *utils_get_setting_locale_string(GKeyFile *keyfile,
 {
 	gchar *result = g_key_file_get_locale_string(keyfile, group, key, NULL, NULL);
 
-	return NVL(result, g_strdup(default_value));
+	return FALLBACK(result, g_strdup(default_value));
 }
 
 


Modified: src/keyfile.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -884,10 +884,10 @@ static void load_dialog_prefs(GKeyFile *config)
 
 	/* tools */
 	cmd = utils_get_setting_string(config, "tools", "terminal_cmd", "");
-	if (!NZV(cmd))
+	if (EMPTY(cmd))
 	{
 		cmd = utils_get_setting_string(config, "tools", "term_cmd", "");
-		if (NZV(cmd))
+		if (!EMPTY(cmd))
 		{
 			tmp_string = cmd;
 #ifdef G_OS_WIN32


Modified: src/main.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -335,7 +335,7 @@ static void get_line_and_column_from_filename(gchar *filename, gint *line, gint
 
 	g_assert(*line == -1 && *column == -1);
 
-	if (G_UNLIKELY(! NZV(filename)))
+	if (G_UNLIKELY(EMPTY(filename)))
 		return;
 
 	/* allow to open files like "test:0" */
@@ -877,7 +877,7 @@ static void load_session_project_file(void)
 
 	locale_filename = utils_get_locale_from_utf8(project_prefs.session_file);
 
-	if (G_LIKELY(NZV(locale_filename)))
+	if (G_LIKELY(!EMPTY(locale_filename)))
 		project_load_file(locale_filename);
 
 	g_free(locale_filename);


Modified: src/msgwindow.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -470,7 +470,7 @@ void msgwin_status_add(const gchar *format, ...)
 		gchar *string;
 
 		gtk_tree_model_get(model, &iter, str_idx, &string, -1);
-		if (NZV(string))
+		if (!EMPTY(string))
 		{
 			gtk_clipboard_set_text(gtk_clipboard_get(gdk_atom_intern("CLIPBOARD", FALSE)),
 				string, -1);
@@ -512,7 +512,7 @@ static void on_compiler_treeview_copy_all_activate(GtkMenuItem *menuitem, gpoint
 		gchar *line;
 
 		gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, str_idx, &line, -1);
-		if (NZV(line))
+		if (!EMPTY(line))
 		{
 			g_string_append(str, line);
 			g_string_append_c(str, '\n');


Modified: src/plugins.c
8 files changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -641,7 +641,7 @@ static gint cmp_plugin_names(gconstpointer a, gconstpointer b)
 	active_plugin_list = g_list_insert_sorted(active_plugin_list, plugin, cmp_plugin_names);
 
 	geany_debug("Loaded:   %s (%s)", plugin->filename,
-		NVL(plugin->info.name, "<Unknown>"));
+		FALLBACK(plugin->info.name, "<Unknown>"));
 }
 
 
@@ -730,7 +730,7 @@ static gint cmp_plugin_names(gconstpointer a, gconstpointer b)
 
 	/* read plugin name, etc. */
 	plugin_set_info(&plugin->info);
-	if (G_UNLIKELY(! NZV(plugin->info.name)))
+	if (G_UNLIKELY(EMPTY(plugin->info.name)))
 	{
 		geany_debug("No plugin name set in plugin_set_info() for \"%s\" - ignoring plugin!",
 			fname);
@@ -856,7 +856,7 @@ static gchar *get_custom_plugin_path(const gchar *plugin_path_config,
 {
 	gchar *plugin_path_custom;
 
-	if (!NZV(prefs.custom_plugin_path))
+	if (EMPTY(prefs.custom_plugin_path))
 		return NULL;
 
 	plugin_path_custom = utils_get_locale_from_utf8(prefs.custom_plugin_path);
@@ -918,7 +918,7 @@ static gboolean check_plugin_path(const gchar *fname)
 	{
 		const gchar *fname = active_plugins_pref[i];
 
-		if (NZV(fname) && g_file_test(fname, G_FILE_TEST_EXISTS))
+		if (!EMPTY(fname) && g_file_test(fname, G_FILE_TEST_EXISTS))
 		{
 			if (!check_plugin_path(fname) || plugin_new(fname, TRUE, FALSE) == NULL)
 				failed_plugins_list = g_list_prepend(failed_plugins_list, g_strdup(fname));


Modified: src/printing.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -164,7 +164,7 @@ static void add_page_header(DocInfo *dinfo, cairo_t *cr, gint width, gint page_n
 	g_free(data);
 
 	datetime = utils_get_date_time(printing_prefs.page_header_datefmt, &(dinfo->print_time));
-	if (G_LIKELY(NZV(datetime)))
+	if (G_LIKELY(!EMPTY(datetime)))
 	{
 		data = g_strdup_printf("<b>%s</b>", datetime);
 		pango_layout_set_markup(layout, data, -1);
@@ -571,7 +571,7 @@ static void print_external(GeanyDocument *doc)
 	if (doc->file_name == NULL)
 		return;
 
-	if (! NZV(printing_prefs.external_print_cmd))
+	if (EMPTY(printing_prefs.external_print_cmd))
 	{
 		dialogs_show_msgbox(GTK_MESSAGE_ERROR,
 			_("Please set a print command in the preferences dialog first."));


Modified: src/project.c
12 files changed, 6 insertions(+), 6 deletions(-)
===================================================================
@@ -667,7 +667,7 @@ static gboolean update_config(const PropertyDialogElements *e, gboolean new_proj
 	else
 		file_name = gtk_label_get_text(GTK_LABEL(e->file_name));
 
-	if (G_UNLIKELY(! NZV(file_name)))
+	if (G_UNLIKELY(EMPTY(file_name)))
 	{
 		SHOW_ERR(_("You have specified an invalid project filename."));
 		gtk_widget_grab_focus(e->file_name);
@@ -676,7 +676,7 @@ static gboolean update_config(const PropertyDialogElements *e, gboolean new_proj
 
 	locale_filename = utils_get_locale_from_utf8(file_name);
 	base_path = gtk_entry_get_text(GTK_ENTRY(e->base_path));
-	if (NZV(base_path))
+	if (!EMPTY(base_path))
 	{	/* check whether the given directory actually exists */
 		gchar *locale_path = utils_get_locale_from_utf8(base_path);
 
@@ -732,7 +732,7 @@ static gboolean update_config(const PropertyDialogElements *e, gboolean new_proj
 	SETPTR(p->name, g_strdup(name));
 	SETPTR(p->file_name, g_strdup(file_name));
 	/* use "." if base_path is empty */
-	SETPTR(p->base_path, g_strdup(NZV(base_path) ? base_path : "./"));
+	SETPTR(p->base_path, g_strdup(!EMPTY(base_path) ? base_path : "./"));
 
 	if (! new_project)	/* save properties specific fields */
 	{
@@ -897,7 +897,7 @@ static void on_name_entry_changed(GtkEditable *editable, PropertyDialogElements
 		return;
 
 	name = gtk_editable_get_chars(editable, 0, -1);
-	if (NZV(name))
+	if (!EMPTY(name))
 	{
 		base_path = g_strconcat(project_dir, G_DIR_SEPARATOR_S,
 			name, G_DIR_SEPARATOR_S, NULL);
@@ -1094,7 +1094,7 @@ gchar *project_get_base_path(void)
 {
 	GeanyProject *project = app->project;
 
-	if (project && NZV(project->base_path))
+	if (project && !EMPTY(project->base_path))
 	{
 		if (g_path_is_absolute(project->base_path))
 			return g_strdup(project->base_path);
@@ -1127,7 +1127,7 @@ void project_save_prefs(GKeyFile *config)
 		g_key_file_set_string(config, "project", "session_file", utf8_filename);
 	}
 	g_key_file_set_string(config, "project", "project_file_path",
-		NVL(local_prefs.project_file_path, ""));
+		FALLBACK(local_prefs.project_file_path, ""));
 }
 
 


Modified: src/search.c
20 files changed, 10 insertions(+), 10 deletions(-)
===================================================================
@@ -781,7 +781,7 @@ static void update_file_patterns(GtkWidget *mode_combo, GtkWidget *fcombo)
 	}
 	else if (selection == FILES_MODE_PROJECT)
 	{
-		if (app->project && NZV(app->project->file_patterns))
+		if (app->project && !EMPTY(app->project->file_patterns))
 		{
 			gchar *patterns;
 
@@ -1063,14 +1063,14 @@ void search_show_find_in_files_dialog_full(const gchar *text, const gchar *dir)
 
 	/* add project's base path directory to the dir list, we do this here once
 	 * (in create_fif_dialog() it would fail if a project is opened after dialog creation) */
-	if (app->project != NULL && NZV(app->project->base_path))
+	if (app->project != NULL && !EMPTY(app->project->base_path))
 	{
 		ui_combo_box_prepend_text_once(GTK_COMBO_BOX_TEXT(fif_dlg.dir_combo),
 			app->project->base_path);
 	}
 
 	entry = gtk_bin_get_child(GTK_BIN(fif_dlg.dir_combo));
-	if (NZV(dir))
+	if (!EMPTY(dir))
 		cur_dir = g_strdup(dir);	/* custom directory argument passed */
 	else
 	{
@@ -1092,7 +1092,7 @@ void search_show_find_in_files_dialog_full(const gchar *text, const gchar *dir)
 
 			last_doc = doc;
 		}
-		if (!cur_dir && ! NZV(gtk_entry_get_text(GTK_ENTRY(entry))))
+		if (!cur_dir && EMPTY(gtk_entry_get_text(GTK_ENTRY(entry))))
 		{
 			/* use default_open_path if no directory could be determined
 			 * (e.g. when no files are open) */
@@ -1226,7 +1226,7 @@ gint search_mark_all(GeanyDocument *doc, const gchar *search_text, gint flags)
 	/* clear previous search indicators */
 	editor_indicator_clear(doc->editor, GEANY_INDICATOR_SEARCH);
 
-	if (G_UNLIKELY(! NZV(search_text)))
+	if (G_UNLIKELY(EMPTY(search_text)))
 		return 0;
 
 	ttf.chrg.cpMin = 0;
@@ -1308,7 +1308,7 @@ static gboolean int_search_flags(gint match_case, gint whole_word, gint regexp,
 		search_data.flags = int_search_flags(settings.find_case_sensitive,
 			settings.find_match_whole_word, settings.find_regexp, settings.find_match_word_start);
 
-		if (! NZV(search_data.text))
+		if (EMPTY(search_data.text))
 		{
 			fail:
 			utils_beep();
@@ -1594,9 +1594,9 @@ static GString *get_grep_options(void)
 		GeanyEncodingIndex enc_idx = gtk_combo_box_get_active(
 			GTK_COMBO_BOX(fif_dlg.encoding_combo));
 
-		if (G_UNLIKELY(! NZV(utf8_dir)))
+		if (G_UNLIKELY(EMPTY(utf8_dir)))
 			ui_set_statusbar(FALSE, _("Invalid directory for find in files."));
-		else if (NZV(search_text))
+		else if (!EMPTY(search_text))
 		{
 			gchar *locale_dir;
 			GString *opts = get_grep_options();
@@ -1638,7 +1638,7 @@ static GString *get_grep_options(void)
 	gboolean ret = FALSE;
 	gssize utf8_text_len;
 
-	if (! NZV(utf8_search_text) || ! dir) return TRUE;
+	if (EMPTY(utf8_search_text) || ! dir) return TRUE;
 
 	command_grep = g_find_program_in_path(tool_prefs.grep_cmd);
 	if (command_grep == NULL)
@@ -2166,7 +2166,7 @@ void search_find_usage(const gchar *search_text, const gchar *original_search_te
 	doc = document_get_current();
 	g_return_if_fail(doc != NULL);
 
-	if (G_UNLIKELY(! NZV(search_text)))
+	if (G_UNLIKELY(EMPTY(search_text)))
 	{
 		utils_beep();
 		return;


Modified: src/sidebar.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -388,7 +388,7 @@ static gchar *get_doc_folder(const gchar *path)
 		dirname = tmp_dirname;
 
 		/* If matches home dir, replace with tilde */
-		if (NZV(home_dir) && utils_filename_has_prefix(dirname, home_dir))
+		if (!EMPTY(home_dir) && utils_filename_has_prefix(dirname, home_dir))
 		{
 			rest = dirname + strlen(home_dir);
 			if (*rest == G_DIR_SEPARATOR || *rest == '\0')
@@ -1032,7 +1032,7 @@ static void documents_menu_update(GtkTreeSelection *selection)
 		gtk_tree_model_get(model, &iter, DOCUMENTS_DOCUMENT, &doc,
 			DOCUMENTS_SHORTNAME, &shortname, -1);
 	}
-	path = NZV(shortname) &&
+	path = !EMPTY(shortname) &&
 		(g_path_is_absolute(shortname) ||
 		(app->project && g_str_has_prefix(shortname, app->project->name)));
 


Modified: src/socket.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -624,7 +624,7 @@ gboolean socket_lock_input_cb(GIOChannel *source, GIOCondition condition, gpoint
 		else if (strncmp(buf, "doclist", 7) == 0)
 		{
 			gchar *doc_list = build_document_list();
-			if (NZV(doc_list))
+			if (!EMPTY(doc_list))
 				socket_fd_write_all(sock, doc_list, strlen(doc_list));
 			else
 				/* send ETX (end-of-text) in case we have no open files, we must send anything


Modified: src/symbols.c
8 files changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -1138,7 +1138,7 @@ static const gchar *get_parent_name(const TMTag *tag, filetype_id ft_id)
 			break;
 	}
 
-	return NZV(str) ? str : NULL;
+	return !EMPTY(str) ? str : NULL;
 }
 
 
@@ -1621,7 +1621,7 @@ static gboolean tag_has_missing_parent(const TMTag *tag, GtkTreeStore *store,
 		GtkTreeIter *iter)
 {
 	/* if the tag has a parent tag, it should be at depth >= 2 */
-	return NZV(tag->atts.entry.scope) &&
+	return !EMPTY(tag->atts.entry.scope) &&
 		gtk_tree_store_iter_depth(store, iter) == 1;
 }
 
@@ -1784,7 +1784,7 @@ int symbols_generate_global_tags(int argc, char **argv, gboolean want_preprocess
 			load_c_ignore_tags();
 
 		if (want_preprocess && (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP))
-			command = g_strdup_printf("%s %s", pre_process, NVL(getenv("CFLAGS"), ""));
+			command = g_strdup_printf("%s %s", pre_process, FALLBACK(getenv("CFLAGS"), ""));
 		else
 			command = NULL;	/* don't preprocess */
 
@@ -2407,7 +2407,7 @@ static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc)
 {
 	gchar *f = g_build_filename(app->configdir, "ignore.tags", NULL);
 
-	g_return_if_fail(NZV(doc->real_path));
+	g_return_if_fail(!EMPTY(doc->real_path));
 
 	if (utils_str_equal(doc->real_path, f))
 		load_c_ignore_tags();


Modified: src/templates.c
8 files changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -300,7 +300,7 @@ static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc)
 {
 	gchar *path = g_build_filename(app->configdir, GEANY_TEMPLATES_SUBDIR, NULL);
 
-	g_return_if_fail(NZV(doc->real_path));
+	g_return_if_fail(!EMPTY(doc->real_path));
 
 	if (strncmp(doc->real_path, path, strlen(path)) == 0)
 	{
@@ -365,9 +365,9 @@ static void make_comment_block(GString *comment_text, gint filetype_idx, guint i
 	template_eol_char = utils_get_eol_char(template_eol_mode);
 
 	filetype_get_comment_open_close(ft, FALSE, &co, &cc);
-	if (NZV(co))
+	if (!EMPTY(co))
 	{
-		if (NZV(cc))
+		if (!EMPTY(cc))
 		{
 			frame_start = g_strconcat(co, template_eol_char, NULL);
 			frame_end = g_strconcat(cc, template_eol_char, NULL);
@@ -388,7 +388,7 @@ static void make_comment_block(GString *comment_text, gint filetype_idx, guint i
 	}
 
 	/* do some magic to nicely format C-like multi-line comments */
-	if (NZV(frame_start) && frame_start[1] == '*')
+	if (!EMPTY(frame_start) && frame_start[1] == '*')
 	{
 		/* prefix the string with a space */
 		SETPTR(frame_end, g_strconcat(" ", frame_end, NULL));


Modified: src/toolbar.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -793,7 +793,7 @@ static void tb_editor_drag_data_get_cb(GtkWidget *widget, GdkDragContext *contex
 		return;
 
 	gtk_tree_model_get(model, &iter, TB_EDITOR_COL_ACTION, &name, -1);
-	if (G_UNLIKELY(! NZV(name)))
+	if (G_UNLIKELY(EMPTY(name)))
 		return;
 
 	atom = gdk_atom_intern(tb_editor_dnd_targets[0].target, FALSE);
@@ -869,7 +869,7 @@ static gboolean tb_editor_foreach_used(GtkTreeModel *model, GtkTreePath *path,
 
 	if (utils_str_equal(action_name, TB_EDITOR_SEPARATOR))
 		g_string_append_printf(data, "\t\t<separator/>\n");
-	else if (G_LIKELY(NZV(action_name)))
+	else if (G_LIKELY(!EMPTY(action_name)))
 		g_string_append_printf(data, "\t\t<toolitem action='%s' />\n", action_name);
 
 	g_free(action_name);


Modified: src/tools.c
12 files changed, 6 insertions(+), 6 deletions(-)
===================================================================
@@ -105,7 +105,7 @@ static void cc_dialog_update_row_status(GtkListStore *store, GtkTreeIter *iter,
 	gint argc;
 	gchar **argv;
 
-	if (! NZV(cmd))
+	if (EMPTY(cmd))
 		stock_id = GTK_STOCK_YES;
 	else if (g_shell_parse_argv(cmd, &argc, &argv, &err))
 	{
@@ -264,7 +264,7 @@ static gboolean cc_iofunc_err(GIOChannel *ioc, GIOCondition cond, gpointer user_
 			}
 		} while (rv == G_IO_STATUS_NORMAL || rv == G_IO_STATUS_AGAIN);
 
-		if (NZV(str->str))
+		if (!EMPTY(str->str))
 		{
 			g_warning("%s: %s\n", data->command, str->str);
 			ui_set_statusbar(TRUE,
@@ -583,7 +583,7 @@ static void cc_show_dialog_custom_commands(void)
 
 		for (i = 0; i < len; i++)
 		{
-			if (! NZV(ui_prefs.custom_commands[i]))
+			if (EMPTY(ui_prefs.custom_commands[i]))
 				continue; /* skip empty fields */
 
 			cc_dialog_add_command(&cc, i, FALSE);
@@ -642,7 +642,7 @@ static void cc_show_dialog_custom_commands(void)
 				gchar *lbl;
 
 				gtk_tree_model_get(GTK_TREE_MODEL(cc.store), &iter, CC_COLUMN_CMD, &cmd, CC_COLUMN_LABEL, &lbl, -1);
-				if (NZV(cmd))
+				if (!EMPTY(cmd))
 				{
 					cmd_list = g_slist_prepend(cmd_list, cmd);
 					lbl_list = g_slist_prepend(lbl_list, lbl);
@@ -770,9 +770,9 @@ void tools_create_insert_custom_command_menu_items(void)
 		{
 			const gchar *label = ui_prefs.custom_commands_labels[i];
 
-			if (! NZV(label))
+			if (EMPTY(label))
 				label = ui_prefs.custom_commands[i];
-			if (NZV(label)) /* skip empty items */
+			if (!EMPTY(label)) /* skip empty items */
 			{
 				cc_insert_custom_command_items(menu_edit, label, ui_prefs.custom_commands[i], idx);
 				idx++;


Modified: src/ui_utils.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -193,7 +193,7 @@ static gchar *create_statusbar_statistics(GeanyDocument *doc,
 	GString *stats_str;
 	ScintillaObject *sci = doc->editor->sci;
 
-	if (NZV(ui_prefs.statusbar_template))
+	if (!EMPTY(ui_prefs.statusbar_template))
 		fmt = ui_prefs.statusbar_template;
 	else
 		fmt = _(DEFAULT_STATUSBAR_TEMPLATE);


Modified: src/utils.c
14 files changed, 7 insertions(+), 7 deletions(-)
===================================================================
@@ -255,7 +255,7 @@ gint utils_write_file(const gchar *filename, const gchar *text)
 		{
 			geany_debug("utils_write_file(): could not write to file %s (%s)",
 				filename, g_strerror(errno));
-			return NVL(errno, EIO);
+			return FALLBACK(errno, EIO);
 		}
 	}
 	return 0;
@@ -420,7 +420,7 @@ gboolean utils_atob(const gchar *str)
 /* NULL-safe version of g_path_is_absolute(). */
 gboolean utils_is_absolute_path(const gchar *path)
 {
-	if (G_UNLIKELY(! NZV(path)))
+	if (G_UNLIKELY(EMPTY(path)))
 		return FALSE;
 
 	return g_path_is_absolute(path);
@@ -1485,7 +1485,7 @@ gboolean utils_str_has_upper(const gchar *str)
 {
 	gunichar c;
 
-	if (! NZV(str) || ! g_utf8_validate(str, -1, NULL))
+	if (EMPTY(str) || ! g_utf8_validate(str, -1, NULL))
 		return FALSE;
 
 	while (*str != '\0')
@@ -1515,7 +1515,7 @@ gint utils_string_find(GString *haystack, gint start, gint end, const gchar *nee
 	if (start >= (gint)haystack->len)
 		return -1;
 
-	g_return_val_if_fail(NZV(needle), -1);
+	g_return_val_if_fail(!EMPTY(needle), -1);
 
 	if (end < 0)
 		end = haystack->len;
@@ -1644,12 +1644,12 @@ guint utils_string_regex_replace_all(GString *haystack, GRegex *regex,
 /* Get project or default startup directory (if set), or NULL. */
 const gchar *utils_get_default_dir_utf8(void)
 {
-	if (app->project && NZV(app->project->base_path))
+	if (app->project && !EMPTY(app->project->base_path))
 	{
 		return app->project->base_path;
 	}
 
-	if (NZV(prefs.default_open_path))
+	if (!EMPTY(prefs.default_open_path))
 	{
 		return prefs.default_open_path;
 	}
@@ -1886,7 +1886,7 @@ gchar *utils_str_remove_chars(gchar *string, const gchar *chars)
 	gchar *w = string;
 
 	g_return_val_if_fail(string, NULL);
-	if (G_UNLIKELY(! NZV(chars)))
+	if (G_UNLIKELY(EMPTY(chars)))
 		return string;
 
 	foreach_str(r, string)


Modified: src/utils.h
11 files changed, 8 insertions(+), 3 deletions(-)
===================================================================
@@ -32,9 +32,14 @@
 #include <time.h>
 
 
-/** Returns TRUE if @a ptr points to a non-zero value. */
-#define NZV(ptr) \
-	((ptr) && (ptr)[0])
+/** Returns @c TRUE if @a ptr is @c NULL or @c *ptr is @c FALSE. */
+#define EMPTY(ptr) \
+	(!(ptr) || !*(ptr))
+
+/** @deprecated 2013/08 - use @c !EMPTY() instead. */
+#ifndef GEANY_DISABLE_DEPRECATED
+#define NZV(ptr) (!EMPTY(ptr))
+#endif
 
 /** Assigns @a result to @a ptr, then frees the old value.
  * @a result can be an expression using the 'old' value of @a ptr.


Modified: src/vte.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -187,7 +187,7 @@ void vte_init(void)
 		return;
 	}
 
-	if (NZV(vte_info.lib_vte))
+	if (!EMPTY(vte_info.lib_vte))
 	{
 		module = g_module_open(vte_info.lib_vte, G_MODULE_BIND_LAZY);
 	}
@@ -732,7 +732,7 @@ static void vte_drag_data_received(GtkWidget *widget, GdkDragContext *drag_conte
 	else
 	{
 		gchar *text = (gchar*) gtk_selection_data_get_text(data);
-		if (NZV(text))
+		if (!EMPTY(text))
 			vf->vte_terminal_feed_child(VTE_TERMINAL(widget), text, strlen(text));
 		g_free(text);
 	}


Modified: tagmanager/src/tm_symbol.c
12 files changed, 6 insertions(+), 6 deletions(-)
===================================================================
@@ -76,8 +76,8 @@ int tm_symbol_compare(const void *p1, const void *p2)
  */
 int tm_arglist_compare(const TMTag* t1, const TMTag* t2)
 {
-	return strcmp(NVL(t1->atts.entry.arglist, ""),
-			NVL(t2->atts.entry.arglist, ""));
+	return strcmp(FALLBACK(t1->atts.entry.arglist, ""),
+			FALLBACK(t2->atts.entry.arglist, ""));
 }
 
 /* Need this custom compare function to generate a symbol tree
@@ -119,8 +119,8 @@ int tm_symbol_tag_compare(const TMTag **t1, const TMTag **t2)
 		return (s1);
 
 	/* Compare scope alphabetically */
-	s1 = strcmp(NVL((*t1)->atts.entry.scope, ""),
-	  NVL((*t2)->atts.entry.scope, ""));
+	s1 = strcmp(FALLBACK((*t1)->atts.entry.scope, ""),
+	  FALLBACK((*t2)->atts.entry.scope, ""));
 	if (s1 != 0)
 		return s1;
 
@@ -208,8 +208,8 @@ TMSymbol *tm_symbol_tree_new(GPtrArray *tags_array)
 			{
 				if (sym && (tm_tag_function_t == sym->tag->type) &&
 				  (!sym->info.equiv) &&
-				  (0 == strcmp(NVL(tag->atts.entry.scope, "")
-							 , NVL(sym->tag->atts.entry.scope, ""))))
+				  (0 == strcmp(FALLBACK(tag->atts.entry.scope, "")
+							 , FALLBACK(sym->tag->atts.entry.scope, ""))))
 				{
 					sym->info.equiv = tag;
 					continue;


Modified: tagmanager/src/tm_tag.c
14 files changed, 7 insertions(+), 7 deletions(-)
===================================================================
@@ -681,9 +681,9 @@ int tm_tag_compare(const void *ptr1, const void *ptr2)
 	if (NULL == s_sort_attrs)
 	{
 		if (s_partial)
-			return strncmp(NVL(t1->name, ""), NVL(t2->name, ""), strlen(NVL(t1->name, "")));
+			return strncmp(FALLBACK(t1->name, ""), FALLBACK(t2->name, ""), strlen(FALLBACK(t1->name, "")));
 		else
-			return strcmp(NVL(t1->name, ""), NVL(t2->name, ""));
+			return strcmp(FALLBACK(t1->name, ""), FALLBACK(t2->name, ""));
 	}
 
 	for (sort_attr = s_sort_attrs; *sort_attr != tm_tag_attr_none_t; ++ sort_attr)
@@ -692,9 +692,9 @@ int tm_tag_compare(const void *ptr1, const void *ptr2)
 		{
 			case tm_tag_attr_name_t:
 				if (s_partial)
-					returnval = strncmp(NVL(t1->name, ""), NVL(t2->name, ""), strlen(NVL(t1->name, "")));
+					returnval = strncmp(FALLBACK(t1->name, ""), FALLBACK(t2->name, ""), strlen(FALLBACK(t1->name, "")));
 				else
-					returnval = strcmp(NVL(t1->name, ""), NVL(t2->name, ""));
+					returnval = strcmp(FALLBACK(t1->name, ""), FALLBACK(t2->name, ""));
 				if (0 != returnval)
 					return returnval;
 				break;
@@ -707,11 +707,11 @@ int tm_tag_compare(const void *ptr1, const void *ptr2)
 					return returnval;
 				break;
 			case tm_tag_attr_scope_t:
-				if (0 != (returnval = strcmp(NVL(t1->atts.entry.scope, ""), NVL(t2->atts.entry.scope, ""))))
+				if (0 != (returnval = strcmp(FALLBACK(t1->atts.entry.scope, ""), FALLBACK(t2->atts.entry.scope, ""))))
 					return returnval;
 				break;
 			case tm_tag_attr_arglist_t:
-				if (0 != (returnval = strcmp(NVL(t1->atts.entry.arglist, ""), NVL(t2->atts.entry.arglist, ""))))
+				if (0 != (returnval = strcmp(FALLBACK(t1->atts.entry.arglist, ""), FALLBACK(t2->atts.entry.arglist, ""))))
 				{
 					int line_diff = (t1->atts.entry.line - t2->atts.entry.line);
 
@@ -719,7 +719,7 @@ int tm_tag_compare(const void *ptr1, const void *ptr2)
 				}
 				break;
 			case tm_tag_attr_vartype_t:
-				if (0 != (returnval = strcmp(NVL(t1->atts.entry.var_type, ""), NVL(t2->atts.entry.var_type, ""))))
+				if (0 != (returnval = strcmp(FALLBACK(t1->atts.entry.var_type, ""), FALLBACK(t2->atts.entry.var_type, ""))))
 					return returnval;
 				break;
 			case tm_tag_attr_line_t:


Modified: tagmanager/src/tm_work_object.h
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -20,7 +20,7 @@
 #endif
 
 /* Evaluates to X is X is defined, else evaluates to Y */
-#define NVL(X,Y) (X)?(X):(Y)
+#define FALLBACK(X,Y) (X)?(X):(Y)
 
 /* Macro to cast a pointer to (TMWorkObject *) */
 #define TM_WORK_OBJECT(work_object) ((TMWorkObject *) work_object)



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list