From 52076d19e8fe7ab41ebc92928ef7832c248a51f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Techet?= Date: Fri, 10 Oct 2014 23:04:45 +0200 Subject: [PATCH] Remove unused tm_file_entry.[ch] --- tagmanager/src/Makefile.am | 2 - tagmanager/src/makefile.win32 | 3 +- tagmanager/src/tm_file_entry.c | 281 ----------------------------------------- tagmanager/src/tm_file_entry.h | 124 ------------------ tagmanager/src/tm_tagmanager.h | 1 - wscript | 1 - 6 files changed, 1 insertion(+), 411 deletions(-) delete mode 100644 tagmanager/src/tm_file_entry.c delete mode 100644 tagmanager/src/tm_file_entry.h diff --git a/tagmanager/src/Makefile.am b/tagmanager/src/Makefile.am index 243e666fe..ec8bf8f6a 100644 --- a/tagmanager/src/Makefile.am +++ b/tagmanager/src/Makefile.am @@ -23,8 +23,6 @@ tagmanager_include_HEADERS = \ libtagmanager_a_SOURCES =\ tm_tagmanager.h \ tm_parser.h \ - tm_file_entry.h \ - tm_file_entry.c \ tm_source_file.h \ tm_source_file.c \ tm_tag.h \ diff --git a/tagmanager/src/makefile.win32 b/tagmanager/src/makefile.win32 index b3b07c38e..f199d444f 100644 --- a/tagmanager/src/makefile.win32 +++ b/tagmanager/src/makefile.win32 @@ -44,8 +44,7 @@ all: $(COMPLIB) clean: -$(RM) deps.mak *.o $(COMPLIB) -$(COMPLIB): tm_workspace.o tm_source_file.o tm_tag.o \ -tm_file_entry.o +$(COMPLIB): tm_workspace.o tm_source_file.o tm_tag.o $(AR) rc $@ $^ $(RANLIB) $@ diff --git a/tagmanager/src/tm_file_entry.c b/tagmanager/src/tm_file_entry.c deleted file mode 100644 index 477961485..000000000 --- a/tagmanager/src/tm_file_entry.c +++ /dev/null @@ -1,281 +0,0 @@ -/* -* -* Copyright (c) 2001-2002, Biswapesh Chattopadhyay -* -* This source code is released for free distribution under the terms of the -* GNU General Public License. -* -*/ - -#include "general.h" - -#include -#include -#include -#include -#include -#ifdef HAVE_FCNTL_H -# include -#endif -#include -#include -#ifdef HAVE_FNMATCH_H -# include -#endif -#include - -#include "tm_file_entry.h" -#include "tm_source_file.h" - -#define FILE_NEW(T) ((T) = g_slice_new0(TMFileEntry)) -#define FILE_FREE(T) g_slice_free(TMFileEntry, (T)) - - -void tm_file_entry_print(TMFileEntry *entry, gpointer UNUSED user_data - , guint level) -{ - guint i; - - g_return_if_fail(entry); - for (i=0; i < level; ++i) - fputc('\t', stderr); - fprintf(stderr, "%s\n", entry->name); -} - -gint tm_file_entry_compare(TMFileEntry *e1, TMFileEntry *e2) -{ - g_return_val_if_fail(e1 && e2 && e1->name && e2->name, 0); -#ifdef TM_DEBUG - g_message("Comparing %s and %s", e1->name, e2->name); -#endif - return strcmp(e1->name, e2->name); -} - -/* TTimo - modified to handle symlinks */ -static TMFileType tm_file_entry_type(const char *path) -{ - struct stat s; - -#ifndef G_OS_WIN32 - if (0 != g_lstat(path, &s)) - return tm_file_unknown_t; -#endif - if (S_ISDIR(s.st_mode)) - return tm_file_dir_t; -#ifndef G_OS_WIN32 - else if (S_ISLNK(s.st_mode)) - return tm_file_link_t; -#endif - else if (S_ISREG(s.st_mode)) - return tm_file_regular_t; - else - return tm_file_unknown_t; -} - -static gboolean apply_filter(const char *name, GList *match, GList *unmatch - , gboolean ignore_hidden) -{ - GList *tmp; - gboolean matched = (match == NULL); - g_return_val_if_fail(name, FALSE); - if (ignore_hidden && ('.' == name[0])) - return FALSE; - /* TTimo - ignore .svn directories */ - if (!strcmp(name, ".svn")) - return FALSE; - for (tmp = match; tmp; tmp = g_list_next(tmp)) - { - if (0 == fnmatch((char *) tmp->data, name, 0)) - { - matched = TRUE; - break; - } - } - if (!matched) - return FALSE; - for (tmp = unmatch; tmp; tmp = g_list_next(tmp)) - { - if (0 == fnmatch((char *) tmp->data, name, 0)) - { - return FALSE; - } - } - return matched; -} - -TMFileEntry *tm_file_entry_new(const char *path, TMFileEntry *parent - , gboolean recurse, GList *file_match, GList *file_unmatch - , GList *dir_match, GList *dir_unmatch, gboolean ignore_hidden_files - , gboolean ignore_hidden_dirs) -{ - TMFileEntry *entry; - /* GList *tmp; */ - char *real_path; - DIR *dir; - struct dirent *dir_entry; - TMFileEntry *new_entry; - char *file_name; - struct stat s; - char *entries = NULL; - - g_return_val_if_fail (path != NULL, NULL); - - /* TTimo - don't follow symlinks */ - if (tm_file_entry_type(path) == tm_file_link_t) - return NULL; - real_path = tm_get_real_path(path); - if (!real_path) - return NULL; - FILE_NEW(entry); - entry->type = tm_file_entry_type(real_path); - entry->parent = parent; - entry->path = real_path; - entry->name = strrchr(entry->path, '/'); - if (entry->name) - ++ (entry->name); - else - entry->name = entry->path; - switch(entry->type) - { - case tm_file_unknown_t: - g_free(real_path); - FILE_FREE(entry); - return NULL; - case tm_file_link_t: - case tm_file_regular_t: - if (parent && !apply_filter(entry->name, file_match, file_unmatch - , ignore_hidden_files)) - { - tm_file_entry_free(entry); - return NULL; - } - break; - case tm_file_dir_t: - if (parent && !(recurse && apply_filter(entry->name, dir_match - , dir_unmatch, ignore_hidden_dirs))) - { - tm_file_entry_free(entry); - return NULL; - } - file_name = g_strdup_printf("%s/CVS/Entries", entry->path); - if (0 == g_stat(file_name, &s)) - { - if (S_ISREG(s.st_mode)) - { - int fd; - entries = g_new(char, s.st_size + 2); - if (0 > (fd = open(file_name, O_RDONLY))) - { - g_free(entries); - entries = NULL; - } - else - { - off_t n =0; - off_t total_read = 1; - while (0 < (n = read(fd, entries + total_read, s.st_size - total_read))) - total_read += n; - entries[s.st_size] = '\0'; - entries[0] = '\n'; - close(fd); - entry->version = g_strdup("D"); - } - } - } - g_free(file_name); - if (NULL != (dir = opendir(entry->path))) - { - while (NULL != (dir_entry = readdir(dir))) - { - if ((0 == strcmp(dir_entry->d_name, ".")) - || (0 == strcmp(dir_entry->d_name, ".."))) - continue; - file_name = g_strdup_printf("%s/%s", entry->path, dir_entry->d_name); - new_entry = tm_file_entry_new(file_name, entry, recurse - , file_match, file_unmatch, dir_match, dir_unmatch - , ignore_hidden_files, ignore_hidden_dirs); - g_free(file_name); - if (new_entry) - { - if (entries) - { - char *str = g_strconcat("\n/", new_entry->name, "/", NULL); - char *name_pos = strstr(entries, str); - if (NULL != name_pos) - { - int len = strlen(str); - char *version_pos = strchr(name_pos + len, '/'); - if (NULL != version_pos) - { - *version_pos = '\0'; - new_entry->version = g_strdup(name_pos + len); - *version_pos = '/'; - } - } - g_free(str); - } - entry->children = g_slist_prepend(entry->children, new_entry); - } - } - } - closedir(dir); - entry->children = g_slist_sort(entry->children, (GCompareFunc) tm_file_entry_compare); - g_free(entries); - break; - } - return entry; -} - -void tm_file_entry_free(gpointer entry) -{ - if (entry) - { - TMFileEntry *file_entry = TM_FILE_ENTRY(entry); - if (file_entry->children) - { - GSList *tmp; - for (tmp = file_entry->children; tmp; tmp = g_slist_next(tmp)) - tm_file_entry_free(tmp->data); - g_slist_free(file_entry->children); - } - g_free(file_entry->version); - g_free(file_entry->path); - FILE_FREE(file_entry); - } -} - -void tm_file_entry_foreach(TMFileEntry *entry, TMFileEntryFunc func - , gpointer user_data, guint level, gboolean reverse) -{ - g_return_if_fail (entry != NULL); - g_return_if_fail (func != NULL); - - if ((reverse) && (entry->children)) - { - GSList *tmp; - for (tmp = entry->children; tmp; tmp = g_slist_next(tmp)) - tm_file_entry_foreach(TM_FILE_ENTRY(tmp->data), func - , user_data, level + 1, TRUE); - } - func(entry, user_data, level); - if ((!reverse) && (entry->children)) - { - GSList *tmp; - for (tmp = entry->children; tmp; tmp = g_slist_next(tmp)) - tm_file_entry_foreach(TM_FILE_ENTRY(tmp->data), func - , user_data, level + 1, FALSE); - } -} - -GList *tm_file_entry_list(TMFileEntry *entry, GList *files) -{ - GSList *tmp; - files = g_list_prepend(files, g_strdup(entry->path)); - for (tmp = entry->children; tmp; tmp = g_slist_next(tmp)) - { - files = tm_file_entry_list((TMFileEntry *) tmp->data, files); - } - if (!files) - files = g_list_reverse(files); - return files; -} diff --git a/tagmanager/src/tm_file_entry.h b/tagmanager/src/tm_file_entry.h deleted file mode 100644 index 8d398e4b9..000000000 --- a/tagmanager/src/tm_file_entry.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -* -* Copyright (c) 2001-2002, Biswapesh Chattopadhyay -* -* This source code is released for free distribution under the terms of the -* GNU General Public License. -* -*/ - -#ifndef TM_FILE_ENTRY_H -#define TM_FILE_ENTRY_H - -#include - -/* \file -The TMFileEntry structure and associated functions can be used -for file and directory traversal. The following example demonstrates -the use of TMFileEntry. -\include tm_file_tree_dump.c -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Enum defining file types */ -typedef enum -{ - tm_file_unknown_t, /* Unknown file type/file does not exist */ - tm_file_regular_t, /* Is a regular file */ - tm_file_dir_t, /* Is a directory */ - tm_file_link_t /* Is a symbolic link */ -} TMFileType; - -/* - This example demonstrates the use of TMFileEntry and associated functions - for managing file hierarchies in a project. - - \example tm_file_tree_dump.c -*/ - -/* This structure stores the file tree */ -typedef struct _TMFileEntry -{ - TMFileType type; /* File type */ - char *path; /* Full path to the file (incl. dir and name) */ - char *name; /* Just the file name (path minus the directory) */ - char *version; /* CVS version in case there is a CVS entry for this file */ - struct _TMFileEntry *parent; /* The parent directory file entry */ - GSList *children; /* List of children (for directory) */ -} TMFileEntry; - -/* Prototype for the function that gets called for each entry when - tm_file_entry_foreach() is called. -*/ -typedef void (*TMFileEntryFunc) (TMFileEntry *entry, gpointer user_data - , guint level); - -/* Convinience casting macro */ -#define TM_FILE_ENTRY(E) ((TMFileEntry *) (E)) - -/* Function that compares two file entries on name and returns the - difference -*/ -gint tm_file_entry_compare(TMFileEntry *e1, TMFileEntry *e2); - -/* Function to create a new file entry structure. -\param path Path to the file for which the entry is to be created. -\param parent Should be NULL for the first call. Since the function calls - itself recursively, this parameter is required to build the hierarchy. -\param recurse Whether the entry is to be recursively scanned (for - directories only) -\param file_match List of file name patterns to match. If set to NULL, - all files match. You can use wildcards like '*.c'. See the example program - for usage. -\param file_unmatch Opposite of file_match. All files matching any of the patterns - supplied are ignored. If set to NULL, no file is ignored. -\param dir_match List of directory name patterns to match. If set to NULL, - all directories match. You can use wildcards like '\.*'. -\param dir_unmatch Opposite of dir_match. All directories matching any of the - patterns supplied are ignored. If set to NULL, no directory is ignored. -\param ignore_hidden_files If set to TRUE, hidden files (starting with '.') - are ignored. -\param ignore_hidden_dirs If set to TRUE, hidden directories (starting with '.') - are ignored. -\return Populated TMFileEntry structure on success, NULL on failure. -*/ -TMFileEntry *tm_file_entry_new(const char *path, TMFileEntry *parent - , gboolean recurse, GList *file_match, GList *file_unmatch - , GList *dir_match, GList *dir_unmatch, gboolean ignore_hidden_files - , gboolean ignore_hidden_dirs); - -/* Frees a TMFileEntry structure. Freeing is recursive, so all child - entries are freed as well. -\param entry The TMFileEntry structure to be freed. -*/ -void tm_file_entry_free(gpointer entry); - -/* This will call the function func() for each file entry. -\param entry The root file entry. -\param func The function to be called. -\param user_data Extra information to be passed to the function. -\param level The recursion level. You should set this to 0 initially. -\param reverse If set to TRUE, traversal is in reverse hierarchical order -*/ -void tm_file_entry_foreach(TMFileEntry *entry, TMFileEntryFunc func - , gpointer user_data, guint level, gboolean reverse); - -/* This is a sample function to show the use of tm_file_entry_foreach(). -*/ -void tm_file_entry_print(TMFileEntry *entry, gpointer user_data, guint level); - -/* Creates a list of path names from a TMFileEntry structure. -\param entry The TMFileEntry structure. -\files Current file list. Should be NULL. -*/ -GList *tm_file_entry_list(TMFileEntry *entry, GList *files); - -#ifdef __cplusplus -} -#endif - -#endif /* TM_FILE_ENTRY_H */ diff --git a/tagmanager/src/tm_tagmanager.h b/tagmanager/src/tm_tagmanager.h index c31b60b54..85782b68b 100644 --- a/tagmanager/src/tm_tagmanager.h +++ b/tagmanager/src/tm_tagmanager.h @@ -14,7 +14,6 @@ #include "tm_workspace.h" #include "tm_source_file.h" #ifdef GEANY_PRIVATE -#include "tm_file_entry.h" #include "tm_parser.h" #endif /* GEANY_PRIVATE */ diff --git a/wscript b/wscript index 2b54c35bc..eb81b4d49 100644 --- a/wscript +++ b/wscript @@ -118,7 +118,6 @@ ctags_sources = set([ 'tagmanager/ctags/vstring.c']) tagmanager_sources = set([ - 'tagmanager/src/tm_file_entry.c', 'tagmanager/src/tm_source_file.c', 'tagmanager/src/tm_tag.c', 'tagmanager/src/tm_workspace.c']) -- 2.11.4.GIT