SF.net SVN: geany:[5349] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Mon Nov 1 15:18:32 UTC 2010


Revision: 5349
          http://geany.svn.sourceforge.net/geany/?rev=5349&view=rev
Author:   ntrel
Date:     2010-11-01 15:18:32 +0000 (Mon, 01 Nov 2010)

Log Message:
-----------
Detect user and system filetype configuration files as Conf
filetype.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/filetypes.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-11-01 15:17:22 UTC (rev 5348)
+++ trunk/ChangeLog	2010-11-01 15:18:32 UTC (rev 5349)
@@ -3,6 +3,9 @@
  * src/utils.c, src/main.c:
    Remove trailing directory separator for app->datadir and
    app->docdir for consistency with the other directory fields.
+ * src/filetypes.c:
+   Detect user and system filetype configuration files as Conf
+   filetype.
 
 
 2010-11-01  Frank Lanitz  <frank(at)frank(dot)uvena(dot)de>

Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c	2010-11-01 15:17:22 UTC (rev 5348)
+++ trunk/src/filetypes.c	2010-11-01 15:18:32 UTC (rev 5349)
@@ -726,6 +726,33 @@
 }
 
 
+static GeanyFiletype *check_builtin_filenames(const gchar *utf8_filename)
+{
+	gchar *lfn = NULL;
+	const gchar *path;
+	gboolean found = FALSE;
+
+#ifdef G_OS_WIN32
+	/* use lower case basename */
+	lfn = g_utf8_strdown(utf8_filename, -1);
+#else
+	lfn = g_strdup(utf8_filename);
+#endif
+	setptr(lfn, utils_get_locale_from_utf8(lfn));
+
+	path = utils_build_path(app->configdir, GEANY_FILEDEFS_SUBDIR, "filetypes.", NULL);
+	if (g_str_has_prefix(lfn, path))
+		found = TRUE;
+
+	path = utils_build_path(app->datadir, "filetypes.", NULL);
+	if (g_str_has_prefix(lfn, path))
+		found = TRUE;
+
+	g_free(lfn);
+	return found ? filetypes[GEANY_FILETYPES_CONF] : NULL;
+}
+
+
 /* Detect filetype only based on the filename extension.
  * utf8_filename can include the full path. */
 GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename)
@@ -733,6 +760,10 @@
 	gchar *base_filename;
 	GeanyFiletype *ft;
 
+	ft = check_builtin_filenames(utf8_filename);
+	if (ft)
+		return ft;
+
 	/* to match against the basename of the file (because of Makefile*) */
 	base_filename = g_path_get_basename(utf8_filename);
 #ifdef G_OS_WIN32


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