summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-10-28 19:19:08 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-10-28 19:19:08 +0000
commitdcc5a532bca372766ea797bfc9c83f815924868f (patch)
tree66260f67188e648e0f27f03cc25ddc2f2d1287db /desktop
parenta112bfb6769fd393b0903f9262a8e1913407eda8 (diff)
downloadnetsurf-dcc5a532bca372766ea797bfc9c83f815924868f.tar.gz
netsurf-dcc5a532bca372766ea797bfc9c83f815924868f.tar.bz2
Use nsurl to add fragment for URL bar display.
svn path=/trunk/netsurf/; revision=13088
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 4f551a3e3..5afeaecef 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1963,8 +1963,6 @@ void browser_window_set_scale_internal(struct browser_window *bw, float scale)
void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url,
const char *frag)
{
- char *url_buf;
-
assert(bw);
assert(url);
@@ -1979,18 +1977,27 @@ void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url,
*/
gui_window_set_url(bw->window, nsurl_access(url));
} else {
- url_buf = malloc(nsurl_length(url) + 1 /* # */ +
- strlen(frag) + 1 /* \0 */);
- if (url_buf != NULL) {
- /* This sprintf is safe because of the above size
- * calculation, thus we don't need snprintf
- */
- sprintf(url_buf, "%s#%s", nsurl_access(url), frag);
- gui_window_set_url(bw->window, url_buf);
- free(url_buf);
- } else {
+ nsurl *display_url;
+ lwc_string *lwc_frag;
+ nserror error;
+ lwc_error lerror;
+
+ lerror = lwc_intern_string(frag, strlen(frag), &lwc_frag);
+ if (lerror != lwc_error_ok) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+
+ error = nsurl_refragment(url, lwc_frag, &display_url);
+ if (error != NSERROR_OK) {
warn_user("NoMemory", 0);
+ lwc_string_unref(lwc_frag);
+ return;
}
+
+ gui_window_set_url(bw->window, nsurl_access(display_url));
+ lwc_string_unref(lwc_frag);
+ nsurl_unref(display_url);
}
}