Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 424789 | Differences between
and this patch

Collapse All | Expand All

(-)a/config/m4/ruby.m4 (-7 / +20 lines)
Lines 32-67 if test "$CONFIG_SCRIPTING_RUBY" = "yes" Link Here
32
	if test "$CONFIG_SCRIPTING_RUBY" != "no"; then
32
	if test "$CONFIG_SCRIPTING_RUBY" != "no"; then
33
33
34
		AC_MSG_CHECKING(Ruby version)
34
		AC_MSG_CHECKING(Ruby version)
35
		if $CONFIG_SCRIPTING_RUBY -e 'exit((VERSION or RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
35
		if $CONFIG_SCRIPTING_RUBY -e 'exit((VERSION rescue RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
36
			ruby_version=`$CONFIG_SCRIPTING_RUBY -e 'puts "#{VERSION rescue RUBY_VERSION}"'`
36
			ruby_version=`$CONFIG_SCRIPTING_RUBY -e 'puts "#{VERSION rescue RUBY_VERSION}"'`
37
			AC_MSG_RESULT($ruby_version)
37
			AC_MSG_RESULT($ruby_version)
38
38
39
			AC_MSG_CHECKING(for Ruby header files)
39
			AC_MSG_CHECKING(for Ruby header files)
40
			rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
40
			rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG[["rubyhdrdir"]] || RbConfig::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
41
41
42
			if test "X$rubyhdrdir" != "X"; then
42
			if test "X$rubyhdrdir" != "X"; then
43
				AC_MSG_RESULT($rubyhdrdir)
43
				AC_MSG_RESULT($rubyhdrdir)
44
				RUBY_CFLAGS="-I$rubyhdrdir"
44
				RUBY_CFLAGS="-I$rubyhdrdir"
45
				rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
45
				rubyarch=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["arch"]]'`
46
				if test -d "$rubyhdrdir/$rubyarch"; then
47
					RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
48
				fi
49
				rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["LIBS"]]'`
46
50
47
				if test "X$rubylibs" != "X"; then
51
				if test "X$rubylibs" != "X"; then
48
					RUBY_LIBS="$rubylibs"
52
					RUBY_LIBS="$rubylibs"
49
				fi
53
				fi
50
54
51
				librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
55
				librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.expand(RbConfig::CONFIG[["LIBRUBYARG"]])'`
52
56
53
				if test -f "$rubyhdrdir/$librubyarg"; then
57
				if test -f "$rubyhdrdir/$librubyarg"; then
54
					librubyarg="$rubyhdrdir/$librubyarg"
58
					librubyarg="$rubyhdrdir/$librubyarg"
55
59
56
				else
60
				else
57
					rubylibdir=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'`
61
					rubylibdir=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.expand(RbConfig::CONFIG[["libdir"]])'`
58
					if test -f "$rubylibdir/$librubyarg"; then
62
					if test -f "$rubylibdir/$librubyarg"; then
59
						librubyarg="$rubylibdir/$librubyarg"
63
						librubyarg="$rubylibdir/$librubyarg"
60
					elif test "$librubyarg" = "libruby.a"; then
64
					elif test "$librubyarg" = "libruby.a"; then
61
						dnl required on Mac OS 10.3 where libruby.a doesn't exist
65
						dnl required on Mac OS 10.3 where libruby.a doesn't exist
62
						librubyarg="-lruby"
66
						librubyarg="-lruby"
63
					else
67
					else
64
						librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"`
68
						librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{RbConfig.expand(RbConfig::CONFIG[\"libdir\"])}')"`
65
					fi
69
					fi
66
				fi
70
				fi
67
71
Lines 69-75 if test "$CONFIG_SCRIPTING_RUBY" = "yes" Link Here
69
					RUBY_LIBS="$librubyarg $RUBY_LIBS"
73
					RUBY_LIBS="$librubyarg $RUBY_LIBS"
70
				fi
74
				fi
71
75
72
				rubyldflags=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
76
				rubyldflags=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["LDFLAGS"]]'`
73
				if test "X$rubyldflags" != "X"; then
77
				if test "X$rubyldflags" != "X"; then
74
					LDFLAGS="$rubyldflags $LDFLAGS"
78
					LDFLAGS="$rubyldflags $LDFLAGS"
75
				fi
79
				fi
Lines 86-91 if test "$CONFIG_SCRIPTING_RUBY" = "yes" Link Here
86
			AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
90
			AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
87
		fi
91
		fi
88
	fi
92
	fi
93
	if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
94
		AC_MSG_CHECKING([for rb_errinfo])
95
		AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ruby.h>]], [[rb_errinfo();]])],have_rb_errinfo="yes",have_rb_errinfo="no")
96
		AC_MSG_RESULT($have_rb_errinfo)
97
		if test "$have_rb_errinfo" = "yes"; then
98
			AC_DEFINE([HAVE_RB_ERRINFO], [1],
99
				[Define to 1 if you have the `rb_errinfo' function.])
100
		fi
101
	fi
89
fi
102
fi
90
103
91
EL_RESTORE_FLAGS
104
EL_RESTORE_FLAGS
(-)a/src/scripting/ruby/core.c (-7 / +7 lines)
Lines 76-85 erb_report_error(struct session *ses, in Link Here
76
		break;
76
		break;
77
	case TAG_RAISE:
77
	case TAG_RAISE:
78
	case TAG_FATAL:
78
	case TAG_FATAL:
79
		eclass = CLASS_OF(ruby_errinfo);
79
		eclass = CLASS_OF(RB_ERRINFO);
80
		einfo = rb_obj_as_string(ruby_errinfo);
80
		einfo = rb_obj_as_string(RB_ERRINFO);
81
81
82
		if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
82
		if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
83
			msg = "unhandled exception";
83
			msg = "unhandled exception";
84
84
85
		} else {
85
		} else {
Lines 88-94 erb_report_error(struct session *ses, in Link Here
88
88
89
			epath = rb_class_path(eclass);
89
			epath = rb_class_path(eclass);
90
			snprintf(buff, MAX_STR_LEN, "%s: %s",
90
			snprintf(buff, MAX_STR_LEN, "%s: %s",
91
				RSTRING(epath)->ptr, RSTRING(einfo)->ptr);
91
				RSTRING_PTR(epath), RSTRING_PTR(einfo));
92
92
93
			p = strchr(buff, '\n');
93
			p = strchr(buff, '\n');
94
			if (p) *p = '\0';
94
			if (p) *p = '\0';
Lines 115-121 erb_module_message(VALUE self, VALUE str Link Here
115
	unsigned char *message, *line_end;
115
	unsigned char *message, *line_end;
116
116
117
	str = rb_obj_as_string(str);
117
	str = rb_obj_as_string(str);
118
	message = memacpy(RSTRING(str)->ptr, RSTRING(str)->len);
118
	message = memacpy(RSTRING_PTR(str), RSTRING_LEN(str));
119
	if (!message) return Qnil;
119
	if (!message) return Qnil;
120
120
121
	line_end = strchr(message, '\n');
121
	line_end = strchr(message, '\n');
Lines 162-169 erb_stdout_p(int argc, VALUE *argv, VALU Link Here
162
		 * the inspect() method, which adds quotes to the strings, so
162
		 * the inspect() method, which adds quotes to the strings, so
163
		 * gently ignore them. */
163
		 * gently ignore them. */
164
164
165
		ptr = RSTRING(substr)->ptr;
165
		ptr = RSTRING_PTR(substr);
166
		len = RSTRING(substr)->len;
166
		len = RSTRING_LEN(substr);
167
167
168
		if (*ptr == '"')
168
		if (*ptr == '"')
169
			ptr++, len--;
169
			ptr++, len--;
(-)a/src/scripting/ruby/core.h (+14 lines)
Lines 7-12 struct session; Link Here
7
7
8
#include <ruby.h>	/* for VALUE */
8
#include <ruby.h>	/* for VALUE */
9
9
10
#ifndef RSTRING_LEN
11
#define RSTRING_LEN(string) (RSTRING(string)->len)
12
#endif
13
14
#ifndef RSTRING_PTR
15
#define RSTRING_PTR(string) (RSTRING(string)->ptr)
16
#endif
17
18
#ifdef HAVE_RB_ERRINFO
19
#define RB_ERRINFO (rb_errinfo())
20
#else
21
#define RB_ERRINFO (ruby_errinfo)
22
#endif
23
10
VALUE erb_module;
24
VALUE erb_module;
11
25
12
void alert_ruby_error(struct session *ses, unsigned char *msg);
26
void alert_ruby_error(struct session *ses, unsigned char *msg);
(-)a/src/scripting/ruby/hooks.c (-5 / +5 lines)
Lines 83-89 script_hook_goto_url(va_list ap, void *d Link Here
83
	{
83
	{
84
		unsigned char *new_url;
84
		unsigned char *new_url;
85
85
86
		new_url = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
86
		new_url = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
87
		if (new_url) {
87
		if (new_url) {
88
			mem_free_set(url, new_url);
88
			mem_free_set(url, new_url);
89
		}
89
		}
Lines 126-132 script_hook_follow_url(va_list ap, void Link Here
126
	{
126
	{
127
		unsigned char *new_url;
127
		unsigned char *new_url;
128
128
129
		new_url = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
129
		new_url = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
130
		if (new_url) {
130
		if (new_url) {
131
			mem_free_set(url, new_url);
131
			mem_free_set(url, new_url);
132
		}
132
		}
Lines 170-178 script_hook_pre_format_html(va_list ap, Link Here
170
	switch (rb_type(result)) {
170
	switch (rb_type(result)) {
171
	case T_STRING:
171
	case T_STRING:
172
	{
172
	{
173
		int len = RSTRING(result)->len;
173
		int len = RSTRING_LEN(result);
174
174
175
		add_fragment(cached, 0, RSTRING(result)->ptr, len);
175
		add_fragment(cached, 0, RSTRING_PTR(result), len);
176
		normalize_cache_entry(cached, len);
176
		normalize_cache_entry(cached, len);
177
177
178
		break;
178
		break;
Lines 216-222 script_hook_get_proxy(va_list ap, void * Link Here
216
	{
216
	{
217
		unsigned char *proxy;
217
		unsigned char *proxy;
218
218
219
		proxy = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
219
		proxy = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
220
		if (proxy) {
220
		if (proxy) {
221
			mem_free_set(new_proxy_url, proxy);
221
			mem_free_set(new_proxy_url, proxy);
222
		}
222
		}

Return to bug 424789