eapi-bump librsvg
[sgilles-overlay.git] / www-client / elinks / files / elinks-0.12_pre5-ruby-1.9.patch
blob1e07bcde190aa4493506b09e3fe22713939675db
1 diff -urp a/config/m4/ruby.m4 b/config/m4/ruby.m4
2 --- a/config/m4/ruby.m4 2009-07-07 13:23:17.000000000 +0100
3 +++ b/config/m4/ruby.m4 2012-09-10 18:23:09.000000000 +0100
4 @@ -32,36 +32,40 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"
5 if test "$CONFIG_SCRIPTING_RUBY" != "no"; then
7 AC_MSG_CHECKING(Ruby version)
8 - if $CONFIG_SCRIPTING_RUBY -e 'exit((VERSION or RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
9 + if $CONFIG_SCRIPTING_RUBY -e 'exit((VERSION rescue RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
10 ruby_version=`$CONFIG_SCRIPTING_RUBY -e 'puts "#{VERSION rescue RUBY_VERSION}"'`
11 AC_MSG_RESULT($ruby_version)
13 AC_MSG_CHECKING(for Ruby header files)
14 - rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
15 + rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG[["rubyhdrdir"]] || RbConfig::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
17 if test "X$rubyhdrdir" != "X"; then
18 AC_MSG_RESULT($rubyhdrdir)
19 RUBY_CFLAGS="-I$rubyhdrdir"
20 - rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
21 + rubyarch=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["arch"]]'`
22 + if test -d "$rubyhdrdir/$rubyarch"; then
23 + RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
24 + fi
25 + rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["LIBS"]]'`
27 if test "X$rubylibs" != "X"; then
28 RUBY_LIBS="$rubylibs"
31 - librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
32 + librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.expand(RbConfig::CONFIG[["LIBRUBYARG"]])'`
34 if test -f "$rubyhdrdir/$librubyarg"; then
35 librubyarg="$rubyhdrdir/$librubyarg"
37 else
38 - rubylibdir=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'`
39 + rubylibdir=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.expand(RbConfig::CONFIG[["libdir"]])'`
40 if test -f "$rubylibdir/$librubyarg"; then
41 librubyarg="$rubylibdir/$librubyarg"
42 elif test "$librubyarg" = "libruby.a"; then
43 dnl required on Mac OS 10.3 where libruby.a doesn't exist
44 librubyarg="-lruby"
45 else
46 - librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"`
47 + librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{RbConfig.expand(RbConfig::CONFIG[\"libdir\"])}')"`
51 @@ -69,7 +73,7 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"
52 RUBY_LIBS="$librubyarg $RUBY_LIBS"
55 - rubyldflags=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
56 + rubyldflags=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["LDFLAGS"]]'`
57 if test "X$rubyldflags" != "X"; then
58 LDFLAGS="$rubyldflags $LDFLAGS"
60 @@ -86,6 +90,15 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"
61 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
64 + if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
65 + AC_MSG_CHECKING([for rb_errinfo])
66 + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ruby.h>]], [[rb_errinfo();]])],have_rb_errinfo="yes",have_rb_errinfo="no")
67 + AC_MSG_RESULT($have_rb_errinfo)
68 + if test "$have_rb_errinfo" = "yes"; then
69 + AC_DEFINE([HAVE_RB_ERRINFO], [1],
70 + [Define to 1 if you have the `rb_errinfo' function.])
71 + fi
72 + fi
75 EL_RESTORE_FLAGS
76 diff -urp a/src/scripting/ruby/core.c b/src/scripting/ruby/core.c
77 --- a/src/scripting/ruby/core.c 2009-07-07 13:23:17.000000000 +0100
78 +++ b/src/scripting/ruby/core.c 2012-09-10 18:27:05.000000000 +0100
79 @@ -76,10 +76,10 @@ erb_report_error(struct session *ses, in
80 break;
81 case TAG_RAISE:
82 case TAG_FATAL:
83 - eclass = CLASS_OF(ruby_errinfo);
84 - einfo = rb_obj_as_string(ruby_errinfo);
85 + eclass = CLASS_OF(RB_ERRINFO);
86 + einfo = rb_obj_as_string(RB_ERRINFO);
88 - if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
89 + if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
90 msg = "unhandled exception";
92 } else {
93 @@ -88,7 +88,7 @@ erb_report_error(struct session *ses, in
95 epath = rb_class_path(eclass);
96 snprintf(buff, MAX_STR_LEN, "%s: %s",
97 - RSTRING(epath)->ptr, RSTRING(einfo)->ptr);
98 + RSTRING_PTR(epath), RSTRING_PTR(einfo));
100 p = strchr(buff, '\n');
101 if (p) *p = '\0';
102 @@ -115,7 +115,7 @@ erb_module_message(VALUE self, VALUE str
103 unsigned char *message, *line_end;
105 str = rb_obj_as_string(str);
106 - message = memacpy(RSTRING(str)->ptr, RSTRING(str)->len);
107 + message = memacpy(RSTRING_PTR(str), RSTRING_LEN(str));
108 if (!message) return Qnil;
110 line_end = strchr(message, '\n');
111 @@ -162,8 +162,8 @@ erb_stdout_p(int argc, VALUE *argv, VALU
112 * the inspect() method, which adds quotes to the strings, so
113 * gently ignore them. */
115 - ptr = RSTRING(substr)->ptr;
116 - len = RSTRING(substr)->len;
117 + ptr = RSTRING_PTR(substr);
118 + len = RSTRING_LEN(substr);
120 if (*ptr == '"')
121 ptr++, len--;
122 diff -urp a/src/scripting/ruby/core.h b/src/scripting/ruby/core.h
123 --- a/src/scripting/ruby/core.h 2009-07-07 13:23:17.000000000 +0100
124 +++ b/src/scripting/ruby/core.h 2012-09-10 18:26:25.000000000 +0100
125 @@ -7,6 +7,20 @@ struct session;
127 #include <ruby.h> /* for VALUE */
129 +#ifndef RSTRING_LEN
130 +#define RSTRING_LEN(string) (RSTRING(string)->len)
131 +#endif
133 +#ifndef RSTRING_PTR
134 +#define RSTRING_PTR(string) (RSTRING(string)->ptr)
135 +#endif
137 +#ifdef HAVE_RB_ERRINFO
138 +#define RB_ERRINFO (rb_errinfo())
139 +#else
140 +#define RB_ERRINFO (ruby_errinfo)
141 +#endif
143 VALUE erb_module;
145 void alert_ruby_error(struct session *ses, unsigned char *msg);
146 diff -urp a/src/scripting/ruby/hooks.c b/src/scripting/ruby/hooks.c
147 --- a/src/scripting/ruby/hooks.c 2009-07-07 13:23:17.000000000 +0100
148 +++ b/src/scripting/ruby/hooks.c 2012-09-10 17:53:48.000000000 +0100
149 @@ -83,7 +83,7 @@ script_hook_goto_url(va_list ap, void *d
151 unsigned char *new_url;
153 - new_url = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
154 + new_url = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
155 if (new_url) {
156 mem_free_set(url, new_url);
158 @@ -126,7 +126,7 @@ script_hook_follow_url(va_list ap, void
160 unsigned char *new_url;
162 - new_url = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
163 + new_url = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
164 if (new_url) {
165 mem_free_set(url, new_url);
167 @@ -170,9 +170,9 @@ script_hook_pre_format_html(va_list ap,
168 switch (rb_type(result)) {
169 case T_STRING:
171 - int len = RSTRING(result)->len;
172 + int len = RSTRING_LEN(result);
174 - add_fragment(cached, 0, RSTRING(result)->ptr, len);
175 + add_fragment(cached, 0, RSTRING_PTR(result), len);
176 normalize_cache_entry(cached, len);
178 break;
179 @@ -216,7 +216,7 @@ script_hook_get_proxy(va_list ap, void *
181 unsigned char *proxy;
183 - proxy = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
184 + proxy = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
185 if (proxy) {
186 mem_free_set(new_proxy_url, proxy);