Hello,

  The attached patch ports ELinks for Ruby 2.1

-- 
 ‎أحمد المحمودي (Ahmed El-Mahmoudy)
  Digital design engineer
 GPG KeyID: 0xEDDDA1B7
 GPG Fingerprint: 8206 A196 2084 7E6D 0DF8  B176 BC19 6A94 EDDD A1B7
Description: Porting for Ruby 2.1
 * Config is deprecated in favor of RbConfig
 * Also, it seems that VERSION is obsolete
 * Added some defines
Author: أحمد المحمودي (Ahmed El-Mahmoudy) <aelmahmo...@sabily.org>
Index: elinks-0.13~20140630/configure
===================================================================
--- elinks-0.13~20140630.orig/configure
+++ elinks-0.13~20140630/configure
@@ -9924,38 +9924,52 @@ fi
 
 		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Ruby version" >&5
 $as_echo_n "checking Ruby version... " >&6; }
-		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((RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
 			ruby_version=`$CONFIG_SCRIPTING_RUBY -e 'puts "#{VERSION rescue RUBY_VERSION}"'`
 			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ruby_version" >&5
 $as_echo "$ruby_version" >&6; }
 
 			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ruby header files" >&5
 $as_echo_n "checking for Ruby header files... " >&6; }
-			rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null`
+			rubyarchdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG["archdir"] || $hdrdir' 2>/dev/null`
+			rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG["rubyhdrdir"]' 2>/dev/null`
+			rubyarchhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG["rubyarchhdrdir"]' 2>/dev/null`
+			rubyarch=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG["arch"]' 2>/dev/null`
 
-			if test "X$rubyhdrdir" != "X"; then
+			if test "X$rubyarchdir" != "X"; then
 				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $rubyhdrdir" >&5
 $as_echo "$rubyhdrdir" >&6; }
-				RUBY_CFLAGS="-I$rubyhdrdir"
-				rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG["LIBS"]'`
+				if test "X$rubyhdrdir" != "X"; then
+				  # >= 1.9
+				  RUBY_CFLAGS="-I$rubyhdrdir -I$rubyhdrdir/$rubyarch"
+				  if test "X$rubyarchhdrdir" != "X"; then
+				    # 2.1
+				    RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyarchhdrdir"
+				  fi
+				else
+				  # 1.8
+				  RUBY_CFLAGS="-I$rubyarchdir"
+				fi
+
+	 			rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG["LIBS"]'`
 
 				if test "X$rubylibs" != "X"; then
 					RUBY_LIBS="$rubylibs"
 				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
 					librubyarg="$rubyhdrdir/$librubyarg"
 
 				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
 						librubyarg="$rubylibdir/$librubyarg"
 					elif test "$librubyarg" = "libruby.a"; then
 												librubyarg="-lruby"
 					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
 
@@ -9963,7 +9977,7 @@ $as_echo "$rubyhdrdir" >&6; }
 					RUBY_LIBS="$librubyarg $RUBY_LIBS"
 				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
 					LDFLAGS="$rubyldflags $LDFLAGS"
 				fi
@@ -9972,6 +9986,7 @@ $as_echo "$rubyhdrdir" >&6; }
 				CFLAGS="$RUBY_CFLAGS $CFLAGS"
 				CPPFLAGS="$CPPFLAGS $RUBY_CFLAGS"
 
+echo "DBG: LIBS=$LIBS CFLAGS=$CFLAGS CPPFLAGS=$CPPFLAGS"
 				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <ruby.h>
@@ -10008,6 +10023,7 @@ fi
 	LIBS="$LIBS_X";
 
 
+echo "DBG: $CONFIG_SCRIPTING_RUBY , $CONFIG_SCRIPTING_RUBY_WITHVAL"
 if test "$CONFIG_SCRIPTING_RUBY" != "yes"; then
 	if test -n "$CONFIG_SCRIPTING_RUBY_WITHVAL" &&
 	   test "$CONFIG_SCRIPTING_RUBY_WITHVAL" != no; then
Index: elinks-0.13~20140630/src/scripting/ruby/core.h
===================================================================
--- elinks-0.13~20140630.orig/src/scripting/ruby/core.h
+++ elinks-0.13~20140630/src/scripting/ruby/core.h
@@ -5,8 +5,21 @@
 struct module;
 struct session;
 
+#include <ruby/version.h>	/* for RUBY_API_VERSION_CODE */
+#if defined(RUBY_API_VERSION_CODE) && RUBY_API_VERSION_CODE >= 10900
+#define ruby_errinfo rb_errinfo()
+#endif
+
 #include <ruby.h>	/* for VALUE */
 
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(s) (RSTRING(s)->ptr)
+#endif
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(s) (RSTRING(s)->len)
+#endif
+
+
 VALUE erb_module;
 
 void alert_ruby_error(struct session *ses, unsigned char *msg);
Index: elinks-0.13~20140630/src/scripting/ruby/core.c
===================================================================
--- elinks-0.13~20140630.orig/src/scripting/ruby/core.c
+++ elinks-0.13~20140630/src/scripting/ruby/core.c
@@ -79,7 +79,7 @@ erb_report_error(struct session *ses, in
 		eclass = CLASS_OF(ruby_errinfo);
 		einfo = rb_obj_as_string(ruby_errinfo);
 
-		if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
+		if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
 			msg = "unhandled exception";
 
 		} else {
@@ -88,7 +88,7 @@ erb_report_error(struct session *ses, in
 
 			epath = rb_class_path(eclass);
 			snprintf(buff, MAX_STR_LEN, "%s: %s",
-				RSTRING(epath)->ptr, RSTRING(einfo)->ptr);
+				RSTRING_PTR(epath), RSTRING_PTR(einfo));
 
 			p = strchr(buff, '\n');
 			if (p) *p = '\0';
@@ -116,7 +116,7 @@ erb_module_message(VALUE self, VALUE str
 	struct terminal *term;
 
 	str = rb_obj_as_string(str);
-	message = memacpy(RSTRING(str)->ptr, RSTRING(str)->len);
+	message = memacpy(RSTRING_PTR(str), RSTRING_LEN(str));
 	if (!message) return Qnil;
 
 	line_end = strchr(message, '\n');
@@ -165,8 +165,8 @@ erb_stdout_p(int argc, VALUE *argv, VALU
 		 * the inspect() method, which adds quotes to the strings, so
 		 * gently ignore them. */
 
-		ptr = RSTRING(substr)->ptr;
-		len = RSTRING(substr)->len;
+		ptr = RSTRING_PTR(substr);
+		len = RSTRING_LEN(substr);
 
 		if (*ptr == '"')
 			ptr++, len--;
Index: elinks-0.13~20140630/src/scripting/ruby/hooks.c
===================================================================
--- elinks-0.13~20140630.orig/src/scripting/ruby/hooks.c
+++ elinks-0.13~20140630/src/scripting/ruby/hooks.c
@@ -83,7 +83,7 @@ script_hook_goto_url(va_list ap, void *d
 	{
 		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) {
 			mem_free_set(url, new_url);
 		}
@@ -126,7 +126,7 @@ script_hook_follow_url(va_list ap, void
 	{
 		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) {
 			mem_free_set(url, new_url);
 		}
@@ -170,9 +170,9 @@ script_hook_pre_format_html(va_list ap,
 	switch (rb_type(result)) {
 	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);
 
 		break;
@@ -216,7 +216,7 @@ script_hook_get_proxy(va_list ap, void *
 	{
 		unsigned char *proxy;
 
-		proxy = memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
+		proxy = memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
 		if (proxy) {
 			mem_free_set(new_proxy_url, proxy);
 		}

Attachment: signature.asc
Description: Digital signature

-- 
http://lists.linuxfromscratch.org/listinfo/elinks-dev
Unsubscribe: See the above information page

Reply via email to