aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2020-10-21 11:30:01 +0000
committerbptato <nincsnevem662@gmail.com>2020-10-21 11:30:01 +0000
commit16e0b6aa63541c83726ade3df6f8c23f9c15c1ff (patch)
tree1b007a2781ce8f5817365c03b9395f187694a925 /file.c
parentImproved gopher support (diff)
downloadw3m-16e0b6aa63541c83726ade3df6f8c23f9c15c1ff.tar.gz
w3m-16e0b6aa63541c83726ade3df6f8c23f9c15c1ff.zip
Improved gopher directory display
Diffstat (limited to '')
-rw-r--r--file.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/file.c b/file.c
index 41e8f58..12f439a 100644
--- a/file.c
+++ b/file.c
@@ -7395,7 +7395,7 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset)
Str volatile tmp;
Str lbuf, name, file, host, port, type;
char *volatile p, *volatile q;
- int link;
+ int link, pre;
MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL;
#ifdef USE_M17N
wc_ces doc_charset = DocumentCharset;
@@ -7415,6 +7415,7 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset)
goto gopher_end;
TRAP_ON;
+ pre = 0;
while (1) {
if (lbuf = StrUFgets(uf), lbuf->length == 0)
break;
@@ -7469,19 +7470,33 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset)
break;
}
type = Strsubstr(name, 0, 1);
- q = Strnew_m_charp("gopher://", host->ptr, ":", port->ptr, file->ptr, type->ptr, NULL)->ptr;
+ if(file->ptr[0] == '/')
+ q = Strnew_m_charp("gopher://", host->ptr, ":", port->ptr, file->ptr, type->ptr, NULL)->ptr;
+ else
+ q = Strnew_m_charp("gopher://", host->ptr, ":", port->ptr, "/", file->ptr, type->ptr, NULL)->ptr;
if(link) {
+ if(pre) {
+ Strcat_charp(tmp, "</pre>");
+ pre = 0;
+ }
Strcat_m_charp(tmp, "<a href=\"",
html_quote(url_encode(q, NULL, *charset)),
"\">", p, " ", html_quote(name->ptr + 1), "</a><br>\n", NULL);
} else {
- Strcat_m_charp(tmp, "<p>", html_quote(name->ptr + 1), "</p>\n", NULL);
+ if(!pre) {
+ Strcat_charp(tmp, "<pre>");
+ pre = 1;
+ }
+
+ Strcat_m_charp(tmp, html_quote(name->ptr + 1), "\n", NULL);
}
}
gopher_end:
TRAP_OFF;
+ if(pre)
+ Strcat_charp(tmp, "</pre>");
Strcat_charp(tmp, "</table>\n</body>\n</html>\n");
return tmp;
}