=================================================================== RCS file: /cvs/mandoc/cgi.c,v retrieving revision 1.26 retrieving revision 1.28 diff -u -p -r1.26 -r1.28 --- mandoc/cgi.c 2011/12/10 22:45:47 1.26 +++ mandoc/cgi.c 2011/12/10 23:09:25 1.28 @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.26 2011/12/10 22:45:47 kristaps Exp $ */ +/* $Id: cgi.c,v 1.28 2011/12/10 23:09:25 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -364,6 +364,7 @@ resp_end_html(void) static void resp_searchform(const struct req *req) { + int i; puts(""); printf("
q.arch ? req->q.arch : ""); - puts("\">.\n" + printf("\">"); + if (req->psz > 1) { + puts(", "); + } + puts(".\n" "\n" "\n" "
"); @@ -837,7 +853,7 @@ pg_search(const struct req *req, char *path) struct opts opt; struct expr *expr; - if (req->q.manroot < 0) { + if (req->q.manroot < 0 || 0 == req->psz) { resp_search(NULL, 0, (void *)req); return; } @@ -1100,14 +1116,17 @@ pathgen(DIR *dir, char *path, struct req *req) if (rc > 0) { /* This also strips the trailing slash. */ - path[(int)sz - 1] = '\0'; + path[(int)--sz] = '\0'; req->p = mandoc_realloc (req->p, (req->psz + 1) * sizeof(struct paths)); + /* + * Strip out the leading "./" unless we're just a ".", + * in which case use an empty string as our name. + */ req->p[(int)req->psz].path = mandoc_strdup(path); - /* And this strips out the leading "./". */ req->p[(int)req->psz].name = - cp = mandoc_strdup(path + 2); + cp = mandoc_strdup(path + (1 == sz ? 1 : 2)); req->psz++; /* * The name is just the path with all the slashes taken