netsurf: branch master updated. release/3.2-289-g1ea422a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/1ea422a9d11f7253f08cc...
...commit http://git.netsurf-browser.org/netsurf.git/commit/1ea422a9d11f7253f08cc4c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/1ea422a9d11f7253f08cc4cc3...
The branch, master has been updated
via 1ea422a9d11f7253f08cc4cc39cf0cbfee79c030 (commit)
via 0f123255069b9c46d4a610c41d533b19e058aa77 (commit)
via 368861faab1cd34a24a72c202d8f8b54d05ab47e (commit)
via 3c82214998d2503cc9d4d080fea3fbf2231ff7bb (commit)
from 98b6d02df61ce2917b001c4647d8c6b623b610e7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=1ea422a9d11f7253f08...
commit 1ea422a9d11f7253f08cc4cc39cf0cbfee79c030
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove old URL header includes.
diff --git a/desktop/download.c b/desktop/download.c
index 6e2aad8..131bc80 100644
--- a/desktop/download.c
+++ b/desktop/download.c
@@ -28,7 +28,6 @@
#include "content/llcache.h"
#include "utils/corestrings.h"
#include "utils/http.h"
-#include "utils/url.h"
#include "utils/utils.h"
#include "desktop/download.h"
#include "desktop/gui_download.h"
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 7c7ce9d..21fedfd 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -30,7 +30,6 @@
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "utils/log.h"
-#include "utils/url.h"
#include "utils/utf8.h"
#include "utils/utils.h"
#include "utils/messages.h"
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=0f123255069b9c46d4a...
commit 0f123255069b9c46d4a610c41d533b19e058aa77
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Don't need old URL header.
diff --git a/amiga/icon.c b/amiga/icon.c
index 01802d3..f8f0dad 100644
--- a/amiga/icon.c
+++ b/amiga/icon.c
@@ -46,7 +46,6 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
-#include "utils/url.h"
#include "utils/file.h"
#define THUMBNAIL_WIDTH 100 /* Icon sizes for thumbnails, usually the same as */
diff --git a/amiga/misc.c b/amiga/misc.c
index 3bd4937..4dedf71 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -35,7 +35,6 @@
#include "utils/log.h"
#include "utils/corestrings.h"
#include "utils/messages.h"
-#include "utils/url.h"
#include "utils/file.h"
#include "utils/utils.h"
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=368861faab1cd34a24a...
commit 368861faab1cd34a24a72c202d8f8b54d05ab47e
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove useless includes of utils/url.h
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 61ef9ad..a8c05e8 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -38,7 +38,6 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
-#include "utils/url.h"
#include "utils/utils.h"
#include "desktop/version.h"
#include "desktop/browser.h"
diff --git a/riscos/save.c b/riscos/save.c
index bfde316..a45cd12 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -39,7 +39,6 @@
#include "utils/config.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/url.h"
#include "utils/utf8.h"
#include "utils/utils.h"
#include "content/content.h"
diff --git a/riscos/window.c b/riscos/window.c
index 4e07293..a7c08b1 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -45,7 +45,6 @@
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/talloc.h"
-#include "utils/url.h"
#include "utils/file.h"
#include "utils/utf8.h"
#include "utils/utils.h"
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3c82214998d2503cc9d...
commit 3c82214998d2503cc9d4d080fea3fbf2231ff7bb
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Don't need the old url header.
diff --git a/gtk/viewdata.c b/gtk/viewdata.c
index 004bb19..b5b5a5a 100644
--- a/gtk/viewdata.c
+++ b/gtk/viewdata.c
@@ -33,7 +33,6 @@
#include "utils/nsoption.h"
#include "utils/utf8.h"
#include "utils/messages.h"
-#include "utils/url.h"
#include "utils/utils.h"
#include "utils/file.h"
#include "utils/filepath.h"
diff --git a/gtk/viewsource.c b/gtk/viewsource.c
index 3c70beb..7ff8ad6 100644
--- a/gtk/viewsource.c
+++ b/gtk/viewsource.c
@@ -19,7 +19,6 @@
#include <gtk/gtk.h>
#include "utils/utils.h"
-#include "utils/url.h"
#include "utils/utf8.h"
#include "utils/messages.h"
#include "desktop/browser.h"
-----------------------------------------------------------------------
Summary of changes:
amiga/icon.c | 1 -
amiga/misc.c | 1 -
desktop/download.c | 1 -
desktop/netsurf.c | 1 -
gtk/viewdata.c | 1 -
gtk/viewsource.c | 1 -
riscos/dialog.c | 1 -
riscos/save.c | 1 -
riscos/window.c | 1 -
9 files changed, 9 deletions(-)
diff --git a/amiga/icon.c b/amiga/icon.c
index 01802d3..f8f0dad 100644
--- a/amiga/icon.c
+++ b/amiga/icon.c
@@ -46,7 +46,6 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
-#include "utils/url.h"
#include "utils/file.h"
#define THUMBNAIL_WIDTH 100 /* Icon sizes for thumbnails, usually the same as */
diff --git a/amiga/misc.c b/amiga/misc.c
index 3bd4937..4dedf71 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -35,7 +35,6 @@
#include "utils/log.h"
#include "utils/corestrings.h"
#include "utils/messages.h"
-#include "utils/url.h"
#include "utils/file.h"
#include "utils/utils.h"
diff --git a/desktop/download.c b/desktop/download.c
index 6e2aad8..131bc80 100644
--- a/desktop/download.c
+++ b/desktop/download.c
@@ -28,7 +28,6 @@
#include "content/llcache.h"
#include "utils/corestrings.h"
#include "utils/http.h"
-#include "utils/url.h"
#include "utils/utils.h"
#include "desktop/download.h"
#include "desktop/gui_download.h"
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 7c7ce9d..21fedfd 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -30,7 +30,6 @@
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "utils/log.h"
-#include "utils/url.h"
#include "utils/utf8.h"
#include "utils/utils.h"
#include "utils/messages.h"
diff --git a/gtk/viewdata.c b/gtk/viewdata.c
index 004bb19..b5b5a5a 100644
--- a/gtk/viewdata.c
+++ b/gtk/viewdata.c
@@ -33,7 +33,6 @@
#include "utils/nsoption.h"
#include "utils/utf8.h"
#include "utils/messages.h"
-#include "utils/url.h"
#include "utils/utils.h"
#include "utils/file.h"
#include "utils/filepath.h"
diff --git a/gtk/viewsource.c b/gtk/viewsource.c
index 3c70beb..7ff8ad6 100644
--- a/gtk/viewsource.c
+++ b/gtk/viewsource.c
@@ -19,7 +19,6 @@
#include <gtk/gtk.h>
#include "utils/utils.h"
-#include "utils/url.h"
#include "utils/utf8.h"
#include "utils/messages.h"
#include "desktop/browser.h"
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 61ef9ad..a8c05e8 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -38,7 +38,6 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
-#include "utils/url.h"
#include "utils/utils.h"
#include "desktop/version.h"
#include "desktop/browser.h"
diff --git a/riscos/save.c b/riscos/save.c
index bfde316..a45cd12 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -39,7 +39,6 @@
#include "utils/config.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/url.h"
#include "utils/utf8.h"
#include "utils/utils.h"
#include "content/content.h"
diff --git a/riscos/window.c b/riscos/window.c
index 4e07293..a7c08b1 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -45,7 +45,6 @@
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/talloc.h"
-#include "utils/url.h"
#include "utils/file.h"
#include "utils/utf8.h"
#include "utils/utils.h"
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.2-285-g98b6d02
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/98b6d02df61ce2917b001...
...commit http://git.netsurf-browser.org/netsurf.git/commit/98b6d02df61ce2917b001c4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/98b6d02df61ce2917b001c464...
The branch, master has been updated
via 98b6d02df61ce2917b001c4647d8c6b623b610e7 (commit)
from 02ff3920ce22f4a4120cab8cee3a72a244604732 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=98b6d02df61ce2917b0...
commit 98b6d02df61ce2917b001c4647d8c6b623b610e7
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Move host_is_ip_address into urldb, as that's the only thing that cares.
diff --git a/content/urldb.c b/content/urldb.c
index 650c7bc..bf873c6 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1580,6 +1580,99 @@ struct host_part *urldb_add_host_node(const char *part,
return d;
}
+
+/**
+ * Check whether a host string is an IP address.
+ *
+ * This call detects IPv4 addresses (all of dotted-quad or subsets,
+ * decimal or hexadecimal notations) and IPv6 addresses (including
+ * those containing embedded IPv4 addresses.)
+ *
+ * \param host a hostname terminated by '\0'
+ * \return true if the hostname is an IP address, false otherwise
+ */
+static bool urldb__host_is_ip_address(const char *host)
+{
+ struct in_addr ipv4;
+ size_t host_len = strlen(host);
+ const char *sane_host;
+ const char *slash;
+#ifndef NO_IPV6
+ struct in6_addr ipv6;
+ char ipv6_addr[64];
+#endif
+ /** @todo FIXME Some parts of urldb.c make confusions between hosts
+ * and "prefixes", we can sometimes be erroneously passed more than
+ * just a host. Sometimes we may be passed trailing slashes, or even
+ * whole path segments. A specific criminal in this class is
+ * urldb_iterate_partial, which takes a prefix to search for, but
+ * passes that prefix to functions that expect only hosts.
+ *
+ * For the time being, we will accept such calls; we check if there
+ * is a / in the host parameter, and if there is, we take a copy and
+ * replace the / with a \0. This is not a permanent solution; we
+ * should search through NetSurf and find all the callers that are
+ * in error and fix them. When doing this task, it might be wise
+ * to replace the hideousness below with code that doesn't have to do
+ * this, and add assert(strchr(host, '/') == NULL); somewhere.
+ * -- rjek - 2010-11-04
+ */
+
+ slash = strchr(host, '/');
+ if (slash == NULL) {
+ sane_host = host;
+ } else {
+ char *c = strdup(host);
+ c[slash - host] = '\0';
+ sane_host = c;
+ host_len = slash - host - 1;
+ LOG(("WARNING: called with non-host '%s'", host));
+ }
+
+ if (strspn(sane_host, "0123456789abcdefABCDEF[].:") < host_len)
+ goto out_false;
+
+ if (inet_aton(sane_host, &ipv4) != 0) {
+ /* This can only be a sane IPv4 address if it contains 3 dots.
+ * Helpfully, inet_aton is happy to treat "a", "a.b", "a.b.c",
+ * and "a.b.c.d" as valid IPv4 address strings where we only
+ * support the full, dotted-quad, form.
+ */
+ int num_dots = 0;
+ size_t index;
+
+ for (index = 0; index < host_len; index++) {
+ if (sane_host[index] == '.')
+ num_dots++;
+ }
+
+ if (num_dots == 3)
+ goto out_true;
+ else
+ goto out_false;
+ }
+
+#ifndef NO_IPV6
+ if (sane_host[0] != '[' || sane_host[host_len] != ']')
+ goto out_false;
+
+ strncpy(ipv6_addr, sane_host + 1, sizeof(ipv6_addr));
+ ipv6_addr[sizeof(ipv6_addr) - 1] = '\0';
+
+ if (inet_pton(AF_INET6, ipv6_addr, &ipv6) == 1)
+ goto out_true;
+#endif
+
+out_false:
+ if (slash != NULL) free((void *)sane_host);
+ return false;
+
+out_true:
+ if (slash != NULL) free((void *)sane_host);
+ return true;
+}
+
+
/**
* Add a host to the database, creating any intermediate entries
*
@@ -1596,7 +1689,7 @@ struct host_part *urldb_add_host(const char *host)
assert(host);
- if (url_host_is_ip_address(host)) {
+ if (urldb__host_is_ip_address(host)) {
/* Host is an IP, so simply add as TLD */
/* Check for existing entry */
@@ -2003,7 +2096,7 @@ struct path_data *urldb_match_path(const struct path_data *parent,
struct search_node **urldb_get_search_tree_direct(const char *host) {
assert(host);
- if (url_host_is_ip_address(host))
+ if (urldb__host_is_ip_address(host))
return &search_trees[ST_IP];
else if (isalpha(*host))
return &search_trees[ST_DN + tolower(*host) - 'a'];
@@ -2266,7 +2359,7 @@ int urldb_search_match_string(const struct host_part *a,
assert(a && a != &db_root && b);
- if (url_host_is_ip_address(b)) {
+ if (urldb__host_is_ip_address(b)) {
/* IP address */
return strcasecmp(a->part, b);
}
@@ -2329,7 +2422,7 @@ int urldb_search_match_prefix(const struct host_part *a,
assert(a && a != &db_root && b);
- if (url_host_is_ip_address(b)) {
+ if (urldb__host_is_ip_address(b)) {
/* IP address */
return strncasecmp(a->part, b, strlen(b));
}
@@ -2769,8 +2862,8 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
const char *rhost_data = lwc_string_data(rhost);
/* Ensure neither host nor rhost are IP addresses */
- if (url_host_is_ip_address(host_data) ||
- url_host_is_ip_address(rhost_data)) {
+ if (urldb__host_is_ip_address(host_data) ||
+ urldb__host_is_ip_address(rhost_data)) {
/* IP address, so no partial match */
lwc_string_unref(rhost);
goto error;
@@ -2886,7 +2979,7 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
assert(c->domain[0] == '.');
/* 4.3.2:iii */
- if (url_host_is_ip_address(lwc_string_data(host))) {
+ if (urldb__host_is_ip_address(lwc_string_data(host))) {
/* IP address, so no partial match */
urldb_free_cookie(c);
goto error;
diff --git a/utils/url.c b/utils/url.c
index b32a734..450d471 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -32,91 +32,6 @@
#include "utils/url.h"
-
-/* exported interface documented in utils/url.h */
-bool url_host_is_ip_address(const char *host)
-{
- struct in_addr ipv4;
- size_t host_len = strlen(host);
- const char *sane_host;
- const char *slash;
-#ifndef NO_IPV6
- struct in6_addr ipv6;
- char ipv6_addr[64];
-#endif
- /** @todo FIXME Some parts of urldb.c (and perhaps other parts of
- * NetSurf) make confusions between hosts and "prefixes", we can
- * sometimes be erroneously passed more than just a host. Sometimes
- * we may be passed trailing slashes, or even whole path segments.
- * A specific criminal in this class is urldb_iterate_partial, which
- * takes a prefix to search for, but passes that prefix to functions
- * that expect only hosts.
- *
- * For the time being, we will accept such calls; we check if there
- * is a / in the host parameter, and if there is, we take a copy and
- * replace the / with a \0. This is not a permanent solution; we
- * should search through NetSurf and find all the callers that are
- * in error and fix them. When doing this task, it might be wise
- * to replace the hideousness below with code that doesn't have to do
- * this, and add assert(strchr(host, '/') == NULL); somewhere.
- * -- rjek - 2010-11-04
- */
-
- slash = strchr(host, '/');
- if (slash == NULL) {
- sane_host = host;
- } else {
- char *c = strdup(host);
- c[slash - host] = '\0';
- sane_host = c;
- host_len = slash - host - 1;
- LOG(("WARNING: called with non-host '%s'", host));
- }
-
- if (strspn(sane_host, "0123456789abcdefABCDEF[].:") < host_len)
- goto out_false;
-
- if (inet_aton(sane_host, &ipv4) != 0) {
- /* This can only be a sane IPv4 address if it contains 3 dots.
- * Helpfully, inet_aton is happy to treat "a", "a.b", "a.b.c",
- * and "a.b.c.d" as valid IPv4 address strings where we only
- * support the full, dotted-quad, form.
- */
- int num_dots = 0;
- size_t index;
-
- for (index = 0; index < host_len; index++) {
- if (sane_host[index] == '.')
- num_dots++;
- }
-
- if (num_dots == 3)
- goto out_true;
- else
- goto out_false;
- }
-
-#ifndef NO_IPV6
- if (sane_host[0] != '[' || sane_host[host_len] != ']')
- goto out_false;
-
- strncpy(ipv6_addr, sane_host + 1, sizeof(ipv6_addr));
- ipv6_addr[sizeof(ipv6_addr) - 1] = '\0';
-
- if (inet_pton(AF_INET6, ipv6_addr, &ipv6) == 1)
- goto out_true;
-#endif
-
-out_false:
- if (slash != NULL) free((void *)sane_host);
- return false;
-
-out_true:
- if (slash != NULL) free((void *)sane_host);
- return true;
-}
-
-
/* exported interface documented in utils/url.h */
nserror url_unescape(const char *str, char **result)
{
diff --git a/utils/url.h b/utils/url.h
index 627bb5c..d6c5b91 100644
--- a/utils/url.h
+++ b/utils/url.h
@@ -35,19 +35,6 @@
/**
- * Check whether a host string is an IP address.
- *
- * This call detects IPv4 addresses (all of dotted-quad or subsets,
- * decimal or hexadecimal notations) and IPv6 addresses (including
- * those containing embedded IPv4 addresses.)
- *
- * \param host a hostname terminated by '\0'
- * \return true if the hostname is an IP address, false otherwise
- */
-bool url_host_is_ip_address(const char *host);
-
-
-/**
* Escape a string suitable for inclusion in an URL.
*
* \param unescaped the unescaped string
-----------------------------------------------------------------------
Summary of changes:
content/urldb.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++----
utils/url.c | 85 -------------------------------------------
utils/url.h | 13 -------
3 files changed, 100 insertions(+), 105 deletions(-)
diff --git a/content/urldb.c b/content/urldb.c
index 650c7bc..bf873c6 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1580,6 +1580,99 @@ struct host_part *urldb_add_host_node(const char *part,
return d;
}
+
+/**
+ * Check whether a host string is an IP address.
+ *
+ * This call detects IPv4 addresses (all of dotted-quad or subsets,
+ * decimal or hexadecimal notations) and IPv6 addresses (including
+ * those containing embedded IPv4 addresses.)
+ *
+ * \param host a hostname terminated by '\0'
+ * \return true if the hostname is an IP address, false otherwise
+ */
+static bool urldb__host_is_ip_address(const char *host)
+{
+ struct in_addr ipv4;
+ size_t host_len = strlen(host);
+ const char *sane_host;
+ const char *slash;
+#ifndef NO_IPV6
+ struct in6_addr ipv6;
+ char ipv6_addr[64];
+#endif
+ /** @todo FIXME Some parts of urldb.c make confusions between hosts
+ * and "prefixes", we can sometimes be erroneously passed more than
+ * just a host. Sometimes we may be passed trailing slashes, or even
+ * whole path segments. A specific criminal in this class is
+ * urldb_iterate_partial, which takes a prefix to search for, but
+ * passes that prefix to functions that expect only hosts.
+ *
+ * For the time being, we will accept such calls; we check if there
+ * is a / in the host parameter, and if there is, we take a copy and
+ * replace the / with a \0. This is not a permanent solution; we
+ * should search through NetSurf and find all the callers that are
+ * in error and fix them. When doing this task, it might be wise
+ * to replace the hideousness below with code that doesn't have to do
+ * this, and add assert(strchr(host, '/') == NULL); somewhere.
+ * -- rjek - 2010-11-04
+ */
+
+ slash = strchr(host, '/');
+ if (slash == NULL) {
+ sane_host = host;
+ } else {
+ char *c = strdup(host);
+ c[slash - host] = '\0';
+ sane_host = c;
+ host_len = slash - host - 1;
+ LOG(("WARNING: called with non-host '%s'", host));
+ }
+
+ if (strspn(sane_host, "0123456789abcdefABCDEF[].:") < host_len)
+ goto out_false;
+
+ if (inet_aton(sane_host, &ipv4) != 0) {
+ /* This can only be a sane IPv4 address if it contains 3 dots.
+ * Helpfully, inet_aton is happy to treat "a", "a.b", "a.b.c",
+ * and "a.b.c.d" as valid IPv4 address strings where we only
+ * support the full, dotted-quad, form.
+ */
+ int num_dots = 0;
+ size_t index;
+
+ for (index = 0; index < host_len; index++) {
+ if (sane_host[index] == '.')
+ num_dots++;
+ }
+
+ if (num_dots == 3)
+ goto out_true;
+ else
+ goto out_false;
+ }
+
+#ifndef NO_IPV6
+ if (sane_host[0] != '[' || sane_host[host_len] != ']')
+ goto out_false;
+
+ strncpy(ipv6_addr, sane_host + 1, sizeof(ipv6_addr));
+ ipv6_addr[sizeof(ipv6_addr) - 1] = '\0';
+
+ if (inet_pton(AF_INET6, ipv6_addr, &ipv6) == 1)
+ goto out_true;
+#endif
+
+out_false:
+ if (slash != NULL) free((void *)sane_host);
+ return false;
+
+out_true:
+ if (slash != NULL) free((void *)sane_host);
+ return true;
+}
+
+
/**
* Add a host to the database, creating any intermediate entries
*
@@ -1596,7 +1689,7 @@ struct host_part *urldb_add_host(const char *host)
assert(host);
- if (url_host_is_ip_address(host)) {
+ if (urldb__host_is_ip_address(host)) {
/* Host is an IP, so simply add as TLD */
/* Check for existing entry */
@@ -2003,7 +2096,7 @@ struct path_data *urldb_match_path(const struct path_data *parent,
struct search_node **urldb_get_search_tree_direct(const char *host) {
assert(host);
- if (url_host_is_ip_address(host))
+ if (urldb__host_is_ip_address(host))
return &search_trees[ST_IP];
else if (isalpha(*host))
return &search_trees[ST_DN + tolower(*host) - 'a'];
@@ -2266,7 +2359,7 @@ int urldb_search_match_string(const struct host_part *a,
assert(a && a != &db_root && b);
- if (url_host_is_ip_address(b)) {
+ if (urldb__host_is_ip_address(b)) {
/* IP address */
return strcasecmp(a->part, b);
}
@@ -2329,7 +2422,7 @@ int urldb_search_match_prefix(const struct host_part *a,
assert(a && a != &db_root && b);
- if (url_host_is_ip_address(b)) {
+ if (urldb__host_is_ip_address(b)) {
/* IP address */
return strncasecmp(a->part, b, strlen(b));
}
@@ -2769,8 +2862,8 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
const char *rhost_data = lwc_string_data(rhost);
/* Ensure neither host nor rhost are IP addresses */
- if (url_host_is_ip_address(host_data) ||
- url_host_is_ip_address(rhost_data)) {
+ if (urldb__host_is_ip_address(host_data) ||
+ urldb__host_is_ip_address(rhost_data)) {
/* IP address, so no partial match */
lwc_string_unref(rhost);
goto error;
@@ -2886,7 +2979,7 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
assert(c->domain[0] == '.');
/* 4.3.2:iii */
- if (url_host_is_ip_address(lwc_string_data(host))) {
+ if (urldb__host_is_ip_address(lwc_string_data(host))) {
/* IP address, so no partial match */
urldb_free_cookie(c);
goto error;
diff --git a/utils/url.c b/utils/url.c
index b32a734..450d471 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -32,91 +32,6 @@
#include "utils/url.h"
-
-/* exported interface documented in utils/url.h */
-bool url_host_is_ip_address(const char *host)
-{
- struct in_addr ipv4;
- size_t host_len = strlen(host);
- const char *sane_host;
- const char *slash;
-#ifndef NO_IPV6
- struct in6_addr ipv6;
- char ipv6_addr[64];
-#endif
- /** @todo FIXME Some parts of urldb.c (and perhaps other parts of
- * NetSurf) make confusions between hosts and "prefixes", we can
- * sometimes be erroneously passed more than just a host. Sometimes
- * we may be passed trailing slashes, or even whole path segments.
- * A specific criminal in this class is urldb_iterate_partial, which
- * takes a prefix to search for, but passes that prefix to functions
- * that expect only hosts.
- *
- * For the time being, we will accept such calls; we check if there
- * is a / in the host parameter, and if there is, we take a copy and
- * replace the / with a \0. This is not a permanent solution; we
- * should search through NetSurf and find all the callers that are
- * in error and fix them. When doing this task, it might be wise
- * to replace the hideousness below with code that doesn't have to do
- * this, and add assert(strchr(host, '/') == NULL); somewhere.
- * -- rjek - 2010-11-04
- */
-
- slash = strchr(host, '/');
- if (slash == NULL) {
- sane_host = host;
- } else {
- char *c = strdup(host);
- c[slash - host] = '\0';
- sane_host = c;
- host_len = slash - host - 1;
- LOG(("WARNING: called with non-host '%s'", host));
- }
-
- if (strspn(sane_host, "0123456789abcdefABCDEF[].:") < host_len)
- goto out_false;
-
- if (inet_aton(sane_host, &ipv4) != 0) {
- /* This can only be a sane IPv4 address if it contains 3 dots.
- * Helpfully, inet_aton is happy to treat "a", "a.b", "a.b.c",
- * and "a.b.c.d" as valid IPv4 address strings where we only
- * support the full, dotted-quad, form.
- */
- int num_dots = 0;
- size_t index;
-
- for (index = 0; index < host_len; index++) {
- if (sane_host[index] == '.')
- num_dots++;
- }
-
- if (num_dots == 3)
- goto out_true;
- else
- goto out_false;
- }
-
-#ifndef NO_IPV6
- if (sane_host[0] != '[' || sane_host[host_len] != ']')
- goto out_false;
-
- strncpy(ipv6_addr, sane_host + 1, sizeof(ipv6_addr));
- ipv6_addr[sizeof(ipv6_addr) - 1] = '\0';
-
- if (inet_pton(AF_INET6, ipv6_addr, &ipv6) == 1)
- goto out_true;
-#endif
-
-out_false:
- if (slash != NULL) free((void *)sane_host);
- return false;
-
-out_true:
- if (slash != NULL) free((void *)sane_host);
- return true;
-}
-
-
/* exported interface documented in utils/url.h */
nserror url_unescape(const char *str, char **result)
{
diff --git a/utils/url.h b/utils/url.h
index 627bb5c..d6c5b91 100644
--- a/utils/url.h
+++ b/utils/url.h
@@ -35,19 +35,6 @@
/**
- * Check whether a host string is an IP address.
- *
- * This call detects IPv4 addresses (all of dotted-quad or subsets,
- * decimal or hexadecimal notations) and IPv6 addresses (including
- * those containing embedded IPv4 addresses.)
- *
- * \param host a hostname terminated by '\0'
- * \return true if the hostname is an IP address, false otherwise
- */
-bool url_host_is_ip_address(const char *host);
-
-
-/**
* Escape a string suitable for inclusion in an URL.
*
* \param unescaped the unescaped string
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.2-284-g02ff392
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/02ff3920ce22f4a4120ca...
...commit http://git.netsurf-browser.org/netsurf.git/commit/02ff3920ce22f4a4120cab8...
...tree http://git.netsurf-browser.org/netsurf.git/tree/02ff3920ce22f4a4120cab8ce...
The branch, master has been updated
via 02ff3920ce22f4a4120cab8cee3a72a244604732 (commit)
from ce3d99191842ded7687dc23c3ccb5f5ccc843558 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=02ff3920ce22f4a4120...
commit 02ff3920ce22f4a4120cab8cee3a72a244604732
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
remove unused url_init function
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 328035f..7c7ce9d 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -217,8 +217,6 @@ nserror netsurf_init(const char *messages, const char *store_path)
if (ret != NSERROR_OK)
return ret;
- url_init();
-
setlocale(LC_ALL, "C");
/* initialise the fetchers */
diff --git a/test/urldbtest.c b/test/urldbtest.c
index cc657ed..2b7e8a0 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -163,7 +163,6 @@ int main(void)
char *path_query;
corestrings_init();
- url_init();
h = urldb_add_host("127.0.0.1");
if (!h) {
diff --git a/utils/url.c b/utils/url.c
index 92e956b..b32a734 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -32,35 +32,6 @@
#include "utils/url.h"
-regex_t url_re, url_up_re;
-
-/* exported interface documented in utils/url.h */
-nserror url_init(void)
-{
- nserror ret;
-
- /* regex from RFC 2396 */
- ret = regcomp_wrapper(&url_re, "^[[:space:]]*"
-#define URL_RE_SCHEME 2
- "(([a-zA-Z][-a-zA-Z0-9+.]*):)?"
-#define URL_RE_AUTHORITY 4
- "(//([^/?#[:space:]]*))?"
-#define URL_RE_PATH 5
- "([^?#[:space:]]*)"
-#define URL_RE_QUERY 7
- "(\\?([^#[:space:]]*))?"
-#define URL_RE_FRAGMENT 9
- "(#([^[:space:]]*))?"
- "[[:space:]]*$", REG_EXTENDED);
- if (ret != NSERROR_OK) {
- return ret;
- }
-
- return regcomp_wrapper(&url_up_re,
- "/([^/]?|[.][^./]|[^./][.]|[^./][^./]|[^/][^/][^/]+)"
- "/[.][.](/|$)",
- REG_EXTENDED);
-}
/* exported interface documented in utils/url.h */
bool url_host_is_ip_address(const char *host)
diff --git a/utils/url.h b/utils/url.h
index d05ac05..627bb5c 100644
--- a/utils/url.h
+++ b/utils/url.h
@@ -35,14 +35,6 @@
/**
- * Initialise URL routines.
- *
- * Compiles regular expressions required by the url_ functions.
- */
-nserror url_init(void);
-
-
-/**
* Check whether a host string is an IP address.
*
* This call detects IPv4 addresses (all of dotted-quad or subsets,
-----------------------------------------------------------------------
Summary of changes:
desktop/netsurf.c | 2 --
test/urldbtest.c | 1 -
utils/url.c | 29 -----------------------------
utils/url.h | 8 --------
4 files changed, 40 deletions(-)
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 328035f..7c7ce9d 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -217,8 +217,6 @@ nserror netsurf_init(const char *messages, const char *store_path)
if (ret != NSERROR_OK)
return ret;
- url_init();
-
setlocale(LC_ALL, "C");
/* initialise the fetchers */
diff --git a/test/urldbtest.c b/test/urldbtest.c
index cc657ed..2b7e8a0 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -163,7 +163,6 @@ int main(void)
char *path_query;
corestrings_init();
- url_init();
h = urldb_add_host("127.0.0.1");
if (!h) {
diff --git a/utils/url.c b/utils/url.c
index 92e956b..b32a734 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -32,35 +32,6 @@
#include "utils/url.h"
-regex_t url_re, url_up_re;
-
-/* exported interface documented in utils/url.h */
-nserror url_init(void)
-{
- nserror ret;
-
- /* regex from RFC 2396 */
- ret = regcomp_wrapper(&url_re, "^[[:space:]]*"
-#define URL_RE_SCHEME 2
- "(([a-zA-Z][-a-zA-Z0-9+.]*):)?"
-#define URL_RE_AUTHORITY 4
- "(//([^/?#[:space:]]*))?"
-#define URL_RE_PATH 5
- "([^?#[:space:]]*)"
-#define URL_RE_QUERY 7
- "(\\?([^#[:space:]]*))?"
-#define URL_RE_FRAGMENT 9
- "(#([^[:space:]]*))?"
- "[[:space:]]*$", REG_EXTENDED);
- if (ret != NSERROR_OK) {
- return ret;
- }
-
- return regcomp_wrapper(&url_up_re,
- "/([^/]?|[.][^./]|[^./][.]|[^./][^./]|[^/][^/][^/]+)"
- "/[.][.](/|$)",
- REG_EXTENDED);
-}
/* exported interface documented in utils/url.h */
bool url_host_is_ip_address(const char *host)
diff --git a/utils/url.h b/utils/url.h
index d05ac05..627bb5c 100644
--- a/utils/url.h
+++ b/utils/url.h
@@ -35,14 +35,6 @@
/**
- * Initialise URL routines.
- *
- * Compiles regular expressions required by the url_ functions.
- */
-nserror url_init(void);
-
-
-/**
* Check whether a host string is an IP address.
*
* This call detects IPv4 addresses (all of dotted-quad or subsets,
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.2-283-gce3d991
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ce3d99191842ded7687dc...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ce3d99191842ded7687dc23...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ce3d99191842ded7687dc23c3...
The branch, master has been updated
via ce3d99191842ded7687dc23c3ccb5f5ccc843558 (commit)
via f995616509fc3c0556da49c915375108bf268f38 (commit)
from 1620f20c4d1e13b05f108407508653841d4887eb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ce3d99191842ded7687...
commit ce3d99191842ded7687dc23c3ccb5f5ccc843558
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
use nsurl_nice and remove url_nice
change all callers over to using new API for generating nice filenames
from a url and remove the old API.
diff --git a/amiga/file.c b/amiga/file.c
index e74c5d0..2eda926 100644
--- a/amiga/file.c
+++ b/amiga/file.c
@@ -220,7 +220,9 @@ void ami_file_save_req(int type, struct gui_window_2 *gwin,
char *fname = AllocVecTags(1024, NULL);
char *initial_fname = NULL;
- if(object) url_nice(nsurl_access(hlcache_handle_get_url(object)), &initial_fname, true);
+ if(object) {
+ nsurl_nice(hlcache_handle_get_url(object), &initial_fname, true);
+ }
if(AslRequestTags(savereq,
ASLFR_Window, gwin->win,
diff --git a/desktop/download.c b/desktop/download.c
index a124c89..6e2aad8 100644
--- a/desktop/download.c
+++ b/desktop/download.c
@@ -76,8 +76,9 @@ static char *download_default_filename(nsurl *url)
{
char *nice;
- if (url_nice(nsurl_access(url), &nice, false) == NSERROR_OK)
+ if (nsurl_nice(url, &nice, false) == NSERROR_OK) {
return nice;
+ }
return NULL;
}
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 571ba93..6e9ec53 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -637,8 +637,8 @@ MULTIHANDLER(savepage)
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fc), filter);
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fc), filter);
- res = url_nice(nsurl_access(browser_window_get_url(
- nsgtk_get_browser_window(g->top_level))), &path, false);
+ res = nsurl_nice(browser_window_get_url(
+ nsgtk_get_browser_window(g->top_level)), &path, false);
if (res != NSERROR_OK) {
path = strdup(messages_get("SaveText"));
if (path == NULL) {
@@ -697,8 +697,7 @@ MULTIHANDLER(pdf)
LOG(("Print preview (generating PDF) started."));
- res = url_nice(nsurl_access(browser_window_get_url(bw)),
- &url_name, true);
+ res = nsurl_nice(browser_window_get_url(bw), &url_name, true);
if (res != NSERROR_OK) {
warn_user(messages_get_errorcode(res), 0);
return TRUE;
@@ -771,8 +770,8 @@ MULTIHANDLER(plaintext)
char *filename;
nserror res;
- res = url_nice(nsurl_access(browser_window_get_url(
- nsgtk_get_browser_window(g->top_level))),
+ res = nsurl_nice(browser_window_get_url(
+ nsgtk_get_browser_window(g->top_level)),
&filename, false);
if (res != NSERROR_OK) {
filename = strdup(messages_get("SaveText"));
diff --git a/gtk/viewsource.c b/gtk/viewsource.c
index 9c28f69..3c70beb 100644
--- a/gtk/viewsource.c
+++ b/gtk/viewsource.c
@@ -51,7 +51,7 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
source_data = content_get_source_data(hlcontent, &source_size);
- ret = url_nice(nsurl_access(browser_window_get_url(bw)), &filename, false);
+ ret = nsurl_nice(browser_window_get_url(bw), &filename, false);
if (ret != NSERROR_OK) {
filename = strdup(messages_get("SaveSource"));
if (filename == NULL) {
diff --git a/riscos/save.c b/riscos/save.c
index 1974d9c..bfde316 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -116,7 +116,7 @@ static void ro_gui_save_bounced(wimp_message *message);
static bool ro_gui_save_object_native(hlcache_handle *h, char *path);
static bool ro_gui_save_link(const char *url, const char *title, link_format format, char *path);
static void ro_gui_save_set_state(hlcache_handle *h, gui_save_type save_type,
- const char *url, char *leaf_buf, size_t leaf_len,
+ const nsurl *url, char *leaf_buf, size_t leaf_len,
char *icon_buf, size_t icon_len);
static void ro_gui_save_drag_end(wimp_dragged *drag, void *data);
static bool ro_gui_save_create_thumbnail(hlcache_handle *h, const char *name);
@@ -254,7 +254,7 @@ void ro_gui_saveas_quit(void)
*/
void ro_gui_save_prepare(gui_save_type save_type, hlcache_handle *h,
- char *s, const char *url, const char *title)
+ char *s, const nsurl *url, const char *title)
{
char name_buf[FILENAME_MAX];
size_t leaf_offset = 0;
@@ -271,7 +271,11 @@ void ro_gui_save_prepare(gui_save_type save_type, hlcache_handle *h,
free(gui_save_selection);
gui_save_selection = s;
- gui_save_url = url;
+ if (url != NULL) {
+ gui_save_url = nsurl_access(url);
+ } else {
+ gui_save_url = NULL;
+ }
gui_save_title = title;
if (save_dir) {
@@ -280,8 +284,11 @@ void ro_gui_save_prepare(gui_save_type save_type, hlcache_handle *h,
name_buf[leaf_offset++] = '.';
}
- ro_gui_save_set_state(h, save_type,
- h ? nsurl_access(hlcache_handle_get_url(h)) : url,
+ if (h != NULL) {
+ url = hlcache_handle_get_url(h);
+ }
+
+ ro_gui_save_set_state(h, save_type, url,
name_buf + leaf_offset, FILENAME_MAX - leaf_offset,
icon_buf, sizeof(icon_buf));
@@ -386,7 +393,7 @@ void gui_drag_save_object(struct gui_window *g, hlcache_handle *c,
return;
}
- ro_gui_save_set_state(c, save_type, nsurl_access(hlcache_handle_get_url(c)),
+ ro_gui_save_set_state(c, save_type, hlcache_handle_get_url(c),
save_leafname, LEAFNAME_MAX,
icon_buf, sizeof(icon_buf));
@@ -454,7 +461,7 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection)
* \
*/
-void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
+void ro_gui_drag_save_link(gui_save_type save_type, const nsurl *url,
const char *title, struct gui_window *g)
{
wimp_pointer pointer;
@@ -466,7 +473,7 @@ void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
ro_gui_dialog_close(dialog_saveas);
- gui_save_url = url;
+ gui_save_url = nsurl_access(url);
gui_save_title = title;
gui_save_sourcew = g->window;
saving_from_dialog = false;
@@ -479,8 +486,8 @@ void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
return;
}
- ro_gui_save_set_state(NULL, save_type, url, save_leafname, LEAFNAME_MAX,
- icon_buf, sizeof(icon_buf));
+ ro_gui_save_set_state(NULL, save_type, url, save_leafname,
+ LEAFNAME_MAX, icon_buf, sizeof(icon_buf));
ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
@@ -1215,7 +1222,7 @@ bool ro_gui_save_link(const char *url, const char *title, link_format format,
*/
void ro_gui_save_set_state(hlcache_handle *h, gui_save_type save_type,
- const char *url, char *leaf_buf, size_t leaf_len,
+ const nsurl *url, char *leaf_buf, size_t leaf_len,
char *icon_buf, size_t icon_len)
{
/* filename */
@@ -1251,8 +1258,9 @@ void ro_gui_save_set_state(hlcache_handle *h, gui_save_type save_type,
}
/* leafname */
- if (url && url_nice(url, &nice, nsoption_bool(strip_extensions)) ==
- NSERROR_OK) {
+ if ((url != NULL) &&
+ (nsurl_nice(url, &nice, nsoption_bool(strip_extensions)) ==
+ NSERROR_OK)) {
size_t i;
for (i = 0; nice[i]; i++) {
if (nice[i] == '.')
diff --git a/riscos/save.h b/riscos/save.h
index d3ca5c2..08bdc17 100644
--- a/riscos/save.h
+++ b/riscos/save.h
@@ -34,10 +34,10 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection);
wimp_w ro_gui_saveas_create(const char *template_name);
void ro_gui_saveas_quit(void);
void ro_gui_save_prepare(enum gui_save_type save_type, struct hlcache_handle *h,
- char *s, const char *url,
+ char *s, const nsurl *url,
const char *title);
void ro_gui_save_start_drag(wimp_pointer *pointer);
-void ro_gui_drag_save_link(enum gui_save_type save_type, const char *url,
+void ro_gui_drag_save_link(enum gui_save_type save_type, const nsurl *url,
const char *title, struct gui_window *g);
void ro_gui_drag_icon(int x, int y, const char *sprite);
void ro_gui_drag_box_cancel(void);
diff --git a/riscos/window.c b/riscos/window.c
index 6a62d56..4e07293 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -194,7 +194,7 @@ static hlcache_handle *current_menu_main = 0;
/** Object under menu, or 0 if no object. */
static hlcache_handle *current_menu_object = 0;
/** URL of link under menu, or 0 if no link. */
-static const char *current_menu_url = 0;
+static nsurl *current_menu_url = 0;
static float scale_snap_to[] = {0.10, 0.125, 0.25, 0.333, 0.5, 0.75,
1.0,
@@ -1284,7 +1284,10 @@ static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
static void gui_window_save_link(struct gui_window *g, const char *url,
const char *title)
{
- ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL, url, title);
+ nsurl *nurl;
+ nsurl_create(url, &nurl);
+ ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL, nurl, title);
+ nsurl_unref(nurl);
ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
}
@@ -2174,7 +2177,10 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
current_menu_main = NULL;
current_menu_object = NULL;
- current_menu_url = NULL;
+ if (current_menu_url != NULL) {
+ nsurl_unref(current_menu_url);
+ current_menu_url = NULL;
+ }
if (ro_gui_window_to_window_pos(g, pointer->pos.x,
pointer->pos.y, &pos)) {
@@ -2183,7 +2189,7 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
current_menu_main = cont.main;
current_menu_object = cont.object;
- current_menu_url = cont.link_url;
+ nsurl_create(cont.link_url, ¤t_menu_url);
}
}
@@ -2444,7 +2450,7 @@ void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_OBJECT_INFO:
if (current_menu_object != NULL)
ro_gui_window_prepare_objectinfo(current_menu_object,
- current_menu_url);
+ nsurl_access(current_menu_url));
break;
case BROWSER_OBJECT_SAVE:
@@ -2463,45 +2469,45 @@ void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_SAVE_URL_URI:
if (h != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(h)),
+ hlcache_handle_get_url(h),
content_get_title(h));
break;
case BROWSER_SAVE_URL_URL:
if (h != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(h)),
+ hlcache_handle_get_url(h),
content_get_title(h));
break;
case BROWSER_SAVE_URL_TEXT:
if (h != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(h)),
+ hlcache_handle_get_url(h),
content_get_title(h));
break;
case BROWSER_OBJECT_SAVE_URL_URI:
if (current_menu_object != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(
- current_menu_object)),
+ hlcache_handle_get_url(
+ current_menu_object),
content_get_title(current_menu_object));
break;
case BROWSER_OBJECT_SAVE_URL_URL:
if (current_menu_object != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(
- current_menu_object)),
+ hlcache_handle_get_url(
+ current_menu_object),
content_get_title(current_menu_object));
break;
case BROWSER_OBJECT_SAVE_URL_TEXT:
if (current_menu_object != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(
- current_menu_object)),
+ hlcache_handle_get_url(
+ current_menu_object),
content_get_title(current_menu_object));
break;
@@ -2759,7 +2765,7 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_OBJECT_INFO:
if (current_menu_object != NULL) {
ro_gui_window_prepare_objectinfo(current_menu_object,
- current_menu_url);
+ nsurl_access(current_menu_url));
ro_gui_dialog_open_persistent(g->window,
dialog_objinfo, false);
}
@@ -2799,33 +2805,25 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_LINK_DOWNLOAD:
if (current_menu_url != NULL) {
- error = nsurl_create(current_menu_url, &url);
- if (error == NSERROR_OK) {
- error = browser_window_navigate(bw,
- url,
- browser_window_get_url(bw),
- BW_NAVIGATE_DOWNLOAD,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
+ error = browser_window_navigate(bw,
+ current_menu_url,
+ browser_window_get_url(bw),
+ BW_NAVIGATE_DOWNLOAD,
+ NULL,
+ NULL,
+ NULL);
}
break;
case BROWSER_LINK_NEW_WINDOW:
if (current_menu_url != NULL) {
- error = nsurl_create(current_menu_url, &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(
- BW_CREATE_HISTORY |
- BW_CREATE_CLONE,
- url,
- browser_window_get_url(bw),
- bw,
- NULL);
- nsurl_unref(url);
- }
+ error = browser_window_create(
+ BW_CREATE_HISTORY |
+ BW_CREATE_CLONE,
+ url,
+ browser_window_get_url(bw),
+ bw,
+ NULL);
}
break;
@@ -3050,7 +3048,10 @@ void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu)
{
if (menu == ro_gui_browser_window_menu) {
current_menu_object = NULL;
- current_menu_url = NULL;
+ if (current_menu_url != NULL) {
+ nsurl_unref(current_menu_url);
+ current_menu_url = NULL;
+ }
} else if (menu == gui_form_select_menu) {
gui_form_select_control = NULL;
}
@@ -3579,8 +3580,7 @@ void ro_gui_window_toolbar_click(void *data,
save_type = GUI_SAVE_LINK_TEXT;
ro_gui_drag_save_link(save_type,
- nsurl_access(
- browser_window_get_url(g->bw)),
+ browser_window_get_url(g->bw),
browser_window_get_title(g->bw), g);
}
break;
diff --git a/utils/url.c b/utils/url.c
index e1903a8..92e956b 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -147,109 +147,6 @@ out_true:
/* exported interface documented in utils/url.h */
-nserror url_nice(const char *url, char **result,
- bool remove_extensions)
-{
- int m;
- regmatch_t match[10];
- regoff_t start, end;
- size_t i;
- char *dot;
-
- *result = 0;
-
- m = regexec(&url_re, url, 10, match, 0);
- if (m) {
- LOG(("url '%s' failed to match regex", url));
- return NSERROR_NOT_FOUND;
- }
-
- /* extract the last component of the path, if possible */
- if (match[URL_RE_PATH].rm_so == -1 || match[URL_RE_PATH].rm_so ==
- match[URL_RE_PATH].rm_eo)
- goto no_path; /* no path, or empty */
- for (end = match[URL_RE_PATH].rm_eo - 1;
- end != match[URL_RE_PATH].rm_so && url[end] == '/';
- end--)
- ;
- if (end == match[URL_RE_PATH].rm_so)
- goto no_path; /* path is a string of '/' */
- end++;
- for (start = end - 1;
- start != match[URL_RE_PATH].rm_so && url[start] != '/';
- start--)
- ;
- if (url[start] == '/')
- start++;
-
- if (!strncasecmp(url + start, "index.", 6) ||
- !strncasecmp(url + start, "default.", 8)) {
- /* try again */
- if (start == match[URL_RE_PATH].rm_so)
- goto no_path;
- for (end = start - 1;
- end != match[URL_RE_PATH].rm_so &&
- url[end] == '/';
- end--)
- ;
- if (end == match[URL_RE_PATH].rm_so)
- goto no_path;
- end++;
- for (start = end - 1;
- start != match[URL_RE_PATH].rm_so &&
- url[start] != '/';
- start--)
- ;
- if (url[start] == '/')
- start++;
- }
-
- *result = malloc(end - start + 1);
- if (!*result) {
- LOG(("malloc failed"));
- return NSERROR_NOMEM;
- }
- strncpy(*result, url + start, end - start);
- (*result)[end - start] = 0;
-
- if (remove_extensions) {
- dot = strchr(*result, '.');
- if (dot && dot != *result)
- *dot = 0;
- }
-
- return NSERROR_OK;
-
-no_path:
-
- /* otherwise, use the host name, with '.' replaced by '_' */
- if (match[URL_RE_AUTHORITY].rm_so != -1 &&
- match[URL_RE_AUTHORITY].rm_so !=
- match[URL_RE_AUTHORITY].rm_eo) {
- *result = malloc(match[URL_RE_AUTHORITY].rm_eo -
- match[URL_RE_AUTHORITY].rm_so + 1);
- if (!*result) {
- LOG(("malloc failed"));
- return NSERROR_NOMEM;
- }
- strncpy(*result, url + match[URL_RE_AUTHORITY].rm_so,
- match[URL_RE_AUTHORITY].rm_eo -
- match[URL_RE_AUTHORITY].rm_so);
- (*result)[match[URL_RE_AUTHORITY].rm_eo -
- match[URL_RE_AUTHORITY].rm_so] = 0;
-
- for (i = 0; (*result)[i]; i++)
- if ((*result)[i] == '.')
- (*result)[i] = '_';
-
- return NSERROR_OK;
- }
-
- return NSERROR_NOT_FOUND;
-}
-
-
-/* exported interface documented in utils/url.h */
nserror url_unescape(const char *str, char **result)
{
char *curlstr;
diff --git a/utils/url.h b/utils/url.h
index a2efbec..d05ac05 100644
--- a/utils/url.h
+++ b/utils/url.h
@@ -56,16 +56,6 @@ bool url_host_is_ip_address(const char *host);
/**
- * Attempt to find a nice filename for a URL.
- *
- * \param url an absolute URL
- * \param result pointer to pointer to buffer to hold filename
- * \param remove_extensions remove any extensions from the filename
- * \return NSERROR_OK on success
- */
-nserror url_nice(const char *url, char **result, bool remove_extensions);
-
-/**
* Escape a string suitable for inclusion in an URL.
*
* \param unescaped the unescaped string
diff --git a/windows/download.c b/windows/download.c
index 8d3cc44..463a836 100644
--- a/windows/download.c
+++ b/windows/download.c
@@ -71,8 +71,9 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
messages_get("UnknownSize") :
human_friendly_bytesize(total_size);
- if (url_nice(nsurl_access(url), &filename, false) != NSERROR_OK)
+ if (nsurl_nice(url, &filename, false) != NSERROR_OK) {
filename = strdup(messages_get("UnknownFile"));
+ }
if (filename == NULL) {
warn_user(messages_get("NoMemory"), 0);
free(w);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f995616509fc3c0556d...
commit f995616509fc3c0556da49c915375108bf268f38
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
remove more user warning calls and replace with error returns
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index f0eda84..a5b86b5 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -412,14 +412,18 @@ static nserror hotlist_tree_node_folder_cb(
return NSERROR_OK;
}
-static nserror hotlist_tree_node_entry_cb(
- struct treeview_node_msg msg, void *data)
+
+/**
+ * callback for hotlist treeview entry manipulation.
+ */
+static nserror
+hotlist_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
{
struct hotlist_entry *e = data;
const char *old_text;
nsurl *old_url;
nsurl *url;
- nserror err;
+ nserror err = NSERROR_OK;
bool match;
switch (msg.msg) {
@@ -456,27 +460,24 @@ static nserror hotlist_tree_node_entry_cb(
msg.data.node_edit.text[0] != '\0') {
/* Requst to change the entry URL text */
err = nsurl_create(msg.data.node_edit.text, &url);
- if (err != NSERROR_OK)
- return err;
-
- old_url = e->url;
+ if (err == NSERROR_OK) {
+ old_url = e->url;
- e->url = url;
- e->data[HL_URL].value = nsurl_access(url);
- e->data[HL_URL].value_len = nsurl_length(e->url);
+ e->url = url;
+ e->data[HL_URL].value = nsurl_access(url);
+ e->data[HL_URL].value_len = nsurl_length(e->url);
- treeview_update_node_entry(hl_ctx.tree,
- e->entry, e->data, e);
- nsurl_unref(old_url);
+ treeview_update_node_entry(hl_ctx.tree,
+ e->entry, e->data, e);
+ nsurl_unref(old_url);
+ }
}
break;
case TREE_MSG_NODE_LAUNCH:
{
- nserror error;
struct browser_window *existing = NULL;
- enum browser_window_create_flags flags =
- BW_CREATE_HISTORY;
+ enum browser_window_create_flags flags = BW_CREATE_HISTORY;
/* TODO: Set existing to window that new tab appears in */
@@ -488,16 +489,14 @@ static nserror hotlist_tree_node_entry_cb(
/* TODO: flags ^= BW_CREATE_TAB; */
}
- error = browser_window_create(flags, e->url, NULL,
+ err = browser_window_create(flags, e->url, NULL,
existing, NULL);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
}
break;
}
- return NSERROR_OK;
+ return err;
}
+
struct treeview_callback_table hl_tree_cb_t = {
.folder = hotlist_tree_node_folder_cb,
.entry = hotlist_tree_node_entry_cb
@@ -517,8 +516,8 @@ typedef struct {
/**
* Parse an entry represented as a li.
*
- * \param li DOM node for parsed li
- * \param ctx Our hotlist loading context.
+ * \param li DOM node for parsed li
+ * \param ctx Our hotlist loading context.
* \return NSERROR_OK on success, or appropriate error otherwise
*/
static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
@@ -533,23 +532,23 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
/* The li must contain an "a" element */
a = libdom_find_first_element(li, corestring_lwc_a);
if (a == NULL) {
- warn_user("TreeLoadError", "(Missing <a> in <li>)");
- return NSERROR_NOMEM;
+ LOG(("Missing <a> in <li>"));
+ return NSERROR_INVALID;
}
derror = dom_node_get_text_content(a, &title1);
if (derror != DOM_NO_ERR) {
- warn_user("TreeLoadError", "(No title)");
+ LOG(("No title"));
dom_node_unref(a);
- return NSERROR_NOMEM;
+ return NSERROR_INVALID;
}
derror = dom_element_get_attribute(a, corestring_dom_href, &url1);
if (derror != DOM_NO_ERR || url1 == NULL) {
- warn_user("TreeLoadError", "(No URL)");
+ LOG(("No URL"));
dom_string_unref(title1);
dom_node_unref(a);
- return NSERROR_NOMEM;
+ return NSERROR_INVALID;
}
dom_node_unref(a);
@@ -566,10 +565,9 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
if (err != NSERROR_OK) {
LOG(("Failed normalising '%s'", dom_string_data(url1)));
- warn_user(messages_get_errorcode(err), NULL);
-
- if (title1 != NULL)
+ if (title1 != NULL) {
dom_string_unref(title1);
+ }
return err;
}
@@ -578,8 +576,9 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
err = hotlist_add_entry_internal(url, title, NULL, ctx->rel,
ctx->relshp, &ctx->rel);
nsurl_unref(url);
- if (title1 != NULL)
+ if (title1 != NULL) {
dom_string_unref(title1);
+ }
ctx->relshp = TREE_REL_NEXT_SIBLING;
if (err != NSERROR_OK) {
@@ -631,7 +630,7 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
error = dom_node_get_node_name(node, &name);
if (error != DOM_NO_ERR || name == NULL)
- return NSERROR_NOMEM;
+ return NSERROR_DOM;
if (dom_string_caseless_lwc_isequal(name, corestring_lwc_li)) {
/* Entry handling */
@@ -644,10 +643,9 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
error = dom_node_get_text_content(node, &title);
if (error != DOM_NO_ERR || title == NULL) {
- warn_user("TreeLoadError", "(Empty <h4> "
- "or memory exhausted.)");
+ LOG(("Empty <h4> or memory exhausted."));
dom_string_unref(name);
- return NSERROR_NOMEM;
+ return NSERROR_DOM;
}
if (current_ctx->title != NULL)
-----------------------------------------------------------------------
Summary of changes:
amiga/file.c | 4 +-
desktop/download.c | 3 +-
desktop/hotlist.c | 72 ++++++++++++++++++------------------
gtk/scaffolding.c | 11 +++---
gtk/viewsource.c | 2 +-
riscos/save.c | 34 ++++++++++-------
riscos/save.h | 4 +-
riscos/window.c | 80 ++++++++++++++++++++--------------------
utils/url.c | 103 ----------------------------------------------------
utils/url.h | 10 -----
windows/download.c | 3 +-
11 files changed, 111 insertions(+), 215 deletions(-)
diff --git a/amiga/file.c b/amiga/file.c
index e74c5d0..2eda926 100644
--- a/amiga/file.c
+++ b/amiga/file.c
@@ -220,7 +220,9 @@ void ami_file_save_req(int type, struct gui_window_2 *gwin,
char *fname = AllocVecTags(1024, NULL);
char *initial_fname = NULL;
- if(object) url_nice(nsurl_access(hlcache_handle_get_url(object)), &initial_fname, true);
+ if(object) {
+ nsurl_nice(hlcache_handle_get_url(object), &initial_fname, true);
+ }
if(AslRequestTags(savereq,
ASLFR_Window, gwin->win,
diff --git a/desktop/download.c b/desktop/download.c
index a124c89..6e2aad8 100644
--- a/desktop/download.c
+++ b/desktop/download.c
@@ -76,8 +76,9 @@ static char *download_default_filename(nsurl *url)
{
char *nice;
- if (url_nice(nsurl_access(url), &nice, false) == NSERROR_OK)
+ if (nsurl_nice(url, &nice, false) == NSERROR_OK) {
return nice;
+ }
return NULL;
}
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index f0eda84..a5b86b5 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -412,14 +412,18 @@ static nserror hotlist_tree_node_folder_cb(
return NSERROR_OK;
}
-static nserror hotlist_tree_node_entry_cb(
- struct treeview_node_msg msg, void *data)
+
+/**
+ * callback for hotlist treeview entry manipulation.
+ */
+static nserror
+hotlist_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
{
struct hotlist_entry *e = data;
const char *old_text;
nsurl *old_url;
nsurl *url;
- nserror err;
+ nserror err = NSERROR_OK;
bool match;
switch (msg.msg) {
@@ -456,27 +460,24 @@ static nserror hotlist_tree_node_entry_cb(
msg.data.node_edit.text[0] != '\0') {
/* Requst to change the entry URL text */
err = nsurl_create(msg.data.node_edit.text, &url);
- if (err != NSERROR_OK)
- return err;
-
- old_url = e->url;
+ if (err == NSERROR_OK) {
+ old_url = e->url;
- e->url = url;
- e->data[HL_URL].value = nsurl_access(url);
- e->data[HL_URL].value_len = nsurl_length(e->url);
+ e->url = url;
+ e->data[HL_URL].value = nsurl_access(url);
+ e->data[HL_URL].value_len = nsurl_length(e->url);
- treeview_update_node_entry(hl_ctx.tree,
- e->entry, e->data, e);
- nsurl_unref(old_url);
+ treeview_update_node_entry(hl_ctx.tree,
+ e->entry, e->data, e);
+ nsurl_unref(old_url);
+ }
}
break;
case TREE_MSG_NODE_LAUNCH:
{
- nserror error;
struct browser_window *existing = NULL;
- enum browser_window_create_flags flags =
- BW_CREATE_HISTORY;
+ enum browser_window_create_flags flags = BW_CREATE_HISTORY;
/* TODO: Set existing to window that new tab appears in */
@@ -488,16 +489,14 @@ static nserror hotlist_tree_node_entry_cb(
/* TODO: flags ^= BW_CREATE_TAB; */
}
- error = browser_window_create(flags, e->url, NULL,
+ err = browser_window_create(flags, e->url, NULL,
existing, NULL);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
}
break;
}
- return NSERROR_OK;
+ return err;
}
+
struct treeview_callback_table hl_tree_cb_t = {
.folder = hotlist_tree_node_folder_cb,
.entry = hotlist_tree_node_entry_cb
@@ -517,8 +516,8 @@ typedef struct {
/**
* Parse an entry represented as a li.
*
- * \param li DOM node for parsed li
- * \param ctx Our hotlist loading context.
+ * \param li DOM node for parsed li
+ * \param ctx Our hotlist loading context.
* \return NSERROR_OK on success, or appropriate error otherwise
*/
static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
@@ -533,23 +532,23 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
/* The li must contain an "a" element */
a = libdom_find_first_element(li, corestring_lwc_a);
if (a == NULL) {
- warn_user("TreeLoadError", "(Missing <a> in <li>)");
- return NSERROR_NOMEM;
+ LOG(("Missing <a> in <li>"));
+ return NSERROR_INVALID;
}
derror = dom_node_get_text_content(a, &title1);
if (derror != DOM_NO_ERR) {
- warn_user("TreeLoadError", "(No title)");
+ LOG(("No title"));
dom_node_unref(a);
- return NSERROR_NOMEM;
+ return NSERROR_INVALID;
}
derror = dom_element_get_attribute(a, corestring_dom_href, &url1);
if (derror != DOM_NO_ERR || url1 == NULL) {
- warn_user("TreeLoadError", "(No URL)");
+ LOG(("No URL"));
dom_string_unref(title1);
dom_node_unref(a);
- return NSERROR_NOMEM;
+ return NSERROR_INVALID;
}
dom_node_unref(a);
@@ -566,10 +565,9 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
if (err != NSERROR_OK) {
LOG(("Failed normalising '%s'", dom_string_data(url1)));
- warn_user(messages_get_errorcode(err), NULL);
-
- if (title1 != NULL)
+ if (title1 != NULL) {
dom_string_unref(title1);
+ }
return err;
}
@@ -578,8 +576,9 @@ static nserror hotlist_load_entry(dom_node *li, hotlist_load_ctx *ctx)
err = hotlist_add_entry_internal(url, title, NULL, ctx->rel,
ctx->relshp, &ctx->rel);
nsurl_unref(url);
- if (title1 != NULL)
+ if (title1 != NULL) {
dom_string_unref(title1);
+ }
ctx->relshp = TREE_REL_NEXT_SIBLING;
if (err != NSERROR_OK) {
@@ -631,7 +630,7 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
error = dom_node_get_node_name(node, &name);
if (error != DOM_NO_ERR || name == NULL)
- return NSERROR_NOMEM;
+ return NSERROR_DOM;
if (dom_string_caseless_lwc_isequal(name, corestring_lwc_li)) {
/* Entry handling */
@@ -644,10 +643,9 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx)
error = dom_node_get_text_content(node, &title);
if (error != DOM_NO_ERR || title == NULL) {
- warn_user("TreeLoadError", "(Empty <h4> "
- "or memory exhausted.)");
+ LOG(("Empty <h4> or memory exhausted."));
dom_string_unref(name);
- return NSERROR_NOMEM;
+ return NSERROR_DOM;
}
if (current_ctx->title != NULL)
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 571ba93..6e9ec53 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -637,8 +637,8 @@ MULTIHANDLER(savepage)
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fc), filter);
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fc), filter);
- res = url_nice(nsurl_access(browser_window_get_url(
- nsgtk_get_browser_window(g->top_level))), &path, false);
+ res = nsurl_nice(browser_window_get_url(
+ nsgtk_get_browser_window(g->top_level)), &path, false);
if (res != NSERROR_OK) {
path = strdup(messages_get("SaveText"));
if (path == NULL) {
@@ -697,8 +697,7 @@ MULTIHANDLER(pdf)
LOG(("Print preview (generating PDF) started."));
- res = url_nice(nsurl_access(browser_window_get_url(bw)),
- &url_name, true);
+ res = nsurl_nice(browser_window_get_url(bw), &url_name, true);
if (res != NSERROR_OK) {
warn_user(messages_get_errorcode(res), 0);
return TRUE;
@@ -771,8 +770,8 @@ MULTIHANDLER(plaintext)
char *filename;
nserror res;
- res = url_nice(nsurl_access(browser_window_get_url(
- nsgtk_get_browser_window(g->top_level))),
+ res = nsurl_nice(browser_window_get_url(
+ nsgtk_get_browser_window(g->top_level)),
&filename, false);
if (res != NSERROR_OK) {
filename = strdup(messages_get("SaveText"));
diff --git a/gtk/viewsource.c b/gtk/viewsource.c
index 9c28f69..3c70beb 100644
--- a/gtk/viewsource.c
+++ b/gtk/viewsource.c
@@ -51,7 +51,7 @@ void nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw)
source_data = content_get_source_data(hlcontent, &source_size);
- ret = url_nice(nsurl_access(browser_window_get_url(bw)), &filename, false);
+ ret = nsurl_nice(browser_window_get_url(bw), &filename, false);
if (ret != NSERROR_OK) {
filename = strdup(messages_get("SaveSource"));
if (filename == NULL) {
diff --git a/riscos/save.c b/riscos/save.c
index 1974d9c..bfde316 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -116,7 +116,7 @@ static void ro_gui_save_bounced(wimp_message *message);
static bool ro_gui_save_object_native(hlcache_handle *h, char *path);
static bool ro_gui_save_link(const char *url, const char *title, link_format format, char *path);
static void ro_gui_save_set_state(hlcache_handle *h, gui_save_type save_type,
- const char *url, char *leaf_buf, size_t leaf_len,
+ const nsurl *url, char *leaf_buf, size_t leaf_len,
char *icon_buf, size_t icon_len);
static void ro_gui_save_drag_end(wimp_dragged *drag, void *data);
static bool ro_gui_save_create_thumbnail(hlcache_handle *h, const char *name);
@@ -254,7 +254,7 @@ void ro_gui_saveas_quit(void)
*/
void ro_gui_save_prepare(gui_save_type save_type, hlcache_handle *h,
- char *s, const char *url, const char *title)
+ char *s, const nsurl *url, const char *title)
{
char name_buf[FILENAME_MAX];
size_t leaf_offset = 0;
@@ -271,7 +271,11 @@ void ro_gui_save_prepare(gui_save_type save_type, hlcache_handle *h,
free(gui_save_selection);
gui_save_selection = s;
- gui_save_url = url;
+ if (url != NULL) {
+ gui_save_url = nsurl_access(url);
+ } else {
+ gui_save_url = NULL;
+ }
gui_save_title = title;
if (save_dir) {
@@ -280,8 +284,11 @@ void ro_gui_save_prepare(gui_save_type save_type, hlcache_handle *h,
name_buf[leaf_offset++] = '.';
}
- ro_gui_save_set_state(h, save_type,
- h ? nsurl_access(hlcache_handle_get_url(h)) : url,
+ if (h != NULL) {
+ url = hlcache_handle_get_url(h);
+ }
+
+ ro_gui_save_set_state(h, save_type, url,
name_buf + leaf_offset, FILENAME_MAX - leaf_offset,
icon_buf, sizeof(icon_buf));
@@ -386,7 +393,7 @@ void gui_drag_save_object(struct gui_window *g, hlcache_handle *c,
return;
}
- ro_gui_save_set_state(c, save_type, nsurl_access(hlcache_handle_get_url(c)),
+ ro_gui_save_set_state(c, save_type, hlcache_handle_get_url(c),
save_leafname, LEAFNAME_MAX,
icon_buf, sizeof(icon_buf));
@@ -454,7 +461,7 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection)
* \
*/
-void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
+void ro_gui_drag_save_link(gui_save_type save_type, const nsurl *url,
const char *title, struct gui_window *g)
{
wimp_pointer pointer;
@@ -466,7 +473,7 @@ void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
ro_gui_dialog_close(dialog_saveas);
- gui_save_url = url;
+ gui_save_url = nsurl_access(url);
gui_save_title = title;
gui_save_sourcew = g->window;
saving_from_dialog = false;
@@ -479,8 +486,8 @@ void ro_gui_drag_save_link(gui_save_type save_type, const char *url,
return;
}
- ro_gui_save_set_state(NULL, save_type, url, save_leafname, LEAFNAME_MAX,
- icon_buf, sizeof(icon_buf));
+ ro_gui_save_set_state(NULL, save_type, url, save_leafname,
+ LEAFNAME_MAX, icon_buf, sizeof(icon_buf));
ro_mouse_drag_start(ro_gui_save_drag_end, NULL, NULL, NULL);
@@ -1215,7 +1222,7 @@ bool ro_gui_save_link(const char *url, const char *title, link_format format,
*/
void ro_gui_save_set_state(hlcache_handle *h, gui_save_type save_type,
- const char *url, char *leaf_buf, size_t leaf_len,
+ const nsurl *url, char *leaf_buf, size_t leaf_len,
char *icon_buf, size_t icon_len)
{
/* filename */
@@ -1251,8 +1258,9 @@ void ro_gui_save_set_state(hlcache_handle *h, gui_save_type save_type,
}
/* leafname */
- if (url && url_nice(url, &nice, nsoption_bool(strip_extensions)) ==
- NSERROR_OK) {
+ if ((url != NULL) &&
+ (nsurl_nice(url, &nice, nsoption_bool(strip_extensions)) ==
+ NSERROR_OK)) {
size_t i;
for (i = 0; nice[i]; i++) {
if (nice[i] == '.')
diff --git a/riscos/save.h b/riscos/save.h
index d3ca5c2..08bdc17 100644
--- a/riscos/save.h
+++ b/riscos/save.h
@@ -34,10 +34,10 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection);
wimp_w ro_gui_saveas_create(const char *template_name);
void ro_gui_saveas_quit(void);
void ro_gui_save_prepare(enum gui_save_type save_type, struct hlcache_handle *h,
- char *s, const char *url,
+ char *s, const nsurl *url,
const char *title);
void ro_gui_save_start_drag(wimp_pointer *pointer);
-void ro_gui_drag_save_link(enum gui_save_type save_type, const char *url,
+void ro_gui_drag_save_link(enum gui_save_type save_type, const nsurl *url,
const char *title, struct gui_window *g);
void ro_gui_drag_icon(int x, int y, const char *sprite);
void ro_gui_drag_box_cancel(void);
diff --git a/riscos/window.c b/riscos/window.c
index 6a62d56..4e07293 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -194,7 +194,7 @@ static hlcache_handle *current_menu_main = 0;
/** Object under menu, or 0 if no object. */
static hlcache_handle *current_menu_object = 0;
/** URL of link under menu, or 0 if no link. */
-static const char *current_menu_url = 0;
+static nsurl *current_menu_url = 0;
static float scale_snap_to[] = {0.10, 0.125, 0.25, 0.333, 0.5, 0.75,
1.0,
@@ -1284,7 +1284,10 @@ static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
static void gui_window_save_link(struct gui_window *g, const char *url,
const char *title)
{
- ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL, url, title);
+ nsurl *nurl;
+ nsurl_create(url, &nurl);
+ ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL, nurl, title);
+ nsurl_unref(nurl);
ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
}
@@ -2174,7 +2177,10 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
current_menu_main = NULL;
current_menu_object = NULL;
- current_menu_url = NULL;
+ if (current_menu_url != NULL) {
+ nsurl_unref(current_menu_url);
+ current_menu_url = NULL;
+ }
if (ro_gui_window_to_window_pos(g, pointer->pos.x,
pointer->pos.y, &pos)) {
@@ -2183,7 +2189,7 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
current_menu_main = cont.main;
current_menu_object = cont.object;
- current_menu_url = cont.link_url;
+ nsurl_create(cont.link_url, ¤t_menu_url);
}
}
@@ -2444,7 +2450,7 @@ void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_OBJECT_INFO:
if (current_menu_object != NULL)
ro_gui_window_prepare_objectinfo(current_menu_object,
- current_menu_url);
+ nsurl_access(current_menu_url));
break;
case BROWSER_OBJECT_SAVE:
@@ -2463,45 +2469,45 @@ void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_SAVE_URL_URI:
if (h != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(h)),
+ hlcache_handle_get_url(h),
content_get_title(h));
break;
case BROWSER_SAVE_URL_URL:
if (h != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(h)),
+ hlcache_handle_get_url(h),
content_get_title(h));
break;
case BROWSER_SAVE_URL_TEXT:
if (h != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(h)),
+ hlcache_handle_get_url(h),
content_get_title(h));
break;
case BROWSER_OBJECT_SAVE_URL_URI:
if (current_menu_object != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_URI, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(
- current_menu_object)),
+ hlcache_handle_get_url(
+ current_menu_object),
content_get_title(current_menu_object));
break;
case BROWSER_OBJECT_SAVE_URL_URL:
if (current_menu_object != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(
- current_menu_object)),
+ hlcache_handle_get_url(
+ current_menu_object),
content_get_title(current_menu_object));
break;
case BROWSER_OBJECT_SAVE_URL_TEXT:
if (current_menu_object != NULL)
ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
- nsurl_access(hlcache_handle_get_url(
- current_menu_object)),
+ hlcache_handle_get_url(
+ current_menu_object),
content_get_title(current_menu_object));
break;
@@ -2759,7 +2765,7 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_OBJECT_INFO:
if (current_menu_object != NULL) {
ro_gui_window_prepare_objectinfo(current_menu_object,
- current_menu_url);
+ nsurl_access(current_menu_url));
ro_gui_dialog_open_persistent(g->window,
dialog_objinfo, false);
}
@@ -2799,33 +2805,25 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case BROWSER_LINK_DOWNLOAD:
if (current_menu_url != NULL) {
- error = nsurl_create(current_menu_url, &url);
- if (error == NSERROR_OK) {
- error = browser_window_navigate(bw,
- url,
- browser_window_get_url(bw),
- BW_NAVIGATE_DOWNLOAD,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
+ error = browser_window_navigate(bw,
+ current_menu_url,
+ browser_window_get_url(bw),
+ BW_NAVIGATE_DOWNLOAD,
+ NULL,
+ NULL,
+ NULL);
}
break;
case BROWSER_LINK_NEW_WINDOW:
if (current_menu_url != NULL) {
- error = nsurl_create(current_menu_url, &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(
- BW_CREATE_HISTORY |
- BW_CREATE_CLONE,
- url,
- browser_window_get_url(bw),
- bw,
- NULL);
- nsurl_unref(url);
- }
+ error = browser_window_create(
+ BW_CREATE_HISTORY |
+ BW_CREATE_CLONE,
+ url,
+ browser_window_get_url(bw),
+ bw,
+ NULL);
}
break;
@@ -3050,7 +3048,10 @@ void ro_gui_window_menu_close(wimp_w w, wimp_i i, wimp_menu *menu)
{
if (menu == ro_gui_browser_window_menu) {
current_menu_object = NULL;
- current_menu_url = NULL;
+ if (current_menu_url != NULL) {
+ nsurl_unref(current_menu_url);
+ current_menu_url = NULL;
+ }
} else if (menu == gui_form_select_menu) {
gui_form_select_control = NULL;
}
@@ -3579,8 +3580,7 @@ void ro_gui_window_toolbar_click(void *data,
save_type = GUI_SAVE_LINK_TEXT;
ro_gui_drag_save_link(save_type,
- nsurl_access(
- browser_window_get_url(g->bw)),
+ browser_window_get_url(g->bw),
browser_window_get_title(g->bw), g);
}
break;
diff --git a/utils/url.c b/utils/url.c
index e1903a8..92e956b 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -147,109 +147,6 @@ out_true:
/* exported interface documented in utils/url.h */
-nserror url_nice(const char *url, char **result,
- bool remove_extensions)
-{
- int m;
- regmatch_t match[10];
- regoff_t start, end;
- size_t i;
- char *dot;
-
- *result = 0;
-
- m = regexec(&url_re, url, 10, match, 0);
- if (m) {
- LOG(("url '%s' failed to match regex", url));
- return NSERROR_NOT_FOUND;
- }
-
- /* extract the last component of the path, if possible */
- if (match[URL_RE_PATH].rm_so == -1 || match[URL_RE_PATH].rm_so ==
- match[URL_RE_PATH].rm_eo)
- goto no_path; /* no path, or empty */
- for (end = match[URL_RE_PATH].rm_eo - 1;
- end != match[URL_RE_PATH].rm_so && url[end] == '/';
- end--)
- ;
- if (end == match[URL_RE_PATH].rm_so)
- goto no_path; /* path is a string of '/' */
- end++;
- for (start = end - 1;
- start != match[URL_RE_PATH].rm_so && url[start] != '/';
- start--)
- ;
- if (url[start] == '/')
- start++;
-
- if (!strncasecmp(url + start, "index.", 6) ||
- !strncasecmp(url + start, "default.", 8)) {
- /* try again */
- if (start == match[URL_RE_PATH].rm_so)
- goto no_path;
- for (end = start - 1;
- end != match[URL_RE_PATH].rm_so &&
- url[end] == '/';
- end--)
- ;
- if (end == match[URL_RE_PATH].rm_so)
- goto no_path;
- end++;
- for (start = end - 1;
- start != match[URL_RE_PATH].rm_so &&
- url[start] != '/';
- start--)
- ;
- if (url[start] == '/')
- start++;
- }
-
- *result = malloc(end - start + 1);
- if (!*result) {
- LOG(("malloc failed"));
- return NSERROR_NOMEM;
- }
- strncpy(*result, url + start, end - start);
- (*result)[end - start] = 0;
-
- if (remove_extensions) {
- dot = strchr(*result, '.');
- if (dot && dot != *result)
- *dot = 0;
- }
-
- return NSERROR_OK;
-
-no_path:
-
- /* otherwise, use the host name, with '.' replaced by '_' */
- if (match[URL_RE_AUTHORITY].rm_so != -1 &&
- match[URL_RE_AUTHORITY].rm_so !=
- match[URL_RE_AUTHORITY].rm_eo) {
- *result = malloc(match[URL_RE_AUTHORITY].rm_eo -
- match[URL_RE_AUTHORITY].rm_so + 1);
- if (!*result) {
- LOG(("malloc failed"));
- return NSERROR_NOMEM;
- }
- strncpy(*result, url + match[URL_RE_AUTHORITY].rm_so,
- match[URL_RE_AUTHORITY].rm_eo -
- match[URL_RE_AUTHORITY].rm_so);
- (*result)[match[URL_RE_AUTHORITY].rm_eo -
- match[URL_RE_AUTHORITY].rm_so] = 0;
-
- for (i = 0; (*result)[i]; i++)
- if ((*result)[i] == '.')
- (*result)[i] = '_';
-
- return NSERROR_OK;
- }
-
- return NSERROR_NOT_FOUND;
-}
-
-
-/* exported interface documented in utils/url.h */
nserror url_unescape(const char *str, char **result)
{
char *curlstr;
diff --git a/utils/url.h b/utils/url.h
index a2efbec..d05ac05 100644
--- a/utils/url.h
+++ b/utils/url.h
@@ -56,16 +56,6 @@ bool url_host_is_ip_address(const char *host);
/**
- * Attempt to find a nice filename for a URL.
- *
- * \param url an absolute URL
- * \param result pointer to pointer to buffer to hold filename
- * \param remove_extensions remove any extensions from the filename
- * \return NSERROR_OK on success
- */
-nserror url_nice(const char *url, char **result, bool remove_extensions);
-
-/**
* Escape a string suitable for inclusion in an URL.
*
* \param unescaped the unescaped string
diff --git a/windows/download.c b/windows/download.c
index 8d3cc44..463a836 100644
--- a/windows/download.c
+++ b/windows/download.c
@@ -71,8 +71,9 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
messages_get("UnknownSize") :
human_friendly_bytesize(total_size);
- if (url_nice(nsurl_access(url), &filename, false) != NSERROR_OK)
+ if (nsurl_nice(url, &filename, false) != NSERROR_OK) {
filename = strdup(messages_get("UnknownFile"));
+ }
if (filename == NULL) {
warn_user(messages_get("NoMemory"), 0);
free(w);
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.2-281-g1620f20
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/1620f20c4d1e13b05f108...
...commit http://git.netsurf-browser.org/netsurf.git/commit/1620f20c4d1e13b05f10840...
...tree http://git.netsurf-browser.org/netsurf.git/tree/1620f20c4d1e13b05f1084075...
The branch, master has been updated
via 1620f20c4d1e13b05f108407508653841d4887eb (commit)
from 07376fc96bfe4f0670bef625295d460865ee114f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=1620f20c4d1e13b05f1...
commit 1620f20c4d1e13b05f108407508653841d4887eb
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make global history treeview callback return error
returns an error instead of directly waning the user.
diff --git a/desktop/global_history.c b/desktop/global_history.c
index 7d679e5..aaf4239 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -661,10 +661,12 @@ static nserror global_history_tree_node_folder_cb(
return NSERROR_OK;
}
-static nserror global_history_tree_node_entry_cb(
- struct treeview_node_msg msg, void *data)
+
+static nserror
+global_history_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
{
struct global_history_entry *e = data;
+ nserror ret = NSERROR_OK;
switch (msg.msg) {
case TREE_MSG_NODE_DELETE:
@@ -678,10 +680,8 @@ static nserror global_history_tree_node_entry_cb(
case TREE_MSG_NODE_LAUNCH:
{
- nserror error;
struct browser_window *existing = NULL;
- enum browser_window_create_flags flags =
- BW_CREATE_HISTORY;
+ enum browser_window_create_flags flags = BW_CREATE_HISTORY;
/* TODO: Set existing to window that new tab appears in */
@@ -693,16 +693,14 @@ static nserror global_history_tree_node_entry_cb(
/* TODO: flags ^= BW_CREATE_TAB; */
}
- error = browser_window_create(flags, e->url, NULL,
+ ret = browser_window_create(flags, e->url, NULL,
existing, NULL);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
}
break;
}
- return NSERROR_OK;
+ return ret;
}
+
struct treeview_callback_table gh_tree_cb_t = {
.folder = global_history_tree_node_folder_cb,
.entry = global_history_tree_node_entry_cb
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 820eb5c..fd03557 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -2402,6 +2402,7 @@ static nserror treeview_node_launch_walk_fwd_cb(treeview_node *n, void *ctx,
bool *skip_children, bool *end)
{
struct treeview_launch_walk_data *lw = ctx;
+ nserror ret = NSERROR_OK;
if (n->type == TREE_NODE_FOLDER && n->flags & TV_NFLAGS_SELECTED) {
lw->selected_depth++;
@@ -2412,10 +2413,10 @@ static nserror treeview_node_launch_walk_fwd_cb(treeview_node *n, void *ctx,
struct treeview_node_msg msg;
msg.msg = TREE_MSG_NODE_LAUNCH;
msg.data.node_launch.mouse = BROWSER_MOUSE_HOVER;
- lw->tree->callbacks->entry(msg, n->client_data);
+ ret = lw->tree->callbacks->entry(msg, n->client_data);
}
- return NSERROR_OK;
+ return ret;
}
/**
* Launch a selection.
-----------------------------------------------------------------------
Summary of changes:
desktop/global_history.c | 18 ++++++++----------
desktop/treeview.c | 5 +++--
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/desktop/global_history.c b/desktop/global_history.c
index 7d679e5..aaf4239 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -661,10 +661,12 @@ static nserror global_history_tree_node_folder_cb(
return NSERROR_OK;
}
-static nserror global_history_tree_node_entry_cb(
- struct treeview_node_msg msg, void *data)
+
+static nserror
+global_history_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
{
struct global_history_entry *e = data;
+ nserror ret = NSERROR_OK;
switch (msg.msg) {
case TREE_MSG_NODE_DELETE:
@@ -678,10 +680,8 @@ static nserror global_history_tree_node_entry_cb(
case TREE_MSG_NODE_LAUNCH:
{
- nserror error;
struct browser_window *existing = NULL;
- enum browser_window_create_flags flags =
- BW_CREATE_HISTORY;
+ enum browser_window_create_flags flags = BW_CREATE_HISTORY;
/* TODO: Set existing to window that new tab appears in */
@@ -693,16 +693,14 @@ static nserror global_history_tree_node_entry_cb(
/* TODO: flags ^= BW_CREATE_TAB; */
}
- error = browser_window_create(flags, e->url, NULL,
+ ret = browser_window_create(flags, e->url, NULL,
existing, NULL);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
}
break;
}
- return NSERROR_OK;
+ return ret;
}
+
struct treeview_callback_table gh_tree_cb_t = {
.folder = global_history_tree_node_folder_cb,
.entry = global_history_tree_node_entry_cb
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 820eb5c..fd03557 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -2402,6 +2402,7 @@ static nserror treeview_node_launch_walk_fwd_cb(treeview_node *n, void *ctx,
bool *skip_children, bool *end)
{
struct treeview_launch_walk_data *lw = ctx;
+ nserror ret = NSERROR_OK;
if (n->type == TREE_NODE_FOLDER && n->flags & TV_NFLAGS_SELECTED) {
lw->selected_depth++;
@@ -2412,10 +2413,10 @@ static nserror treeview_node_launch_walk_fwd_cb(treeview_node *n, void *ctx,
struct treeview_node_msg msg;
msg.msg = TREE_MSG_NODE_LAUNCH;
msg.data.node_launch.mouse = BROWSER_MOUSE_HOVER;
- lw->tree->callbacks->entry(msg, n->client_data);
+ ret = lw->tree->callbacks->entry(msg, n->client_data);
}
- return NSERROR_OK;
+ return ret;
}
/**
* Launch a selection.
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.2-280-g07376fc
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/07376fc96bfe4f0670bef...
...commit http://git.netsurf-browser.org/netsurf.git/commit/07376fc96bfe4f0670bef62...
...tree http://git.netsurf-browser.org/netsurf.git/tree/07376fc96bfe4f0670bef6252...
The branch, master has been updated
via 07376fc96bfe4f0670bef625295d460865ee114f (commit)
from 6f09b64c5931ae3615f381436558e82d01862ed3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=07376fc96bfe4f0670b...
commit 07376fc96bfe4f0670bef625295d460865ee114f
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove unused variable.
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 7479e72..5992c2b 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -2212,7 +2212,6 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
/* exported interface documented in utils/nsurl.h */
nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions)
{
- char *dot;
const char *data;
size_t len;
size_t pos;
-----------------------------------------------------------------------
Summary of changes:
utils/nsurl.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 7479e72..5992c2b 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -2212,7 +2212,6 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
/* exported interface documented in utils/nsurl.h */
nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions)
{
- char *dot;
const char *data;
size_t len;
size_t pos;
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.2-279-g6f09b64
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6f09b64c5931ae3615f38...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6f09b64c5931ae3615f3814...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6f09b64c5931ae3615f381436...
The branch, master has been updated
via 6f09b64c5931ae3615f381436558e82d01862ed3 (commit)
via 13832a453a6a4433b4dc62fb0092810671e8751e (commit)
via 3ff7557c34618d8e5d0dceccbbfafa2361712f69 (commit)
from 612100bd1a1690fb0884b1e6904c4ab2671ad023 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6f09b64c5931ae3615f...
commit 6f09b64c5931ae3615f381436558e82d01862ed3
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add some nsurl_nice tests.
diff --git a/test/nsurl.c b/test/nsurl.c
index bd7dc80..49ccdba 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -165,6 +165,32 @@ static const struct test_pairs join_tests[] = {
{ NULL, NULL }
};
+static const struct test_pairs nice_tests[] = {
+ { "www.foo.org", "www_foo_org" },
+ { "www.foo.org/index.html", "www_foo_org" },
+ { "www.foo.org/default.en", "www_foo_org" },
+ { "www.foo.org/about", "about" },
+ { "www.foo.org/about.jpg", "about.jpg" },
+ { "www.foo.org/moose/index.en", "moose" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "http://www.f.org//index.en", "www_f_org" },
+ { NULL, NULL }
+};
+
+static const struct test_pairs nice_strip_tests[] = {
+ { "www.foo.org", "www_foo_org" },
+ { "www.foo.org/index.html", "www_foo_org" },
+ { "www.foo.org/default.en", "www_foo_org" },
+ { "www.foo.org/about", "about" },
+ { "www.foo.org/about.jpg", "about" },
+ { "www.foo.org/moose/index.en", "moose" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "http://www.f.org//index.en", "www_f_org" },
+ { NULL, NULL }
+};
+
static const struct test_triplets replace_query_tests[] = {
{ "http://netsurf-browser.org/?magical=true",
"?magical=true&result=win",
@@ -284,6 +310,74 @@ int main(void)
count++;
}
+ /* nice filename tests */
+ LOG(("Testing nsurl_nice (no strip)"));
+ for (test = nice_tests; test->test != NULL; test++) {
+ err = nsurl_create(test->test, &base);
+ if (err != NSERROR_OK) {
+ LOG(("Failed to create URL:\n\t\t%s.", test->test));
+ } else {
+ char *res;
+ err = nsurl_nice(base, &res, false);
+ if (err == NSERROR_OK && test->res != NULL) {
+ if (strcmp(res, test->res) == 0) {
+ LOG(("\tPASS: \"%s\"\t--> %s",
+ test->test, res));
+ passed++;
+ } else {
+ LOG(("\tFAIL: \"%s\"\t--> %s",
+ test->test, res));
+ LOG(("\t\tExpecting %s", test->res));
+ }
+ free(res);
+ } else {
+ if (test->res == NULL && err == NSERROR_OK) {
+ LOG(("\tFAIL: \"%s\"\t--> %s",
+ test->test, res));
+ LOG(("\t\tExpecting BAD_INPUT"));
+ free(res);
+ } else {
+ LOG(("\tFAIL: \"%s\"", test->test));
+ }
+ }
+ nsurl_unref(base);
+ }
+ count++;
+ }
+ LOG(("Testing nsurl_nice (strip)"));
+ for (test = nice_strip_tests; test->test != NULL; test++) {
+ err = nsurl_create(test->test, &base);
+ if (err != NSERROR_OK) {
+ LOG(("Failed to create URL:\n\t\t%s.", test->test));
+ } else {
+ char *res;
+ err = nsurl_nice(base, &res, true);
+ if (err == NSERROR_OK && test->res != NULL) {
+ if (strcmp(res, test->res) == 0) {
+ LOG(("\tPASS: \"%s\"\t--> %s",
+ test->test, res));
+ passed++;
+ } else {
+ LOG(("\tFAIL: \"%s\"\t--> %s",
+ test->test, res));
+ LOG(("\t\tExpecting %s", test->res));
+ }
+ free(res);
+ } else {
+ if (test->res == NULL && err == NSERROR_OK) {
+ LOG(("\tFAIL: \"%s\"\t--> %s",
+ test->test, res));
+ LOG(("\t\tExpecting BAD_INPUT"));
+ free(res);
+ } else {
+ LOG(("\tFAIL: \"%s\"", test->test));
+ }
+ }
+ nsurl_unref(base);
+ }
+ count++;
+ }
+
/* Replace query tests */
LOG(("Testing nsurl_replace_query"));
for (ttest = replace_query_tests; ttest->test1 != NULL; ttest++) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=13832a453a6a4433b4d...
commit 13832a453a6a4433b4dc62fb0092810671e8751e
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add a nsurl_nice, which can replace url_nice.
diff --git a/utils/nsurl.c b/utils/nsurl.c
index f5bb06f..7479e72 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -2209,6 +2209,110 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
}
+/* exported interface documented in utils/nsurl.h */
+nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions)
+{
+ char *dot;
+ const char *data;
+ size_t len;
+ size_t pos;
+ bool match;
+ char *name;
+
+ *result = 0;
+
+ /* extract the last component of the path, if possible */
+ if ((url->components.path != NULL) &&
+ lwc_string_length(url->components.path) != 0 &&
+ lwc_string_isequal(url->components.path,
+ corestring_lwc_slash_, &match) == lwc_error_ok &&
+ match != true) {
+ bool first = true;
+ bool keep_looking;
+
+ /* Get hold of the string data we're examining */
+ data = lwc_string_data(url->components.path);
+ len = lwc_string_length(url->components.path);
+ pos = len;
+
+ do {
+ keep_looking = false;
+ pos--;
+
+ /* Find last '/' with stuff after it */
+ while (pos != 0) {
+ if (data[pos] == '/' && pos < len - 1) {
+ break;
+ }
+ pos--;
+ }
+
+ if (pos == 0) {
+ break;
+ }
+
+ if (first) {
+ if (strncasecmp("/default.", data + pos,
+ SLEN("/default.")) == 0) {
+ keep_looking = true;
+
+ } else if (strncasecmp("/index.",
+ data + pos,
+ 6) == 0) {
+ keep_looking = true;
+
+ }
+ first = false;
+ }
+
+ } while (keep_looking);
+
+ if (data[pos] == '/')
+ pos++;
+
+ if (strncasecmp("default.", data + pos, 8) != 0 &&
+ strncasecmp("index.", data + pos, 6) != 0) {
+ size_t end = pos;
+ while (data[end] != '\0' && data[end] != '/') {
+ end++;
+ }
+ if (end - pos != 0) {
+ name = malloc(end - pos + 1);
+ if (name == NULL) {
+ return NSERROR_NOMEM;
+ }
+ memcpy(name, data + pos, end - pos);
+ name[end - pos] = '\0';
+ if (remove_extensions) {
+ /* strip any extenstion */
+ char *dot = strchr(name, '.');
+ if (dot && dot != name) {
+ *dot = '\0';
+ }
+ }
+ *result = name;
+ return NSERROR_OK;
+ }
+ }
+ }
+
+ if (url->components.host != NULL) {
+ name = strdup(lwc_string_data(url->components.host));
+
+ for (pos = 0; name[pos] != '\0'; pos++) {
+ if (name[pos] == '.') {
+ name[pos] = '_';
+ }
+ }
+
+ *result = name;
+ return NSERROR_OK;
+ }
+
+ return NSERROR_NOT_FOUND;
+}
+
+
/* exported interface, documented in nsurl.h */
nserror nsurl_parent(const nsurl *url, nsurl **new_url)
{
diff --git a/utils/nsurl.h b/utils/nsurl.h
index 435df73..ec00ded 100644
--- a/utils/nsurl.h
+++ b/utils/nsurl.h
@@ -285,6 +285,19 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
/**
+ * Attempt to find a nice filename for a URL.
+ *
+ * \param url A NetSurf URL object to create a filename from
+ * \param result Updated to caller-owned string with filename
+ * \param remove_extensions remove any extensions from the filename
+ * \return NSERROR_OK on success, appropriate error otherwise
+ *
+ * Caller must ensure string result string is freed, if NSERROR_OK returned.
+ */
+nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions);
+
+
+/**
* Create a NetSurf URL object for URL with parent location of an existing URL.
*
* \param url NetSurf URL to create new NetSurf URL from
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3ff7557c34618d8e5d0...
commit 3ff7557c34618d8e5d0dceccbbfafa2361712f69
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add a lwc corestring for "/".
diff --git a/utils/corestrings.c b/utils/corestrings.c
index cb340e9..0f9c4d6 100644
--- a/utils/corestrings.c
+++ b/utils/corestrings.c
@@ -121,6 +121,7 @@ lwc_string *corestring_lwc__blank;
lwc_string *corestring_lwc__parent;
lwc_string *corestring_lwc__self;
lwc_string *corestring_lwc__top;
+lwc_string *corestring_lwc_slash_;
/* dom_string strings */
dom_string *corestring_dom_a;
@@ -380,6 +381,7 @@ void corestrings_fini(void)
CSS_LWC_STRING_UNREF(_parent);
CSS_LWC_STRING_UNREF(_self);
CSS_LWC_STRING_UNREF(_top);
+ CSS_LWC_STRING_UNREF(slash_);
#undef CSS_LWC_STRING_UNREF
@@ -687,6 +689,13 @@ nserror corestrings_init(void)
goto error;
}
+ lerror = lwc_intern_string("/", SLEN("/"),
+ &corestring_lwc_slash_);
+ if ((lerror != lwc_error_ok) || (corestring_lwc_slash_ == NULL)) {
+ error = NSERROR_NOMEM;
+ goto error;
+ }
+
#define CSS_DOM_STRING_INTERN(NAME) \
do { \
diff --git a/utils/corestrings.h b/utils/corestrings.h
index b41d1f8..9fcc224 100644
--- a/utils/corestrings.h
+++ b/utils/corestrings.h
@@ -126,6 +126,7 @@ extern lwc_string *corestring_lwc__blank;
extern lwc_string *corestring_lwc__parent;
extern lwc_string *corestring_lwc__self;
extern lwc_string *corestring_lwc__top;
+extern lwc_string *corestring_lwc_slash_; /* / */
struct dom_string;
-----------------------------------------------------------------------
Summary of changes:
test/nsurl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++
utils/corestrings.c | 9 +++++
utils/corestrings.h | 1 +
utils/nsurl.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++
utils/nsurl.h | 13 +++++++
5 files changed, 221 insertions(+)
diff --git a/test/nsurl.c b/test/nsurl.c
index bd7dc80..49ccdba 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -165,6 +165,32 @@ static const struct test_pairs join_tests[] = {
{ NULL, NULL }
};
+static const struct test_pairs nice_tests[] = {
+ { "www.foo.org", "www_foo_org" },
+ { "www.foo.org/index.html", "www_foo_org" },
+ { "www.foo.org/default.en", "www_foo_org" },
+ { "www.foo.org/about", "about" },
+ { "www.foo.org/about.jpg", "about.jpg" },
+ { "www.foo.org/moose/index.en", "moose" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "http://www.f.org//index.en", "www_f_org" },
+ { NULL, NULL }
+};
+
+static const struct test_pairs nice_strip_tests[] = {
+ { "www.foo.org", "www_foo_org" },
+ { "www.foo.org/index.html", "www_foo_org" },
+ { "www.foo.org/default.en", "www_foo_org" },
+ { "www.foo.org/about", "about" },
+ { "www.foo.org/about.jpg", "about" },
+ { "www.foo.org/moose/index.en", "moose" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "http://www.f.org//index.en", "www_f_org" },
+ { NULL, NULL }
+};
+
static const struct test_triplets replace_query_tests[] = {
{ "http://netsurf-browser.org/?magical=true",
"?magical=true&result=win",
@@ -284,6 +310,74 @@ int main(void)
count++;
}
+ /* nice filename tests */
+ LOG(("Testing nsurl_nice (no strip)"));
+ for (test = nice_tests; test->test != NULL; test++) {
+ err = nsurl_create(test->test, &base);
+ if (err != NSERROR_OK) {
+ LOG(("Failed to create URL:\n\t\t%s.", test->test));
+ } else {
+ char *res;
+ err = nsurl_nice(base, &res, false);
+ if (err == NSERROR_OK && test->res != NULL) {
+ if (strcmp(res, test->res) == 0) {
+ LOG(("\tPASS: \"%s\"\t--> %s",
+ test->test, res));
+ passed++;
+ } else {
+ LOG(("\tFAIL: \"%s\"\t--> %s",
+ test->test, res));
+ LOG(("\t\tExpecting %s", test->res));
+ }
+ free(res);
+ } else {
+ if (test->res == NULL && err == NSERROR_OK) {
+ LOG(("\tFAIL: \"%s\"\t--> %s",
+ test->test, res));
+ LOG(("\t\tExpecting BAD_INPUT"));
+ free(res);
+ } else {
+ LOG(("\tFAIL: \"%s\"", test->test));
+ }
+ }
+ nsurl_unref(base);
+ }
+ count++;
+ }
+ LOG(("Testing nsurl_nice (strip)"));
+ for (test = nice_strip_tests; test->test != NULL; test++) {
+ err = nsurl_create(test->test, &base);
+ if (err != NSERROR_OK) {
+ LOG(("Failed to create URL:\n\t\t%s.", test->test));
+ } else {
+ char *res;
+ err = nsurl_nice(base, &res, true);
+ if (err == NSERROR_OK && test->res != NULL) {
+ if (strcmp(res, test->res) == 0) {
+ LOG(("\tPASS: \"%s\"\t--> %s",
+ test->test, res));
+ passed++;
+ } else {
+ LOG(("\tFAIL: \"%s\"\t--> %s",
+ test->test, res));
+ LOG(("\t\tExpecting %s", test->res));
+ }
+ free(res);
+ } else {
+ if (test->res == NULL && err == NSERROR_OK) {
+ LOG(("\tFAIL: \"%s\"\t--> %s",
+ test->test, res));
+ LOG(("\t\tExpecting BAD_INPUT"));
+ free(res);
+ } else {
+ LOG(("\tFAIL: \"%s\"", test->test));
+ }
+ }
+ nsurl_unref(base);
+ }
+ count++;
+ }
+
/* Replace query tests */
LOG(("Testing nsurl_replace_query"));
for (ttest = replace_query_tests; ttest->test1 != NULL; ttest++) {
diff --git a/utils/corestrings.c b/utils/corestrings.c
index cb340e9..0f9c4d6 100644
--- a/utils/corestrings.c
+++ b/utils/corestrings.c
@@ -121,6 +121,7 @@ lwc_string *corestring_lwc__blank;
lwc_string *corestring_lwc__parent;
lwc_string *corestring_lwc__self;
lwc_string *corestring_lwc__top;
+lwc_string *corestring_lwc_slash_;
/* dom_string strings */
dom_string *corestring_dom_a;
@@ -380,6 +381,7 @@ void corestrings_fini(void)
CSS_LWC_STRING_UNREF(_parent);
CSS_LWC_STRING_UNREF(_self);
CSS_LWC_STRING_UNREF(_top);
+ CSS_LWC_STRING_UNREF(slash_);
#undef CSS_LWC_STRING_UNREF
@@ -687,6 +689,13 @@ nserror corestrings_init(void)
goto error;
}
+ lerror = lwc_intern_string("/", SLEN("/"),
+ &corestring_lwc_slash_);
+ if ((lerror != lwc_error_ok) || (corestring_lwc_slash_ == NULL)) {
+ error = NSERROR_NOMEM;
+ goto error;
+ }
+
#define CSS_DOM_STRING_INTERN(NAME) \
do { \
diff --git a/utils/corestrings.h b/utils/corestrings.h
index b41d1f8..9fcc224 100644
--- a/utils/corestrings.h
+++ b/utils/corestrings.h
@@ -126,6 +126,7 @@ extern lwc_string *corestring_lwc__blank;
extern lwc_string *corestring_lwc__parent;
extern lwc_string *corestring_lwc__self;
extern lwc_string *corestring_lwc__top;
+extern lwc_string *corestring_lwc_slash_; /* / */
struct dom_string;
diff --git a/utils/nsurl.c b/utils/nsurl.c
index f5bb06f..7479e72 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -2209,6 +2209,110 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
}
+/* exported interface documented in utils/nsurl.h */
+nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions)
+{
+ char *dot;
+ const char *data;
+ size_t len;
+ size_t pos;
+ bool match;
+ char *name;
+
+ *result = 0;
+
+ /* extract the last component of the path, if possible */
+ if ((url->components.path != NULL) &&
+ lwc_string_length(url->components.path) != 0 &&
+ lwc_string_isequal(url->components.path,
+ corestring_lwc_slash_, &match) == lwc_error_ok &&
+ match != true) {
+ bool first = true;
+ bool keep_looking;
+
+ /* Get hold of the string data we're examining */
+ data = lwc_string_data(url->components.path);
+ len = lwc_string_length(url->components.path);
+ pos = len;
+
+ do {
+ keep_looking = false;
+ pos--;
+
+ /* Find last '/' with stuff after it */
+ while (pos != 0) {
+ if (data[pos] == '/' && pos < len - 1) {
+ break;
+ }
+ pos--;
+ }
+
+ if (pos == 0) {
+ break;
+ }
+
+ if (first) {
+ if (strncasecmp("/default.", data + pos,
+ SLEN("/default.")) == 0) {
+ keep_looking = true;
+
+ } else if (strncasecmp("/index.",
+ data + pos,
+ 6) == 0) {
+ keep_looking = true;
+
+ }
+ first = false;
+ }
+
+ } while (keep_looking);
+
+ if (data[pos] == '/')
+ pos++;
+
+ if (strncasecmp("default.", data + pos, 8) != 0 &&
+ strncasecmp("index.", data + pos, 6) != 0) {
+ size_t end = pos;
+ while (data[end] != '\0' && data[end] != '/') {
+ end++;
+ }
+ if (end - pos != 0) {
+ name = malloc(end - pos + 1);
+ if (name == NULL) {
+ return NSERROR_NOMEM;
+ }
+ memcpy(name, data + pos, end - pos);
+ name[end - pos] = '\0';
+ if (remove_extensions) {
+ /* strip any extenstion */
+ char *dot = strchr(name, '.');
+ if (dot && dot != name) {
+ *dot = '\0';
+ }
+ }
+ *result = name;
+ return NSERROR_OK;
+ }
+ }
+ }
+
+ if (url->components.host != NULL) {
+ name = strdup(lwc_string_data(url->components.host));
+
+ for (pos = 0; name[pos] != '\0'; pos++) {
+ if (name[pos] == '.') {
+ name[pos] = '_';
+ }
+ }
+
+ *result = name;
+ return NSERROR_OK;
+ }
+
+ return NSERROR_NOT_FOUND;
+}
+
+
/* exported interface, documented in nsurl.h */
nserror nsurl_parent(const nsurl *url, nsurl **new_url)
{
diff --git a/utils/nsurl.h b/utils/nsurl.h
index 435df73..ec00ded 100644
--- a/utils/nsurl.h
+++ b/utils/nsurl.h
@@ -285,6 +285,19 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
/**
+ * Attempt to find a nice filename for a URL.
+ *
+ * \param url A NetSurf URL object to create a filename from
+ * \param result Updated to caller-owned string with filename
+ * \param remove_extensions remove any extensions from the filename
+ * \return NSERROR_OK on success, appropriate error otherwise
+ *
+ * Caller must ensure string result string is freed, if NSERROR_OK returned.
+ */
+nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions);
+
+
+/**
* Create a NetSurf URL object for URL with parent location of an existing URL.
*
* \param url NetSurf URL to create new NetSurf URL from
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.2-276-g612100b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/612100bd1a1690fb0884b...
...commit http://git.netsurf-browser.org/netsurf.git/commit/612100bd1a1690fb0884b1e...
...tree http://git.netsurf-browser.org/netsurf.git/tree/612100bd1a1690fb0884b1e69...
The branch, master has been updated
via 612100bd1a1690fb0884b1e6904c4ab2671ad023 (commit)
from c3522ea74785426e00335ec2652cabe8b23f3378 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=612100bd1a1690fb088...
commit 612100bd1a1690fb0884b1e6904c4ab2671ad023
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make local history navigation return errors
The local history interface now reports errors to its callers isntead
of inconsistantly waning the user occasionally on error.
The documentation comemhts were also updated to match reality
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index d4785d8..a73766b 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -413,14 +413,7 @@ static bool browser_window_history__enumerate_entry(
/* -------------------------------------------------------------------------- */
-/**
- * Create a new history tree for a browser window window.
- *
- * \param bw browser window to create history for.
- *
- * \return NSERROR_OK or appropriate error otherwise
- */
-
+/* exported interface documented in desktop/browser_history.h */
nserror browser_window_history_create(struct browser_window *bw)
{
struct history *history;
@@ -440,15 +433,7 @@ nserror browser_window_history_create(struct browser_window *bw)
}
-/**
- * Clone a bw's history tree for new bw
- *
- * \param existing browser window with history to clone.
- * \param clone browser window to make cloned history for.
- *
- * \return NSERROR_OK or appropriate error otherwise
- */
-
+/* exported interface documented in desktop/browser_history.h */
nserror browser_window_history_clone(const struct browser_window *existing,
struct browser_window *clone)
{
@@ -587,12 +572,8 @@ nserror browser_window_history_update(struct browser_window *bw,
}
-/**
- * Free a history structure.
- *
- * \param history opaque history structure, as returned by history_create()
- */
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_destroy(struct browser_window *bw)
{
assert(bw != NULL);
@@ -607,48 +588,34 @@ void browser_window_history_destroy(struct browser_window *bw)
}
-/**
- * Go back in the history.
- *
- * \param bw browser window
- * \param history history of the window
- * \param new_window whether to open in new window
- */
-void browser_window_history_back(struct browser_window *bw, bool new_window)
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_back(struct browser_window *bw, bool new_window)
{
if (!bw || !bw->history || !bw->history->current ||
- !bw->history->current->back)
- return;
- browser_window_history_go(bw, bw->history->current->back, new_window);
+ !bw->history->current->back) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ return browser_window_history_go(bw, bw->history->current->back,
+ new_window);
}
-/**
- * Go forward in the history.
- *
- * \param bw browser window
- * \param history history of the window
- * \param new_window whether to open in new window
- */
-void browser_window_history_forward(struct browser_window *bw, bool new_window)
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_forward(struct browser_window *bw,
+ bool new_window)
{
if (!bw || !bw->history || !bw->history->current ||
- !bw->history->current->forward_pref)
- return;
- browser_window_history_go(bw, bw->history->current->forward_pref,
- new_window);
+ !bw->history->current->forward_pref) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ return browser_window_history_go(bw, bw->history->current->forward_pref,
+ new_window);
}
-/**
- * Check whether it is pssible to go back in the history.
- *
- * \param history history of the window
- * \return true if the history can go back, false otherwise
- */
-
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_back_available(struct browser_window *bw)
{
return (bw && bw->history && bw->history->current &&
@@ -656,13 +623,7 @@ bool browser_window_history_back_available(struct browser_window *bw)
}
-/**
- * Check whether it is pssible to go forwards in the history.
- *
- * \param history history of the window
- * \return true if the history can go forwards, false otherwise
- */
-
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_forward_available(struct browser_window *bw)
{
return (bw && bw->history && bw->history->current &&
@@ -670,8 +631,8 @@ bool browser_window_history_forward_available(struct browser_window *bw)
}
-/* Documented in local_history.h */
-void browser_window_history_go(struct browser_window *bw,
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_go(struct browser_window *bw,
struct history_entry *entry, bool new_window)
{
struct history *history;
@@ -687,8 +648,7 @@ void browser_window_history_go(struct browser_window *bw,
entry->page.frag_id, &url);
if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return;
+ return error;
}
} else {
url = nsurl_ref(entry->page.url);
@@ -701,28 +661,19 @@ void browser_window_history_go(struct browser_window *bw,
error = browser_window_create(BW_CREATE_CLONE,
url, NULL, bw, NULL);
history->current = current;
- if (error != NSERROR_OK) {
- nsurl_unref(url);
- return;
- }
} else {
history->current = entry;
- browser_window_navigate(bw, url, NULL,
+ error = browser_window_navigate(bw, url, NULL,
BW_NAVIGATE_NONE, NULL, NULL, NULL);
}
nsurl_unref(url);
-}
+ return error;
+}
-/**
- * Get the dimensions of a history.
- *
- * \param history history to measure
- * \param width updated to width
- * \param height updated to height
- */
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_size(struct browser_window *bw,
int *width, int *height)
{
@@ -734,13 +685,7 @@ void browser_window_history_size(struct browser_window *bw,
}
-/**
- * Redraw a history.
- *
- * \param history history to render
- * \param ctx current redraw context
- */
-
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_redraw(struct browser_window *bw,
const struct redraw_context *ctx)
{
@@ -760,19 +705,8 @@ bool browser_window_history_redraw(struct browser_window *bw,
0, 0, 0, 0, 0, 0, false, ctx);
}
-/**
- * Redraw part of a history.
- *
- * \param history history to render
- * \param x0 left X co-ordinate of redraw area
- * \param y0 top Y co-ordinate of redraw area
- * \param x1 right X co-ordinate of redraw area
- * \param y1 lower Y co-ordinate of redraw area
- * \param x start X co-ordinate on plot canvas
- * \param y start Y co-ordinate on plot canvas
- * \param ctx current redraw context
- */
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_redraw_rectangle(struct browser_window *bw,
int x0, int y0, int x1, int y1,
int x, int y, const struct redraw_context *ctx)
@@ -789,16 +723,7 @@ bool browser_window_history_redraw_rectangle(struct browser_window *bw,
}
-/**
- * Handle a mouse click in a history.
- *
- * \param bw browser window containing history
- * \param x click coordinate
- * \param y click coordinate
- * \param new_window open a new window instead of using bw
- * \return true if action was taken, false if click was not on an entry
- */
-
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_click(struct browser_window *bw,
int x, int y, bool new_window)
{
@@ -820,15 +745,7 @@ bool browser_window_history_click(struct browser_window *bw,
}
-/**
- * Determine the URL of the entry at a position.
- *
- * \param history history to search
- * \param x coordinate
- * \param y coordinate
- * \return URL, or 0 if no entry at (x, y)
- */
-
+/* exported interface documented in desktop/browser_history.h */
const char *browser_window_history_position_url(struct browser_window *bw,
int x, int y)
{
@@ -845,7 +762,8 @@ const char *browser_window_history_position_url(struct browser_window *bw,
return nsurl_access(entry->page.url);
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_enumerate_forward(const struct browser_window *bw,
browser_window_history_enumerate_cb cb, void *user_data)
{
@@ -862,7 +780,8 @@ void browser_window_history_enumerate_forward(const struct browser_window *bw,
}
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_enumerate_back(const struct browser_window *bw,
browser_window_history_enumerate_cb cb, void *user_data)
{
@@ -878,7 +797,8 @@ void browser_window_history_enumerate_back(const struct browser_window *bw,
}
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_enumerate(const struct browser_window *bw,
browser_window_history_enumerate_cb cb, void *user_data)
{
@@ -888,21 +808,24 @@ void browser_window_history_enumerate(const struct browser_window *bw,
bw->history->start, cb, user_data);
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
const char *browser_window_history_entry_get_url(
const struct history_entry *entry)
{
return nsurl_access(entry->page.url);
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
const char *browser_window_history_entry_get_fragment_id(
const struct history_entry *entry)
{
return (entry->page.frag_id) ? lwc_string_data(entry->page.frag_id) : 0;
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
const char *browser_window_history_entry_get_title(
const struct history_entry *entry)
{
diff --git a/desktop/browser_history.h b/desktop/browser_history.h
index 1aac414..8ffb612 100644
--- a/desktop/browser_history.h
+++ b/desktop/browser_history.h
@@ -33,7 +33,23 @@ struct browser_window;
struct history_entry;
struct redraw_context;
+/**
+ * Create a new history tree for a browser window window.
+ *
+ * \param bw browser window to create history for.
+ *
+ * \return NSERROR_OK or appropriate error otherwise
+ */
nserror browser_window_history_create(struct browser_window *bw);
+
+/**
+ * Clone a bw's history tree for new bw
+ *
+ * \param existing browser window with history to clone.
+ * \param clone browser window to make cloned history for.
+ *
+ * \return NSERROR_OK or appropriate error otherwise
+ */
nserror browser_window_history_clone(const struct browser_window *existing,
struct browser_window *clone);
/**
@@ -59,20 +75,102 @@ nserror browser_window_history_add(struct browser_window *bw,
nserror browser_window_history_update(struct browser_window *bw,
struct hlcache_handle *content);
+/**
+ * Free a history structure.
+ *
+ * \param bw The browser window to destroy the history within.
+ */
void browser_window_history_destroy(struct browser_window *bw);
-void browser_window_history_back(struct browser_window *bw, bool new_window);
-void browser_window_history_forward(struct browser_window *bw, bool new_window);
+
+/**
+ * Go back in the history.
+ *
+ * \param bw A browser window to navigate the history in.
+ * \param new_window whether to open in new window.
+ * \return NSERROR_OK or error code on faliure.
+ */
+nserror browser_window_history_back(struct browser_window *bw, bool new_window);
+
+/**
+ * Go forward in the history.
+ *
+ * \param bw A browser window to navigate the history in.
+ * \param new_window whether to open in new window.
+ * \return NSERROR_OK or error code on faliure.
+ */
+nserror browser_window_history_forward(struct browser_window *bw, bool new_window);
+
+/**
+ * Check whether it is pssible to go back in the history.
+ *
+ * \param bw A browser window to check the history navigation in.
+ * \return true if the history can go back, false otherwise
+ */
bool browser_window_history_back_available(struct browser_window *bw);
+
+/**
+ * Check whether it is pssible to go forwards in the history.
+ *
+ * \param bw A browser window to check the history navigation in.
+ * \return true if the history can go forwards, false otherwise
+ */
bool browser_window_history_forward_available(struct browser_window *bw);
+
+/**
+ * Get the dimensions of a history.
+ *
+ * \param bw browser window with history object.
+ * \param width updated to width
+ * \param height updated to height
+ */
void browser_window_history_size(struct browser_window *bw,
int *width, int *height);
+
+/**
+ * Redraw all of a history area.
+ *
+ * \param bw browser window with history object.
+ * \param ctx current redraw context
+ */
bool browser_window_history_redraw(struct browser_window *bw,
const struct redraw_context *ctx);
+
+/**
+ * Redraw part of a history area.
+ *
+ * \param bw browser window with history object.
+ * \param x0 left X co-ordinate of redraw area
+ * \param y0 top Y co-ordinate of redraw area
+ * \param x1 right X co-ordinate of redraw area
+ * \param y1 lower Y co-ordinate of redraw area
+ * \param x start X co-ordinate on plot canvas
+ * \param y start Y co-ordinate on plot canvas
+ * \param ctx current redraw context
+ */
bool browser_window_history_redraw_rectangle(struct browser_window *bw,
int x0, int y0, int x1, int y1, int x, int y,
const struct redraw_context *ctx);
+
+/**
+ * Handle a mouse click in a history.
+ *
+ * \param bw browser window containing history
+ * \param x click coordinate
+ * \param y click coordinate
+ * \param new_window open a new window instead of using bw
+ * \return true if action was taken, false if click was not on an entry
+ */
bool browser_window_history_click(struct browser_window *bw,
int x, int y, bool new_window);
+
+/**
+ * Determine the URL of the entry at a position.
+ *
+ * \param bw browser window containing history
+ * \param x x coordinate.
+ * \param y y coordinate.
+ * \return URL, or 0 if no entry at (x, y)
+ */
const char *browser_window_history_position_url(struct browser_window *bw,
int x, int y);
@@ -153,8 +251,9 @@ const char *browser_window_history_entry_get_title(
* \param bw browser window
* \param entry entry to open
* \param new_window open entry in new window
+ * \return NSERROR_OK or error code on faliure.
*/
-void browser_window_history_go(struct browser_window *bw,
+nserror browser_window_history_go(struct browser_window *bw,
struct history_entry *entry, bool new_window);
#endif
-----------------------------------------------------------------------
Summary of changes:
desktop/browser_history.c | 163 ++++++++++++---------------------------------
desktop/browser_history.h | 105 ++++++++++++++++++++++++++++-
2 files changed, 145 insertions(+), 123 deletions(-)
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index d4785d8..a73766b 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -413,14 +413,7 @@ static bool browser_window_history__enumerate_entry(
/* -------------------------------------------------------------------------- */
-/**
- * Create a new history tree for a browser window window.
- *
- * \param bw browser window to create history for.
- *
- * \return NSERROR_OK or appropriate error otherwise
- */
-
+/* exported interface documented in desktop/browser_history.h */
nserror browser_window_history_create(struct browser_window *bw)
{
struct history *history;
@@ -440,15 +433,7 @@ nserror browser_window_history_create(struct browser_window *bw)
}
-/**
- * Clone a bw's history tree for new bw
- *
- * \param existing browser window with history to clone.
- * \param clone browser window to make cloned history for.
- *
- * \return NSERROR_OK or appropriate error otherwise
- */
-
+/* exported interface documented in desktop/browser_history.h */
nserror browser_window_history_clone(const struct browser_window *existing,
struct browser_window *clone)
{
@@ -587,12 +572,8 @@ nserror browser_window_history_update(struct browser_window *bw,
}
-/**
- * Free a history structure.
- *
- * \param history opaque history structure, as returned by history_create()
- */
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_destroy(struct browser_window *bw)
{
assert(bw != NULL);
@@ -607,48 +588,34 @@ void browser_window_history_destroy(struct browser_window *bw)
}
-/**
- * Go back in the history.
- *
- * \param bw browser window
- * \param history history of the window
- * \param new_window whether to open in new window
- */
-void browser_window_history_back(struct browser_window *bw, bool new_window)
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_back(struct browser_window *bw, bool new_window)
{
if (!bw || !bw->history || !bw->history->current ||
- !bw->history->current->back)
- return;
- browser_window_history_go(bw, bw->history->current->back, new_window);
+ !bw->history->current->back) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ return browser_window_history_go(bw, bw->history->current->back,
+ new_window);
}
-/**
- * Go forward in the history.
- *
- * \param bw browser window
- * \param history history of the window
- * \param new_window whether to open in new window
- */
-void browser_window_history_forward(struct browser_window *bw, bool new_window)
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_forward(struct browser_window *bw,
+ bool new_window)
{
if (!bw || !bw->history || !bw->history->current ||
- !bw->history->current->forward_pref)
- return;
- browser_window_history_go(bw, bw->history->current->forward_pref,
- new_window);
+ !bw->history->current->forward_pref) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ return browser_window_history_go(bw, bw->history->current->forward_pref,
+ new_window);
}
-/**
- * Check whether it is pssible to go back in the history.
- *
- * \param history history of the window
- * \return true if the history can go back, false otherwise
- */
-
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_back_available(struct browser_window *bw)
{
return (bw && bw->history && bw->history->current &&
@@ -656,13 +623,7 @@ bool browser_window_history_back_available(struct browser_window *bw)
}
-/**
- * Check whether it is pssible to go forwards in the history.
- *
- * \param history history of the window
- * \return true if the history can go forwards, false otherwise
- */
-
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_forward_available(struct browser_window *bw)
{
return (bw && bw->history && bw->history->current &&
@@ -670,8 +631,8 @@ bool browser_window_history_forward_available(struct browser_window *bw)
}
-/* Documented in local_history.h */
-void browser_window_history_go(struct browser_window *bw,
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_go(struct browser_window *bw,
struct history_entry *entry, bool new_window)
{
struct history *history;
@@ -687,8 +648,7 @@ void browser_window_history_go(struct browser_window *bw,
entry->page.frag_id, &url);
if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return;
+ return error;
}
} else {
url = nsurl_ref(entry->page.url);
@@ -701,28 +661,19 @@ void browser_window_history_go(struct browser_window *bw,
error = browser_window_create(BW_CREATE_CLONE,
url, NULL, bw, NULL);
history->current = current;
- if (error != NSERROR_OK) {
- nsurl_unref(url);
- return;
- }
} else {
history->current = entry;
- browser_window_navigate(bw, url, NULL,
+ error = browser_window_navigate(bw, url, NULL,
BW_NAVIGATE_NONE, NULL, NULL, NULL);
}
nsurl_unref(url);
-}
+ return error;
+}
-/**
- * Get the dimensions of a history.
- *
- * \param history history to measure
- * \param width updated to width
- * \param height updated to height
- */
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_size(struct browser_window *bw,
int *width, int *height)
{
@@ -734,13 +685,7 @@ void browser_window_history_size(struct browser_window *bw,
}
-/**
- * Redraw a history.
- *
- * \param history history to render
- * \param ctx current redraw context
- */
-
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_redraw(struct browser_window *bw,
const struct redraw_context *ctx)
{
@@ -760,19 +705,8 @@ bool browser_window_history_redraw(struct browser_window *bw,
0, 0, 0, 0, 0, 0, false, ctx);
}
-/**
- * Redraw part of a history.
- *
- * \param history history to render
- * \param x0 left X co-ordinate of redraw area
- * \param y0 top Y co-ordinate of redraw area
- * \param x1 right X co-ordinate of redraw area
- * \param y1 lower Y co-ordinate of redraw area
- * \param x start X co-ordinate on plot canvas
- * \param y start Y co-ordinate on plot canvas
- * \param ctx current redraw context
- */
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_redraw_rectangle(struct browser_window *bw,
int x0, int y0, int x1, int y1,
int x, int y, const struct redraw_context *ctx)
@@ -789,16 +723,7 @@ bool browser_window_history_redraw_rectangle(struct browser_window *bw,
}
-/**
- * Handle a mouse click in a history.
- *
- * \param bw browser window containing history
- * \param x click coordinate
- * \param y click coordinate
- * \param new_window open a new window instead of using bw
- * \return true if action was taken, false if click was not on an entry
- */
-
+/* exported interface documented in desktop/browser_history.h */
bool browser_window_history_click(struct browser_window *bw,
int x, int y, bool new_window)
{
@@ -820,15 +745,7 @@ bool browser_window_history_click(struct browser_window *bw,
}
-/**
- * Determine the URL of the entry at a position.
- *
- * \param history history to search
- * \param x coordinate
- * \param y coordinate
- * \return URL, or 0 if no entry at (x, y)
- */
-
+/* exported interface documented in desktop/browser_history.h */
const char *browser_window_history_position_url(struct browser_window *bw,
int x, int y)
{
@@ -845,7 +762,8 @@ const char *browser_window_history_position_url(struct browser_window *bw,
return nsurl_access(entry->page.url);
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_enumerate_forward(const struct browser_window *bw,
browser_window_history_enumerate_cb cb, void *user_data)
{
@@ -862,7 +780,8 @@ void browser_window_history_enumerate_forward(const struct browser_window *bw,
}
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_enumerate_back(const struct browser_window *bw,
browser_window_history_enumerate_cb cb, void *user_data)
{
@@ -878,7 +797,8 @@ void browser_window_history_enumerate_back(const struct browser_window *bw,
}
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
void browser_window_history_enumerate(const struct browser_window *bw,
browser_window_history_enumerate_cb cb, void *user_data)
{
@@ -888,21 +808,24 @@ void browser_window_history_enumerate(const struct browser_window *bw,
bw->history->start, cb, user_data);
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
const char *browser_window_history_entry_get_url(
const struct history_entry *entry)
{
return nsurl_access(entry->page.url);
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
const char *browser_window_history_entry_get_fragment_id(
const struct history_entry *entry)
{
return (entry->page.frag_id) ? lwc_string_data(entry->page.frag_id) : 0;
}
-/* Documented in local_history.h */
+
+/* exported interface documented in desktop/browser_history.h */
const char *browser_window_history_entry_get_title(
const struct history_entry *entry)
{
diff --git a/desktop/browser_history.h b/desktop/browser_history.h
index 1aac414..8ffb612 100644
--- a/desktop/browser_history.h
+++ b/desktop/browser_history.h
@@ -33,7 +33,23 @@ struct browser_window;
struct history_entry;
struct redraw_context;
+/**
+ * Create a new history tree for a browser window window.
+ *
+ * \param bw browser window to create history for.
+ *
+ * \return NSERROR_OK or appropriate error otherwise
+ */
nserror browser_window_history_create(struct browser_window *bw);
+
+/**
+ * Clone a bw's history tree for new bw
+ *
+ * \param existing browser window with history to clone.
+ * \param clone browser window to make cloned history for.
+ *
+ * \return NSERROR_OK or appropriate error otherwise
+ */
nserror browser_window_history_clone(const struct browser_window *existing,
struct browser_window *clone);
/**
@@ -59,20 +75,102 @@ nserror browser_window_history_add(struct browser_window *bw,
nserror browser_window_history_update(struct browser_window *bw,
struct hlcache_handle *content);
+/**
+ * Free a history structure.
+ *
+ * \param bw The browser window to destroy the history within.
+ */
void browser_window_history_destroy(struct browser_window *bw);
-void browser_window_history_back(struct browser_window *bw, bool new_window);
-void browser_window_history_forward(struct browser_window *bw, bool new_window);
+
+/**
+ * Go back in the history.
+ *
+ * \param bw A browser window to navigate the history in.
+ * \param new_window whether to open in new window.
+ * \return NSERROR_OK or error code on faliure.
+ */
+nserror browser_window_history_back(struct browser_window *bw, bool new_window);
+
+/**
+ * Go forward in the history.
+ *
+ * \param bw A browser window to navigate the history in.
+ * \param new_window whether to open in new window.
+ * \return NSERROR_OK or error code on faliure.
+ */
+nserror browser_window_history_forward(struct browser_window *bw, bool new_window);
+
+/**
+ * Check whether it is pssible to go back in the history.
+ *
+ * \param bw A browser window to check the history navigation in.
+ * \return true if the history can go back, false otherwise
+ */
bool browser_window_history_back_available(struct browser_window *bw);
+
+/**
+ * Check whether it is pssible to go forwards in the history.
+ *
+ * \param bw A browser window to check the history navigation in.
+ * \return true if the history can go forwards, false otherwise
+ */
bool browser_window_history_forward_available(struct browser_window *bw);
+
+/**
+ * Get the dimensions of a history.
+ *
+ * \param bw browser window with history object.
+ * \param width updated to width
+ * \param height updated to height
+ */
void browser_window_history_size(struct browser_window *bw,
int *width, int *height);
+
+/**
+ * Redraw all of a history area.
+ *
+ * \param bw browser window with history object.
+ * \param ctx current redraw context
+ */
bool browser_window_history_redraw(struct browser_window *bw,
const struct redraw_context *ctx);
+
+/**
+ * Redraw part of a history area.
+ *
+ * \param bw browser window with history object.
+ * \param x0 left X co-ordinate of redraw area
+ * \param y0 top Y co-ordinate of redraw area
+ * \param x1 right X co-ordinate of redraw area
+ * \param y1 lower Y co-ordinate of redraw area
+ * \param x start X co-ordinate on plot canvas
+ * \param y start Y co-ordinate on plot canvas
+ * \param ctx current redraw context
+ */
bool browser_window_history_redraw_rectangle(struct browser_window *bw,
int x0, int y0, int x1, int y1, int x, int y,
const struct redraw_context *ctx);
+
+/**
+ * Handle a mouse click in a history.
+ *
+ * \param bw browser window containing history
+ * \param x click coordinate
+ * \param y click coordinate
+ * \param new_window open a new window instead of using bw
+ * \return true if action was taken, false if click was not on an entry
+ */
bool browser_window_history_click(struct browser_window *bw,
int x, int y, bool new_window);
+
+/**
+ * Determine the URL of the entry at a position.
+ *
+ * \param bw browser window containing history
+ * \param x x coordinate.
+ * \param y y coordinate.
+ * \return URL, or 0 if no entry at (x, y)
+ */
const char *browser_window_history_position_url(struct browser_window *bw,
int x, int y);
@@ -153,8 +251,9 @@ const char *browser_window_history_entry_get_title(
* \param bw browser window
* \param entry entry to open
* \param new_window open entry in new window
+ * \return NSERROR_OK or error code on faliure.
*/
-void browser_window_history_go(struct browser_window *bw,
+nserror browser_window_history_go(struct browser_window *bw,
struct history_entry *entry, bool new_window);
#endif
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.2-275-gc3522ea
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c3522ea74785426e00335...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c3522ea74785426e00335ec...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c3522ea74785426e00335ec26...
The branch, master has been updated
via c3522ea74785426e00335ec2652cabe8b23f3378 (commit)
from c646d05ae572c6e9a53139ad2867a41bfeaa86c2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c3522ea74785426e003...
commit c3522ea74785426e00335ec2652cabe8b23f3378
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Change min stack (again) to 128K
It has come to my attention that some websites (eg amigakit.com) are using marginally more than the 96K stack space set previously. This should give plenty of breathing space.
diff --git a/amiga/gui.c b/amiga/gui.c
index 4788a08..aef0759 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -191,7 +191,7 @@ static char *current_user;
static char *current_user_dir;
static char *current_user_faviconcache;
-static const __attribute__((used)) char *stack_cookie = "\0$STACK:98304\0";
+static const __attribute__((used)) char *stack_cookie = "\0$STACK:131072\0";
const char * const versvn;
const char * const verdate;
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index 4788a08..aef0759 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -191,7 +191,7 @@ static char *current_user;
static char *current_user_dir;
static char *current_user_faviconcache;
-static const __attribute__((used)) char *stack_cookie = "\0$STACK:98304\0";
+static const __attribute__((used)) char *stack_cookie = "\0$STACK:131072\0";
const char * const versvn;
const char * const verdate;
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.2-274-gc646d05
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c646d05ae572c6e9a5313...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c646d05ae572c6e9a53139a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c646d05ae572c6e9a53139ad2...
The branch, master has been updated
via c646d05ae572c6e9a53139ad2867a41bfeaa86c2 (commit)
from 8947af72ce5fb2600531a9a0f2ac711030b7e06a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c646d05ae572c6e9a53...
commit c646d05ae572c6e9a53139ad2867a41bfeaa86c2
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
update nsurl file header to contain references to the specifications it implements
diff --git a/utils/nsurl.c b/utils/nsurl.c
index a85b447..f5bb06f 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -16,8 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * NetSurf URL handling (implementation).
+/**
+ * \file
+ * NetSurf URL handling implementation.
+ *
+ * This is the common implementation of all URL handling within the
+ * browser. This implemntation is based upon RFC3986 although this has
+ * been superceeded by https://url.spec.whatwg.org/ which is based on
+ * actual contemporary implementations.
*/
#include <assert.h>
-----------------------------------------------------------------------
Summary of changes:
utils/nsurl.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/utils/nsurl.c b/utils/nsurl.c
index a85b447..f5bb06f 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -16,8 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * NetSurf URL handling (implementation).
+/**
+ * \file
+ * NetSurf URL handling implementation.
+ *
+ * This is the common implementation of all URL handling within the
+ * browser. This implemntation is based upon RFC3986 although this has
+ * been superceeded by https://url.spec.whatwg.org/ which is based on
+ * actual contemporary implementations.
*/
#include <assert.h>
--
NetSurf Browser
9 years, 1 month