eapi-bump librsvg
[sgilles-overlay.git] / www-client / elinks / files / elinks-0.13-ruby.patch
bloba716439b5124026fa911808aa53f96f1b7cff5a8
1 --- a/config/m4/ruby.m4
2 +++ b/config/m4/ruby.m4
3 @@ -32,36 +32,40 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
4 if test "$CONFIG_SCRIPTING_RUBY" != "no"; then
6 AC_MSG_CHECKING(Ruby version)
7 - if $CONFIG_SCRIPTING_RUBY -e 'exit((VERSION or RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
8 + if $CONFIG_SCRIPTING_RUBY -e 'exit((VERSION rescue RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
9 ruby_version=`$CONFIG_SCRIPTING_RUBY -e 'puts "#{VERSION rescue RUBY_VERSION}"'`
10 AC_MSG_RESULT($ruby_version)
12 AC_MSG_CHECKING(for Ruby header files)
13 - rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
14 + rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG[["rubyhdrdir"]] || RbConfig::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
16 if test "X$rubyhdrdir" != "X"; then
17 AC_MSG_RESULT($rubyhdrdir)
18 RUBY_CFLAGS="-I$rubyhdrdir"
19 - rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
20 + rubyarch=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["arch"]]'`
21 + if test -d "$rubyhdrdir/$rubyarch"; then
22 + RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
23 + fi
24 + rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["LIBS"]]'`
26 if test "X$rubylibs" != "X"; then
27 RUBY_LIBS="$rubylibs"
30 - librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
31 + librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.expand(RbConfig::CONFIG[["LIBRUBYARG"]])'`
33 if test -f "$rubyhdrdir/$librubyarg"; then
34 librubyarg="$rubyhdrdir/$librubyarg"
36 else
37 - rubylibdir=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'`
38 + rubylibdir=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.expand(RbConfig::CONFIG[["libdir"]])'`
39 if test -f "$rubylibdir/$librubyarg"; then
40 librubyarg="$rubylibdir/$librubyarg"
41 elif test "$librubyarg" = "libruby.a"; then
42 dnl required on Mac OS 10.3 where libruby.a doesn't exist
43 librubyarg="-lruby"
44 else
45 - librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"`
46 + librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{RbConfig.expand(RbConfig::CONFIG[\"libdir\"])}')"`
50 @@ -69,7 +73,7 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
51 RUBY_LIBS="$librubyarg $RUBY_LIBS"
54 - rubyldflags=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
55 + rubyldflags=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["LDFLAGS"]]'`
56 if test "X$rubyldflags" != "X"; then
57 LDFLAGS="$rubyldflags $LDFLAGS"
59 @@ -86,6 +90,15 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
60 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
63 + if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
64 + AC_MSG_CHECKING([for rb_errinfo])
65 + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ruby.h>]], [[rb_errinfo();]])],have_rb_errinfo="yes",have_rb_errinfo="no")
66 + AC_MSG_RESULT($have_rb_errinfo)
67 + if test "$have_rb_errinfo" = "yes"; then
68 + AC_DEFINE([HAVE_RB_ERRINFO], [1],
69 + [Define to 1 if you have the `rb_errinfo' function.])
70 + fi
71 + fi
74 EL_RESTORE_FLAGS
75 --- a/src/scripting/ruby/core.c
76 +++ b/src/scripting/ruby/core.c
77 @@ -76,10 +76,10 @@ erb_report_error(struct session *ses, int error)
78 break;
79 case TAG_RAISE:
80 case TAG_FATAL:
81 - eclass = CLASS_OF(ruby_errinfo);
82 - einfo = rb_obj_as_string(ruby_errinfo);
83 + eclass = CLASS_OF(RB_ERRINFO);
84 + einfo = rb_obj_as_string(RB_ERRINFO);
86 - if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
87 + if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
88 msg = "unhandled exception";
90 } else {
91 @@ -88,7 +88,7 @@ erb_report_error(struct session *ses, int error)
93 epath = rb_class_path(eclass);
94 snprintf(buff, MAX_STR_LEN, "%s: %s",
95 - RSTRING(epath)->ptr, RSTRING(einfo)->ptr);
96 + RSTRING_PTR(epath), RSTRING_PTR(einfo));
98 p = strchr((const char *)buff, '\n');
99 if (p) *p = '\0';
100 @@ -116,7 +116,7 @@ erb_module_message(VALUE self, VALUE str)
101 struct terminal *term;
103 str = rb_obj_as_string(str);
104 - message = memacpy(RSTRING(str)->ptr, RSTRING(str)->len);
105 + message = memacpy(RSTRING_PTR(str), RSTRING_PTR(str));
106 if (!message) return Qnil;
108 line_end = strchr((const char *)message, '\n');
109 @@ -165,8 +165,8 @@ erb_stdout_p(int argc, VALUE *argv, VALUE self)
110 * the inspect() method, which adds quotes to the strings, so
111 * gently ignore them. */
113 - ptr = RSTRING(substr)->ptr;
114 - len = RSTRING(substr)->len;
115 + ptr = RSTRING_PTR(substr);
116 + len = RSTRING_LEN(substr);
118 if (*ptr == '"')
119 ptr++, len--;
120 --- a/src/scripting/ruby/core.h
121 +++ b/src/scripting/ruby/core.h
122 @@ -7,6 +7,20 @@ struct session;
124 #include <ruby.h> /* for VALUE */
126 +#ifndef RSTRING_LEN
127 +#define RSTRING_LEN(string) (RSTRING(string)->len)
128 +#endif
130 +#ifndef RSTRING_PTR
131 +#define RSTRING_PTR(string) (RSTRING(string)->ptr)
132 +#endif
134 +#ifdef HAVE_RB_ERRINFO
135 +#define RB_ERRINFO (rb_errinfo())
136 +#else
137 +#define RB_ERRINFO (ruby_errinfo)
138 +#endif
140 VALUE erb_module;
142 void alert_ruby_error(struct session *ses, unsigned char *msg);
143 --- a/src/scripting/ruby/hooks.c
144 +++ b/src/scripting/ruby/hooks.c
145 @@ -83,7 +83,7 @@ script_hook_goto_url(va_list ap, void *data)
147 unsigned char *new_url;
149 - new_url = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
150 + new_url = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
151 if (new_url) {
152 mem_free_set(url, new_url);
154 @@ -126,7 +126,7 @@ script_hook_follow_url(va_list ap, void *data)
156 unsigned char *new_url;
158 - new_url = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
159 + new_url = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
160 if (new_url) {
161 mem_free_set(url, new_url);
163 @@ -170,9 +170,9 @@ script_hook_pre_format_html(va_list ap, void *data)
164 switch (rb_type(result)) {
165 case T_STRING:
167 - int len = RSTRING(result)->len;
168 + int len = RSTRING_LEN(result);
170 - add_fragment(cached, 0, RSTRING(result)->ptr, len);
171 + add_fragment(cached, 0, RSTRING_PTR(result), len);
172 normalize_cache_entry(cached, len);
174 break;
175 @@ -216,7 +216,7 @@ script_hook_get_proxy(va_list ap, void *data)
177 unsigned char *proxy;
179 - proxy = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
180 + proxy = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
181 if (proxy) {
182 mem_free_set(new_proxy_url, proxy);