Accepting request 146359 from home:scarabeus_iv
Update to 0.12pre6. OBS-URL: https://build.opensuse.org/request/show/146359 OBS-URL: https://build.opensuse.org/package/show/network/elinks?expand=0&rev=4
This commit is contained in:
parent
e8f0ff71e3
commit
c8dd862afd
187
build-with-ruby-1.9.patch
Normal file
187
build-with-ruby-1.9.patch
Normal file
@ -0,0 +1,187 @@
|
||||
diff -urp a/config/m4/ruby.m4 b/config/m4/ruby.m4
|
||||
--- a/config/m4/ruby.m4 2009-07-07 13:23:17.000000000 +0100
|
||||
+++ b/config/m4/ruby.m4 2012-09-10 18:23:09.000000000 +0100
|
||||
@@ -32,36 +32,40 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"
|
||||
if test "$CONFIG_SCRIPTING_RUBY" != "no"; then
|
||||
|
||||
AC_MSG_CHECKING(Ruby version)
|
||||
- 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((VERSION rescue RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
|
||||
ruby_version=`$CONFIG_SCRIPTING_RUBY -e 'puts "#{VERSION rescue RUBY_VERSION}"'`
|
||||
AC_MSG_RESULT($ruby_version)
|
||||
|
||||
AC_MSG_CHECKING(for Ruby header files)
|
||||
- rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
|
||||
+ rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print RbConfig::CONFIG[["rubyhdrdir"]] || RbConfig::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
|
||||
|
||||
if test "X$rubyhdrdir" != "X"; then
|
||||
AC_MSG_RESULT($rubyhdrdir)
|
||||
RUBY_CFLAGS="-I$rubyhdrdir"
|
||||
- rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
|
||||
+ rubyarch=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print RbConfig::CONFIG[["arch"]]'`
|
||||
+ if test -d "$rubyhdrdir/$rubyarch"; then
|
||||
+ RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
|
||||
+ 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
|
||||
dnl required on Mac OS 10.3 where libruby.a doesn't exist
|
||||
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
|
||||
|
||||
@@ -69,7 +73,7 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"
|
||||
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
|
||||
@@ -86,6 +90,15 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"
|
||||
AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
|
||||
fi
|
||||
fi
|
||||
+ if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
|
||||
+ AC_MSG_CHECKING([for rb_errinfo])
|
||||
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ruby.h>]], [[rb_errinfo();]])],have_rb_errinfo="yes",have_rb_errinfo="no")
|
||||
+ AC_MSG_RESULT($have_rb_errinfo)
|
||||
+ if test "$have_rb_errinfo" = "yes"; then
|
||||
+ AC_DEFINE([HAVE_RB_ERRINFO], [1],
|
||||
+ [Define to 1 if you have the `rb_errinfo' function.])
|
||||
+ fi
|
||||
+ fi
|
||||
fi
|
||||
|
||||
EL_RESTORE_FLAGS
|
||||
diff -urp a/src/scripting/ruby/core.c b/src/scripting/ruby/core.c
|
||||
--- a/src/scripting/ruby/core.c 2009-07-07 13:23:17.000000000 +0100
|
||||
+++ b/src/scripting/ruby/core.c 2012-09-10 18:27:05.000000000 +0100
|
||||
@@ -76,10 +76,10 @@ erb_report_error(struct session *ses, in
|
||||
break;
|
||||
case TAG_RAISE:
|
||||
case TAG_FATAL:
|
||||
- eclass = CLASS_OF(ruby_errinfo);
|
||||
- einfo = rb_obj_as_string(ruby_errinfo);
|
||||
+ eclass = CLASS_OF(RB_ERRINFO);
|
||||
+ einfo = rb_obj_as_string(RB_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';
|
||||
@@ -115,7 +115,7 @@ erb_module_message(VALUE self, VALUE str
|
||||
unsigned char *message, *line_end;
|
||||
|
||||
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');
|
||||
@@ -162,8 +162,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--;
|
||||
diff -urp a/src/scripting/ruby/core.h b/src/scripting/ruby/core.h
|
||||
--- a/src/scripting/ruby/core.h 2009-07-07 13:23:17.000000000 +0100
|
||||
+++ b/src/scripting/ruby/core.h 2012-09-10 18:26:25.000000000 +0100
|
||||
@@ -7,6 +7,20 @@ struct session;
|
||||
|
||||
#include <ruby.h> /* for VALUE */
|
||||
|
||||
+#ifndef RSTRING_LEN
|
||||
+#define RSTRING_LEN(string) (RSTRING(string)->len)
|
||||
+#endif
|
||||
+
|
||||
+#ifndef RSTRING_PTR
|
||||
+#define RSTRING_PTR(string) (RSTRING(string)->ptr)
|
||||
+#endif
|
||||
+
|
||||
+#ifdef HAVE_RB_ERRINFO
|
||||
+#define RB_ERRINFO (rb_errinfo())
|
||||
+#else
|
||||
+#define RB_ERRINFO (ruby_errinfo)
|
||||
+#endif
|
||||
+
|
||||
VALUE erb_module;
|
||||
|
||||
void alert_ruby_error(struct session *ses, unsigned char *msg);
|
||||
diff -urp a/src/scripting/ruby/hooks.c b/src/scripting/ruby/hooks.c
|
||||
--- a/src/scripting/ruby/hooks.c 2009-07-07 13:23:17.000000000 +0100
|
||||
+++ b/src/scripting/ruby/hooks.c 2012-09-10 17:53:48.000000000 +0100
|
||||
@@ -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);
|
||||
}
|
@ -1,376 +0,0 @@
|
||||
From a3f59264b9504e8bf3d0ac70b99a237bc964089d Mon Sep 17 00:00:00 2001
|
||||
From: Miciah Dashiel Butler Masters <miciah.masters@gmail.com>
|
||||
Date: Sat, 18 Jul 2009 23:41:01 +0000
|
||||
Subject: [PATCH 1/3] Heartbeat code using JS_TriggerOperationCallback
|
||||
|
||||
Implement new heartbeat code to catch runaway execution of document
|
||||
ECMAScript code. The old code uses JS_SetBranchCallback which is
|
||||
deprecated in new versions of SpiderMonkey. The new code uses setitimer(2)
|
||||
and the JS_SetOperationCallback and JS_TriggerOperationCallback interfaces,
|
||||
introduced in SpiderMonkey 1.8.1. Compatibility with both the old
|
||||
JS_SetBranchCallback and the new interfaces is maintained.
|
||||
|
||||
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
||||
---
|
||||
Makefile.config.in | 1 +
|
||||
configure.in | 12 +++
|
||||
src/ecmascript/ecmascript.h | 4 +
|
||||
src/ecmascript/spidermonkey.c | 38 ++++++++-
|
||||
src/ecmascript/spidermonkey/Makefile | 2 +
|
||||
src/ecmascript/spidermonkey/heartbeat.c | 125 +++++++++++++++++++++++++++++++
|
||||
src/ecmascript/spidermonkey/heartbeat.h | 24 ++++++
|
||||
7 files changed, 201 insertions(+), 5 deletions(-)
|
||||
create mode 100644 src/ecmascript/spidermonkey/heartbeat.c
|
||||
create mode 100644 src/ecmascript/spidermonkey/heartbeat.h
|
||||
|
||||
diff --git a/Makefile.config.in b/Makefile.config.in
|
||||
index c463868..40a8cd7 100644
|
||||
--- a/Makefile.config.in
|
||||
+++ b/Makefile.config.in
|
||||
@@ -117,6 +117,7 @@ CONFIG_DOM = @CONFIG_DOM@
|
||||
CONFIG_ECMASCRIPT = @CONFIG_ECMASCRIPT@
|
||||
CONFIG_ECMASCRIPT_SEE = @CONFIG_ECMASCRIPT_SEE@
|
||||
CONFIG_ECMASCRIPT_SMJS = @CONFIG_ECMASCRIPT_SMJS@
|
||||
+CONFIG_ECMASCRIPT_SMJS_HEARTBEAT = @CONFIG_ECMASCRIPT_SMJS@
|
||||
CONFIG_EXMODE = @CONFIG_EXMODE@
|
||||
CONFIG_FASTMEM = @CONFIG_FASTMEM@
|
||||
CONFIG_FINGER = @CONFIG_FINGER@
|
||||
diff --git a/configure.in b/configure.in
|
||||
index f3e3d77..f79ca78 100644
|
||||
--- a/configure.in
|
||||
+++ b/configure.in
|
||||
@@ -283,6 +283,7 @@ AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
|
||||
AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop)
|
||||
AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
|
||||
AC_CHECK_FUNCS(gettimeofday clock_gettime)
|
||||
+AC_CHECK_FUNCS(setitimer, HAVE_SETITIMER=yes)
|
||||
|
||||
AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
|
||||
|
||||
@@ -651,6 +652,8 @@ AC_MSG_RESULT($cf_result)
|
||||
CONFIG_SPIDERMONKEY="$cf_result"
|
||||
if test "$cf_result" = "yes"; then
|
||||
AC_CHECK_FUNCS([[JS_ReportAllocationOverflow]])
|
||||
+ AC_CHECK_FUNCS(JS_SetBranchCallback)
|
||||
+ AC_CHECK_FUNCS(JS_TriggerOperationCallback, HAVE_JS_TRIGGEROPERATIONCALLBACK=yes)
|
||||
fi
|
||||
EL_RESTORE_FLAGS
|
||||
|
||||
@@ -665,6 +668,15 @@ EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SM
|
||||
AC_SUBST(CONFIG_ECMASCRIPT_SEE)
|
||||
AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
|
||||
|
||||
+if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes &&
|
||||
+ test "x$HAVE_JS_TRIGGEROPERATIONCALLBACK" = xyes &&
|
||||
+ test "x$HAVE_SETITIMER" = xyes; then
|
||||
+ EL_CONFIG(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT, [ECMAScript heartbeat support])
|
||||
+else
|
||||
+ CONFIG_ECMASCRIPT_SMJS_HEARTBEAT=no
|
||||
+fi
|
||||
+AC_SUBST(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
|
||||
+
|
||||
|
||||
# ===================================================================
|
||||
# Optional Spidermonkey-based ECMAScript browser scripting
|
||||
diff --git a/src/ecmascript/ecmascript.h b/src/ecmascript/ecmascript.h
|
||||
index e8d84b5..8613b34 100644
|
||||
--- a/src/ecmascript/ecmascript.h
|
||||
+++ b/src/ecmascript/ecmascript.h
|
||||
@@ -32,7 +32,11 @@ struct ecmascript_interpreter {
|
||||
/* The code evaluated by setTimeout() */
|
||||
struct string code;
|
||||
|
||||
+#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
|
||||
+ struct heartbeat *heartbeat;
|
||||
+#elif defined(HAVE_JS_SETBRANCHCALLBACK)
|
||||
time_t exec_start;
|
||||
+#endif
|
||||
|
||||
/* This is a cross-rerenderings accumulator of
|
||||
* @document.onload_snippets (see its description for juicy details).
|
||||
diff --git a/src/ecmascript/spidermonkey.c b/src/ecmascript/spidermonkey.c
|
||||
index 78c3bca..16fb0a4 100644
|
||||
--- a/src/ecmascript/spidermonkey.c
|
||||
+++ b/src/ecmascript/spidermonkey.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "ecmascript/spidermonkey.h"
|
||||
#include "ecmascript/spidermonkey/document.h"
|
||||
#include "ecmascript/spidermonkey/form.h"
|
||||
+#include "ecmascript/spidermonkey/heartbeat.h"
|
||||
#include "ecmascript/spidermonkey/location.h"
|
||||
#include "ecmascript/spidermonkey/navigator.h"
|
||||
#include "ecmascript/spidermonkey/unibar.h"
|
||||
@@ -109,6 +110,7 @@ reported:
|
||||
JS_ClearPendingException(ctx);
|
||||
}
|
||||
|
||||
+#if !defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT) && defined(HAVE_JS_SETBRANCHCALLBACK)
|
||||
static JSBool
|
||||
safeguard(JSContext *ctx, JSScript *script)
|
||||
{
|
||||
@@ -132,6 +134,7 @@ setup_safeguard(struct ecmascript_interpreter *interpreter,
|
||||
interpreter->exec_start = time(NULL);
|
||||
JS_SetBranchCallback(ctx, safeguard);
|
||||
}
|
||||
+#endif
|
||||
|
||||
|
||||
static void
|
||||
@@ -172,6 +175,9 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
* some kind of bytecode cache. (If we will ever do that.) */
|
||||
JS_SetOptions(ctx, JSOPTION_VAROBJFIX | JSOPTION_COMPILE_N_GO);
|
||||
JS_SetErrorReporter(ctx, error_reporter);
|
||||
+#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
|
||||
+ JS_SetOperationCallback(ctx, heartbeat_callback);
|
||||
+#endif
|
||||
|
||||
window_obj = JS_NewObject(ctx, (JSClass *) &window_class, NULL, NULL);
|
||||
if (!window_obj) goto release_and_fail;
|
||||
@@ -263,10 +269,17 @@ spidermonkey_eval(struct ecmascript_interpreter *interpreter,
|
||||
assert(interpreter);
|
||||
if (!js_module_init_ok) return;
|
||||
ctx = interpreter->backend_data;
|
||||
+#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
|
||||
+ interpreter->heartbeat = add_heartbeat(interpreter);
|
||||
+#elif defined(HAVE_JS_SETBRANCHCALLBACK)
|
||||
setup_safeguard(interpreter, ctx);
|
||||
+#endif
|
||||
interpreter->ret = ret;
|
||||
JS_EvaluateScript(ctx, JS_GetGlobalObject(ctx),
|
||||
code->source, code->length, "", 0, &rval);
|
||||
+#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
|
||||
+ done_heartbeat(interpreter->heartbeat);
|
||||
+#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -274,17 +287,25 @@ unsigned char *
|
||||
spidermonkey_eval_stringback(struct ecmascript_interpreter *interpreter,
|
||||
struct string *code)
|
||||
{
|
||||
+ JSBool ret;
|
||||
JSContext *ctx;
|
||||
jsval rval;
|
||||
|
||||
assert(interpreter);
|
||||
if (!js_module_init_ok) return NULL;
|
||||
ctx = interpreter->backend_data;
|
||||
- setup_safeguard(interpreter, ctx);
|
||||
interpreter->ret = NULL;
|
||||
- if (JS_EvaluateScript(ctx, JS_GetGlobalObject(ctx),
|
||||
- code->source, code->length, "", 0, &rval)
|
||||
- == JS_FALSE) {
|
||||
+#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
|
||||
+ interpreter->heartbeat = add_heartbeat(interpreter);
|
||||
+#elif defined(HAVE_JS_SETBRANCHCALLBACK)
|
||||
+ setup_safeguard(interpreter, ctx);
|
||||
+#endif
|
||||
+ ret = JS_EvaluateScript(ctx, JS_GetGlobalObject(ctx),
|
||||
+ code->source, code->length, "", 0, &rval);
|
||||
+#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
|
||||
+ done_heartbeat(interpreter->heartbeat);
|
||||
+#endif
|
||||
+ if (ret == JS_FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
if (JSVAL_IS_VOID(rval)) {
|
||||
@@ -308,14 +329,21 @@ spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter,
|
||||
assert(interpreter);
|
||||
if (!js_module_init_ok) return 0;
|
||||
ctx = interpreter->backend_data;
|
||||
- setup_safeguard(interpreter, ctx);
|
||||
interpreter->ret = NULL;
|
||||
fun = JS_CompileFunction(ctx, NULL, "", 0, NULL, code->source,
|
||||
code->length, "", 0);
|
||||
if (!fun)
|
||||
return -1;
|
||||
|
||||
+#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
|
||||
+ interpreter->heartbeat = add_heartbeat(interpreter);
|
||||
+#elif defined(HAVE_JS_SETBRANCHCALLBACK)
|
||||
+ setup_safeguard(interpreter, ctx);
|
||||
+#endif
|
||||
ret = JS_CallFunction(ctx, NULL, fun, 0, NULL, &rval);
|
||||
+#if defined(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
|
||||
+ done_heartbeat(interpreter->heartbeat);
|
||||
+#endif
|
||||
if (ret == 2) { /* onClick="history.back()" */
|
||||
return 0;
|
||||
}
|
||||
diff --git a/src/ecmascript/spidermonkey/Makefile b/src/ecmascript/spidermonkey/Makefile
|
||||
index f1c0fef..377ca80 100644
|
||||
--- a/src/ecmascript/spidermonkey/Makefile
|
||||
+++ b/src/ecmascript/spidermonkey/Makefile
|
||||
@@ -2,6 +2,8 @@ top_builddir=../../..
|
||||
include $(top_builddir)/Makefile.config
|
||||
INCLUDES += $(SPIDERMONKEY_CFLAGS)
|
||||
|
||||
+OBJS-$(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT) += heartbeat.o
|
||||
+
|
||||
OBJS = document.o form.o location.o navigator.o unibar.o window.o
|
||||
|
||||
include $(top_srcdir)/Makefile.lib
|
||||
diff --git a/src/ecmascript/spidermonkey/heartbeat.c b/src/ecmascript/spidermonkey/heartbeat.c
|
||||
new file mode 100644
|
||||
index 0000000..bf95d92
|
||||
--- /dev/null
|
||||
+++ b/src/ecmascript/spidermonkey/heartbeat.c
|
||||
@@ -0,0 +1,125 @@
|
||||
+/* The SpiderMonkey ECMAScript backend heartbeat fuctionality. */
|
||||
+
|
||||
+#ifdef HAVE_CONFIG_H
|
||||
+#include "config.h"
|
||||
+#endif
|
||||
+
|
||||
+#include <sys/time.h> /* setitimer(2) */
|
||||
+
|
||||
+#include "elinks.h"
|
||||
+
|
||||
+#include "ecmascript/spidermonkey/util.h"
|
||||
+
|
||||
+#include "config/options.h"
|
||||
+#include "document/view.h"
|
||||
+#include "ecmascript/ecmascript.h"
|
||||
+#include "ecmascript/spidermonkey.h"
|
||||
+#include "ecmascript/spidermonkey/heartbeat.h"
|
||||
+#include "osdep/signals.h"
|
||||
+#include "session/session.h"
|
||||
+#include "util/lists.h"
|
||||
+#include "util/math.h" /* int_upper_bound */
|
||||
+#include "util/memory.h"
|
||||
+#include "viewer/text/vs.h"
|
||||
+
|
||||
+
|
||||
+
|
||||
+static INIT_LIST_OF(struct heartbeat, heartbeats);
|
||||
+
|
||||
+static struct itimerval heartbeat_timer = { { 1, 0 }, { 1, 0 } };
|
||||
+
|
||||
+
|
||||
+/* This callback is installed by JS_SetOperationCallback and triggered
|
||||
+ * by JS_TriggerOperationCallback in the heartbeat code below. Returning
|
||||
+ * JS_FALSE terminates script execution immediately. */
|
||||
+JSBool
|
||||
+heartbeat_callback(JSContext *ctx)
|
||||
+{
|
||||
+ return JS_FALSE;
|
||||
+}
|
||||
+
|
||||
+/* Callback for SIGVTALRM. Go through all heartbeats, decrease each
|
||||
+ * one's TTL, and call JS_TriggerOperationCallback if a heartbeat's TTL
|
||||
+ * goes to 0. */
|
||||
+static void
|
||||
+check_heartbeats(void *data)
|
||||
+{
|
||||
+ struct heartbeat *hb;
|
||||
+
|
||||
+ foreach (hb, heartbeats) {
|
||||
+ assert(hb->interpreter);
|
||||
+
|
||||
+ --hb->ttl;
|
||||
+
|
||||
+ if (hb->ttl <= 0) {
|
||||
+ if (hb->interpreter->vs
|
||||
+ && hb->interpreter->vs->doc_view
|
||||
+ && hb->interpreter->vs->doc_view->session
|
||||
+ && hb->interpreter->vs->doc_view->session->tab
|
||||
+ && hb->interpreter->vs->doc_view->session->tab->term) {
|
||||
+ struct session *ses = hb->interpreter->vs->doc_view->session;
|
||||
+ struct terminal *term = ses->tab->term;
|
||||
+ int max_exec_time = get_opt_int("ecmascript.max_exec_time");
|
||||
+
|
||||
+ ecmascript_timeout_dialog(term, max_exec_time);
|
||||
+ }
|
||||
+
|
||||
+ JS_TriggerOperationCallback(hb->interpreter->backend_data);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ install_signal_handler(SIGVTALRM, check_heartbeats, NULL, 1);
|
||||
+}
|
||||
+
|
||||
+/* Create a new heartbeat for the given interpreter. */
|
||||
+struct heartbeat *
|
||||
+add_heartbeat(struct ecmascript_interpreter *interpreter)
|
||||
+{
|
||||
+ struct session *ses;
|
||||
+ struct heartbeat *hb;
|
||||
+
|
||||
+ assert(interpreter);
|
||||
+
|
||||
+ if (!interpreter->vs || !interpreter->vs->doc_view)
|
||||
+ ses = NULL;
|
||||
+ else
|
||||
+ ses = interpreter->vs->doc_view->session;
|
||||
+
|
||||
+ hb = mem_alloc(sizeof(struct heartbeat));
|
||||
+ if (!hb) return NULL;
|
||||
+
|
||||
+ hb->ttl = get_opt_int("ecmascript.max_exec_time");
|
||||
+ hb->interpreter = interpreter;
|
||||
+
|
||||
+ add_to_list(heartbeats, hb);
|
||||
+
|
||||
+ /* Update the heartbeat timer. */
|
||||
+ if (list_is_singleton(*hb)) {
|
||||
+ heartbeat_timer.it_value.tv_sec = 1;
|
||||
+ setitimer(ITIMER_VIRTUAL, &heartbeat_timer, NULL);
|
||||
+ }
|
||||
+
|
||||
+ /* We install the handler every call to add_heartbeat instead of only on
|
||||
+ * module initialisation because other code may set other handlers for
|
||||
+ * the signal. */
|
||||
+ install_signal_handler(SIGVTALRM, check_heartbeats, NULL, 1);
|
||||
+
|
||||
+ return hb;
|
||||
+}
|
||||
+
|
||||
+/* Destroy the given heartbeat. */
|
||||
+void
|
||||
+done_heartbeat(struct heartbeat *hb)
|
||||
+{
|
||||
+ assert(hb->interpreter);
|
||||
+
|
||||
+ /* Stop the heartbeat timer if this heartbeat is the only one. */
|
||||
+ if (list_is_singleton(*hb)) {
|
||||
+ heartbeat_timer.it_value.tv_sec = 0;
|
||||
+ setitimer(ITIMER_VIRTUAL, &heartbeat_timer, NULL);
|
||||
+ }
|
||||
+
|
||||
+ del_from_list(hb);
|
||||
+ hb->interpreter->heartbeat = NULL;
|
||||
+ mem_free(hb);
|
||||
+}
|
||||
diff --git a/src/ecmascript/spidermonkey/heartbeat.h b/src/ecmascript/spidermonkey/heartbeat.h
|
||||
new file mode 100644
|
||||
index 0000000..f7c8b12
|
||||
--- /dev/null
|
||||
+++ b/src/ecmascript/spidermonkey/heartbeat.h
|
||||
@@ -0,0 +1,24 @@
|
||||
+#ifndef EL__ECMASCRIPT_SPIDERMONKEY_HEARTBEAT_H
|
||||
+#define EL__ECMASCRIPT_SPIDERMONKEY_HEARTBEAT_H
|
||||
+
|
||||
+#include "ecmascript/spidermonkey/util.h"
|
||||
+
|
||||
+#include "ecmascript/spidermonkey.h"
|
||||
+
|
||||
+struct heartbeat {
|
||||
+ LIST_HEAD(struct heartbeat);
|
||||
+
|
||||
+ int ttl; /* Time to live. This value is assigned when the
|
||||
+ * script begins execution and is decremented every
|
||||
+ * second. When it reaches 0, script execution is
|
||||
+ * terminated. */
|
||||
+
|
||||
+ struct ecmascript_interpreter *interpreter;
|
||||
+};
|
||||
+
|
||||
+struct heartbeat *add_heartbeat(struct ecmascript_interpreter *interpreter);
|
||||
+void done_heartbeat(struct heartbeat *hb);
|
||||
+
|
||||
+JSBool heartbeat_callback(JSContext *ctx);
|
||||
+
|
||||
+#endif
|
||||
--
|
||||
1.7.4.2
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,57 +0,0 @@
|
||||
From 32109054ce40067b8c55837fb69f1bc1249e38fd Mon Sep 17 00:00:00 2001
|
||||
From: witekfl <witekfl@poczta.onet.pl>
|
||||
Date: Mon, 25 Apr 2011 21:04:03 +0200
|
||||
Subject: [PATCH 3/3] SpiderMonkey: fix issue with javascript:history.back()
|
||||
|
||||
In history.back() and others set rval to NULL.
|
||||
Do not convert NULL to string in spidermoney_eval_stringback.
|
||||
|
||||
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
||||
---
|
||||
src/ecmascript/spidermonkey.c | 2 +-
|
||||
src/ecmascript/spidermonkey/location.c | 3 +++
|
||||
2 files changed, 4 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/src/ecmascript/spidermonkey.c b/src/ecmascript/spidermonkey.c
|
||||
index 021e6bd..5360455 100644
|
||||
--- a/src/ecmascript/spidermonkey.c
|
||||
+++ b/src/ecmascript/spidermonkey.c
|
||||
@@ -303,7 +303,7 @@ spidermonkey_eval_stringback(struct ecmascript_interpreter *interpreter,
|
||||
if (ret == JS_FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
- if (JSVAL_IS_VOID(rval)) {
|
||||
+ if (JSVAL_IS_VOID(rval) || JSVAL_IS_NULL(rval)) {
|
||||
/* Undefined value. */
|
||||
return NULL;
|
||||
}
|
||||
diff --git a/src/ecmascript/spidermonkey/location.c b/src/ecmascript/spidermonkey/location.c
|
||||
index 752a890..d1fbdfb 100644
|
||||
--- a/src/ecmascript/spidermonkey/location.c
|
||||
+++ b/src/ecmascript/spidermonkey/location.c
|
||||
@@ -78,6 +78,7 @@ history_back(JSContext *ctx, uintN argc, jsval *rval)
|
||||
* and return non zero for <a href="javascript:history.back()"> to prevent
|
||||
* "calculating" new link. Returned value 2 is changed to 0 in function
|
||||
* spidermonkey_eval_boolback */
|
||||
+ JS_SET_RVAL(ctx, rval, JSVAL_NULL);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -91,6 +92,7 @@ history_forward(JSContext *ctx, uintN argc, jsval *rval)
|
||||
|
||||
go_unback(ses);
|
||||
|
||||
+ JS_SET_RVAL(ctx, rval, JSVAL_NULL);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -121,6 +123,7 @@ history_go(JSContext *ctx, uintN argc, jsval *rval)
|
||||
index += index > 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
+ JS_SET_RVAL(ctx, rval, JSVAL_NULL);
|
||||
return 2;
|
||||
}
|
||||
|
||||
--
|
||||
1.7.4.4
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2d19547831098acff0c5f97f9fbc7912240f122961fd49fb8b76738417dd24d2
|
||||
size 2783523
|
3
elinks-0.12pre6.tar.bz2
Normal file
3
elinks-0.12pre6.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:383646375b8a325bef5a132c8300caab90eb0b842c5f8eff68febc00e29acada
|
||||
size 2854500
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Dec 24 22:07:46 UTC 2012 - tchvatal@suse.com
|
||||
|
||||
- Version bump to 0.12_pre6.
|
||||
* Remove upstream included js186 patches.
|
||||
* Add new patch for ruby1.9 build.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Jun 10 17:19:18 UTC 2012 - asterios.dramis@gmail.com
|
||||
|
||||
|
38
elinks.spec
38
elinks.spec
@ -15,27 +15,22 @@
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
%define pkg_version 0.12pre5
|
||||
%define pkg_version 0.12pre6
|
||||
|
||||
Name: elinks
|
||||
Version: 0.11.995
|
||||
Version: 0.11.996
|
||||
Release: 0
|
||||
License: GPL-2.0
|
||||
Summary: An advanced and well-established feature-rich text mode web browser
|
||||
Url: http://elinks.or.cz/
|
||||
Group: Productivity/Networking/Web/Browsers
|
||||
Source0: http://elinks.or.cz/download/%{name}-%{pkg_version}.tar.bz2
|
||||
# PATCH-FIX-UPSTREAM elinks-0.12_pre5-js185-1-heartbeat.patch asterios.dramis@gmail.com -- Support for new js-1.8.5 (patch taken from Gentoo)
|
||||
Patch0: elinks-0.12_pre5-js185-1-heartbeat.patch
|
||||
# PATCH-FIX-UPSTREAM elinks-0.12_pre5-js185-2-up.patch asterios.dramis@gmail.com -- Support for new js-1.8.5 (patch taken from Gentoo)
|
||||
Patch1: elinks-0.12_pre5-js185-2-up.patch
|
||||
# PATCH-FIX-UPSTREAM elinks-0.12_pre5-js185-3-histback.patch asterios.dramis@gmail.com -- Support for new js-1.8.5 (patch taken from Gentoo)
|
||||
Patch2: elinks-0.12_pre5-js185-3-histback.patch
|
||||
# PATCH-FIX-UPSTREAM elinks-0.12_pre5-compilation-fix.patch asterios.dramis@gmail.com -- Fix compilation with gc (patch taken from Gentoo)
|
||||
Patch3: elinks-0.12_pre5-compilation-fix.patch
|
||||
Patch0: elinks-0.12_pre5-compilation-fix.patch
|
||||
# PATCH-FIX-UPSTREAM use_lua-5.1.patch asterios.dramis@gmail.com -- Support for lua-5.1 (based on patch from Debian)
|
||||
Patch4: use_lua-5.1.patch
|
||||
BuildRequires: automake
|
||||
Patch1: use_lua-5.1.patch
|
||||
# PATCH-FIX-UPSTREAM build-with-ruby-1.9.patch dabbot@gentoo.org -- Support for ruby-1.9 (patch taken from Gentoo)
|
||||
Patch2: build-with-ruby-1.9.patch
|
||||
%if 0%{?suse_version} > 1140
|
||||
BuildRequires: gc-devel
|
||||
%endif
|
||||
@ -54,11 +49,10 @@ BuildRequires: lua-devel
|
||||
%endif
|
||||
BuildRequires: openssl-devel
|
||||
BuildRequires: pkg-config
|
||||
%if 0%{?suse_version} && 0%{?suse_version} <= 1210
|
||||
BuildRequires: ruby-devel
|
||||
%endif
|
||||
BuildRequires: tre-devel
|
||||
BuildRequires: zlib-devel
|
||||
BuildRequires: automake autoconf libtool
|
||||
Provides: web_browser
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
|
||||
@ -72,10 +66,8 @@ description.
|
||||
%prep
|
||||
%setup -q -n %{name}-%{pkg_version}
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4
|
||||
|
||||
# Remove build time references so build-compare can do its work
|
||||
FAKE_BUILDTIME=$(LC_ALL=C date -u -r %{_sourcedir}/%{name}.changes '+%%H:%%M')
|
||||
@ -84,8 +76,8 @@ sed -i "s/__TIME__/\"$FAKE_BUILDTIME\"/" src/vernum.c
|
||||
sed -i "s/__DATE__/\"$FAKE_BUILDDATE\"/" src/vernum.c
|
||||
|
||||
%build
|
||||
# Regenerate build system because of patches modifying configure.in
|
||||
autoreconf -vif
|
||||
# required for ruby patch
|
||||
sh ./autogen.sh
|
||||
export CFLAGS="%{optflags} -fstack-protector"
|
||||
%configure \
|
||||
--sysconfdir=%{_sysconfdir}/elinks \
|
||||
@ -110,16 +102,11 @@ export CFLAGS="%{optflags} -fstack-protector"
|
||||
%endif
|
||||
--without-lzma \
|
||||
--with-gssapi \
|
||||
--without-see \
|
||||
--without-guile \
|
||||
--with-perl \
|
||||
--without-python \
|
||||
--with-lua \
|
||||
%if 0%{?suse_version} && 0%{?suse_version} <= 1210
|
||||
--with-ruby \
|
||||
%else
|
||||
--without-ruby \
|
||||
%endif
|
||||
--without-gnutls \
|
||||
--without-x
|
||||
make %{?_smp_mflags}
|
||||
@ -144,14 +131,11 @@ install -Dd -m 0755 %{_pkgdocdir}/scripts/
|
||||
install -pm 0644 contrib/wipe-out-ssl* contrib/conv/* %{_pkgdocdir}/scripts/
|
||||
rm -f %{_pkgdocdir}/scripts/conv/.gitignore
|
||||
# Install only the languages that are compiled
|
||||
for lang in lua perl smjs; do
|
||||
for lang in lua perl smjs ruby; do
|
||||
install -Dd -m 0755 %{_pkgdocdir}/${lang}
|
||||
install -pm 0644 contrib/${lang}/* %{_pkgdocdir}/${lang}
|
||||
done
|
||||
rm -f %{_pkgdocdir}/lua/.gitignore
|
||||
%if 0%{?suse_version} && 0%{?suse_version} <= 1210
|
||||
cp -a contrib/ruby %{_pkgdocdir}/
|
||||
%endif
|
||||
|
||||
%files -f %{name}.lang
|
||||
%defattr(-,root,root,-)
|
||||
|
Loading…
x
Reference in New Issue
Block a user