Revision: 1573 http://svn.sourceforge.net/geany/?rev=1573&view=rev Author: eht16 Date: 2007-05-25 08:19:23 -0700 (Fri, 25 May 2007)
Log Message: ----------- Add shebank-like detection for XML files.
Modified Paths: -------------- trunk/ChangeLog trunk/src/filetypes.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-25 14:42:43 UTC (rev 1572) +++ trunk/ChangeLog 2007-05-25 15:19:23 UTC (rev 1573) @@ -6,6 +6,7 @@ * geany.glade, src/callbacks.c, src/callbacks.h, src/geany.h, src/interface.c, src/main.c, src/ui_utils.c: Improve sensitivity of recent files sub menus. + * src/filetypes.c: Add shebank-like detection for XML files.
2007-05-25 Nick Treleaven nick.treleaven@btinternet.com
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2007-05-25 14:42:43 UTC (rev 1572) +++ trunk/src/filetypes.c 2007-05-25 15:19:23 UTC (rev 1573) @@ -574,7 +574,7 @@ gchar *line = sci_get_line(doc_list[idx].sci, 0); filetype *ft = NULL;
- if (strlen(line) > 2 && line[0] == '#' && line[1]=='!') + if (strlen(line) > 2 && line[0] == '#' && line[1] == '!') { /// TODO does g_path_get_basename() also work under Win32 for Unix filenames? gchar *basename_interpreter = g_path_get_basename(line + 2); @@ -609,7 +609,21 @@
g_free(basename_interpreter); } + // detect XML files + if (strncmp(line, "<?xml", 5) == 0) + { + // HTML and DocBook files might also start with <?xml, so detect them based on filename + // extension and use the detected filetype, else assume XML + ft = filetypes_detect_from_filename(doc_list[idx].file_name); + if (FILETYPE_ID(ft) != GEANY_FILETYPES_HTML && + FILETYPE_ID(ft) != GEANY_FILETYPES_DOCBOOK && + FILETYPE_ID(ft) != GEANY_FILETYPES_PERL && // Perl, Python and PHP only to be safe + FILETYPE_ID(ft) != GEANY_FILETYPES_PHP && + FILETYPE_ID(ft) != GEANY_FILETYPES_PYTHON)
+ ft = filetypes[GEANY_FILETYPES_XML]; + } + g_free(line); return ft; } @@ -624,6 +638,7 @@ return filetypes[GEANY_FILETYPES_ALL];
// try to find a shebang and if found use it prior to the filename extension + // also checks for <?xml ft = find_shebang(idx); if (ft != NULL) return ft;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.