From f6b315a17f689e85fa1b6a376b4e230fdaf13be2 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Fri, 5 Jun 2015 15:10:21 +0200
Subject: [PATCH] Fixed history handling.
- The wraparound handling when using the history with the 'back' button is actually depending on history_last being unsigned (which is the default for cc65) so define it explicitly as unsigned to make it work on other targets too.
- As there's no 'forward' button it doesn't make sense to keep history entries after using them with the 'back' button. Clearing them on use on the other hand avoids an "infinite history".
---
apps/webbrowser/www.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/apps/webbrowser/www.c b/apps/webbrowser/www.c
index 2722f842c..47900de51 100644
--- a/apps/webbrowser/www.c
+++ b/apps/webbrowser/www.c
@@ -125,7 +125,7 @@ static struct ctk_button wgetyesbutton =
#if WWW_CONF_HISTORY_SIZE > 0
/* The char arrays that hold the history of visited URLs. */
static char history[WWW_CONF_HISTORY_SIZE][WWW_CONF_MAX_URLLEN];
-static char history_last;
+static unsigned char history_last;
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
struct linkattrib {
@@ -516,10 +516,12 @@ PROCESS_THREAD(www_process, ev, data)
firsty = 0;
start_loading();
--history_last;
+ /* Note: history_last is unsigned ! */
if(history_last > WWW_CONF_HISTORY_SIZE) {
history_last = WWW_CONF_HISTORY_SIZE - 1;
}
memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN);
+ *history[(int)history_last] = 0;
open_url();
CTK_WIDGET_FOCUS(&mainwindow, &backbutton);
#endif /* WWW_CONF_HISTORY_SIZE > 0 */