commit d2eabbdefaf205667738eac23c45665567510034
parent 02cf3cd56cac150229d559742d32411504c88546
Author: ukai <ukai>
Date:   Sat, 26 Jan 2002 17:24:01 +0000
[w3m-dev 02914]
* history.c (copyHist): added
* history.h (copyHist): ditto
* main.c (goURL0): copyHist(URLHist), push current and anchor URLs
	default set by DefaultURLString
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
Diffstat:
4 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,11 @@
+2002-01-27  Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
+
+	* [w3m-dev 02914]
+	* history.c (copyHist): added
+	* history.h (copyHist): ditto
+	* main.c (goURL0): copyHist(URLHist), push current and anchor URLs
+		default set by DefaultURLString
+
 2002-01-26  Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
 
 	* [w3m-dev 02913] wrong table width calculation
diff --git a/history.c b/history.c
@@ -82,6 +82,20 @@ newHist()
     return hist;
 }
 
+Hist *
+copyHist(Hist *hist)
+{
+    Hist *new;
+    HistItem *item;
+
+    if (hist == NULL)
+	return NULL;
+    new = newHist();
+    for (item = hist->list->first; item; item = item->next)
+	pushHist(new, (char *)item->ptr);
+    return new;
+}
+
 HistItem *
 unshiftHist(Hist *hist, char *ptr)
 {
diff --git a/history.h b/history.h
@@ -18,6 +18,7 @@ typedef struct {
 } Hist;
 
 extern Hist *newHist();
+extern Hist *copyHist(Hist *hist);
 extern HistItem *unshiftHist(Hist *hist, char *ptr);
 extern HistItem *pushHist(Hist *hist, char *ptr);
 extern HistItem *pushHashHist(Hist *hist, char *ptr);
diff --git a/main.c b/main.c
@@ -3621,19 +3621,28 @@ goURL0(char *prompt, int relative)
 
     url = searchKeyData();
     if (url == NULL) {
-	if (DefaultURLString == DEFAULT_URL_CURRENT) {
-	    current = baseURL(Currentbuf);
-	    if (current)
-		url = parsedURL2Str(current)->ptr;
+	Hist *hist = copyHist(URLHist);
+	Anchor *a;
+
+	current = baseURL(Currentbuf);
+	if (current) {
+	    char *c_url = parsedURL2Str(current)->ptr;
+	    if (DefaultURLString == DEFAULT_URL_CURRENT)
+		url = c_url;
+	    else
+		pushHist(hist, c_url);
 	}
-	else if (DefaultURLString == DEFAULT_URL_LINK) {
-	    Anchor *a = retrieveCurrentAnchor(Currentbuf);
-	    if (a) {
-		parseURL2(a->url, &p_url, baseURL(Currentbuf));
-		url = parsedURL2Str(&p_url)->ptr;
-	    }
+	a = retrieveCurrentAnchor(Currentbuf);
+	if (a) {
+	    char *a_url;
+	    parseURL2(a->url, &p_url, current);
+	    a_url = parsedURL2Str(&p_url)->ptr;
+	    if (DefaultURLString == DEFAULT_URL_LINK)
+		url = a_url;
+	    else
+		pushHist(hist, a_url);
 	}
-	url = inputLineHist(prompt, url, IN_URL, URLHist);
+	url = inputLineHist(prompt, url, IN_URL, hist);
 	if (url != NULL)
 	    SKIP_BLANKS(url);
     }