1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-20 00:15:31 +00:00

Merge branch 'elinks-0.12' into elinks-0.13

Conflicts:
	src/intl/charsets.h
	src/viewer/text/search.c
This commit is contained in:
Kalle Olavi Niemitalo 2009-05-21 19:50:16 +03:00 committed by Kalle Olavi Niemitalo
commit 82e67f8ebc
7 changed files with 120 additions and 72 deletions

View File

@ -214,6 +214,10 @@ Gianluca Montecchi <gianluca@pluto.linux.it>
Harold L Hunt II <huntharo@msu.edu>
Build system minor fixes
Hema Seetharamaiah <hema@treap.net>
Licenses the change under GPLv2-or-later and the modified BSD and X11 license, and permits linking with OpenSSL and with code licensed under LGPL.
Add configure --without-tre option
Hugo Haas <hugo@larve.net>
Minor random hacking
debian/watch file

1
NEWS
View File

@ -81,6 +81,7 @@ includes the changes listed under ``ELinks 0.11.6.GIT now'' below.
* critical bug 1071: Fix crash in get_dom_node_child.
* Debian build bug 526349: Include asciidoc.py from AsciiDoc 7.1.2,
to remove all dependencies on the installed version.
* build enhancement: Recognize ``configure --without-tre''.
ELinks 0.12pre3:
----------------

View File

@ -928,46 +928,51 @@ fi
# ===================================================================
# Check for TRE library
# ===================================================================
#
# This section only checks that --without-tre is not given and the
# library seems to work, and sets TRE_CFLAGS, TRE_LIBS, and
# tre_log. It does not define CONFIG_TRE, and always resets
# LIBS and CFLAGS back to their original values.
#
# After any --enable-utf-8 and --disable-utf-8 options have been
# handled, a separate section decides whether to actually use TRE.
AC_MSG_CHECKING([[for TRE in pkg-config]])
if pkg-config tre; then
TRE_CFLAGS=`pkg-config --cflags tre`
TRE_LIBS=`pkg-config --libs tre`
AC_MSG_RESULT([[yes]])
AC_ARG_WITH([[tre]], [[ --without-tre disable TRE regex search support]])
if test "$with_tre" = no; then
AC_MSG_CHECKING([[for TRE]])
AC_MSG_RESULT([[disabled]])
tre_log="no (explicitly disabled)"
else
# <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513055>
# "libtre-dev: /usr/lib/pkgconfig/tre.pc missing"
# so we look for the library even if pkg-config doesn't know about it.
TRE_CFLAGS=
TRE_LIBS=-ltre
AC_MSG_RESULT([[no, but let's try defaults]])
AC_MSG_CHECKING([[for TRE in pkg-config]])
if pkg-config tre; then
TRE_CFLAGS=`pkg-config --cflags tre`
TRE_LIBS=`pkg-config --libs tre`
AC_MSG_RESULT([[yes]])
else
# <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513055>
# "libtre-dev: /usr/lib/pkgconfig/tre.pc missing"
# so we look for the library even if pkg-config doesn't know about it.
TRE_CFLAGS=
TRE_LIBS=-ltre
AC_MSG_RESULT([[no, but let's try defaults]])
fi
AC_MSG_CHECKING([[for TRE header and library]])
EL_SAVE_FLAGS
CFLAGS="$TRE_CFLAGS $CFLAGS"
LIBS="$TRE_LIBS $LIBS"
AC_TRY_LINK([#include <tre/regex.h>],
[regex_t re;
regmatch_t match[1];
regwcomp(&re, L"zap", REG_ICASE);
regwexec(&re, L"ELIZAPROGRAM", 1, match, 0);],
[AC_MSG_RESULT([[yes]])
tre_log="available"],
[AC_MSG_RESULT([[no]])
tre_log="no (TRE not found)"])
EL_RESTORE_FLAGS
fi
AC_MSG_CHECKING([[for TRE header and library]])
EL_SAVE_FLAGS
CFLAGS="$TRE_CFLAGS $CFLAGS"
LIBS="$TRE_LIBS $LIBS"
AC_TRY_LINK([#include <tre/regex.h>],
[regex_t re;
regmatch_t match[1];
regwcomp(&re, L"zap", REG_ICASE);
regwexec(&re, L"ELIZAPROGRAM", 1, match, 0);],
[AC_MSG_RESULT([[yes]])
AC_DEFINE([HAVE_TRE_REGEX_H], [1],
[Define to 1 if you have the <tre/regex.h> header file.])
# TRE_CFLAGS will be used only where needed.
# TRE_LIBS will be kept in LIBS and used everywhere.
EL_RESTORE_FLAGS
LIBS="$TRE_LIBS $LIBS"],
[AC_MSG_RESULT([[no]])
TRE_CFLAGS=
TRE_LIBS=
EL_RESTORE_FLAGS])
AC_SUBST(TRE_CFLAGS)
AC_SUBST(TRE_LIBS)
AC_CHECK_SIZEOF([wchar_t], [4], [[#include <wchar.h>]])
# ===================================================================
# Check for Ruby, optional even if installed.
# ===================================================================
@ -1418,6 +1423,66 @@ AC_ARG_ENABLE(weehoofooboomookerchoo,
[AC_MSG_ERROR(Are you strange, or what?)])
# ===================================================================
# Decide whether to use TRE
# ===================================================================
#
# This must be done after the CONFIG_UTF8 check above.
# The first part of the TRE check is separate, to get
# the configure --help output in a sensible order.
if test "$tre_log" = "available"; then
if test "$CONFIG_UTF8" = "yes"; then
# When CONFIG_UTF8 and CONFIG_TRE are both defined,
# src/viewer/text/search.c makes a string of
# unicode_val_T and gives it to regwexec(), which
# expects a string of wchar_t. If the unicode_val_T
# and wchar_t types are too different, this won't
# work, so try to detect that and disable regexp
# operations entirely in that case.
#
# Currently, this code only compares the sizes of the
# types. src/intl/charsets.h defines unicode_val_T as
# uint32_t, so we check whether wchar_t has exactly 32
# bits. But don't use AC_CHECK_SIZEOF for this, because
# there doesn't seem to be a documented way to get the
# result of that for use in the configure script.
#
# C99 says the implementation can define
# __STDC_ISO_10646__ if wchar_t values match ISO 10646
# (or Unicode) numbers in all locales. Do not check
# that macro here, because it is too restrictive: it
# should be enough for ELinks if the values match in
# the locales where ELinks is actually run.
AC_MSG_CHECKING([[whether wchar_t is exactly 32-bit]])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <limits.h>
#include <stddef.h>
int dummy[(sizeof(wchar_t) * CHAR_BIT == 32) ? 1 : -1];]], [])],
[AC_MSG_RESULT([[yes]])
tre_log="TRE"],
[AC_MSG_RESULT([[no]])
tre_log="no (unsuitable wchar_t)"])
else
# If UTF-8 is not used, then wchar_t doesn't matter.
tre_log="TRE"
fi
fi
if test "$tre_log" = "TRE"; then
AC_DEFINE([CONFIG_TRE], [1],
[Define as 1 to use the TRE library for regular expression searching. This requires the <tre/regex.h> header file. If you define CONFIG_UTF8 too, then wchar_t must be exactly 32-bit so that it matches unicode_val_T.])
# TRE_CFLAGS will be used only where needed.
LIBS="$LIBS $TRE_LIBS"
else
TRE_LIBS=
TRE_CFLAGS=
fi
AC_SUBST(TRE_CFLAGS)
AC_SUBST(TRE_LIBS)
EL_LOG_CONFIG([[CONFIG_TRE]], [[Regexp searching]], [[$tre_log]])
# ===================================================================
# Further LDFLAGS tweaks
# ===================================================================

View File

@ -407,7 +407,7 @@ static struct option_info config_options_info[] = {
N_("Whether the search should match the document text while "
"maintaining case sensitivity.")),
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
INIT_OPT_INT("document.browse.search", N_("Regular expressions"),
"regex", 0, 0, 2, 0,
N_("Enable searching with regular expressions:\n"

View File

@ -29,30 +29,6 @@
#define DEBUG_MEMLEAK
#endif
/* When CONFIG_UTF8 is defined, src/viewer/text/search.c makes a string
* of unicode_val_T and gives it to regwexec(), which expects a string
* of wchar_t. If the unicode_val_T and wchar_t types are too different,
* this won't work, so try to detect that and disable regexp operations
* entirely in that case.
*
* Currently, this code only compares the sizes of the types. Because
* unicode_val_T is defined as uint32_t and POSIX says bytes are 8-bit,
* sizeof(unicode_val_T) is 4 and the following compares SIZEOF_WCHAR_T
* to that.
*
* C99 says the implementation can define __STDC_ISO_10646__ if wchar_t
* values match ISO 10646 (or Unicode) numbers in all locales. Do not
* check that macro here, because it is too restrictive: it should be
* enough for ELinks if the values match in the locales where ELinks is
* actually run. */
#ifdef CONFIG_UTF8
#if SIZEOF_WCHAR_T != 4
#undef HAVE_TRE_REGEX_H
#endif
#endif
/* This maybe overrides some of the standard high-level functions, to ensure
* the expected behaviour. These overrides are not system specific. */
#include "osdep/stub.h"

View File

@ -2,6 +2,8 @@
#define EL__INTL_CHARSETS_H
struct hash;
/* The TRE check in configure.in assumes unicode_val_T is uint32_t. */
typedef uint32_t unicode_val_T;
/* U+0020 SPACE. Normally the same as ' ' or L' ' but perhaps ELinks

View File

@ -18,7 +18,7 @@
#include <sys/types.h> /* FreeBSD needs this before regex.h */
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
#include <tre/regex.h>
#endif
@ -270,7 +270,7 @@ get_range(struct document *document, int y, int height, int l,
return 0;
}
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
/** Returns a string @c doc that is a copy of the text in the search
* nodes from @a s1 to (@a s1 + @a doclen - 1) with the space at the
* end of each line converted to a new-line character (LF). */
@ -465,7 +465,7 @@ is_in_range_regex(struct document *document, int y, int height,
return common_ctx.found;
}
#endif /* HAVE_TRE_REGEX_H */
#endif /* CONFIG_TRE */
static UCHAR *
memacpy_u(unsigned char *text, int textlen, int utf8)
@ -602,7 +602,7 @@ is_in_range(struct document *document, int y, int height,
if (get_range(document, y, height, textlen, &s1, &s2))
return 0;
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
if (get_opt_int("document.browse.search.regex", NULL))
return is_in_range_regex(document, y, height, text, textlen,
min, max, s1, s2, utf8);
@ -681,7 +681,7 @@ srch_failed:
*pl = len;
}
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
struct get_searched_regex_context {
int xoffset;
int yoffset;
@ -749,7 +749,7 @@ get_searched_regex(struct document_view *doc_view, struct point **pt, int *pl,
*pt = ctx.points;
*pl = ctx.len;
}
#endif /* HAVE_TRE_REGEX_H */
#endif /* CONFIG_TRE */
static void
get_searched(struct document_view *doc_view, struct point **pt, int *pl, int utf8)
@ -773,7 +773,7 @@ get_searched(struct document_view *doc_view, struct point **pt, int *pl, int utf
return;
}
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
if (get_opt_int("document.browse.search.regex", NULL))
get_searched_regex(doc_view, pt, pl, l, s1, s2, utf8);
else
@ -1594,7 +1594,7 @@ search_typeahead(struct session *ses, struct document_view *doc_view,
* a nice cleanup target ;-). --pasky */
enum search_option {
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
SEARCH_OPT_REGEX,
#endif
SEARCH_OPT_CASE,
@ -1602,7 +1602,7 @@ enum search_option {
};
static struct option_resolver resolvers[] = {
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
{ SEARCH_OPT_REGEX, "regex" },
#endif
{ SEARCH_OPT_CASE, "case" },
@ -1669,7 +1669,7 @@ search_dlg_do(struct terminal *term, struct memory_list *ml,
hop->values, SEARCH_OPTIONS);
hop->data = data;
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
#define SEARCH_WIDGETS_COUNT 8
#else
#define SEARCH_WIDGETS_COUNT 5
@ -1693,7 +1693,7 @@ search_dlg_do(struct terminal *term, struct memory_list *ml,
field = get_dialog_offset(dlg, SEARCH_WIDGETS_COUNT);
add_dlg_field(dlg, text, 0, 0, NULL, MAX_STR_LEN, field, history);
#ifdef HAVE_TRE_REGEX_H
#ifdef CONFIG_TRE
add_dlg_radio(dlg, _("Normal search", term), 1, 0, &hop->values[SEARCH_OPT_REGEX].number);
add_dlg_radio(dlg, _("Regexp search", term), 1, 1, &hop->values[SEARCH_OPT_REGEX].number);
add_dlg_radio(dlg, _("Extended regexp search", term), 1, 2, &hop->values[SEARCH_OPT_REGEX].number);