aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mason Larobina <mason.larobina@gmail.com>2009-12-05 10:53:02 +0800
committerGravatar Mason Larobina <mason.larobina@gmail.com>2009-12-05 10:53:02 +0800
commitae4f28681d7aae24674990e2bf28c503ec5e3fed (patch)
tree22d142d4f2e63c3733def5f47546af729b6fec2e
parent0061e5afefebcba68f5922e5d9d97ff6852788f3 (diff)
parent011cc338cbf8207f7d658be8f7a17003d38bf008 (diff)
Merge branch 'experimental' of github.com:robm/uzbl into experimental
-rw-r--r--Makefile4
-rw-r--r--README4
-rw-r--r--uzbl-core.c30
3 files changed, 31 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 50fe09b..026deeb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
# first entries are for gnu make, 2nd for BSD make. see http://lists.uzbl.org/pipermail/uzbl-dev-uzbl.org/2009-July/000177.html
-CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic -ggdb3
-CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`git log | head -n1 | sed "s/.* //"`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic -ggdb3
+CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
+CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`git log | head -n1 | sed "s/.* //"`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS)
LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS)
diff --git a/README b/README
index 348ba5f..23b0f4e 100644
--- a/README
+++ b/README
@@ -306,6 +306,10 @@ the java script in @< >@.
print The currently viewed document contains @<document.links.length>@ links
+The @<>@ substitution can also load JavaScript from a file, syntax: @<+filename>@
+
+ print JS return value from file: @<+/path/to/file.js>@
+
Variable expansion also works within a java script substitution.
diff --git a/uzbl-core.c b/uzbl-core.c
index edb3e54..42e274e 100644
--- a/uzbl-core.c
+++ b/uzbl-core.c
@@ -266,6 +266,7 @@ expand(const char *s, guint recurse) {
}
else if(recurse != 1 &&
etype == EXP_EXPR) {
+
mycmd = expand(ret, 1);
gchar *quoted = g_shell_quote(mycmd);
gchar *tmp = g_strdup_printf("%s %s",
@@ -293,9 +294,22 @@ expand(const char *s, guint recurse) {
}
else if(recurse != 2 &&
etype == EXP_JS) {
- mycmd = expand(ret, 2);
- eval_js(uzbl.gui.web_view, mycmd, js_ret);
- g_free(mycmd);
+
+ /* read JS from file */
+ if(ret[0] == '+') {
+ GArray *tmp = g_array_new(TRUE, FALSE, sizeof(gchar *));
+ mycmd = expand(ret+1, 2);
+ g_array_append_val(tmp, mycmd);
+
+ run_external_js(uzbl.gui.web_view, tmp, js_ret);
+ g_array_free(tmp, TRUE);
+ }
+ /* JS from string */
+ else {
+ mycmd = expand(ret, 2);
+ eval_js(uzbl.gui.web_view, mycmd, js_ret);
+ g_free(mycmd);
+ }
if(js_ret->str) {
g_string_append(buf, js_ret->str);
@@ -380,7 +394,9 @@ read_file_by_line (const gchar *path) {
g_io_channel_unref (chan);
} else {
- fprintf(stderr, "File '%s' not be read.\n", path);
+ gchar *tmp = g_strdup_printf("File %s can not be read.", path);
+ send_event(COMMAND_ERROR, tmp, NULL);
+ g_free(tmp);
}
return lines;
@@ -519,13 +535,17 @@ void
catch_signal(int s) {
if(s == SIGTERM ||
s == SIGINT ||
- s == SIGSEGV ||
s == SIGILL ||
s == SIGFPE ||
s == SIGQUIT) {
clean_up();
exit(EXIT_SUCCESS);
}
+ else if(s == SIGSEGV) {
+ clean_up();
+ fprintf(stderr, "Program aborted, segmentation fault!\nAttempting to clean up...\n");
+ exit(EXIT_FAILURE);
+ }
else if(s == SIGALRM && uzbl.state.event_buffer) {
g_ptr_array_free(uzbl.state.event_buffer, TRUE);
uzbl.state.event_buffer = NULL;