aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Barrucadu <mike@barrucadu.co.uk>2009-05-18 21:51:46 +0100
committerGravatar Barrucadu <mike@barrucadu.co.uk>2009-05-18 21:51:46 +0100
commit7e301b27e4e61e0c1bd1bc40f1008608969033e6 (patch)
treef1505cb4a88de049a65aabc977d931096b8bd649
parent987d4c7ba787b30a965a4f01356672009b1ec2db (diff)
Edited run_external_js() to use read_file_by_line()
-rw-r--r--uzbl.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/uzbl.c b/uzbl.c
index 82258cf..d4fd90b 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -547,27 +547,20 @@ static void
run_external_js (WebKitWebView * web_view, const gchar *param) {
if (param) {
gchar** splitted = g_strsplit (param, " ", 2);
+ gchar** lines = read_file_by_line (splitted[0]);
+ gchar* js = NULL;
+ int i;
- GIOChannel *chan = NULL;
- gchar *readbuf = NULL;
- gsize len;
- gchar* js = NULL;
-
- chan = g_io_channel_new_file(splitted[0], "r", NULL);
-
- if (chan) {
- while (g_io_channel_read_line(chan, &readbuf, &len, NULL, NULL)
- == G_IO_STATUS_NORMAL) {
+ if (lines[0] != NULL) {
+ for (i = 0; lines[i] != NULL; i ++) {
if (js == NULL) {
- js = g_strdup (readbuf);
+ js = g_strdup (lines[i]);
} else {
- gchar* newjs = g_strconcat (js, readbuf, NULL);
+ gchar* newjs = g_strconcat (js, lines[i], NULL);
js = newjs;
}
- g_free (readbuf);
}
- g_io_channel_unref (chan);
if (uzbl.state.verbose)
printf ("External JavaScript file %s loaded\n", splitted[0]);