Revision: 5199 http://geany.svn.sourceforge.net/geany/?rev=5199&view=rev Author: ntrel Date: 2010-08-25 11:44:33 +0000 (Wed, 25 Aug 2010)
Log Message: ----------- Auto-enable building with included regex if no regcomp function is found. Remove checks for HAVE_REGCOMP in Geany source (not TagManager) - regex support is required.
Modified Paths: -------------- trunk/ChangeLog trunk/configure.ac trunk/src/encodings.c trunk/src/filetypes.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-08-25 10:49:44 UTC (rev 5198) +++ trunk/ChangeLog 2010-08-25 11:44:33 UTC (rev 5199) @@ -2,6 +2,11 @@
* src/build.c: Fix broken editing of build menu labels. + * src/encodings.c, src/filetypes.c, configure.ac: + Auto-enable building with included regex if no regcomp function is + found. + Remove checks for HAVE_REGCOMP in Geany source (not TagManager) - + regex support is required.
2010-08-24 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-08-25 10:49:44 UTC (rev 5198) +++ trunk/configure.ac 2010-08-25 11:44:33 UTC (rev 5199) @@ -43,7 +43,7 @@ AC_STRUCT_TM
# Checks for library functions. -AC_CHECK_FUNCS([gethostname ftruncate fgetpos mkstemp regcomp strerror strstr]) +AC_CHECK_FUNCS([gethostname ftruncate fgetpos mkstemp strerror strstr])
# autoscan end
@@ -164,6 +164,9 @@ # Use included GNU regex library AC_ARG_ENABLE(gnu-regex, [AC_HELP_STRING([--enable-gnu-regex], [compile with included GNU regex library [default=no]])], , enable_gnu_regex=no)
+# auto-enable included regex if necessary +AC_CHECK_FUNCS([regcomp], [], [enable_gnu_regex="yes"]) + if test "x$enable_gnu_regex" = "xyes" ; then AC_DEFINE(USE_INCLUDED_REGEX, 1, [Define if included GNU regex code should be used.]) AC_DEFINE(HAVE_REGCOMP, 1, [Define if you have the 'regcomp' function.]) @@ -314,6 +317,12 @@ echo "Build with plugin support : ${enable_plugins}" echo "Use virtual terminal support : ${want_vte}" echo "Use (UNIX domain) socket support : ${want_socket}" +if test "x$enable_gnu_regex" = "xyes" ; then + echo "GNU regex library : built-in" +else + echo "GNU regex library : system" +fi + if test "${REVISION}" != "-1" then echo "Compiling Subversion revision : ${REVISION}"
Modified: trunk/src/encodings.c =================================================================== --- trunk/src/encodings.c 2010-08-25 10:49:44 UTC (rev 5198) +++ trunk/src/encodings.c 2010-08-25 11:44:33 UTC (rev 5199) @@ -44,21 +44,20 @@ #include "callbacks.h" #include "ui_utils.h"
+#ifdef HAVE_REGEX_H +# include <regex.h> +#else +# include "gnuregex.h" +#endif
-#ifdef HAVE_REGCOMP -# ifdef HAVE_REGEX_H -# include <regex.h> -# else -# include "gnuregex.h" -# endif /* <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> */ -# define PATTERN_HTMLMETA "<meta[ \t\n\r\f]http-equiv[ \t\n\r\f]*=[ \t\n\r\f]*"content-type"[ \t\n\r\f]+content[ \t\n\r\f]*=[ \t\n\r\f]*"text/x?html;[ \t\n\r\f]*charset=([a-z0-9_-]+)"[ \t\n\r\f]*/?>" +#define PATTERN_HTMLMETA "<meta[ \t\n\r\f]http-equiv[ \t\n\r\f]*=[ \t\n\r\f]*"content-type"[ \t\n\r\f]+content[ \t\n\r\f]*=[ \t\n\r\f]*"text/x?html;[ \t\n\r\f]*charset=([a-z0-9_-]+)"[ \t\n\r\f]*/?>" /* " geany_encoding=utf-8 " or " coding: utf-8 " */ -# define PATTERN_CODING "coding[\t ]*[:=][\t ]*([a-z0-9-]+)[\t ]*" +#define PATTERN_CODING "coding[\t ]*[:=][\t ]*([a-z0-9-]+)[\t ]*" + /* precompiled regexps */ static regex_t pregs[2]; static gboolean pregs_loaded = FALSE; -#endif
GeanyEncoding encodings[GEANY_ENCODINGS_MAX]; @@ -257,7 +256,6 @@ }
-#ifdef HAVE_REGCOMP /* Regexp detection of file encoding declared in the file itself. * Idea and parts of code taken from Bluefish, thanks. * regex_compile() is used to compile regular expressions on program init and keep it in memory @@ -301,7 +299,6 @@ g_free(tmp_buf); return encoding; } -#endif
static void encodings_radio_item_change_cb(GtkCheckMenuItem *menuitem, gpointer user_data) @@ -327,7 +324,6 @@
void encodings_finalize(void) { -#ifdef HAVE_REGCOMP if (pregs_loaded) { guint i, len; @@ -337,7 +333,6 @@ regfree(&pregs[i]); } } -#endif }
@@ -354,14 +349,12 @@
init_encodings();
-#ifdef HAVE_REGCOMP if (! pregs_loaded) { regex_compile(&pregs[0], PATTERN_HTMLMETA); regex_compile(&pregs[1], PATTERN_CODING); pregs_loaded = TRUE; } -#endif
/* create encodings submenu in document menu */ menu[0] = ui_lookup_widget(main_widgets.window, "set_encoding1_menu"); @@ -534,7 +527,6 @@ size = strlen(buffer); }
-#ifdef HAVE_REGCOMP /* first try to read the encoding from the file content */ len = (gint) G_N_ELEMENTS(pregs); for (i = 0; i < len && ! check_regex; i++) @@ -542,7 +534,6 @@ if ((regex_charset = regex_match(&pregs[i], buffer, size)) != NULL) check_regex = TRUE; } -#endif
/* current locale is not UTF-8, we have to check this charset */ check_locale = ! g_get_charset((const gchar**) &charset);
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2010-08-25 10:49:44 UTC (rev 5198) +++ trunk/src/filetypes.c 2010-08-25 11:44:33 UTC (rev 5199) @@ -46,12 +46,10 @@
#include <stdlib.h>
-#ifdef HAVE_REGCOMP -# ifdef HAVE_REGEX_H -# include <regex.h> -# else -# include "gnuregex.h" -# endif +#ifdef HAVE_REGEX_H +# include <regex.h> +#else +# include "gnuregex.h" #endif
@@ -60,11 +58,9 @@ { GtkWidget *menu_item; /* holds a pointer to the menu item for this filetype */ gboolean keyfile_loaded; -#ifdef HAVE_REGCOMP regex_t error_regex; gboolean error_regex_compiled; gchar *last_string; /* last one compiled */ -#endif gboolean custom; } GeanyFiletypePrivate; @@ -1152,13 +1148,11 @@ { setptr(ft->error_regex_string, string);
-#ifdef HAVE_REGCOMP if (ft->priv->error_regex_compiled) regfree(&ft->priv->error_regex);
ft->priv->error_regex_compiled = FALSE; /* regex will be compiled when needed */ -#endif }
@@ -1472,7 +1466,6 @@ }
-#ifdef HAVE_REGCOMP static gchar *get_regex_match_string(const gchar *message, regmatch_t *pmatch, gint match_idx) { return g_strndup(&message[pmatch[match_idx].rm_so], @@ -1495,7 +1488,6 @@ } /* regex will be freed in set_error_regex(). */ } -#endif
gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message, @@ -1504,10 +1496,9 @@ gchar *regstr; gchar **tmp; GeanyDocument *doc; -#ifdef HAVE_REGCOMP regex_t *regex; regmatch_t pmatch[3]; -#endif + if (ft == NULL) { doc = document_get_current(); @@ -1518,11 +1509,6 @@ if (tmp == NULL) return FALSE; regstr = *tmp; -#ifndef HAVE_REGCOMP - if (!NZV(regstr)) - geany_debug("No regex support - maybe you should configure with --enable-gnu-regex!"); - return FALSE; -#else regex = &ft->priv->error_regex;
*filename = NULL; @@ -1573,7 +1559,6 @@ } } return *filename != NULL; -#endif }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.