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. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5199 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
b6a500dbdf
commit
a24d6dca6a
@ -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>
|
||||
|
11
configure.ac
11
configure.ac
@ -43,7 +43,7 @@ AC_TYPE_SIZE_T
|
||||
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 @@ fi
|
||||
# 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 GTK printing support : ${enable_printing}"
|
||||
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}"
|
||||
|
@ -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 @@ void encodings_select_radio_item(const gchar *charset)
|
||||
}
|
||||
|
||||
|
||||
#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 @@ static gchar *regex_match(regex_t *preg, const gchar *buffer, gsize size)
|
||||
g_free(tmp_buf);
|
||||
return encoding;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void encodings_radio_item_change_cb(GtkCheckMenuItem *menuitem, gpointer user_data)
|
||||
@ -327,7 +324,6 @@ static void encodings_radio_item_change_cb(GtkCheckMenuItem *menuitem, gpointer
|
||||
|
||||
void encodings_finalize(void)
|
||||
{
|
||||
#ifdef HAVE_REGCOMP
|
||||
if (pregs_loaded)
|
||||
{
|
||||
guint i, len;
|
||||
@ -337,7 +333,6 @@ void encodings_finalize(void)
|
||||
regfree(&pregs[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -354,14 +349,12 @@ void encodings_init(void)
|
||||
|
||||
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 @@ gchar *encodings_convert_to_utf8(const gchar *buffer, gsize size, gchar **used_e
|
||||
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 @@ gchar *encodings_convert_to_utf8(const gchar *buffer, gsize size, gchar **used_e
|
||||
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);
|
||||
|
@ -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 @@ typedef struct GeanyFiletypePrivate
|
||||
{
|
||||
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 @@ static void set_error_regex(GeanyFiletype *ft, gchar *string)
|
||||
{
|
||||
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 @@ GeanyFiletype *filetypes_lookup_by_name(const gchar *name)
|
||||
}
|
||||
|
||||
|
||||
#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 @@ static void compile_regex(GeanyFiletype *ft, regex_t *regex, gchar *regstr)
|
||||
}
|
||||
/* regex will be freed in set_error_regex(). */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
|
||||
@ -1504,10 +1496,9 @@ gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
|
||||
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 @@ gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
|
||||
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 @@ gboolean filetypes_parse_error_message(GeanyFiletype *ft, const gchar *message,
|
||||
}
|
||||
}
|
||||
return *filename != NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user