mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Fix compatibility with Ruby >= 1.9
Based on patch by Ian Abbott Bug: https://bugs.gentoo.org/424789
This commit is contained in:
parent
0dd3aaabe6
commit
7a403ef735
@ -32,36 +32,40 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
|
|||||||
if test "$CONFIG_SCRIPTING_RUBY" != "no"; then
|
if test "$CONFIG_SCRIPTING_RUBY" != "no"; then
|
||||||
|
|
||||||
AC_MSG_CHECKING(Ruby version)
|
AC_MSG_CHECKING(Ruby version)
|
||||||
if $CONFIG_SCRIPTING_RUBY -e 'exit((VERSION or RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
|
if $CONFIG_SCRIPTING_RUBY -e 'exit((VERSION rescue RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
|
||||||
ruby_version=`$CONFIG_SCRIPTING_RUBY -e 'puts "#{VERSION rescue RUBY_VERSION}"'`
|
ruby_version=`$CONFIG_SCRIPTING_RUBY -e 'puts "#{VERSION rescue RUBY_VERSION}"'`
|
||||||
AC_MSG_RESULT($ruby_version)
|
AC_MSG_RESULT($ruby_version)
|
||||||
|
|
||||||
AC_MSG_CHECKING(for Ruby header files)
|
AC_MSG_CHECKING(for Ruby header files)
|
||||||
rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
|
rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG[["rubyhdrdir"]] || RbConfig::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
|
||||||
|
|
||||||
if test "X$rubyhdrdir" != "X"; then
|
if test "X$rubyhdrdir" != "X"; then
|
||||||
AC_MSG_RESULT($rubyhdrdir)
|
AC_MSG_RESULT($rubyhdrdir)
|
||||||
RUBY_CFLAGS="-I$rubyhdrdir"
|
RUBY_CFLAGS="-I$rubyhdrdir"
|
||||||
rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
|
rubyarch=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["arch"]]'`
|
||||||
|
if test -d "$rubyhdrdir/$rubyarch"; then
|
||||||
|
RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
|
||||||
|
fi
|
||||||
|
rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["LIBS"]]'`
|
||||||
|
|
||||||
if test "X$rubylibs" != "X"; then
|
if test "X$rubylibs" != "X"; then
|
||||||
RUBY_LIBS="$rubylibs"
|
RUBY_LIBS="$rubylibs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
|
librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.expand(RbConfig::CONFIG[["LIBRUBYARG"]])'`
|
||||||
|
|
||||||
if test -f "$rubyhdrdir/$librubyarg"; then
|
if test -f "$rubyhdrdir/$librubyarg"; then
|
||||||
librubyarg="$rubyhdrdir/$librubyarg"
|
librubyarg="$rubyhdrdir/$librubyarg"
|
||||||
|
|
||||||
else
|
else
|
||||||
rubylibdir=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'`
|
rubylibdir=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.expand(RbConfig::CONFIG[["libdir"]])'`
|
||||||
if test -f "$rubylibdir/$librubyarg"; then
|
if test -f "$rubylibdir/$librubyarg"; then
|
||||||
librubyarg="$rubylibdir/$librubyarg"
|
librubyarg="$rubylibdir/$librubyarg"
|
||||||
elif test "$librubyarg" = "libruby.a"; then
|
elif test "$librubyarg" = "libruby.a"; then
|
||||||
dnl required on Mac OS 10.3 where libruby.a doesn't exist
|
dnl required on Mac OS 10.3 where libruby.a doesn't exist
|
||||||
librubyarg="-lruby"
|
librubyarg="-lruby"
|
||||||
else
|
else
|
||||||
librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"`
|
librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{RbConfig.expand(RbConfig::CONFIG[\"libdir\"])}')"`
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -69,7 +73,7 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
|
|||||||
RUBY_LIBS="$librubyarg $RUBY_LIBS"
|
RUBY_LIBS="$librubyarg $RUBY_LIBS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rubyldflags=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
|
rubyldflags=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["LDFLAGS"]]'`
|
||||||
if test "X$rubyldflags" != "X"; then
|
if test "X$rubyldflags" != "X"; then
|
||||||
LDFLAGS="$rubyldflags $LDFLAGS"
|
LDFLAGS="$rubyldflags $LDFLAGS"
|
||||||
fi
|
fi
|
||||||
@ -86,6 +90,15 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
|
|||||||
AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
|
AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
|
||||||
|
AC_MSG_CHECKING([for rb_errinfo])
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ruby.h>]], [[rb_errinfo();]])],have_rb_errinfo="yes",have_rb_errinfo="no")
|
||||||
|
AC_MSG_RESULT($have_rb_errinfo)
|
||||||
|
if test "$have_rb_errinfo" = "yes"; then
|
||||||
|
AC_DEFINE([HAVE_RB_ERRINFO], [1],
|
||||||
|
[Define to 1 if you have the `rb_errinfo' function.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
EL_RESTORE_FLAGS
|
EL_RESTORE_FLAGS
|
||||||
|
@ -76,10 +76,10 @@ erb_report_error(struct session *ses, int error)
|
|||||||
break;
|
break;
|
||||||
case TAG_RAISE:
|
case TAG_RAISE:
|
||||||
case TAG_FATAL:
|
case TAG_FATAL:
|
||||||
eclass = CLASS_OF(ruby_errinfo);
|
eclass = CLASS_OF(RB_ERRINFO);
|
||||||
einfo = rb_obj_as_string(ruby_errinfo);
|
einfo = rb_obj_as_string(RB_ERRINFO);
|
||||||
|
|
||||||
if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
|
if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
|
||||||
msg = "unhandled exception";
|
msg = "unhandled exception";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -88,7 +88,7 @@ erb_report_error(struct session *ses, int error)
|
|||||||
|
|
||||||
epath = rb_class_path(eclass);
|
epath = rb_class_path(eclass);
|
||||||
snprintf(buff, MAX_STR_LEN, "%s: %s",
|
snprintf(buff, MAX_STR_LEN, "%s: %s",
|
||||||
RSTRING(epath)->ptr, RSTRING(einfo)->ptr);
|
RSTRING_PTR(epath), RSTRING_PTR(einfo));
|
||||||
|
|
||||||
p = strchr((const char *)buff, '\n');
|
p = strchr((const char *)buff, '\n');
|
||||||
if (p) *p = '\0';
|
if (p) *p = '\0';
|
||||||
@ -116,7 +116,7 @@ erb_module_message(VALUE self, VALUE str)
|
|||||||
struct terminal *term;
|
struct terminal *term;
|
||||||
|
|
||||||
str = rb_obj_as_string(str);
|
str = rb_obj_as_string(str);
|
||||||
message = memacpy(RSTRING(str)->ptr, RSTRING(str)->len);
|
message = memacpy(RSTRING_PTR(str), RSTRING_PTR(str));
|
||||||
if (!message) return Qnil;
|
if (!message) return Qnil;
|
||||||
|
|
||||||
line_end = strchr((const char *)message, '\n');
|
line_end = strchr((const char *)message, '\n');
|
||||||
@ -165,8 +165,8 @@ erb_stdout_p(int argc, VALUE *argv, VALUE self)
|
|||||||
* the inspect() method, which adds quotes to the strings, so
|
* the inspect() method, which adds quotes to the strings, so
|
||||||
* gently ignore them. */
|
* gently ignore them. */
|
||||||
|
|
||||||
ptr = RSTRING(substr)->ptr;
|
ptr = RSTRING_PTR(substr);
|
||||||
len = RSTRING(substr)->len;
|
len = RSTRING_LEN(substr);
|
||||||
|
|
||||||
if (*ptr == '"')
|
if (*ptr == '"')
|
||||||
ptr++, len--;
|
ptr++, len--;
|
||||||
|
@ -7,6 +7,20 @@ struct session;
|
|||||||
|
|
||||||
#include <ruby.h> /* for VALUE */
|
#include <ruby.h> /* for VALUE */
|
||||||
|
|
||||||
|
#ifndef RSTRING_LEN
|
||||||
|
#define RSTRING_LEN(string) (RSTRING(string)->len)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef RSTRING_PTR
|
||||||
|
#define RSTRING_PTR(string) (RSTRING(string)->ptr)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_RB_ERRINFO
|
||||||
|
#define RB_ERRINFO (rb_errinfo())
|
||||||
|
#else
|
||||||
|
#define RB_ERRINFO (ruby_errinfo)
|
||||||
|
#endif
|
||||||
|
|
||||||
VALUE erb_module;
|
VALUE erb_module;
|
||||||
|
|
||||||
void alert_ruby_error(struct session *ses, unsigned char *msg);
|
void alert_ruby_error(struct session *ses, unsigned char *msg);
|
||||||
|
@ -83,7 +83,7 @@ script_hook_goto_url(va_list ap, void *data)
|
|||||||
{
|
{
|
||||||
unsigned char *new_url;
|
unsigned char *new_url;
|
||||||
|
|
||||||
new_url = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
|
new_url = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
|
||||||
if (new_url) {
|
if (new_url) {
|
||||||
mem_free_set(url, new_url);
|
mem_free_set(url, new_url);
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ script_hook_follow_url(va_list ap, void *data)
|
|||||||
{
|
{
|
||||||
unsigned char *new_url;
|
unsigned char *new_url;
|
||||||
|
|
||||||
new_url = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
|
new_url = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
|
||||||
if (new_url) {
|
if (new_url) {
|
||||||
mem_free_set(url, new_url);
|
mem_free_set(url, new_url);
|
||||||
}
|
}
|
||||||
@ -170,9 +170,9 @@ script_hook_pre_format_html(va_list ap, void *data)
|
|||||||
switch (rb_type(result)) {
|
switch (rb_type(result)) {
|
||||||
case T_STRING:
|
case T_STRING:
|
||||||
{
|
{
|
||||||
int len = RSTRING(result)->len;
|
int len = RSTRING_LEN(result);
|
||||||
|
|
||||||
add_fragment(cached, 0, RSTRING(result)->ptr, len);
|
add_fragment(cached, 0, RSTRING_PTR(result), len);
|
||||||
normalize_cache_entry(cached, len);
|
normalize_cache_entry(cached, len);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -216,7 +216,7 @@ script_hook_get_proxy(va_list ap, void *data)
|
|||||||
{
|
{
|
||||||
unsigned char *proxy;
|
unsigned char *proxy;
|
||||||
|
|
||||||
proxy = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
|
proxy = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
|
||||||
if (proxy) {
|
if (proxy) {
|
||||||
mem_free_set(new_proxy_url, proxy);
|
mem_free_set(new_proxy_url, proxy);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user