From 16e0b6aa63541c83726ade3df6f8c23f9c15c1ff Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 21 Oct 2020 13:30:01 +0200 Subject: Improved gopher directory display --- file.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'file.c') 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 = 0; + } Strcat_m_charp(tmp, "", p, " ", html_quote(name->ptr + 1), "
\n", NULL); } else { - Strcat_m_charp(tmp, "

", html_quote(name->ptr + 1), "

\n", NULL); + if(!pre) { + Strcat_charp(tmp, "
");
+		pre = 1;
+	    }
+
+	    Strcat_m_charp(tmp, html_quote(name->ptr + 1), "\n", NULL);
 	}
     }
 
   gopher_end:
     TRAP_OFF;
 
+    if(pre)
+	Strcat_charp(tmp, "
"); Strcat_charp(tmp, "\n\n\n"); return tmp; } -- cgit v1.2.3