Re: Fw: [elinks-users] ELinks cannot run perl scripts that use perl modules.

Kalle Olavi Niemitalo <[email protected]> Sat, 27 Sep 2008 22:03:42 +0300
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
أحمد المحمودي <[email protected]> writes:

>   From the perlembed manpage I found this: 
>   perl -MExtUtils::Embed -e ccopts -e ldopts

The configure script of ELinks appears to do that already.
So, please try the following patch.

Let Perl scripts dynamically load libraries.

XML::LibXML::SAX appears to require this.

---
commit b0ce4adcbe970778e4082fed36a3cef35e31bd86
tree 44d444118d0fa37fad7d9f5f923e1f1d3bb79418
parent 58ebb4447b59a07c780184ee573c66354c7e4be3
author Kalle Olavi Niemitalo <[email protected]> Sat, 27 Sep 2008 21:58:08 +0300
committer Kalle Olavi Niemitalo <[email protected]> Sat, 27 Sep 2008 21:58:08 +0300

 NEWS                      |    8 ++++++++
 src/scripting/perl/core.c |   20 ++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 6ebb649..3375d7d 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,14 @@ You can see the complete list of recent changes, bugfixes and new features
 in the http://repo.or.cz/w/elinks.git[gitweb interface]. See the ChangeLog
 file for details.
 
+ELinks 0.12pre2.GIT now:
+------------------------
+
+To be released as 0.12pre3, 0.12rc1, or even 0.12.0.
+
+* Perl scripts can use modules that dynamically load C libraries, like
+  XML::LibXML::SAX does.
+
 ELinks 0.12pre2:
 ----------------
 
diff --git a/src/scripting/perl/core.c b/src/scripting/perl/core.c
index 85d9428..afc8d3e 100644
--- a/src/scripting/perl/core.c
+++ b/src/scripting/perl/core.c
@@ -15,6 +15,12 @@
 #include "scripting/perl/core.h"
 #include "util/file.h"
 
+/* The configure script runs "perl -MExtUtils::Embed -e ccopts -e ldopts",
+ * which should output the location of the DynaLoader.a where this function
+ * is defined.  This prototype does not appear to be in any public header
+ * file of Perl.  */
+EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
+
 #define PERL_HOOKS_FILENAME	"hooks.pl"
 
 
@@ -65,6 +71,16 @@ cleanup_perl(struct module *module)
 #endif
 }
 
+/** Tell Perl about XSUBs that were linked into ELinks.  */
+static void
+xs_init(pTHX)
+{
+	/* DynaLoader is the only Perl module whose library is
+	 * statically linked into ELinks.  DynaLoader::bootstrap will
+	 * then load other libraries and register their XSUBs as
+	 * needed.  */
+	newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, __FILE__);
+}
 
 void
 init_perl(struct module *module)
@@ -97,9 +113,9 @@ init_perl(struct module *module)
 
 		perl_construct(my_perl);
 		if (hook_local)
-			err = perl_parse(my_perl, NULL, 2, local_argv, NULL);
+			err = perl_parse(my_perl, xs_init, 2, local_argv, NULL);
 		else if (hook_global)
-			err = perl_parse(my_perl, NULL, 2, global_argv, NULL);
+			err = perl_parse(my_perl, xs_init, 2, global_argv, NULL);
 #ifdef PERL_EXIT_DESTRUCT_END
 		PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
 #endif

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev
signature.asc (application/pgp-signature, 188 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFI3oOcHm9IGt60eMgRAsjpAJ0SR/u80ChrqPqhNUn3JgXXg/kiMgCg2QJ4
BQzKcrFGeeDxI9xEc77cbvY=
=ZO9B
-----END PGP SIGNATURE-----