SF.net SVN: geany: [1714] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Tue Jul 17 12:04:46 UTC 2007
Revision: 1714
http://svn.sourceforge.net/geany/?rev=1714&view=rev
Author: eht16
Date: 2007-07-17 05:04:46 -0700 (Tue, 17 Jul 2007)
Log Message:
-----------
Always use g_fopen() and g_stat() instead of fopen() and stat() to fix several problems with filenames containing special characters on Windows. Use GetFullPathName() instead of lrealpath() to get Tagmanager working on files containing special characters on Windows.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/build.c
trunk/src/document.c
trunk/src/utils.c
trunk/src/win32.c
trunk/tagmanager/ctags.c
trunk/tagmanager/entry.c
trunk/tagmanager/parse.c
trunk/tagmanager/read.c
trunk/tagmanager/regex.c
trunk/tagmanager/sort.c
trunk/tagmanager/strlist.c
trunk/tagmanager/tm_file_entry.c
trunk/tagmanager/tm_project.c
trunk/tagmanager/tm_work_object.c
trunk/tagmanager/tm_workspace.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/ChangeLog 2007-07-17 12:04:46 UTC (rev 1714)
@@ -17,6 +17,16 @@
when running make.
* src/win32.c: Fix creation of wrong hex colours when inserting colours
from the colour chooser dialog.
+ * tagmanager/ctags.c, tagmanager/entry.c, tagmanager/tm_source_file.c,
+ tagmanager/strlist.c, tagmanager/tm_project.c, tagmanager/sort.c,
+ tagmanager/tm_work_object.c, tagmanager/read.c, tagmanager/regex.c,
+ tagmanager/tm_workspace.c, tagmanager/parse.c,
+ tagmanager/tm_file_entry.c, src/build.c, src/document.c, src/utils.c:
+ Always use g_fopen() and g_stat() instead of fopen() and stat() to
+ fix several problems with filenames containing special characters on
+ Windows.
+ Use GetFullPathName() instead of lrealpath() to get Tagmanager
+ working on files containing special characters on Windows.
2007-07-16 Enrico Tröger <enrico.troeger at uvena.de>
Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/src/build.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -941,7 +941,7 @@
gchar *tmp;
#endif
- fp = fopen(fname, "w");
+ fp = g_fopen(fname, "w");
if (! fp) return FALSE;
#ifdef G_OS_WIN32
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/src/document.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -1054,10 +1054,10 @@
len = strlen(data);
}
#ifdef G_OS_WIN32
- fp = fopen(doc_list[idx].file_name, "wb"); // this should fix the windows \n problem
+ fp = g_fopen(doc_list[idx].file_name, "wb"); // this should fix the windows \n problem
#else
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
- fp = fopen(locale_filename, "w");
+ fp = g_fopen(locale_filename, "w");
g_free(locale_filename);
#endif
if (fp == NULL)
@@ -1538,10 +1538,15 @@
if (doc_list[idx].tm_file == NULL)
{
+#ifdef GEANY_OS_WIN32
+ doc_list[idx].tm_file = tm_source_file_new(
+ doc_list[idx].file_name, FALSE, doc_list[idx].file_type->name);
+#else
gchar *locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
- doc_list[idx].tm_file = tm_source_file_new(locale_filename, FALSE,
- doc_list[idx].file_type->name);
+ doc_list[idx].tm_file = tm_source_file_new(
+ locale_filename, FALSE, doc_list[idx].file_type->name);
g_free(locale_filename);
+#endif
if (! doc_list[idx].tm_file) return;
tm_workspace_add_object(doc_list[idx].tm_file);
if (update)
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/src/utils.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -249,7 +249,7 @@
len = strlen(text);
- fp = fopen(filename, "w");
+ fp = g_fopen(filename, "w");
if (fp != NULL)
{
bytes_written = fwrite(text, sizeof (gchar), len, fp);
Modified: trunk/src/win32.c
===================================================================
--- trunk/src/win32.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/src/win32.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -29,6 +29,8 @@
#ifdef G_OS_WIN32
+#define VC_EXTRALEAN
+#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commdlg.h>
#include <shlobj.h>
Modified: trunk/tagmanager/ctags.c
===================================================================
--- trunk/tagmanager/ctags.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/ctags.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -427,7 +427,7 @@
struct stat fileStatus;
unsigned long size = 0;
- if (stat (name, &fileStatus) == 0)
+ if (g_stat (name, &fileStatus) == 0)
size = fileStatus.st_size;
return size;
@@ -442,7 +442,7 @@
struct stat fileStatus;
boolean result = FALSE;
- if (lstat (name, &fileStatus) == 0)
+ if (g_lstat (name, &fileStatus) == 0)
result = (boolean) (S_ISLNK (fileStatus.st_mode));
return result;
@@ -454,7 +454,7 @@
struct stat fileStatus;
boolean result = FALSE;
- if (stat (name, &fileStatus) == 0)
+ if (g_stat (name, &fileStatus) == 0)
result = (boolean) (S_ISREG (fileStatus.st_mode));
return result;
@@ -466,7 +466,7 @@
struct stat fileStatus;
boolean result = FALSE;
- if (stat (name, &fileStatus) == 0)
+ if (g_stat (name, &fileStatus) == 0)
result = (boolean) ((fileStatus.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) != 0);
return result;
@@ -478,7 +478,7 @@
#ifdef HAVE_STAT_ST_INO
struct stat stat1, stat2;
- if (stat (name1, &stat1) == 0 && stat (name2, &stat2) == 0)
+ if (g_stat (name1, &stat1) == 0 && g_stat (name2, &stat2) == 0)
result = (boolean) (stat1.st_ino == stat2.st_ino);
#endif
return result;
@@ -494,7 +494,7 @@
struct stat fileStatus;
boolean result = FALSE;
- if (stat (name, &fileStatus) == 0)
+ if (g_stat (name, &fileStatus) == 0)
result = (boolean) ((fileStatus.st_mode & S_ISUID) != 0);
return result;
@@ -525,7 +525,7 @@
#else
struct stat fileStatus;
- if (stat (name, &fileStatus) == 0)
+ if (g_stat (name, &fileStatus) == 0)
result = (boolean) S_ISDIR (fileStatus.st_mode);
#endif
return result;
@@ -536,7 +536,7 @@
{
struct stat fileStatus;
- return (boolean) (stat (fileName, &fileStatus) == 0);
+ return (boolean) (g_stat (fileName, &fileStatus) == 0);
}
//#ifndef HAVE_FGETPOS
@@ -1194,7 +1194,7 @@
resize = createTagsFromFileInput (stdin, FALSE);
else
{
- FILE* const fp = fopen (fileName, "r");
+ FILE* const fp = g_fopen (fileName, "r");
if (fp == NULL)
error (FATAL | PERROR, "cannot open list file \"%s\"", fileName);
resize = createTagsFromFileInput (fp, FALSE);
Modified: trunk/tagmanager/entry.c
===================================================================
--- trunk/tagmanager/entry.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/entry.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -248,7 +248,7 @@
static boolean isTagFile (const char *const filename)
{
boolean ok = FALSE; /* we assume not unless confirmed */
- FILE *const fp = fopen (filename, "rb");
+ FILE *const fp = g_fopen (filename, "rb");
if (fp == NULL && errno == ENOENT)
ok = TRUE;
@@ -284,12 +284,12 @@
extern void copyFile (const char *const from, const char *const to, const long size)
{
- FILE* const fromFp = fopen (from, "rb");
+ FILE* const fromFp = g_fopen (from, "rb");
if (fromFp == NULL)
error (FATAL | PERROR, "cannot open file to copy");
else
{
- FILE* const toFp = fopen (to, "wb");
+ FILE* const toFp = g_fopen (to, "wb");
if (toFp == NULL)
error (FATAL | PERROR, "cannot open copy destination");
else
@@ -327,17 +327,17 @@
if (Option.append && fileExists)
{
- TagFile.fp = fopen (TagFile.name, "r+");
+ TagFile.fp = g_fopen (TagFile.name, "r+");
if (TagFile.fp != NULL)
{
TagFile.numTags.prev = updatePseudoTags (TagFile.fp);
fclose (TagFile.fp);
- TagFile.fp = fopen (TagFile.name, "a+");
+ TagFile.fp = g_fopen (TagFile.name, "a+");
}
}
else
{
- TagFile.fp = fopen (TagFile.name, "w");
+ TagFile.fp = g_fopen (TagFile.name, "w");
if (TagFile.fp != NULL)
addPseudoTags ();
}
Modified: trunk/tagmanager/parse.c
===================================================================
--- trunk/tagmanager/parse.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/parse.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -156,7 +156,7 @@
static langType getInterpreterLanguage (const char *const fileName)
{
langType result = LANG_IGNORE;
- FILE* const fp = fopen (fileName, "r");
+ FILE* const fp = g_fopen (fileName, "r");
if (fp != NULL)
{
vString* const vLine = vStringNew ();
Modified: trunk/tagmanager/read.c
===================================================================
--- trunk/tagmanager/read.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/read.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -250,7 +250,7 @@
File.fp = NULL;
}
- File.fp = fopen (fileName, openMode);
+ File.fp = g_fopen (fileName, openMode);
if (File.fp == NULL)
error (WARNING | PERROR, "cannot open \"%s\"", fileName);
else
Modified: trunk/tagmanager/regex.c
===================================================================
--- trunk/tagmanager/regex.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/regex.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -372,7 +372,7 @@
else
{
const char* regexfile = parameter + 1;
- FILE* const fp = fopen (regexfile, "r");
+ FILE* const fp = g_fopen (regexfile, "r");
if (fp == NULL)
error (WARNING | PERROR, regexfile);
else
Modified: trunk/tagmanager/sort.c
===================================================================
--- trunk/tagmanager/sort.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/sort.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -36,7 +36,7 @@
extern void catFile (const char *const name)
{
- FILE *const fp = fopen (name, "r");
+ FILE *const fp = g_fopen (name, "r");
if (fp != NULL)
{
@@ -135,7 +135,7 @@
fp = stdout;
else
{
- fp = fopen (tagFileName (), "w");
+ fp = g_fopen (tagFileName (), "w");
if (fp == NULL)
failedSort (fp, NULL);
}
@@ -173,7 +173,7 @@
/* Open the tag file and place its lines into allocated buffers.
*/
- fp = fopen (tagFileName (), "r");
+ fp = g_fopen (tagFileName (), "r");
if (fp == NULL)
failedSort (fp, NULL);
for (i = 0 ; i < numTags && ! feof (fp) ; )
Modified: trunk/tagmanager/strlist.c
===================================================================
--- trunk/tagmanager/strlist.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/strlist.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -91,7 +91,7 @@
extern stringList* stringListNewFromFile (const char* const fileName)
{
stringList* result = NULL;
- FILE* const fp = fopen (fileName, "r");
+ FILE* const fp = g_fopen (fileName, "r");
if (fp != NULL)
{
result = stringListNew ();
Modified: trunk/tagmanager/tm_file_entry.c
===================================================================
--- trunk/tagmanager/tm_file_entry.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/tm_file_entry.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -62,7 +62,7 @@
struct stat s;
#ifndef G_OS_WIN32
- if (0 != lstat(path, &s))
+ if (0 != g_lstat(path, &s))
return tm_file_unknown_t;
#endif
if S_ISDIR(s.st_mode)
@@ -163,7 +163,7 @@
return NULL;
}
g_snprintf(file_name, PATH_MAX, "%s/CVS/Entries", entry->path);
- if (0 == stat(file_name, &s))
+ if (0 == g_stat(file_name, &s))
{
if (S_ISREG(s.st_mode))
{
Modified: trunk/tagmanager/tm_project.c
===================================================================
--- trunk/tagmanager/tm_project.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/tm_project.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -72,7 +72,7 @@
, tm_project_find_file);
}
- if ((0 != stat(dir, &s)) || (!S_ISDIR(s.st_mode)))
+ if ((0 != g_stat(dir, &s)) || (!S_ISDIR(s.st_mode)))
{
g_warning("%s: Not a valid directory", dir);
return FALSE;
@@ -88,7 +88,7 @@
project->ignore = s_ignore;
project->file_list = NULL;
g_snprintf(path, PATH_MAX, "%s/%s", project->dir, TM_FILE_NAME);
- if ((0 != stat(path, &s)) || (0 == s.st_size))
+ if ((0 != g_stat(path, &s)) || (0 == s.st_size))
force = TRUE;
if (FALSE == tm_work_object_init(&(project->work_object),
project_class_id, path, force))
@@ -352,7 +352,7 @@
{
struct stat s;
char *ignore_file = g_strconcat(project->dir, "/", IGNORE_FILE, NULL);
- if (0 == stat(ignore_file, &s))
+ if (0 == g_stat(ignore_file, &s))
{
if (NULL != Option.ignore)
stringListClear(Option.ignore);
@@ -373,7 +373,7 @@
g_message("Opening project %s", project->work_object.file_name);
#endif
tm_project_set_ignorelist(project);
- if (NULL == (fp = fopen(project->work_object.file_name, "r")))
+ if (NULL == (fp = g_fopen(project->work_object.file_name, "r")))
return FALSE;
while (NULL != (tag = tm_tag_new_from_file(source_file, fp, 0)))
{
@@ -443,7 +443,7 @@
if (!project)
return FALSE;
- if (NULL == (fp = fopen(project->work_object.file_name, "w")))
+ if (NULL == (fp = g_fopen(project->work_object.file_name, "w")))
{
g_warning("Unable to save project %s", project->work_object.file_name);
return FALSE;
Modified: trunk/tagmanager/tm_work_object.c
===================================================================
--- trunk/tagmanager/tm_work_object.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/tm_work_object.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -14,23 +14,50 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#ifdef G_OS_WIN32
+# define VC_EXTRALEAN
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h> /* for GetFullPathName */
+#endif
#include "tm_tag.h"
#include "tm_work_object.h"
static GPtrArray *s_work_object_subclasses = NULL;
+#ifdef G_OS_WIN32
+/* realpath implementation for Windows found at http://bugzilla.gnome.org/show_bug.cgi?id=342926
+ * this one is better than e.g. liberty's lrealpath because this one uses Win32 API and works
+ * with special chars within the filename */
+static char *realpath (const char *pathname, char resolved_path[PATH_MAX])
+{
+ int size;
+
+ if (resolved_path != NULL)
+ {
+ size = GetFullPathNameA (pathname, PATH_MAX, resolved_path, NULL);
+ if (size > PATH_MAX)
+ return NULL;
+ else
+ return resolved_path;
+ }
+ else
+ {
+ size = GetFullPathNameA (pathname, 0, NULL, NULL);
+ resolved_path = g_new0 (char, size);
+ GetFullPathNameA (pathname, size, resolved_path, NULL);
+ return resolved_path;
+ }
+}
+#endif
+
gchar *tm_get_real_path(const gchar *file_name)
{
if (file_name)
{
gchar path[PATH_MAX+1];
memset(path, '\0', PATH_MAX+1);
-#ifdef G_OS_WIN32
- return lrealpath(file_name);
-#else
realpath(file_name, path);
-#endif
return g_strdup(path);
}
else
@@ -63,18 +90,18 @@
struct stat s;
int status;
- if (0 != (status = stat(file_name, &s)))
+ if (0 != (status = g_stat(file_name, &s)))
{
if (create)
{
FILE *f;
- if (NULL == (f = fopen(file_name, "a+")))
+ if (NULL == (f = g_fopen(file_name, "a+")))
{
g_warning("Unable to create file %s", file_name);
return FALSE;
}
fclose(f);
- status = stat(file_name, &s);
+ status = g_stat(file_name, &s);
}
}
if (0 != status)
@@ -106,7 +133,7 @@
g_return_val_if_fail(file_name, 0);
- if (0 != stat(file_name, &s))
+ if (0 != g_stat(file_name, &s))
{
/*g_warning("Unable to stat %s", file_name);*/
return (time_t) 0;
Modified: trunk/tagmanager/tm_workspace.c
===================================================================
--- trunk/tagmanager/tm_workspace.c 2007-07-17 09:14:13 UTC (rev 1713)
+++ trunk/tagmanager/tm_workspace.c 2007-07-17 12:04:46 UTC (rev 1714)
@@ -145,7 +145,7 @@
FILE *fp;
TMTag *tag;
- if (NULL == (fp = fopen(tags_file, "r")))
+ if (NULL == (fp = g_fopen(tags_file, "r")))
return FALSE;
if (NULL == theWorkspace)
tm_create_workspace();
@@ -166,7 +166,7 @@
{
struct stat file_stat;
const char *filename = (const char*)key;
- if (stat(filename, &file_stat) == 0)
+ if (g_stat(filename, &file_stat) == 0)
{
#ifdef TM_DEBUG
g_message ("Hash for '%s' is '%d'\n", filename, file_stat.st_ino);
@@ -270,7 +270,7 @@
char *temp_file2 = g_strdup_printf("%s/%d_%ld_2.cpp", P_tmpdir, getpid(), time(NULL));
#endif
- if (NULL == (fp = fopen(temp_file, "w")))
+ if (NULL == (fp = g_fopen(temp_file, "w")))
return FALSE;
includes_files_hash = g_hash_table_new_full (tm_file_inode_hash,
@@ -401,7 +401,7 @@
tm_source_file_free(source_file);
return FALSE;
}
- if (NULL == (fp = fopen(tags_file, "w")))
+ if (NULL == (fp = g_fopen(tags_file, "w")))
{
tm_source_file_free(source_file);
return FALSE;
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