Fix generating global tags (geany -g) when the configdir doesn't exist

When creating temporary files for generating global tag files, use
the system directory for temporary files rather than the configuration
directory, so it works even if the configuration directory doesn't
already exist.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5890 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Colomban Wendling 2011-08-19 00:07:41 +00:00
parent 02dcab4b14
commit 9d2975b8fa
4 changed files with 28 additions and 14 deletions

View File

@ -3,6 +3,10 @@
* data/filetype_extensions.conf, data/filetypes.Cython.conf, * data/filetype_extensions.conf, data/filetypes.Cython.conf,
data/filetypes.python: data/filetypes.python:
Add Cython filetype (patch by Matthew Brush, thanks). Add Cython filetype (patch by Matthew Brush, thanks).
* src/symbols.c, tagmanager/include/tm_workspace.h,
tagmanager/tm_workspace.c:
Create temporary files used for generating global tags files in the
system directory for temp files.
2011-08-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> 2011-08-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>

View File

@ -1624,8 +1624,7 @@ int symbols_generate_global_tags(int argc, char **argv, gboolean want_preprocess
geany_debug("Generating %s tags file.", ft->name); geany_debug("Generating %s tags file.", ft->name);
tm_get_workspace(); tm_get_workspace();
status = tm_workspace_create_global_tags(app->configdir, command, status = tm_workspace_create_global_tags(command, (const char **) (argv + 2),
(const char **) (argv + 2),
argc - 2, tags_file, ft->lang); argc - 2, tags_file, ft->lang);
g_free(command); g_free(command);
symbols_finalize(); /* free c_tags_ignore data */ symbols_finalize(); /* free c_tags_ignore data */

View File

@ -89,8 +89,8 @@ gboolean tm_workspace_load_global_tags(const char *tags_file, gint mode);
\param lang The language to use for the tags file. \param lang The language to use for the tags file.
\return TRUE on success, FALSE on failure. \return TRUE on success, FALSE on failure.
*/ */
gboolean tm_workspace_create_global_tags(const char *config_dir, const char *pre_process, gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
const char **includes, int includes_count, const char *tags_file, int lang); int includes_count, const char *tags_file, int lang);
/* Recreates the tag array of the workspace by collecting the tags of /* Recreates the tag array of the workspace by collecting the tags of
all member work objects. You shouldn't have to call this directly since all member work objects. You shouldn't have to call this directly since

View File

@ -258,8 +258,22 @@ static void append_to_temp_file(FILE *fp, GList *file_list)
} }
} }
gboolean tm_workspace_create_global_tags(const char *config_dir, const char *pre_process, static gchar *create_temp_file(const gchar *tpl)
const char **includes, int includes_count, const char *tags_file, int lang) {
gchar *name;
gint fd;
fd = g_file_open_tmp(tpl, &name, NULL);
if (fd < 0)
name = NULL;
else
close(fd);
return name;
}
gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
int includes_count, const char *tags_file, int lang)
{ {
#ifdef HAVE_GLOB_H #ifdef HAVE_GLOB_H
glob_t globbuf; glob_t globbuf;
@ -273,15 +287,11 @@ gboolean tm_workspace_create_global_tags(const char *config_dir, const char *pre
GPtrArray *tags_array; GPtrArray *tags_array;
GHashTable *includes_files_hash; GHashTable *includes_files_hash;
GList *includes_files = NULL; GList *includes_files = NULL;
#ifdef G_OS_WIN32 gchar *temp_file = create_temp_file("tmp_XXXXXX.cpp");
char *temp_file = g_strdup_printf("%s\\_%d_%ld_1.cpp", config_dir, getpid(), time(NULL)); gchar *temp_file2 = create_temp_file("tmp_XXXXXX.cpp");
char *temp_file2 = g_strdup_printf("%s\\_%d_%ld_2.cpp", config_dir, getpid(), time(NULL));
#else
char *temp_file = g_strdup_printf("%s/%d_%ld_1.cpp", config_dir, getpid(), time(NULL));
char *temp_file2 = g_strdup_printf("%s/%d_%ld_2.cpp", config_dir, getpid(), time(NULL));
#endif
if (NULL == theWorkspace || NULL == (fp = g_fopen(temp_file, "w"))) if (NULL == temp_file || NULL == temp_file2 ||
NULL == theWorkspace || NULL == (fp = g_fopen(temp_file, "w")))
{ {
g_free(temp_file); g_free(temp_file);
g_free(temp_file2); g_free(temp_file2);
@ -387,6 +397,7 @@ gboolean tm_workspace_create_global_tags(const char *config_dir, const char *pre
else else
{ {
/* no pre-processing needed, so temp_file2 = temp_file */ /* no pre-processing needed, so temp_file2 = temp_file */
g_unlink(temp_file2);
g_free(temp_file2); g_free(temp_file2);
temp_file2 = temp_file; temp_file2 = temp_file;
temp_file = NULL; temp_file = NULL;