Kaydet (Commit) ade798f9 authored tarafından Enrico Tröger's avatar Enrico Tröger

Add configure option --enable-gnu-regex to implicitly build the included GNU…

Add configure option --enable-gnu-regex to implicitly build the included GNU regex library (in case the host system doesn't provide a usable regex library).
Rename tagmanger/include/regex.h in tagmanager/include/gnuregex.h to avoid unintended inclusion in source files (this fixes the OpenSolaris crashes).
Don't use GNU regex specific regex_t::buffer element to build also without this extension (e.g. on OpenSolaris).


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2532 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 6ca83a87
2008-04-27 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* configure.in, tagmanager/lregex.c, tagmanager/include/regex.h,
tagmanager/regex.c,tagmanager/include/Makefile.am,
tagmanager/include/gnuregex.h, tagmanager/Makefile.am :
Add configure option --enable-gnu-regex to implicitly build the
included GNU regex library (in case the host system doesn't provide
a usable regex library).
Rename tagmanger/include/regex.h in tagmanager/include/gnuregex.h
to avoid unintended inclusion in source files (this fixes the
OpenSolaris crashes).
* src/encodings.c:
Don't use GNU regex specific regex_t::buffer element to build also
without this extension (e.g. on OpenSolaris).
2008-04-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/document.c:
......
......@@ -33,7 +33,7 @@ LIBTOOL="$LIBTOOL --silent"
# autoscan start
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h fnmatch.h glob.h libintl.h limits.h stddef.h stdlib.h string.h sys/time.h unistd.h])
AC_CHECK_HEADERS([fcntl.h fnmatch.h glob.h libintl.h limits.h regex.h stddef.h stdlib.h string.h sys/time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_OFF_T
......@@ -125,7 +125,7 @@ AC_ARG_ENABLE(deprecated, [ --disable-deprecated Disable deprecated GTK func
[GTK_CFLAGS="$GTK_CFLAGS -DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"], [])
# Plugins support
AC_ARG_ENABLE(plugins, [AC_HELP_STRING([--disable-plugins], [compile without plugin support [[default=no]]])], , enable_plugins=yes)
AC_ARG_ENABLE(plugins, [AC_HELP_STRING([--disable-plugins], [compile without plugin support [default=no]])], , enable_plugins=yes)
if test "x$enable_plugins" = "xyes" ; then
AC_DEFINE(HAVE_PLUGINS, 1, [Define if plugins are enabled.])
......@@ -134,6 +134,17 @@ else
AM_CONDITIONAL(PLUGINS, false)
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)
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.])
AM_CONDITIONAL(USE_INCLUDED_REGEX, true)
else
AM_CONDITIONAL(USE_INCLUDED_REGEX, false)
fi
# Check for random number paths (skip when cross compiling)
if test "x$build" = "x$host"; then
AC_CHECK_FILE([/dev/urandom], AC_DEFINE([HAVE_DEVURANDOM], [1], [Define that you found /dev/urandom]))
......
......@@ -43,13 +43,18 @@
#ifdef HAVE_REGCOMP
# include <regex.h>
# 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]*/?>"
/* " geany_encoding=utf-8 " */
# define PATTERN_GEANY "[\t ]geany_encoding=([a-z0-9-]+)[\t ]"
/* precompiled regexps */
static regex_t pregs[2];
static gboolean pregs_loaded = FALSE;
#endif
......@@ -266,7 +271,7 @@ static gchar *regex_match(regex_t *preg, const gchar *buffer, gsize size)
gchar *encoding = NULL;
regmatch_t pmatch[10];
if (buffer == NULL || preg->buffer == NULL)
if (! pregs_loaded || buffer == NULL)
return NULL;
if (size > 512)
......@@ -289,10 +294,10 @@ static gchar *regex_match(regex_t *preg, const gchar *buffer, gsize size)
void encodings_finalize(void)
{
#ifdef HAVE_REGCOMP
guint i;
for (i = 0; i < G_N_ELEMENTS(pregs); i++)
if (pregs_loaded)
{
if (pregs[i].buffer == NULL)
guint i;
for (i = 0; i < G_N_ELEMENTS(pregs); i++)
{
regfree(&pregs[i]);
}
......@@ -315,8 +320,12 @@ void encodings_init(void)
init_encodings();
#ifdef HAVE_REGCOMP
regex_compile(&pregs[0], PATTERN_HTMLMETA);
regex_compile(&pregs[1], PATTERN_GEANY);
if (! pregs_loaded)
{
regex_compile(&pregs[0], PATTERN_HTMLMETA);
regex_compile(&pregs[1], PATTERN_GEANY);
pregs_loaded = TRUE;
}
#endif
/* create encodings submenu in document menu */
......
......@@ -73,3 +73,6 @@ libtagmanager_a_SOURCES =\
tm_file_entry.c\
tm_tagmanager.c
if USE_INCLUDED_REGEX
libtagmanager_a_SOURCES += regex.c
endif
noinst_HEADERS = \
regex.h
gnuregex.h
tagmanager_includedir = $(includedir)/geany/tagmanager/
tagmanager_include_HEADERS = \
......
......@@ -27,7 +27,11 @@
# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h> /* declare off_t (not known to regex.h on FreeBSD) */
# endif
# include <regex.h>
# ifdef HAVE_REGEX_H
# include <regex.h>
# else
# include "gnuregex.h"
# endif
#endif
#include "main.h"
......
......@@ -120,9 +120,9 @@ init_syntax_once ()
#define SYNTAX(c) re_syntax_table[c]
#endif /* not emacs */
/* Get the interface, including the syntax bits. */
#include "regex.h"
#include "gnuregex.h"
/* isalpha etc. are used for the character classes. */
#include <ctype.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment