SF.net SVN: geany: [1460] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Wed Apr 18 12:12:51 UTC 2007
Revision: 1460
http://svn.sourceforge.net/geany/?rev=1460&view=rev
Author: ntrel
Date: 2007-04-18 05:12:51 -0700 (Wed, 18 Apr 2007)
Log Message:
-----------
Split filetypes_get_from_filename() into filetypes_detect_from_file()
and filetypes_detect_from_filename().
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
trunk/src/filetypes.c
trunk/src/filetypes.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-04-18 12:01:06 UTC (rev 1459)
+++ trunk/ChangeLog 2007-04-18 12:12:51 UTC (rev 1460)
@@ -2,6 +2,9 @@
* doc/geany.docbook:
Update Search section: escape sequences, Find All, Mark, Replace All.
+ * src/filetypes.c, src/filetypes.h, src/document.c:
+ Split filetypes_get_from_filename() into filetypes_detect_from_file()
+ and filetypes_detect_from_filename().
2007-04-16 Enrico Tröger <enrico.troeger at uvena.de>
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2007-04-18 12:01:06 UTC (rev 1459)
+++ trunk/src/document.c 2007-04-18 12:12:51 UTC (rev 1460)
@@ -439,7 +439,7 @@
//document_set_filetype(idx, (ft == NULL) ? filetypes[GEANY_FILETYPES_ALL] : ft);
if (ft == NULL && filename != NULL) // guess the filetype from the filename if one is given
- ft = filetypes_get_from_filename(idx);
+ ft = filetypes_detect_from_file(idx);
document_set_filetype(idx, ft); // also clears taglist
if (ft == NULL) filetypes[GEANY_FILETYPES_ALL]->style_func_ptr(doc_list[idx].sci);
@@ -807,7 +807,7 @@
g_signal_connect((GtkWidget*) doc_list[idx].sci, "sci-notify",
G_CALLBACK(on_editor_notification), GINT_TO_POINTER(idx));
- use_ft = (ft != NULL) ? ft : filetypes_get_from_filename(idx);
+ use_ft = (ft != NULL) ? ft : filetypes_detect_from_file(idx);
}
else
{ // reloading
@@ -1058,7 +1058,7 @@
if (doc_list[idx].file_type == NULL || doc_list[idx].file_type->id == GEANY_FILETYPES_ALL)
{
- doc_list[idx].file_type = filetypes_get_from_filename(idx);
+ doc_list[idx].file_type = filetypes_detect_from_file(idx);
filetypes_select_radio_item(doc_list[idx].file_type);
}
document_set_filetype(idx, doc_list[idx].file_type);
Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c 2007-04-18 12:01:06 UTC (rev 1459)
+++ trunk/src/filetypes.c 2007-04-18 12:12:51 UTC (rev 1460)
@@ -681,14 +681,10 @@
}
-/* simple filetype selection based on the filename extension */
-filetype *filetypes_get_from_filename(gint idx)
+/* Detect the filetype for document idx, checking for a shebang, then filename extension. */
+filetype *filetypes_detect_from_file(gint idx)
{
- GPatternSpec *pattern;
filetype *ft;
- const gchar *utf8_filename;
- gchar *base_filename;
- gint i, j;
if (! DOC_IDX_VALID(idx))
return filetypes[GEANY_FILETYPES_ALL];
@@ -699,9 +695,19 @@
if (doc_list[idx].file_name == NULL)
return filetypes[GEANY_FILETYPES_ALL];
- else
- utf8_filename = doc_list[idx].file_name;
+ return filetypes_detect_from_filename(doc_list[idx].file_name);
+}
+
+
+/* Detect filetype based on the filename extension.
+ * utf8_filename can include the full path. */
+filetype *filetypes_detect_from_filename(const gchar *utf8_filename)
+{
+ GPatternSpec *pattern;
+ gchar *base_filename;
+ gint i, j;
+
// to match against the basename of the file(because of Makefile*)
base_filename = g_path_get_basename(utf8_filename);
Modified: trunk/src/filetypes.h
===================================================================
--- trunk/src/filetypes.h 2007-04-18 12:01:06 UTC (rev 1459)
+++ trunk/src/filetypes.h 2007-04-18 12:12:51 UTC (rev 1460)
@@ -119,9 +119,13 @@
* and create the filetype menu*/
void filetypes_init_types();
-/* simple filetype selection based on the filename extension */
-filetype *filetypes_get_from_filename(gint idx);
+/* Detect the filetype for document idx, checking for a shebang, then filename extension. */
+filetype *filetypes_detect_from_file(gint idx);
+/* Detect filetype based on the filename extension.
+ * utf8_filename can include the full path. */
+filetype *filetypes_detect_from_filename(const gchar *utf8_filename);
+
/* frees the array and all related pointers */
void filetypes_free_types();
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