[geany/geany] fb39f6: Merge pull request #1991 from b4n/tm-lookup-includes-cleaup

Colomban Wendling git-noreply at xxxxx
Tue Nov 13 07:38:45 UTC 2018


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Tue, 13 Nov 2018 07:38:45 UTC
Commit:      fb39f67f90376f3334dd78a80ef984cc5373bae0
             https://github.com/geany/geany/commit/fb39f67f90376f3334dd78a80ef984cc5373bae0

Log Message:
-----------
Merge pull request #1991 from b4n/tm-lookup-includes-cleaup

Process files in the order they appear on the command line when
generating tags file, instead of a more or less random order.

Closes #1989.


Modified Paths:
--------------
    src/tagmanager/tm_workspace.c
    tests/ctags/Makefile.am
    tests/ctags/process_order.c.tags
    tests/ctags/process_order_1.h
    tests/ctags/process_order_2.h
    tests/ctags/runner.sh

Modified: src/tagmanager/tm_workspace.c
37 lines changed, 5 insertions(+), 32 deletions(-)
===================================================================
@@ -370,34 +370,6 @@ gboolean tm_workspace_load_global_tags(const char *tags_file, TMParserType mode)
 }
 
 
-static guint tm_file_inode_hash(gconstpointer key)
-{
-	GStatBuf file_stat;
-	const char *filename = (const char*)key;
-
-	if (g_stat(filename, &file_stat) == 0)
-	{
-#ifdef TM_DEBUG
-		g_message ("Hash for '%s' is '%d'\n", filename, file_stat.st_ino);
-#endif
-		return g_direct_hash ((gpointer)(intptr_t)file_stat.st_ino);
-	}
-
-	return 0;
-}
-
-
-static void tm_move_entries_to_g_list(gpointer key, gpointer value, gpointer user_data)
-{
-	GList **pp_list = (GList**)user_data;
-
-	if (user_data == NULL)
-		return;
-
-	*pp_list = g_list_prepend(*pp_list, g_strdup(value));
-}
-
-
 static gboolean write_includes_file(const gchar *outf, GList *includes_files)
 {
 	FILE *fp = g_fopen(outf, "w");
@@ -470,14 +442,14 @@ static gchar *create_temp_file(const gchar *tpl)
 static GList *lookup_includes(const gchar **includes, gint includes_count)
 {
 	GList *includes_files = NULL;
-	GHashTable *table;
+	GHashTable *table; /* used for deduping */
 	gint i;
 #ifdef HAVE_GLOB_H
 	glob_t globbuf;
 	size_t idx_glob;
 #endif
 
-	table = g_hash_table_new_full(tm_file_inode_hash, g_direct_equal, NULL, g_free);
+	table = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
 
 #ifdef HAVE_GLOB_H
 	globbuf.gl_offs = 0;
@@ -515,6 +487,7 @@ static GList *lookup_includes(const gchar **includes, gint includes_count)
 				{
 					gchar *file_name_copy = g_strdup(globbuf.gl_pathv[idx_glob]);
 
+					includes_files = g_list_prepend(includes_files, file_name_copy);
 					g_hash_table_insert(table, file_name_copy, file_name_copy);
 #ifdef TM_DEBUG
 					g_message ("Added ...\n");
@@ -535,15 +508,15 @@ static GList *lookup_includes(const gchar **includes, gint includes_count)
 			{
 				gchar* file_name_copy = g_strdup(includes[i]);
 
+				includes_files = g_list_prepend(includes_files, file_name_copy);
 				g_hash_table_insert(table, file_name_copy, file_name_copy);
 			}
 		}
 	}
 
-	g_hash_table_foreach(table, tm_move_entries_to_g_list, &includes_files);
 	g_hash_table_destroy(table);
 
-	return includes_files;
+	return g_list_reverse(includes_files);
 }
 
 static gchar *pre_process_file(const gchar *cmd, const gchar *inf)


Modified: tests/ctags/Makefile.am
10 lines changed, 10 insertions(+), 0 deletions(-)
===================================================================
@@ -319,3 +319,13 @@ TAGS_LOG_COMPILER = $(srcdir)/runner.sh
 
 TESTS = $(test_results)
 EXTRA_DIST = $(test_sources) $(test_results)
+
+# check processing order of files on the command line
+check_processing_order_sources = \
+	process_order.c.tags process_order_1.h process_order_2.h
+EXTRA_DIST += $(check_processing_order_sources)
+.PHONY: check-processing-order
+check-processing-order: $(check_processing_order_sources)
+	srcdir="$(srcdir)" top_builddir="$(top_builddir)" \
+	$(srcdir)/runner.sh --result $(check_processing_order_sources:%=$(srcdir)/%)
+check-local: check-processing-order


Modified: tests/ctags/process_order.c.tags
7 lines changed, 7 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,7 @@
+# format=tagmanager
+I1_E1�4�anon_enum_0�0
+I1_E2�4�anon_enum_0�0
+I2_E1�4�anon_enum_1�0
+I2_E2�4�anon_enum_1�0
+anon_enum_0�2�0
+anon_enum_1�2�0


Modified: tests/ctags/process_order_1.h
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,4 @@
+enum {
+	I1_E1,
+	I1_E2,
+};


Modified: tests/ctags/process_order_2.h
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,4 @@
+enum {
+	I2_E1,
+	I2_E2,
+};


Modified: tests/ctags/runner.sh
18 lines changed, 15 insertions(+), 3 deletions(-)
===================================================================
@@ -17,9 +17,21 @@ mkdir -p "$CONFDIR/filedefs/" || exit 99
 cp "${srcdir:-.}"/../../data/filetype_extensions.conf "$CONFDIR" || exit 99
 cp "${srcdir:-.}"/../../data/filedefs/filetypes.* "$CONFDIR/filedefs/" || exit 99
 
-result="$1"
-source="${result%.*}"
+if [ "$1" = "--result" ]; then
+  # --result $result $source...
+  [ $# -gt 2 ] || exit 99
+  shift
+  result="$1"
+  shift
+  source="$1"
+else
+  # result is $1 and source is inferred from result
+  result="$1"
+  source="${result%.*}"
+fi
+shift
+
 tagfile="$TMPDIR/test.${source##*.}.tags"
 
-"$GEANY" -c "$CONFDIR" -P -g "$tagfile" "$source" || exit 1
+"$GEANY" -c "$CONFDIR" -P -g "$tagfile" "$source" "$@" || exit 1
 diff -u "$result" "$tagfile" || exit 2



--------------
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