Port for Ruby 2.1

أحمد المحمودي <[email protected]> Sat, 23 Aug 2014 11:35:42 +0300
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
--===============7776832494850027721==
Content-Type: multipart/signed; micalg=pgp-sha256;
	protocol="application/pgp-signature"; boundary="hoZxPH4CaxYzWscb"
Content-Disposition: inline


--hoZxPH4CaxYzWscb
Content-Type: multipart/mixed; boundary="iFRdW5/EC4oqxDHL"
Content-Disposition: inline


--iFRdW5/EC4oqxDHL
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello,

  The attached patch ports ELinks for Ruby 2.1

--=20
 =E2=80=8E=D8=A3=D8=AD=D9=85=D8=AF =D8=A7=D9=84=D9=85=D8=AD=D9=85=D9=88=D8=
=AF=D9=8A (Ahmed El-Mahmoudy)
  Digital design engineer
 GPG KeyID: 0xEDDDA1B7
 GPG Fingerprint: 8206 A196 2084 7E6D 0DF8  B176 BC19 6A94 EDDD A1B7

--iFRdW5/EC4oqxDHL
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment; filename="ruby2.1.diff"
Content-Transfer-Encoding: quoted-printable

Description: Porting for Ruby 2.1
 * Config is deprecated in favor of RbConfig
 * Also, it seems that VERSION is obsolete
 * Added some defines
Author: =D8=A3=D8=AD=D9=85=D8=AF =D8=A7=D9=84=D9=85=D8=AD=D9=85=D9=88=D8=AF=
=D9=8A (Ahmed El-Mahmoudy) <[email protected]>
Index: elinks-0.13~20140630/configure
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- elinks-0.13~20140630.orig/configure
+++ elinks-0.13~20140630/configure
@@ -9924,38 +9924,52 @@ fi
=20
 		{ $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) >=3D "1.6.0=
")' >/dev/null 2>/dev/null; then
+		if $CONFIG_SCRIPTING_RUBY -e 'exit((RUBY_VERSION) >=3D "1.6.0")' >/dev/n=
ull 2>/dev/null; then
 			ruby_version=3D`$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; }
=20
 			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ruby header files=
" >&5
 $as_echo_n "checking for Ruby header files... " >&6; }
-			rubyhdrdir=3D`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print Config::CONFIG["=
archdir"] || $hdrdir' 2>/dev/null`
+			rubyarchdir=3D`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFI=
G["archdir"] || $hdrdir' 2>/dev/null`
+			rubyhdrdir=3D`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG=
["rubyhdrdir"]' 2>/dev/null`
+			rubyarchhdrdir=3D`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CO=
NFIG["rubyarchhdrdir"]' 2>/dev/null`
+			rubyarch=3D`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG["=
arch"]' 2>/dev/null`
=20
-			if test "X$rubyhdrdir" !=3D "X"; then
+			if test "X$rubyarchdir" !=3D "X"; then
 				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $rubyhdrdir" >&5
 $as_echo "$rubyhdrdir" >&6; }
-				RUBY_CFLAGS=3D"-I$rubyhdrdir"
-				rubylibs=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFI=
G["LIBS"]'`
+				if test "X$rubyhdrdir" !=3D "X"; then
+				  # >=3D 1.9
+				  RUBY_CFLAGS=3D"-I$rubyhdrdir -I$rubyhdrdir/$rubyarch"
+				  if test "X$rubyarchhdrdir" !=3D "X"; then
+				    # 2.1
+				    RUBY_CFLAGS=3D"$RUBY_CFLAGS -I$rubyarchhdrdir"
+				  fi
+				else
+				  # 1.8
+				  RUBY_CFLAGS=3D"-I$rubyarchdir"
+				fi
+
+	 			rubylibs=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CO=
NFIG["LIBS"]'`
=20
 				if test "X$rubylibs" !=3D "X"; then
 					RUBY_LIBS=3D"$rubylibs"
 				fi
=20
-				librubyarg=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expa=
nd(Config::CONFIG["LIBRUBYARG"])'`
+				librubyarg=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.ex=
pand(RbConfig::CONFIG["LIBRUBYARG"])'`
=20
 				if test -f "$rubyhdrdir/$librubyarg"; then
 					librubyarg=3D"$rubyhdrdir/$librubyarg"
=20
 				else
-					rubylibdir=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.exp=
and(Config::CONFIG["libdir"])'`
+					rubylibdir=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig.e=
xpand(RbConfig::CONFIG["libdir"])'`
 					if test -f "$rubylibdir/$librubyarg"; then
 						librubyarg=3D"$rubylibdir/$librubyarg"
 					elif test "$librubyarg" =3D "libruby.a"; then
 												librubyarg=3D"-lruby"
 					else
-						librubyarg=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$libruby=
arg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"`
+						librubyarg=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$libruby=
arg'.gsub(/-L\./, %'-L#{RbConfig.expand(RbConfig::CONFIG[\"libdir\"])}')"`
 					fi
 				fi
=20
@@ -9963,7 +9977,7 @@ $as_echo "$rubyhdrdir" >&6; }
 					RUBY_LIBS=3D"$librubyarg $RUBY_LIBS"
 				fi
=20
-				rubyldflags=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CO=
NFIG["LDFLAGS"]'`
+				rubyldflags=3D`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::=
CONFIG["LDFLAGS"]'`
 				if test "X$rubyldflags" !=3D "X"; then
 					LDFLAGS=3D"$rubyldflags $LDFLAGS"
 				fi
@@ -9972,6 +9986,7 @@ $as_echo "$rubyhdrdir" >&6; }
 				CFLAGS=3D"$RUBY_CFLAGS $CFLAGS"
 				CPPFLAGS=3D"$CPPFLAGS $RUBY_CFLAGS"
=20
+echo "DBG: LIBS=3D$LIBS CFLAGS=3D$CFLAGS CPPFLAGS=3D$CPPFLAGS"
 				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <ruby.h>
@@ -10008,6 +10023,7 @@ fi
 	LIBS=3D"$LIBS_X";
=20
=20
+echo "DBG: $CONFIG_SCRIPTING_RUBY , $CONFIG_SCRIPTING_RUBY_WITHVAL"
 if test "$CONFIG_SCRIPTING_RUBY" !=3D "yes"; then
 	if test -n "$CONFIG_SCRIPTING_RUBY_WITHVAL" &&
 	   test "$CONFIG_SCRIPTING_RUBY_WITHVAL" !=3D no; then
Index: elinks-0.13~20140630/src/scripting/ruby/core.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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;
=20
+#include <ruby/version.h>	/* for RUBY_API_VERSION_CODE */
+#if defined(RUBY_API_VERSION_CODE) && RUBY_API_VERSION_CODE >=3D 10900
+#define ruby_errinfo rb_errinfo()
+#endif
+
 #include <ruby.h>	/* for VALUE */
=20
+#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;
=20
 void alert_ruby_error(struct session *ses, unsigned char *msg);
Index: elinks-0.13~20140630/src/scripting/ruby/core.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 =3D CLASS_OF(ruby_errinfo);
 		einfo =3D rb_obj_as_string(ruby_errinfo);
=20
-		if (eclass =3D=3D rb_eRuntimeError && RSTRING(einfo)->len =3D=3D 0) {
+		if (eclass =3D=3D rb_eRuntimeError && RSTRING_LEN(einfo) =3D=3D 0) {
 			msg =3D "unhandled exception";
=20
 		} else {
@@ -88,7 +88,7 @@ erb_report_error(struct session *ses, in
=20
 			epath =3D rb_class_path(eclass);
 			snprintf(buff, MAX_STR_LEN, "%s: %s",
-				RSTRING(epath)->ptr, RSTRING(einfo)->ptr);
+				RSTRING_PTR(epath), RSTRING_PTR(einfo));
=20
 			p =3D strchr(buff, '\n');
 			if (p) *p =3D '\0';
@@ -116,7 +116,7 @@ erb_module_message(VALUE self, VALUE str
 	struct terminal *term;
=20
 	str =3D rb_obj_as_string(str);
-	message =3D memacpy(RSTRING(str)->ptr, RSTRING(str)->len);
+	message =3D memacpy(RSTRING_PTR(str), RSTRING_LEN(str));
 	if (!message) return Qnil;
=20
 	line_end =3D 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. */
=20
-		ptr =3D RSTRING(substr)->ptr;
-		len =3D RSTRING(substr)->len;
+		ptr =3D RSTRING_PTR(substr);
+		len =3D RSTRING_LEN(substr);
=20
 		if (*ptr =3D=3D '"')
 			ptr++, len--;
Index: elinks-0.13~20140630/src/scripting/ruby/hooks.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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;
=20
-		new_url =3D memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
+		new_url =3D 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;
=20
-		new_url =3D memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
+		new_url =3D 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 =3D RSTRING(result)->len;
+		int len =3D RSTRING_LEN(result);
=20
-		add_fragment(cached, 0, RSTRING(result)->ptr, len);
+		add_fragment(cached, 0, RSTRING_PTR(result), len);
 		normalize_cache_entry(cached, len);
=20
 		break;
@@ -216,7 +216,7 @@ script_hook_get_proxy(va_list ap, void *
 	{
 		unsigned char *proxy;
=20
-		proxy =3D memacpy(RSTRING(result)->ptr, RSTRING(result)->len);
+		proxy =3D memacpy(RSTRING_PTR(result), RSTRING_LEN(result));
 		if (proxy) {
 			mem_free_set(new_proxy_url, proxy);
 		}

--iFRdW5/EC4oqxDHL--

--hoZxPH4CaxYzWscb
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEcBAEBCAAGBQJT+FJeAAoJELwZapTt3aG3Z2YIAJKwXP2AU88IxmZ0yIK/cX7y
hAOJO6fWxZpMAzsZ1SflHOIcdo0W/1JG5EuqrBY8v/nrg3nRrNYgJcevHnECyTEX
H40+rYdzBFSq4yHev0yyqdkSy7MbqCo8k/NMAGXQBJO04rCL7rH/ci1BQwggyrGR
tfmF2SwQ7L0aXNIa2OiicM3ZfQDJ110bT3qqAMOgEHWChPHGzDmbTsYT0834Krlx
3Gl+yPUfEcQj+I1qfpvvcswi/QTK4lGAmySgYjSH9qbCxwgD9WoLyHrsC2eQEZF/
q0+DOUVL++wUsK+PtoEaXyDecisTgvV096tDU8RAoadhVHl8DFBjVqA+9aiCZe8=
=7zFa
-----END PGP SIGNATURE-----

--hoZxPH4CaxYzWscb--

--===============7776832494850027721==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--===============7776832494850027721==--