diff options
author | jcid <devnull@localhost> | 2008-04-04 00:23:21 +0200 |
---|---|---|
committer | jcid <devnull@localhost> | 2008-04-04 00:23:21 +0200 |
commit | 7650ae10e77d0058fe617ef670bad60349b45fed (patch) | |
tree | 73f1acb8f5a87c21391ea9d6925b5e6608bff649 /src/history.c | |
parent | 963d90761006e0b296f64ea93e29bbac696bae09 (diff) |
- Fixed a SEGFAULT bug in http.c (handling of web->url).
- Fixed handling of #anchors with repush, and other operations.
Diffstat (limited to 'src/history.c')
-rw-r--r-- | src/history.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/history.c b/src/history.c index ad08611b..4b8fb426 100644 --- a/src/history.c +++ b/src/history.c @@ -13,6 +13,7 @@ * Linear history (it also provides indexes for the navigation stack) */ +#include "msg.h" #include "list.h" #include "history.h" @@ -30,6 +31,19 @@ static int history_size_max = 16; /* + * Debug procedure. + */ +void History_show() +{ + int i; + + MSG(" {"); + for (i = 0; i < history_size; ++i) + MSG(" %s", URL_STR(history[i].url)); + MSG(" }\n"); +} + +/* * Add a new H_Item at the end of the history list * (taking care of not making a duplicate entry) */ @@ -37,16 +51,26 @@ int a_History_add_url(DilloUrl *url) { int i, idx; + _MSG("a_History_add_url: '%s' ", URL_STR(url)); for (i = 0; i < history_size; ++i) if (!a_Url_cmp(history[i].url, url) && !strcmp(URL_FRAGMENT(history[i].url), URL_FRAGMENT(url))) - return i; + break; + + if (i < history_size) { + idx = i; + _MSG("FOUND at idx=%d\n", idx); + } else { + idx = history_size; + a_List_add(history, history_size, history_size_max); + history[idx].url = a_Url_dup(url); + history[idx].title = NULL; + ++history_size; + _MSG("ADDED at idx=%d\n", idx); + } + + /* History_show(); */ - idx = history_size; - a_List_add(history, history_size, history_size_max); - history[idx].url = a_Url_dup(url); - history[idx].title = NULL; - ++history_size; return idx; } @@ -68,6 +92,9 @@ int a_History_set_title(int idx, const char *title) */ DilloUrl *a_History_get_url(int idx) { + _MSG("a_History_get_url: "); + /* History_show(); */ + dReturn_val_if_fail(idx >= 0 && idx < history_size, NULL); return history[idx].url; |