diff options
| author | bptato <nincsnevem662@gmail.com> | 2020-10-21 11:30:01 +0000 | 
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2020-10-21 11:30:01 +0000 | 
| commit | 16e0b6aa63541c83726ade3df6f8c23f9c15c1ff (patch) | |
| tree | 1b007a2781ce8f5817365c03b9395f187694a925 | |
| parent | Improved gopher support (diff) | |
| download | w3m-16e0b6aa63541c83726ade3df6f8c23f9c15c1ff.tar.gz w3m-16e0b6aa63541c83726ade3df6f8c23f9c15c1ff.zip | |
Improved gopher directory display
| -rw-r--r-- | file.c | 21 | 
1 files changed, 18 insertions, 3 deletions
| @@ -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;  } | 
