From 7e301b27e4e61e0c1bd1bc40f1008608969033e6 Mon Sep 17 00:00:00 2001 From: Barrucadu Date: Mon, 18 May 2009 21:51:46 +0100 Subject: Edited run_external_js() to use read_file_by_line() --- uzbl.c | 21 +++++++-------------- 1 file 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]); -- cgit v1.2.3