X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/blobdiff_plain/353bc75ddcc747e241296418a985ad2b265a86cf..522edd92f2bbef89ccd1dd0a3e874516fb47e2ef:/html.c diff --git a/html.c b/html.c index f7f8c3e..db6c25b 100644 --- a/html.c +++ b/html.c @@ -2,18 +2,9 @@ * html.c: implementation of html.h. */ -#include -#include -#include -#include -#include -#include -#include -#include - #include "agedu.h" #include "html.h" -#include "malloc.h" +#include "alloc.h" #include "trie.h" #include "index.h" @@ -36,9 +27,16 @@ static void vhtprintf(struct html *ctx, char *fmt, va_list ap) { va_list ap2; int size, size2; + char testbuf[2]; va_copy(ap2, ap); - size = vsnprintf(NULL, 0, fmt, ap2); + /* + * Some C libraries (Solaris, I'm looking at you) don't like + * an output buffer size of zero in vsnprintf, but will return + * sensible values given any non-zero buffer size. Hence, we + * use testbuf to gauge the length of the string. + */ + size = vsnprintf(testbuf, 1, fmt, ap2); va_end(ap2); if (ctx->buflen + size >= ctx->bufsize) { @@ -425,7 +423,7 @@ char *html_query(const void *t, unsigned long index, */ htprintf(ctx, "\n"); trie_getpath(t, index, path); - htprintf(ctx, "agedu: "); + htprintf(ctx, "<title>%s: ", PNAME); htescape(ctx, path, strlen(path), 0); htprintf(ctx, "\n"); htprintf(ctx, "\n");