From c9fe40035329d906c025430fad5f8842b0382299 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 15 Oct 2012 15:09:17 +0100 Subject: [PATCH 01/24] remove -a from cp command as mac os x 10.5 cp does not have the switch --- cocoa/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target index 635790a61..e8e787022 100644 --- a/cocoa/Makefile.target +++ b/cocoa/Makefile.target @@ -221,7 +221,7 @@ package-cocoa: NetSurf.dmg NetSurf.tmp.dmg: NetSurf.app hdiutil create -size 8m -fs HFS+ -volname "NetSurf" $@ hdiutil attach $@ - cp -a $^ /Volumes/NetSurf/ + cp $^ /Volumes/NetSurf/ hdiutil detach $$(echo $$(hdiutil attach $@ | cut -f 1) | cut -f 1 -d ' ') NetSurf.dmg: NetSurf.tmp.dmg From 248fc0acc9c1bb78b44f545ba88d86067ea3eaa0 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 15 Oct 2012 15:49:52 +0100 Subject: [PATCH 02/24] add packaging objects to clean target --- cocoa/Makefile.target | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target index e8e787022..bfe9c9a54 100644 --- a/cocoa/Makefile.target +++ b/cocoa/Makefile.target @@ -218,12 +218,24 @@ NetSurf.app/Contents/Info.plist: cocoa/res/NetSurf-Info.plist cocoa/Makefile.tar package-cocoa: NetSurf.dmg +.INTERMEDIATE: NetSurf.tmp.dmg + NetSurf.tmp.dmg: NetSurf.app hdiutil create -size 8m -fs HFS+ -volname "NetSurf" $@ + sleep 2 hdiutil attach $@ + sleep 2 cp $^ /Volumes/NetSurf/ hdiutil detach $$(echo $$(hdiutil attach $@ | cut -f 1) | cut -f 1 -d ' ') + sleep 2 NetSurf.dmg: NetSurf.tmp.dmg hdiutil convert $^ -format UDZO -o $@ +CLEANS += clean-package-cocoa + +clean-package-cocoa: + $(RM) NetSurf.tmp.dmg + $(RM) NetSurf.dmg + $(RM) -r NetSurf.app + From 42657ea9a4735613b90e2fcce6d099e9d450c569 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 15 Oct 2012 16:04:51 +0100 Subject: [PATCH 03/24] bodge the makefile version extraction. --- cocoa/Makefile.target | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target index bfe9c9a54..719d084a2 100644 --- a/cocoa/Makefile.target +++ b/cocoa/Makefile.target @@ -41,7 +41,8 @@ endif CFLAGS += -I/usr/include/libxml2 CFLAGS += -include cocoa/Prefix.pch - VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c) +# VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c) + VERSION_FULL := "3.0 (Dev)" VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c) VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c) From b40fd3a88ac8ce748855988efb418aad7a9cf91d Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 15 Oct 2012 16:15:14 +0100 Subject: [PATCH 04/24] use correct flags with cp for mac os directory copying --- cocoa/Makefile.target | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target index 719d084a2..82900b6b0 100644 --- a/cocoa/Makefile.target +++ b/cocoa/Makefile.target @@ -42,6 +42,7 @@ endif CFLAGS += -include cocoa/Prefix.pch # VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c) +# TODO: this needs fixing properly everywhere VERSION_FULL := "3.0 (Dev)" VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c) VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c) @@ -226,7 +227,7 @@ NetSurf.tmp.dmg: NetSurf.app sleep 2 hdiutil attach $@ sleep 2 - cp $^ /Volumes/NetSurf/ + cp -pPR $^ /Volumes/NetSurf/ hdiutil detach $$(echo $$(hdiutil attach $@ | cut -f 1) | cut -f 1 -d ' ') sleep 2 @@ -236,7 +237,10 @@ NetSurf.dmg: NetSurf.tmp.dmg CLEANS += clean-package-cocoa clean-package-cocoa: - $(RM) NetSurf.tmp.dmg - $(RM) NetSurf.dmg - $(RM) -r NetSurf.app + $(VQ)echo " CLEAN: NetSurf.tmp.dmg" + $(Q)$(RM) NetSurf.tmp.dmg + $(VQ)echo " CLEAN: NetSurf.dmg" + $(Q)$(RM) NetSurf.dmg + $(VQ)echo " CLEAN: NetSurf.app" + $(Q)$(RM) -r NetSurf.app From fe3582667c5cf70785f873bb862022ced50820fc Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 15 Oct 2012 19:40:13 +0100 Subject: [PATCH 05/24] Update. --- !NetSurf/Resources/Icons/directory.png | Bin 259 -> 294 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/!NetSurf/Resources/Icons/directory.png b/!NetSurf/Resources/Icons/directory.png index de3d7687fa0d0c9c8d8b4e0b4c3f33c7dc114b6b..1d683bf1ee18cfaefb421c53440ee737e2ae5a3e 100644 GIT binary patch delta 248 zcmVxm;vzI<@&<<0X4o%hX7y^7Zmx3swh{DQ)T;!4^w zEUauO-uwIK&;OVAufJye|NA;F1Kz)Tw}FM3k;%Z;(_apkC2^{1N@5HQ3}Uzp*}i{{LrS_(_2w|Nk>Eu>50SVEFl)LYMseN1=EAF)*^X0000>Pg7)}_XvC5t8`OCz}!1QNO z#LlQ8v`Y5>|NmoT{Qib)1OEU2$H>C? Date: Tue, 16 Oct 2012 18:32:14 +0100 Subject: [PATCH 06/24] Fix url encoded query generation, when there's no name/value pairs. --- render/form.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/render/form.c b/render/form.c index f60a2bad3..42e76e1f2 100644 --- a/render/form.c +++ b/render/form.c @@ -684,7 +684,7 @@ static char *form_url_encode(struct form *form, { char *name, *value; char *s, *s2; - unsigned int len, len1; + unsigned int len, len1, len_init; url_func_result url_err; if (query_string) @@ -698,10 +698,10 @@ static char *form_url_encode(struct form *form, if (query_string) { s[0] = '?'; s[1] = '\0'; - len = 1; + len_init = len = 1; } else { s[0] = '\0'; - len = 0; + len_init = len = 0; } for (; control; control = control->next) { @@ -737,7 +737,8 @@ static char *form_url_encode(struct form *form, free(value); } - if (len) + if (len > len_init) + /* Replace trailing '&' */ s[len - 1] = '\0'; return s; } From e2bde3482b07ee61c933dedaa8089b3d2daceeb3 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 16 Oct 2012 18:36:34 +0100 Subject: [PATCH 07/24] Remove double ;. --- utils/libdom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/libdom.c b/utils/libdom.c index 430a7e227..95f7254f9 100644 --- a/utils/libdom.c +++ b/utils/libdom.c @@ -31,7 +31,7 @@ bool libdom_treewalk(dom_node *root, void *ctx) { dom_node *node; - bool result = true;; + bool result = true; node = dom_node_ref(root); /* tree root */ From e3261a38e2ca461caebcd4a67365c81ba39014d0 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 16 Oct 2012 22:01:55 +0100 Subject: [PATCH 08/24] Document messages_load behaviour. --- riscos/gui.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/riscos/gui.c b/riscos/gui.c index 2926f63aa..d689094ab 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -780,6 +780,8 @@ int main(int argc, char** argv) setbuf(stderr, NULL); + /* Pass a NULL pointer for Messages path, because until the Choices + * are loaded in netsurf_init, we don't know the Messages path. */ netsurf_init(&argc, &argv, "NetSurf:Choices", NULL); artworks_init(); @@ -794,7 +796,9 @@ int main(int argc, char** argv) "NetSurf:Resources.%s.Messages", nsoption_charp(language))) < 0 || length >= (int)sizeof(path)) die("Failed to locate Messages resource."); + /* We disabled core Messages load, so have to load them here */ messages_load(path); + /* Also load some extra RISC OS specific Messages */ messages_load("NetSurf:Resources.LangNames"); gui_init(argc, argv); From ca555e7fd132306ab0931145fde1079879c3cd38 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Tue, 16 Oct 2012 22:10:49 +0100 Subject: [PATCH 09/24] remove extraneous linefeeds --- amiga/font_scan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/amiga/font_scan.c b/amiga/font_scan.c index 549ea5064..5091314e6 100644 --- a/amiga/font_scan.c +++ b/amiga/font_scan.c @@ -259,10 +259,10 @@ ULONG ami_font_scan_fonts(struct MinList *list, do { nnode = (struct nsObject *)GetSucc((struct Node *)node); ami_font_scan_gui_update(win, node->dtz_Node.ln_Name, font_num, total); - LOG(("Scanning %s\n", node->dtz_Node.ln_Name)); + LOG(("Scanning %s", node->dtz_Node.ln_Name)); found = ami_font_scan_font(node->dtz_Node.ln_Name, glypharray); total += found; - LOG(("Found %ld new glyphs (total = %ld)\n", found, total)); + LOG(("Found %ld new glyphs (total = %ld)", found, total)); font_num++; } while(node = nnode); @@ -308,7 +308,7 @@ ULONG ami_font_scan_list(struct MinList *list) if(node) { node->dtz_Node.ln_Name = strdup(af[i].af_Attr.ta_Name); found++; - LOG(("Added %s\n", af[i].af_Attr.ta_Name)); + LOG(("Added %s", af[i].af_Attr.ta_Name)); } } } From f0a568b861fb8e200ec95f4b10344fa0f44dfff6 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Tue, 16 Oct 2012 22:12:12 +0100 Subject: [PATCH 10/24] remove standalone code which no longer compiles --- amiga/font_scan.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/amiga/font_scan.c b/amiga/font_scan.c index 5091314e6..a58acf01b 100644 --- a/amiga/font_scan.c +++ b/amiga/font_scan.c @@ -493,31 +493,4 @@ void ami_font_scan_init(const char *filename, bool force_scan, bool save, LOG(("Initialised with %ld glyphs", found)); } -#ifdef AMI_FONT_SCAN_STANDALONE -/* This can be compiled as standalone using: -* gcc -o font_scan font_scan.c object.c -lwapcaplet -lauto -I .. -D__USE_INLINE__ -DAMI_FONT_SCAN_STANDALONE -*/ -int main(int argc, char** argv) -{ - lwc_string *glypharray[0xffff + 1]; - ULONG found = 0; - BPTR fh; - struct MinList *list; - if(argc < 2) return 5; - - printf("%s\n",argv[1]); - - list = NewObjList(); - ami_font_scan_init(argv[1], list, glypharray); - FreeObjList(list); - - ami_font_scan_fini(glypharray); - - return 0; -} - -void ami_font_close(APTR discard) { } -void ami_mime_entry_free(APTR discard) { } - -#endif From 0c0b263b29b044c8517a51d8d22a0eeb622ae6b4 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 17 Oct 2012 11:41:25 +0100 Subject: [PATCH 11/24] Add some startup logging. --- desktop/history_global_core.c | 3 +++ riscos/font.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c index 50c326684..3222dc7b8 100644 --- a/desktop/history_global_core.c +++ b/desktop/history_global_core.c @@ -287,11 +287,14 @@ bool history_global_initialise(struct tree *tree, const char* folder_icon_name) if (!history_global_initialise_nodes()) return false; + LOG(("Building history tree")); + global_history_initialised = true; urldb_iterate_entries(global_history_add_internal); global_history_initialised = false; tree_set_node_expanded(global_history_tree, global_history_tree_root, false, true, true); + LOG(("History tree built")); return true; } diff --git a/riscos/font.c b/riscos/font.c index ff9127c0b..717b9606c 100644 --- a/riscos/font.c +++ b/riscos/font.c @@ -76,6 +76,7 @@ void nsfont_init(void) nsfont_check_fonts(); + LOG(("Initialise RUfl")); code = rufl_init(); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) @@ -87,6 +88,7 @@ void nsfont_init(void) die("The Unicode font library could not be initialized. " "Please report this to the developers."); } + LOG(("RUfl initialised")); if (rufl_family_list_entries == 0) die("No fonts could be found. At least one font must be " From 35eb251244ee360cedef6ec1143e65b59da604a8 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 17 Oct 2012 14:20:18 +0100 Subject: [PATCH 12/24] Fix "error setting certificate verify locations" problem when the Choices file doesn't exist. Now there's a single place for front ends to set options overrides. Fix nsoption_setnull_charp leak. --- amiga/gui.c | 9 +++-- atari/gui.c | 24 ++++++++----- beos/gui.cpp | 6 ++++ cocoa/NetsurfApp.m | 12 +++++-- desktop/netsurf.c | 1 + desktop/options.h | 12 +++++-- framebuffer/gui.c | 27 ++++++++------- gtk/gui.c | 86 +++++++++++++++++++++------------------------- monkey/main.c | 6 ++++ riscos/gui.c | 81 ++++++++++++++++++++++++------------------- windows/main.c | 12 +++++-- 11 files changed, 164 insertions(+), 112 deletions(-) diff --git a/amiga/gui.c b/amiga/gui.c index 01f149c31..ab94e8ca0 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -540,6 +540,13 @@ nsurl *gui_get_resource_url(const char *path) return url; } +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) +{ + /* Set defaults for absent option strings */ + ami_set_options(); /* check options and set defaults where required */ +} + void gui_init(int argc, char** argv) { BPTR lock = 0; @@ -549,8 +556,6 @@ void gui_init(int argc, char** argv) ami_clipboard_init(); ami_openurl_open(); - ami_set_options(); /* check options and set defaults where required */ - win_destroyed = false; nsscreentitle = ASPrintf("NetSurf %s",netsurf_version); diff --git a/atari/gui.c b/atari/gui.c index a2dac21d3..c2158e05e 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -553,12 +553,12 @@ gui_window_remove_caret(struct gui_window *w) void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) -{ - struct bitmap *bmp_icon; +{ + struct bitmap *bmp_icon; - bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL; - - window_set_icon(g, bmp_icon); + bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL; + + window_set_icon(g, bmp_icon); } void @@ -911,6 +911,17 @@ nsurl *gui_get_resource_url(const char *path) return url; } +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) +{ + /* Set defaults for absent option strings */ + nsoption_setnull_charp(cookie_file, strdup("cookies")); + + if (nsoption_charp(cookie_file) == NULL) { + die("Failed initialising string options"); + } +} + static void gui_init(int argc, char** argv) { char buf[PATH_MAX]; @@ -961,9 +972,6 @@ static void gui_init(int argc, char** argv) urldb_load(nsoption_charp(url_file)); } - if (nsoption_charp(cookie_file) == NULL ){ - nsoption_set_charp(cookie_file, (char*)"cookies"); - } LOG(("Loading cookies from: %s", nsoption_charp(cookie_file) )); if( strlen(nsoption_charp(cookie_file)) ){ urldb_load_cookies(nsoption_charp(cookie_file)); diff --git a/beos/gui.cpp b/beos/gui.cpp index dc3c33538..b275616f5 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -475,6 +475,12 @@ int main(int argc, char** argv) return 0; } +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) +{ + /* Set defaults for absent option strings */ +} + void gui_init(int argc, char** argv) { diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m index 65c9f8cd1..4c2dfc185 100644 --- a/cocoa/NetsurfApp.m +++ b/cocoa/NetsurfApp.m @@ -164,15 +164,21 @@ void cocoa_autorelease( void ) pool = [[NSAutoreleasePool alloc] init]; } +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) +{ + /* Set defaults for absent option strings */ + const char * const ca_bundle = [[[NSBundle mainBundle] pathForResource: @"ca-bundle" ofType: @""] UTF8String]; + + nsoption_setnull_charp(ca_bundle, strdup(ca_bundle)); +} + int main( int argc, char **argv ) { cocoa_autorelease(); const char * const messages = [[[NSBundle mainBundle] pathForResource: @"Messages" ofType: @""] UTF8String]; const char * const options = cocoa_get_options_file(); - const char * const ca_bundle = [[[NSBundle mainBundle] pathForResource: @"ca-bundle" ofType: @""] UTF8String]; - - nsoption_setnull_charp(ca_bundle, strdup(ca_bundle)); netsurf_init(&argc, &argv, options, messages); diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 65765fae4..0b1cffe0a 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -166,6 +166,7 @@ nserror netsurf_init(int *pargc, LOG(("Using '%s' for Options file", options)); nsoption_read(options); + gui_options_init_defaults(); messages_load(messages); diff --git a/desktop/options.h b/desktop/options.h index b96aaec52..53c025c18 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -114,13 +114,16 @@ extern struct ns_options nsoptions; } \ } while (0) -#define nsoption_setnull_charp(OPTION, VALUE) do { \ - if (nsoptions.OPTION == NULL) { \ +#define nsoption_setnull_charp(OPTION, VALUE) \ + do { \ + if (nsoptions.OPTION == NULL) { \ nsoptions.OPTION = VALUE; \ if (*nsoptions.OPTION == 0) { \ free(nsoptions.OPTION); \ nsoptions.OPTION = NULL; \ } \ + } else { \ + free(VALUE); \ } \ } while (0) @@ -175,5 +178,10 @@ int nsoption_snoptionf(char *string, size_t size, unsigned int option, */ void nsoption_commandline(int *pargc, char **argv); +/** + * Set default values for unset front-end specific options + */ +void gui_options_init_defaults(void); + #endif diff --git a/framebuffer/gui.c b/framebuffer/gui.c index b8bb5cede..0f3f7b921 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -476,26 +476,27 @@ process_cmdline(int argc, char** argv) return true; } +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) +{ + /* Set defaults for absent option strings */ + nsoption_setnull_charp(cookie_file, strdup("~/.netsurf/Cookies")); + nsoption_setnull_charp(cookie_jar, strdup("~/.netsurf/Cookies")); + + if (nsoption_charp(cookie_file) == NULL || + nsoption_charp(cookie_jar == NULL)) { + die("Failed initialising cookie options"); + } +} + static void gui_init(int argc, char** argv) { nsfb_t *nsfb; + /* Override, since we have no support for non-core SELECT menu */ nsoption_set_bool(core_select_menu, true); - if (nsoption_charp(cookie_file) == NULL) { - nsoption_set_charp(cookie_file, strdup("~/.netsurf/Cookies")); - LOG(("Using '%s' as Cookies file", nsoption_charp(cookie_file))); - } - - if (nsoption_charp(cookie_jar) == NULL) { - nsoption_set_charp(cookie_jar, strdup("~/.netsurf/Cookies")); - LOG(("Using '%s' as Cookie Jar file", nsoption_charp(cookie_jar))); - } - - if (nsoption_charp(cookie_file) == NULL || nsoption_charp(cookie_jar == NULL)) - die("Failed initialising cookie options"); - if (process_cmdline(argc,argv) != true) die("unable to process command line.\n"); diff --git a/gtk/gui.c b/gtk/gui.c index b24fecfb8..891910407 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -241,11 +241,49 @@ nsgtk_init_glade(char **respath) widWarning = GTK_WIDGET(gtk_builder_get_object(gladeWarning, "labelWarning")); } -static void check_options(char **respath) +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) { char *hdir = getenv("HOME"); char buf[PATH_MAX]; + /* Set defaults for absent option strings */ + snprintf(buf, PATH_MAX, "%s/.netsurf/Cookies", hdir); + nsoption_setnull_charp(cookie_file, strdup(buf)); + nsoption_setnull_charp(cookie_jar, strdup(buf)); + if (nsoption_charp(cookie_file) == NULL || + nsoption_charp(cookie_jar) == NULL) + die("Failed initialising cookie options"); + + if (nsoption_charp(downloads_directory) == NULL) { + snprintf(buf, PATH_MAX, "%s/", hdir); + nsoption_set_charp(downloads_directory, strdup(buf)); + } + + if (nsoption_charp(url_file) == NULL) { + snprintf(buf, PATH_MAX, "%s/.netsurf/URLs", hdir); + nsoption_set_charp(url_file, strdup(buf)); + } + + if (nsoption_charp(hotlist_path) == NULL) { + snprintf(buf, PATH_MAX, "%s/.netsurf/Hotlist", hdir); + nsoption_set_charp(hotlist_path, strdup(buf)); + } + + nsoption_setnull_charp(ca_path, strdup("/etc/ssl/certs")); + + if (nsoption_charp(url_file) == NULL || + nsoption_charp(ca_path) == NULL || + nsoption_charp(downloads_directory) == NULL || + nsoption_charp(hotlist_path) == NULL) { + die("Failed initialising string options"); + } +} + +static void check_options(char **respath) +{ + char *hdir = getenv("HOME"); + char buf[PATH_MAX]; nsoption_set_bool(core_select_menu, true); /* Attempt to handle nonsense status bar widths. These may exist @@ -259,57 +297,13 @@ static void check_options(char **respath) } /* user options should be stored in the users home directory */ - snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir); + snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir); options_file_location = strdup(buf); - - /* VRS - I do not beleive these setting should search the - * resource path, they should just be set to the default - * values! - */ - if (nsoption_charp(cookie_file) == NULL) { - filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/"); - LOG(("Using '%s' as Cookies file", buf)); - nsoption_set_charp(cookie_file, strdup(buf)); - } - if (nsoption_charp(cookie_jar) == NULL) { - filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/"); - LOG(("Using '%s' as Cookie Jar file", buf)); - nsoption_set_charp(cookie_jar, strdup(buf)); - } - if (nsoption_charp(cookie_file) == NULL || - nsoption_charp(cookie_jar) == NULL) - die("Failed initialising cookie options"); - - if (nsoption_charp(url_file) == NULL) { - filepath_sfinddef(respath, buf, "URLs", "~/.netsurf/"); - LOG(("Using '%s' as URL file", buf)); - nsoption_set_charp(url_file, strdup(buf)); - } - - if (nsoption_charp(ca_path) == NULL) { - filepath_sfinddef(respath, buf, "certs", "/etc/ssl/"); - LOG(("Using '%s' as certificate path", buf)); - nsoption_set_charp(ca_path, strdup(buf)); - } - - if (nsoption_charp(downloads_directory) == NULL) { - LOG(("Using '%s' as download directory", hdir)); - nsoption_set_charp(downloads_directory, strdup(hdir)); - } filepath_sfinddef(respath, buf, "icons/", "~/.netsurf/"); LOG(("Using '%s' as Tree icons dir", buf)); tree_set_icon_dir(strdup(buf)); - if (nsoption_charp(hotlist_path) == NULL) { - filepath_sfinddef(respath, buf, "Hotlist", "~/.netsurf/"); - LOG(("Using '%s' as Hotlist file", buf)); - nsoption_set_charp(hotlist_path, strdup(buf)); - } - if (nsoption_charp(hotlist_path) == NULL) - die("Failed initialising hotlist option"); - - filepath_sfinddef(respath, buf, "Print", "~/.netsurf/"); LOG(("Using '%s' as Print Settings file", buf)); print_options_file_location = strdup(buf); diff --git a/monkey/main.c b/monkey/main.c index 45be754e1..03421ef03 100644 --- a/monkey/main.c +++ b/monkey/main.c @@ -91,6 +91,12 @@ static void quit_handler(int argc, char **argv) netsurf_quit = true; } +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) +{ + /* Set defaults for absent option strings */ +} + int main(int argc, char **argv) { diff --git a/riscos/gui.c b/riscos/gui.c index d689094ab..93fc3db65 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -328,6 +328,47 @@ nsurl *gui_get_resource_url(const char *path) return url; } +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) +{ + /* Set defaults for absent option strings */ + nsoption_setnull_charp(theme, strdup("Aletheia")); + nsoption_setnull_charp(toolbar_browser, strdup("0123|58|9")); + nsoption_setnull_charp(toolbar_hotlist, strdup("40|12|3")); + nsoption_setnull_charp(toolbar_history, strdup("0|12|3")); + nsoption_setnull_charp(toolbar_cookies, strdup("0|12")); + nsoption_setnull_charp(ca_bundle, strdup("NetSurf:Resources.ca-bundle")); + nsoption_setnull_charp(cookie_file, strdup("NetSurf:Cookies")); + nsoption_setnull_charp(cookie_jar, strdup(CHOICES_PREFIX "Cookies")); + nsoption_setnull_charp(url_path, strdup("NetSurf:URL")); + nsoption_setnull_charp(url_save, strdup(CHOICES_PREFIX "URL")); + nsoption_setnull_charp(hotlist_path, strdup("NetSurf:Hotlist")); + nsoption_setnull_charp(hotlist_save, strdup(CHOICES_PREFIX "Hotlist")); + nsoption_setnull_charp(recent_path, strdup("NetSurf:Recent")); + nsoption_setnull_charp(recent_save, strdup(CHOICES_PREFIX "Recent")); + nsoption_setnull_charp(theme_path, strdup("NetSurf:Themes")); + nsoption_setnull_charp(theme_save, strdup(CHOICES_PREFIX "Themes")); + + if (nsoption_charp(theme) == NULL || + nsoption_charp(toolbar_browser) == NULL || + nsoption_charp(toolbar_hotlist) == NULL || + nsoption_charp(toolbar_history) == NULL || + nsoption_charp(toolbar_cookies) == NULL || + nsoption_charp(ca_bundle) == NULL || + nsoption_charp(cookie_file) == NULL || + nsoption_charp(cookie_jar) == NULL || + nsoption_charp(url_path) == NULL || + nsoption_charp(url_save) == NULL || + nsoption_charp(hotlist_path) == NULL || + nsoption_charp(hotlist_save) == NULL || + nsoption_charp(recent_path) == NULL || + nsoption_charp(recent_save) == NULL || + nsoption_charp(theme_path) == NULL || + nsoption_charp(theme_save) == NULL) { + die("Failed initialising string options"); + } +} + /** * Initialise the gui (RISC OS specific part). */ @@ -347,6 +388,7 @@ static void gui_init(int argc, char** argv) int length; char *nsdir_temp; byte *base; + char *tree_icons_dir; /* re-enable all FPU exceptions/traps except inexact operations, * which we're not interested in, and underflow which is incorrectly @@ -375,42 +417,11 @@ static void gui_init(int argc, char** argv) ro_plot_patterned_lines = false; } - /* Set defaults for absent option strings */ - nsoption_setnull_charp(theme, strdup("Aletheia")); - nsoption_setnull_charp(toolbar_browser, strdup("0123|58|9")); - nsoption_setnull_charp(toolbar_hotlist, strdup("40|12|3")); - nsoption_setnull_charp(toolbar_history, strdup("0|12|3")); - nsoption_setnull_charp(toolbar_cookies, strdup("0|12")); - nsoption_setnull_charp(ca_bundle, strdup("NetSurf:Resources.ca-bundle")); - nsoption_setnull_charp(cookie_file, strdup("NetSurf:Cookies")); - nsoption_setnull_charp(cookie_jar, strdup(CHOICES_PREFIX "Cookies")); - nsoption_setnull_charp(url_path, strdup("NetSurf:URL")); - nsoption_setnull_charp(url_save, strdup(CHOICES_PREFIX "URL")); - nsoption_setnull_charp(hotlist_path, strdup("NetSurf:Hotlist")); - nsoption_setnull_charp(hotlist_save, strdup(CHOICES_PREFIX "Hotlist")); - nsoption_setnull_charp(recent_path, strdup("NetSurf:Recent")); - nsoption_setnull_charp(recent_save, strdup(CHOICES_PREFIX "Recent")); - nsoption_setnull_charp(theme_path, strdup("NetSurf:Themes")); - nsoption_setnull_charp(theme_save, strdup(CHOICES_PREFIX "Themes")); - - tree_set_icon_dir(strdup("NetSurf:Resources.Icons")); - - if (nsoption_charp(theme) == NULL || - nsoption_charp(toolbar_browser) == NULL || - nsoption_charp(toolbar_hotlist) == NULL || - nsoption_charp(toolbar_history) == NULL || - nsoption_charp(ca_bundle) == NULL || - nsoption_charp(cookie_file) == NULL || - nsoption_charp(cookie_jar) == NULL || - nsoption_charp(url_path) == NULL || - nsoption_charp(url_save) == NULL || - nsoption_charp(hotlist_path) == NULL || - nsoption_charp(hotlist_save) == NULL || - nsoption_charp(recent_path) == NULL || - nsoption_charp(recent_save) == NULL || - nsoption_charp(theme_path) == NULL || - nsoption_charp(theme_save) == NULL) + tree_icons_dir = strdup("NetSurf:Resources.Icons"); + if (tree_icons_dir == NULL) die("Failed initialising string options"); + tree_set_icon_dir(tree_icons_dir); + /* Create our choices directories */ ro_gui_create_dirs(); diff --git a/windows/main.c b/windows/main.c index 6fbf40174..7d158660a 100644 --- a/windows/main.c +++ b/windows/main.c @@ -79,6 +79,15 @@ bool nslog_ensure(FILE *fptr) return true; } +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) +{ + /* Set defaults for absent option strings */ + + /* ensure homepage option has a default */ + nsoption_setnull_charp(homepage_url, strdup(NETSURF_HOMEPAGE)); +} + /** * Entry point from operating system **/ @@ -138,9 +147,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) nsws_window_init_pointers(hInstance); - /* ensure homepage option has a default */ - nsoption_setnull_charp(homepage_url, strdup(NETSURF_HOMEPAGE)); - /* If there is a url specified on the command line use it */ if (argc > 1) { addr = argv[1]; From f18bbd48c7265ef68e8559f20a74bd1b57a4d1cb Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 17 Oct 2012 21:52:43 +0100 Subject: [PATCH 13/24] Improve error handling in html content --- content/content.h | 5 +- desktop/browser.c | 119 ++++++++++++++++++++++++++++++++++ render/html.c | 158 ++++++++++++++++++++++++++++++---------------- render/imagemap.c | 19 ++++-- render/imagemap.h | 2 +- utils/errors.h | 16 ++++- 6 files changed, 255 insertions(+), 64 deletions(-) diff --git a/content/content.h b/content/content.h index b07af4fe1..649f54dfa 100644 --- a/content/content.h +++ b/content/content.h @@ -67,6 +67,7 @@ typedef enum { CONTENT_MSG_READY, /**< may be displayed */ CONTENT_MSG_DONE, /**< finished */ CONTENT_MSG_ERROR, /**< error occurred */ + CONTENT_MSG_ERRORCODE, /**< error occurred return nserror */ CONTENT_MSG_STATUS, /**< new status string */ CONTENT_MSG_REFORMAT, /**< content_reformat done */ CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */ @@ -96,7 +97,9 @@ struct content_rfc5988_link { /** Extra data for some content_msg messages. */ union content_msg_data { /** CONTENT_MSG_ERROR - Error message */ - const char *error; + const char *error; + /** CONTENT_MSG_ERRORCODE - Error code */ + nserror errorcode; /** CONTENT_MSG_REDRAW - Area of content which needs redrawing */ struct { int x, y, width, height; diff --git a/desktop/browser.c b/desktop/browser.c index d3237f5ef..9fa359194 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1187,6 +1187,121 @@ static void browser_window_update_favicon(hlcache_handle *c, nsurl_unref(nsurl); } +/** window callback errorcode handling */ +void +browser_window_callback_errorcode(hlcache_handle *c, + struct browser_window *bw, + nserror code) +{ + const char* message; + + switch (code) { + case NSERROR_OK: + /**< No error */ + message = messages_get("OK"); + break; + + case NSERROR_UNKNOWN: + /**< Unknown error */ + message = messages_get("Unknown"); + break; + + case NSERROR_NOMEM: + /**< Memory exhaustion */ + message = messages_get("NoMemory"); + break; + + case NSERROR_NO_FETCH_HANDLER: + /**< No fetch handler for URL scheme */ + message = messages_get("NoHandler"); + break; + + case NSERROR_NOT_FOUND: + /**< Requested item not found */ + message = messages_get("NotFound"); + break; + + case NSERROR_SAVE_FAILED: + /**< Failed to save data */ + message = messages_get("SaveFailed"); + break; + + case NSERROR_CLONE_FAILED: + /**< Failed to clone handle */ + message = messages_get("CloneFailed"); + break; + + case NSERROR_INIT_FAILED: + /**< Initialisation failed */ + message = messages_get("InitFailed"); + break; + + case NSERROR_MNG_ERROR: + /**< An MNG error occurred */ + message = messages_get("MNGError"); + break; + + case NSERROR_BAD_ENCODING: + /**< The character set is unknown */ + message = messages_get("BadEncoding"); + break; + + case NSERROR_NEED_DATA: + /**< More data needed */ + message = messages_get("NeedData"); + break; + + case NSERROR_BAD_PARAMETER: + /**< Bad Parameter */ + message = messages_get("BadParameter"); + break; + + case NSERROR_INVALID: + /**< Invalid data */ + message = messages_get("Invalid"); + break; + + case NSERROR_BOX_CONVERT: + /**< Box conversion failed */ + message = messages_get("BoxConvert"); + break; + + case NSERROR_STOPPED: + /**< Content conversion stopped */ + message = messages_get("Stopped"); + break; + + case NSERROR_DOM: + /**< DOM call returned error */ + message = messages_get("ParsingFail"); + break; + + case NSERROR_BAD_URL: + /**< Bad URL */ + message = messages_get("BadURL"); + break; + + } + + browser_window_set_status(bw, message); + + /* Only warn the user about errors in top-level windows */ + if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) { + warn_user(message, 0); + } + + if (c == bw->loading_content) { + bw->loading_content = NULL; + } else if (c == bw->current_content) { + bw->current_content = NULL; + browser_window_remove_caret(bw); + } + + hlcache_handle_release(c); + + browser_window_stop_throbber(bw); +} + /** * Callback for fetchcache() for browser window fetches. */ @@ -1320,6 +1435,10 @@ nserror browser_window_callback(hlcache_handle *c, browser_window_refresh, bw); break; + case CONTENT_MSG_ERRORCODE: + browser_window_callback_errorcode(c, bw, event->data.errorcode); + break; + case CONTENT_MSG_ERROR: browser_window_set_status(bw, event->data.error); diff --git a/render/html.c b/render/html.c index 09256a6fa..4e79e085e 100644 --- a/render/html.c +++ b/render/html.c @@ -113,13 +113,14 @@ static void html_box_convert_done(html_content *c, bool success) LOG(("Done XML to box (%p)", c)); /* Clean up and report error if unsuccessful or aborted */ - if ((success == false) || c->aborted) { + if ((success == false) || (c->aborted)) { + if (success == false) { + msg_data.errorcode = NSERROR_BOX_CONVERT; + } else { + msg_data.errorcode = NSERROR_STOPPED; + } html_destroy_objects(c); - if (success == false) - msg_data.error = messages_get("NoMemory"); - else - msg_data.error = messages_get("Stopped"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data); content_set_error(&c->base); return; } @@ -134,19 +135,22 @@ static void html_box_convert_done(html_content *c, bool success) exc = dom_document_get_document_element(c->document, (void *) &html); if ((exc != DOM_NO_ERR) || (html == NULL)) { + /** @todo should this call html_destroy_objects(c); + * like the other error paths + */ LOG(("error retrieving html element from dom")); - msg_data.error = messages_get("ParsingFail"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + msg_data.errorcode = NSERROR_DOM; + content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data); content_set_error(&c->base); return; } /* extract image maps - can't do this sensibly in xml_to_box */ - if (imagemap_extract(c) == false) { + msg_data.errorcode = imagemap_extract(c); + if (msg_data.errorcode != NSERROR_OK) { LOG(("imagemap extraction failed")); html_destroy_objects(c); - msg_data.error = messages_get("NoMemory"); - content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); + content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data); content_set_error(&c->base); dom_node_unref(html); return; @@ -159,8 +163,9 @@ static void html_box_convert_done(html_content *c, bool success) content_set_ready(&c->base); - if (c->base.active == 0) + if (c->base.active == 0) { content_set_done(&c->base); + } html_set_status(c, ""); dom_node_unref(html); @@ -413,9 +418,62 @@ html_create(const content_handler *handler, return NSERROR_OK; } +static nserror +parse_chunk_to_nserror(dom_hubbub_error error) +{ + switch (error) { + + /* HUBBUB_REPROCESS is not handled here because it can + * never occur outside the hubbub treebuilder + */ + + case DOM_HUBBUB_OK: + /* parsed ok */ + return NSERROR_OK; + + case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED): + /* hubbub input paused */ + return NSERROR_OK; + + case DOM_HUBBUB_NOMEM: + /* out of memory error from DOM */ + return NSERROR_NOMEM; + + case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE): + /* encoding changed */ + return NSERROR_ENCODING_CHANGE; + + case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM): + /* out of memory error from parser */ + return NSERROR_NOMEM; + + case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM): + return NSERROR_BAD_PARAMETER; + + case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID): + return NSERROR_INVALID; + + case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND): + return NSERROR_NOT_FOUND; + + case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA): + return NSERROR_NEED_DATA; + + case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING): + return NSERROR_BAD_ENCODING; + + case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN): + /* currently only generated by the libdom hubbub binding */ + default: + /* unknown error */ + /** @todo better error handling and reporting */ + return NSERROR_UNKNOWN; + } + return NSERROR_UNKNOWN; +} -static bool +static nserror html_process_encoding_change(struct content *c, const char *data, unsigned int size) @@ -425,34 +483,30 @@ html_process_encoding_change(struct content *c, const char *encoding; const char *source_data; unsigned long source_size; - union content_msg_data msg_data; /* Retrieve new encoding */ encoding = dom_hubbub_parser_get_encoding(html->parser, &html->encoding_source); - if (encoding == NULL) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - return false; + return NSERROR_NOMEM; } - if (html->encoding != NULL) + if (html->encoding != NULL) { free(html->encoding); + } html->encoding = strdup(encoding); if (html->encoding == NULL) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - return false; + return NSERROR_NOMEM; } /* Destroy binding */ dom_hubbub_parser_destroy(html->parser); html->parser = NULL; - if (html->document != NULL) + if (html->document != NULL) { dom_node_unref(html->document); + } /* Create new binding, using the new encoding */ html->parser = dom_hubbub_parser_create(html->encoding, @@ -468,9 +522,7 @@ html_process_encoding_change(struct content *c, free(html->encoding); html->encoding = strdup("Windows-1252"); if (html->encoding == NULL) { - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - return false; + return NSERROR_NOMEM; } html->parser = dom_hubbub_parser_create(html->encoding, @@ -486,10 +538,7 @@ html_process_encoding_change(struct content *c, * parser errors back instead of everything being * OOM */ - - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - return false; + return NSERROR_NOMEM; } } @@ -498,21 +547,16 @@ html_process_encoding_change(struct content *c, /* Reprocess all the data. This is safe because * the encoding is now specified at parser start which means - * it cannot be changed again. */ - error = dom_hubbub_parser_parse_chunk(html->parser, (const uint8_t *)source_data, source_size); - - if ((error == DOM_HUBBUB_OK) || - (error == (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED))) { - return true; - } - - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - - return false; + * it cannot be changed again. + */ + error = dom_hubbub_parser_parse_chunk(html->parser, + (const uint8_t *)source_data, + source_size); + return parse_chunk_to_nserror(error); } + /** * Process data for CONTENT_HTML. */ @@ -524,21 +568,27 @@ html_process_data(struct content *c, const char *data, unsigned int size) dom_hubbub_error error; union content_msg_data msg_data; - error = dom_hubbub_parser_parse_chunk(html->parser, (const uint8_t *) data, size); + msg_data.errorcode = NSERROR_OK; /* assume its all going to be ok */ - if ((error == DOM_HUBBUB_OK) || - (error == (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED))) { - return true; - } else if (error == (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE)) { - return html_process_encoding_change(c, data, size); - } + error = dom_hubbub_parser_parse_chunk(html->parser, + (const uint8_t *) data, + size); - /** @todo better error handling and reporting */ - msg_data.error = messages_get("NoMemory"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - return false; - + msg_data.errorcode = parse_chunk_to_nserror(error); + + /* deal with encoding change */ + if (msg_data.errorcode == NSERROR_ENCODING_CHANGE) { + msg_data.errorcode = html_process_encoding_change(c, data, size); + } + + /* broadcast the error if necessary */ + if (msg_data.errorcode != NSERROR_OK) { + content_broadcast(c, CONTENT_MSG_ERRORCODE, msg_data); + return false; + } + + return true; } diff --git a/render/imagemap.c b/render/imagemap.c index bf90443c4..c41b86d0b 100644 --- a/render/imagemap.c +++ b/render/imagemap.c @@ -251,23 +251,25 @@ void imagemap_dump(html_content *c) * \param map_str A dom_string which is "map" * \return false on memory exhaustion, true otherwise */ -bool +nserror imagemap_extract(html_content *c) { dom_nodelist *nlist; dom_exception exc; unsigned long mapnr; uint32_t maybe_maps; - + nserror ret = NSERROR_OK; + exc = dom_document_get_elements_by_tag_name(c->document, corestring_dom_map, &nlist); if (exc != DOM_NO_ERR) { - return false; + return NSERROR_DOM; } exc = dom_nodelist_get_length(nlist, &maybe_maps); if (exc != DOM_NO_ERR) { + ret = NSERROR_DOM; goto out_nlist; } @@ -276,6 +278,7 @@ imagemap_extract(html_content *c) dom_string *name; exc = dom_nodelist_item(nlist, mapnr, &node); if (exc != DOM_NO_ERR) { + ret = NSERROR_DOM; goto out_nlist; } @@ -283,6 +286,7 @@ imagemap_extract(html_content *c) &name); if (exc != DOM_NO_ERR) { dom_node_unref(node); + ret = NSERROR_DOM; goto out_nlist; } @@ -292,6 +296,7 @@ imagemap_extract(html_content *c) &name); if (exc != DOM_NO_ERR) { dom_node_unref(node); + ret = NSERROR_DOM; goto out_nlist; } } @@ -301,6 +306,7 @@ imagemap_extract(html_content *c) if (imagemap_extract_map(node, c, &entry) == false) { dom_string_unref(name); dom_node_unref(node); + ret = NSERROR_NOMEM; /** @todo check this */ goto out_nlist; } @@ -313,6 +319,7 @@ imagemap_extract(html_content *c) (imagemap_add(c, name, entry) == false)) { dom_string_unref(name); dom_node_unref(node); + ret = NSERROR_NOMEM; /** @todo check this */ goto out_nlist; } } @@ -321,14 +328,12 @@ imagemap_extract(html_content *c) dom_node_unref(node); } - dom_nodelist_unref(nlist); - - return true; out_nlist: dom_nodelist_unref(nlist); - return false; + + return ret; } /** diff --git a/render/imagemap.h b/render/imagemap.h index edbfea08f..d450cda86 100644 --- a/render/imagemap.h +++ b/render/imagemap.h @@ -28,7 +28,7 @@ struct hlcache_handle; void imagemap_destroy(struct html_content *c); void imagemap_dump(struct html_content *c); -bool imagemap_extract(struct html_content *c); +nserror imagemap_extract(struct html_content *c); nsurl *imagemap_get(struct html_content *c, const char *key, unsigned long x, unsigned long y, diff --git a/utils/errors.h b/utils/errors.h index 546709703..9ad613da6 100644 --- a/utils/errors.h +++ b/utils/errors.h @@ -29,6 +29,8 @@ typedef enum { NSERROR_OK, /**< No error */ + NSERROR_UNKNOWN, /**< Unknown error - DO *NOT* USE */ + NSERROR_NOMEM, /**< Memory exhaustion */ NSERROR_NO_FETCH_HANDLER, /**< No fetch handler for URL scheme */ @@ -47,7 +49,19 @@ typedef enum { NSERROR_NEED_DATA, /**< More data needed */ - NSERROR_BAD_URL /**< More data needed */ + NSERROR_ENCODING_CHANGE, /**< The character changed */ + + NSERROR_BAD_PARAMETER, /**< Bad Parameter */ + + NSERROR_INVALID, /**< Invalid data */ + + NSERROR_BOX_CONVERT, /**< Box conversion failed */ + + NSERROR_STOPPED, /**< Content conversion stopped */ + + NSERROR_DOM, /**< DOM call returned error */ + + NSERROR_BAD_URL /**< Bad URL */ } nserror; #endif From a1d052399a9714db382e5b4f7f6c97665df6e4d8 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 18 Oct 2012 10:40:53 +0100 Subject: [PATCH 14/24] fix warnings --- desktop/browser.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/desktop/browser.c b/desktop/browser.c index 9fa359194..89484609e 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1188,7 +1188,7 @@ static void browser_window_update_favicon(hlcache_handle *c, } /** window callback errorcode handling */ -void +static void browser_window_callback_errorcode(hlcache_handle *c, struct browser_window *bw, nserror code) @@ -1201,11 +1201,6 @@ browser_window_callback_errorcode(hlcache_handle *c, message = messages_get("OK"); break; - case NSERROR_UNKNOWN: - /**< Unknown error */ - message = messages_get("Unknown"); - break; - case NSERROR_NOMEM: /**< Memory exhaustion */ message = messages_get("NoMemory"); @@ -1251,6 +1246,11 @@ browser_window_callback_errorcode(hlcache_handle *c, message = messages_get("NeedData"); break; + case NSERROR_ENCODING_CHANGE: + /**< The character set encoding change was unhandled */ + message = messages_get("EncodingChanged"); + break; + case NSERROR_BAD_PARAMETER: /**< Bad Parameter */ message = messages_get("BadParameter"); @@ -1281,6 +1281,12 @@ browser_window_callback_errorcode(hlcache_handle *c, message = messages_get("BadURL"); break; + default: + case NSERROR_UNKNOWN: + /**< Unknown error */ + message = messages_get("Unknown"); + break; + } browser_window_set_status(bw, message); From 004e61e138c78017077db4c4c41ea660d4f614df Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Thu, 18 Oct 2012 23:21:33 +0200 Subject: [PATCH 15/24] Use malloc instead of alloca. (Fixes drag and drop) --- atari/browser_win.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/atari/browser_win.c b/atari/browser_win.c index 8beb39645..f6daf37c4 100755 --- a/atari/browser_win.c +++ b/atari/browser_win.c @@ -103,6 +103,9 @@ int window_create( struct gui_window * gw, } if( inflags & WIDGET_RESIZE ){ flags |= ( SIZER ); + } + if( inflags & WIDGET_STATUSBAR ){ + flags |= ( INFO ); } gw->root = malloc( sizeof(struct s_gui_win_root) ); @@ -141,8 +144,10 @@ int window_create( struct gui_window * gw, /* create statusbar component: */ if( sb ) { - gw->root->statusbar = sb_create( gw ); - mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp ); + gw->root->statusbar = sb_create( gw ); +#ifdef WITH_COMOPONENT_STATUSBAR + mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp ); +#endif } else { gw->root->statusbar = NULL; } @@ -231,7 +236,7 @@ void window_open( struct gui_window * gw, GRECT pos ) plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h); gw->browser->attached = true; if( gw->root->statusbar != NULL ){ - gw->root->statusbar->attached = true; + sb_attach(gw->root->statusbar, gw); } tb_adjust_size( gw ); /*TBD: get already present content and set size? */ @@ -247,7 +252,7 @@ void window_update_back_forward( struct gui_window * gw) tb_update_buttons( gw, -1 ); } -void window_set_stauts( struct gui_window * gw , char * text ) +void window_set_stauts(struct gui_window * gw , char * text ) { if( gw->root == NULL ) return; @@ -428,13 +433,11 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) if( !strncmp( ext, "ARGS", 4) && dd_msg > 0) { ddreply(dd_hdl, DD_OK); - buff = (char*)alloca(sizeof(char)*(size+1)); - if( buff != NULL ) + buff = (char*)malloc(sizeof(char)*(size+1)); + if (buff != NULL) { - if( Fread(dd_hdl, size, buff ) == size) - { + if (Fread(dd_hdl, size, buff ) == size) buff[size] = 0; - } LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n", (char*)buff, (char*)&ext, size, mx, my @@ -451,8 +454,9 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) utf8_convert_ret ret; char *utf8_fn; - ret = utf8_from_local_encoding( buff, 0, &utf8_fn); - if (ret != UTF8_CONVERT_OK) { + ret = utf8_from_local_encoding(buff, 0, &utf8_fn); + if (ret != UTF8_CONVERT_OK) { + free(buff); /* A bad encoding should never happen */ LOG(("utf8_from_local_encoding failed")); assert(ret != UTF8_CONVERT_BADENC); @@ -463,7 +467,8 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) mx+gw->browser->scroll.current.x, my+gw->browser->scroll.current.y, utf8_fn ); - free( utf8_fn ); + free(utf8_fn); + free(buff); } } } From 7d18cf2b413753fbe63a602e9572c96196643a18 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Fri, 19 Oct 2012 00:07:37 +0200 Subject: [PATCH 16/24] Use malloc instead of alloca. --- atari/findfile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/atari/findfile.c b/atari/findfile.c index 3a06f61e9..93bf4638e 100755 --- a/atari/findfile.c +++ b/atari/findfile.c @@ -41,7 +41,7 @@ char * local_file_to_url( const char * filename ) return( NULL ); } - char * fname_local = alloca( strlen(filename)+1 ); + char * fname_local = malloc( strlen(filename)+1 ); char * start = (char*)fname_local; strcpy( start, filename ); @@ -72,6 +72,9 @@ char * local_file_to_url( const char * filename ) url = malloc( strlen(start) + FILE_SCHEME_PREFIX_LEN + 1); strcpy( url, FILE_SCHEME_PREFIX ); strcat( url, start ); + + free(fname_local); + return( url ); #undef BACKSLASH } From c528d108640f9cdc7c5268a1e464b7e18b04cd59 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Fri, 19 Oct 2012 00:14:11 +0200 Subject: [PATCH 17/24] Use GEM Window Statusbar when WITH_CUSTOM_STATUSBAR is undefined. --- atari/statusbar.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- atari/statusbar.h | 12 ++++++++---- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/atari/statusbar.c b/atari/statusbar.c index f4dbbe578..08a62c55d 100755 --- a/atari/statusbar.c +++ b/atari/statusbar.c @@ -44,7 +44,8 @@ #include "atari/res/netsurf.rsh" #include "atari/plot/plot.h" #include "atari/osspec.h" - + +#ifdef WITH_CUSTOM_STATUSBAR extern int atari_plot_vdi_handle; static @@ -182,7 +183,8 @@ void sb_destroy( CMP_STATUSBAR s ) } void sb_set_text( CMP_STATUSBAR sb , char * text ) -{ +{ + LGRECT work; assert( sb != NULL ); assert( sb->comp != NULL ); @@ -197,4 +199,42 @@ void sb_set_text( CMP_STATUSBAR sb , char * text ) work.g_x, work.g_y, work.g_w, work.g_h ); } } +} + +#else + +CMP_STATUSBAR sb_create( struct gui_window * gw ) +{ + CMP_STATUSBAR s = malloc( sizeof(struct s_statusbar) ); + s->attached = false; + sb_set_text( s, (char*)"" ); + return( s ); } + +void sb_destroy( CMP_STATUSBAR s ) +{ + LOG(("%s\n", __FUNCTION__ )); + if( s ) { + free( s ); + } +} + +void sb_attach(CMP_STATUSBAR sb, struct gui_window * gw) +{ + sb->aes_win = gw->root->handle->handle; + sb->attached = true; +} + +void sb_set_text(CMP_STATUSBAR sb, char * text ) +{ + LGRECT work; + assert( sb != NULL ); + strncpy(sb->text, text, STATUSBAR_MAX_SLEN); + sb->text[STATUSBAR_MAX_SLEN]=0; + sb->textlen = strlen(sb->text); + if(sb->attached){ + wind_set_str(sb->aes_win, WF_INFO, sb->text); + } +} + +#endif diff --git a/atari/statusbar.h b/atari/statusbar.h index fd01a0c79..fc6749e91 100755 --- a/atari/statusbar.h +++ b/atari/statusbar.h @@ -23,15 +23,19 @@ #define STATUSBAR_MAX_SLEN 255 struct s_statusbar -{ - COMPONENT * comp; +{ +#ifdef WITH_COMPONENT_STATUSBAR + COMPONENT * comp; +#endif char text[STATUSBAR_MAX_SLEN+1]; size_t textlen; - bool attached; + bool attached; + short aes_win; }; CMP_STATUSBAR sb_create( struct gui_window * gw ); void sb_destroy( CMP_STATUSBAR s ); -void sb_set_text( CMP_STATUSBAR sb , char * text ); +void sb_set_text( CMP_STATUSBAR sb , char * text ); +void sb_attach(CMP_STATUSBAR sb, struct gui_window * gw); #endif From 8136ad44a9295117c2f31cbb199a48e9b3125cf3 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Fri, 19 Oct 2012 00:41:00 +0100 Subject: [PATCH 18/24] Fix links. --- !NetSurf/Resources/de/welcome.html,faf | 6 +++--- !NetSurf/Resources/it/welcome.html,faf | 8 ++++---- !NetSurf/Resources/ja/welcome.html,faf | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/!NetSurf/Resources/de/welcome.html,faf b/!NetSurf/Resources/de/welcome.html,faf index fbbed0399..8cbcbd8c5 100644 --- a/!NetSurf/Resources/de/welcome.html,faf +++ b/!NetSurf/Resources/de/welcome.html,faf @@ -10,9 +10,9 @@
diff --git a/!NetSurf/Resources/it/welcome.html,faf b/!NetSurf/Resources/it/welcome.html,faf index 2d44436de..dd9c63e1b 100644 --- a/!NetSurf/Resources/it/welcome.html,faf +++ b/!NetSurf/Resources/it/welcome.html,faf @@ -10,9 +10,9 @@
@@ -61,4 +61,4 @@
- \ No newline at end of file + diff --git a/!NetSurf/Resources/ja/welcome.html,faf b/!NetSurf/Resources/ja/welcome.html,faf index 152847443..ce7b36343 100644 --- a/!NetSurf/Resources/ja/welcome.html,faf +++ b/!NetSurf/Resources/ja/welcome.html,faf @@ -11,9 +11,9 @@
From df70c7daa3632d9aab9a59e73c6d3935e870fe43 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 19 Oct 2012 20:27:10 +0100 Subject: [PATCH 19/24] Ensure stack size is at least 128KB --- amiga/gui.c | 1 + 1 file changed, 1 insertion(+) diff --git a/amiga/gui.c b/amiga/gui.c index ab94e8ca0..15ac1f553 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -158,6 +158,7 @@ static char *current_user_dir; const char tree_directory_icon_name[] = "def_drawer.info"; const char tree_content_icon_name[] = "def_project.info"; +static const __attribute__((used)) char *stack_cookie = "\0$STACK:131072\0"; static struct DrawInfo *dri; From aa3760bd550fe2a625947828fb7847693657aba2 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Sat, 20 Oct 2012 13:48:59 +0100 Subject: [PATCH 20/24] Link against libiconv --- amiga/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amiga/Makefile.target b/amiga/Makefile.target index f0eabf86e..61de77b36 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -64,7 +64,7 @@ else ifeq ($(SUBTARGET),os3) LDFLAGS += -liconv else - LDFLAGS += -lauto -lpbl + LDFLAGS += -lauto -lpbl -liconv endif ifeq ($(NETSURF_AMIGA_CAIRO_AVAILABLE),yes) From 02996802d92a76f380a9db4d7e138b91d8d06014 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Sat, 20 Oct 2012 13:53:40 +0100 Subject: [PATCH 21/24] Revert "Link against libiconv" This reverts commit aa3760bd550fe2a625947828fb7847693657aba2. --- amiga/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amiga/Makefile.target b/amiga/Makefile.target index 61de77b36..f0eabf86e 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -64,7 +64,7 @@ else ifeq ($(SUBTARGET),os3) LDFLAGS += -liconv else - LDFLAGS += -lauto -lpbl -liconv + LDFLAGS += -lauto -lpbl endif ifeq ($(NETSURF_AMIGA_CAIRO_AVAILABLE),yes) From 0a9e8ee734c0cdd7ee11f3312269a0e3460fd8b6 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Sun, 21 Oct 2012 01:58:09 +0100 Subject: [PATCH 22/24] Revert "Revert "Link against libiconv"" This reverts commit 02996802d92a76f380a9db4d7e138b91d8d06014. --- amiga/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amiga/Makefile.target b/amiga/Makefile.target index f0eabf86e..61de77b36 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -64,7 +64,7 @@ else ifeq ($(SUBTARGET),os3) LDFLAGS += -liconv else - LDFLAGS += -lauto -lpbl + LDFLAGS += -lauto -lpbl -liconv endif ifeq ($(NETSURF_AMIGA_CAIRO_AVAILABLE),yes) From 5097223570a4f1a529b518e14fcace5d3578f55f Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 22 Oct 2012 16:17:09 +0100 Subject: [PATCH 23/24] add javascript build support to framebuffer --- framebuffer/Makefile.target | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target index 3ca054069..2a41f4128 100644 --- a/framebuffer/Makefile.target +++ b/framebuffer/Makefile.target @@ -17,6 +17,8 @@ NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF +NETSURF_FEATURE_JS_CFLAGS := -DWITH_JS -DJS_HAS_FILE_OBJECT=0 +NETSURF_FEATURE_MOZJS_CFLAGS := -DWITH_MOZJS -DJS_HAS_FILE_OBJECT=0 CFLAGS += -Dnsframebuffer @@ -39,6 +41,8 @@ CFLAGS += '-DNETSURF_FB_FONT_FANTASY="$(NETSURF_FB_FONT_FANTASY)"' $(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,Sprite)) $(eval $(call pkg_config_find_and_add,BMP,libnsbmp,BMP)) $(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF)) +$(eval $(call pkg_config_find_and_add,MOZJS,mozjs185,JavaScript)) +$(eval $(call pkg_config_find_and_add,JS,mozilla-js,JavaScript)) CFLAGS += -std=c99 -g -I. -Dsmall $(WARNFLAGS) \ -D_BSD_SOURCE \ From 9629e428a55961106fcd15fd9e0ad9de0649f314 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 22 Oct 2012 16:37:31 +0100 Subject: [PATCH 24/24] add javascript compilation to monkey --- monkey/Makefile.target | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/monkey/Makefile.target b/monkey/Makefile.target index b72734fe3..569837bac 100644 --- a/monkey/Makefile.target +++ b/monkey/Makefile.target @@ -8,26 +8,30 @@ # ---------------------------------------------------------------------------- - LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libdom libcss) - LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl) +LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libdom libcss) +LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl) - # define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here - NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG - NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE - NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP - NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF - NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG - NETSURF_FEATURE_WEBP_CFLAGS := -DWITH_WEBP +# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here +NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG +NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE +NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP +NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF +NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG +NETSURF_FEATURE_WEBP_CFLAGS := -DWITH_WEBP +NETSURF_FEATURE_JS_CFLAGS := -DWITH_JS -DJS_HAS_FILE_OBJECT=0 +NETSURF_FEATURE_MOZJS_CFLAGS := -DWITH_MOZJS -DJS_HAS_FILE_OBJECT=0 - # add a line similar to below for each optional pkg-configed lib here - $(eval $(call pkg_config_find_and_add,NSSVG,libsvgtiny,SVG)) - $(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,Sprite)) - $(eval $(call pkg_config_find_and_add,BMP,libnsbmp,BMP)) - $(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF)) - $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG )) +# add a line similar to below for each optional pkg-configed lib here +$(eval $(call pkg_config_find_and_add,NSSVG,libsvgtiny,SVG)) +$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,Sprite)) +$(eval $(call pkg_config_find_and_add,BMP,libnsbmp,BMP)) +$(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF)) +$(eval $(call pkg_config_find_and_add,PNG,libpng,PNG )) +$(eval $(call pkg_config_find_and_add,MOZJS,mozjs185,JavaScript)) +$(eval $(call pkg_config_find_and_add,JS,mozilla-js,JavaScript)) - # no pkg-config for this library - $(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp -lvpx,WebP (libwebp))) +# no pkg-config for this library +$(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp -lvpx,WebP (libwebp))) MONKEYCFLAGS := -std=c99 -Dmonkey -Dnsmonkey \ -D_BSD_SOURCE \