SF.net SVN: geany:[5890] trunk

colombanw at users.sourceforge.net colombanw at xxxxx
Fri Aug 19 00:07:42 UTC 2011


Revision: 5890
          http://geany.svn.sourceforge.net/geany/?rev=5890&view=rev
Author:   colombanw
Date:     2011-08-19 00:07:41 +0000 (Fri, 19 Aug 2011)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/symbols.c
    trunk/tagmanager/include/tm_workspace.h
    trunk/tagmanager/tm_workspace.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2011-08-18 23:01:45 UTC (rev 5889)
+++ trunk/ChangeLog	2011-08-19 00:07:41 UTC (rev 5890)
@@ -3,6 +3,10 @@
  * data/filetype_extensions.conf, data/filetypes.Cython.conf,
    data/filetypes.python:
    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>

Modified: trunk/src/symbols.c
===================================================================
--- trunk/src/symbols.c	2011-08-18 23:01:45 UTC (rev 5889)
+++ trunk/src/symbols.c	2011-08-19 00:07:41 UTC (rev 5890)
@@ -1624,8 +1624,7 @@
 
 		geany_debug("Generating %s tags file.", ft->name);
 		tm_get_workspace();
-		status = tm_workspace_create_global_tags(app->configdir, command,
-												 (const char **) (argv + 2),
+		status = tm_workspace_create_global_tags(command, (const char **) (argv + 2),
 												 argc - 2, tags_file, ft->lang);
 		g_free(command);
 		symbols_finalize(); /* free c_tags_ignore data */

Modified: trunk/tagmanager/include/tm_workspace.h
===================================================================
--- trunk/tagmanager/include/tm_workspace.h	2011-08-18 23:01:45 UTC (rev 5889)
+++ trunk/tagmanager/include/tm_workspace.h	2011-08-19 00:07:41 UTC (rev 5890)
@@ -89,8 +89,8 @@
  \param lang The language to use for the tags file.
  \return TRUE on success, FALSE on failure.
 */
-gboolean tm_workspace_create_global_tags(const char *config_dir, const char *pre_process,
-    const char **includes, int includes_count, const char *tags_file, int lang);
+gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
+    int includes_count, const char *tags_file, int lang);
 
 /* 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

Modified: trunk/tagmanager/tm_workspace.c
===================================================================
--- trunk/tagmanager/tm_workspace.c	2011-08-18 23:01:45 UTC (rev 5889)
+++ trunk/tagmanager/tm_workspace.c	2011-08-19 00:07:41 UTC (rev 5890)
@@ -258,9 +258,23 @@
 	}
 }
 
-gboolean tm_workspace_create_global_tags(const char *config_dir, const char *pre_process,
-	const char **includes, int includes_count, const char *tags_file, int lang)
+static gchar *create_temp_file(const gchar *tpl)
 {
+	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
 	glob_t globbuf;
 	size_t idx_glob;
@@ -273,15 +287,11 @@
 	GPtrArray *tags_array;
 	GHashTable *includes_files_hash;
 	GList *includes_files = NULL;
-#ifdef G_OS_WIN32
-	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));
-#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
+	gchar *temp_file = create_temp_file("tmp_XXXXXX.cpp");
+	gchar *temp_file2 = create_temp_file("tmp_XXXXXX.cpp");
 
-	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_file2);
@@ -387,6 +397,7 @@
 	else
 	{
 		/* no pre-processing needed, so temp_file2 = temp_file */
+		g_unlink(temp_file2);
 		g_free(temp_file2);
 		temp_file2 = temp_file;
 		temp_file = NULL;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list