From 41d771c205302dbe28a6f6f1b60efb9ff360268c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Tue, 17 May 2022 18:51:52 +0200 Subject: [PATCH] Remove built in globbing support when generating tag files We can rely on shell to expand wildcards for us and the current detection of whether globbing should be enabled based on \" presence is questionable, undocumented and probably unused. --- configure.ac | 2 +- meson.build | 1 - src/tagmanager/tm_workspace.c | 69 +++-------------------------------- 3 files changed, 6 insertions(+), 66 deletions(-) diff --git a/configure.ac b/configure.ac index 716dacc11f..fd3fcd9634 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ fi # autoscan start # Checks for header files. -AC_CHECK_HEADERS([fcntl.h glob.h stdlib.h sys/time.h errno.h limits.h]) +AC_CHECK_HEADERS([fcntl.h stdlib.h sys/time.h errno.h limits.h]) # Checks for dependencies needed by ctags AC_CHECK_HEADERS([dirent.h fnmatch.h direct.h io.h sys/dir.h]) diff --git a/meson.build b/meson.build index 963d3bea73..732181f232 100644 --- a/meson.build +++ b/meson.build @@ -46,7 +46,6 @@ check_headers = [ 'errno.h', 'fcntl.h', 'fnmatch.h', - 'glob.h', 'inttypes.h', 'io.h', 'langinfo.h', diff --git a/src/tagmanager/tm_workspace.c b/src/tagmanager/tm_workspace.c index 0f34477503..0cd3c6f7be 100644 --- a/src/tagmanager/tm_workspace.c +++ b/src/tagmanager/tm_workspace.c @@ -24,9 +24,6 @@ #include #include #include -#ifdef HAVE_GLOB_H -# include -#endif #include #include "tm_workspace.h" @@ -443,73 +440,17 @@ static GList *lookup_includes(const gchar **includes, gint includes_count) GList *includes_files = NULL; 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(g_str_hash, g_str_equal, NULL, NULL); -#ifdef HAVE_GLOB_H - globbuf.gl_offs = 0; - - if (includes[0][0] == '"') /* leading \" char for glob matching */ - { - for (i = 0; i < includes_count; i++) - { - size_t dirty_len = strlen(includes[i]); - gchar *clean_path; - - if (dirty_len < 2) - continue; - - clean_path = g_malloc(dirty_len - 1); - - strncpy(clean_path, includes[i] + 1, dirty_len - 1); - clean_path[dirty_len - 2] = 0; - -#ifdef TM_DEBUG - g_message ("[o][%s]\n", clean_path); -#endif - glob(clean_path, 0, NULL, &globbuf); - -#ifdef TM_DEBUG - g_message ("matches: %d\n", globbuf.gl_pathc); -#endif - - for (idx_glob = 0; idx_glob < globbuf.gl_pathc; idx_glob++) - { -#ifdef TM_DEBUG - g_message (">>> %s\n", globbuf.gl_pathv[idx_glob]); -#endif - if (!g_hash_table_lookup(table, globbuf.gl_pathv[idx_glob])) - { - 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"); -#endif - } - } - globfree(&globbuf); - g_free(clean_path); - } - } - else -#endif /* HAVE_GLOB_H */ + for (i = 0; i < includes_count; i++) { - /* no glob support or globbing not wanted */ - for (i = 0; i < includes_count; i++) + if (!g_hash_table_lookup(table, includes[i])) { - if (!g_hash_table_lookup(table, includes[i])) - { - gchar* file_name_copy = g_strdup(includes[i]); + 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); - } + includes_files = g_list_prepend(includes_files, file_name_copy); + g_hash_table_insert(table, file_name_copy, file_name_copy); } }