=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/cgi.c,v retrieving revision 1.65 retrieving revision 1.66 diff -c -r1.65 -r1.66 *** src/usr.bin/mandoc/cgi.c 2016/04/15 01:33:48 1.65 --- src/usr.bin/mandoc/cgi.c 2016/04/15 15:13:02 1.66 *************** *** 1,4 **** ! /* $OpenBSD: cgi.c,v 1.65 2016/04/15 01:33:48 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014, 2015, 2016 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: cgi.c,v 1.66 2016/04/15 15:13:02 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014, 2015, 2016 Ingo Schwarze *************** *** 1083,1089 **** static void path_parse(struct req *req, const char *path) { ! int dir_done; req->isquery = 0; req->q.equal = 1; --- 1083,1089 ---- static void path_parse(struct req *req, const char *path) { ! char *dir; req->isquery = 0; req->q.equal = 1; *************** *** 1113,1135 **** req->q.query = mandoc_strdup(req->q.query); /* Optional architecture. */ ! dir_done = 0; ! for (;;) { ! if ((req->q.arch = strrchr(req->q.manpath, '/')) == NULL) ! break; ! *req->q.arch++ = '\0'; ! if (dir_done || strncmp(req->q.arch, "man", 3)) { ! req->q.arch = mandoc_strdup(req->q.arch); ! break; ! } ! /* Optional directory name. */ ! req->q.arch += 3; ! if (*req->q.arch != '\0') { ! free(req->q.sec); ! req->q.sec = mandoc_strdup(req->q.arch); ! } ! dir_done = 1; } } --- 1113,1131 ---- req->q.query = mandoc_strdup(req->q.query); /* Optional architecture. */ ! dir = strrchr(req->q.manpath, '/'); ! if (dir != NULL && strncmp(dir + 1, "man", 3) != 0) { ! *dir++ = '\0'; ! req->q.arch = mandoc_strdup(dir); ! dir = strrchr(req->q.manpath, '/'); ! } else ! req->q.arch = NULL; ! /* Optional directory name. */ ! if (dir != NULL && strncmp(dir + 1, "man", 3) == 0) { ! *dir++ = '\0'; ! free(req->q.sec); ! req->q.sec = mandoc_strdup(dir + 3); } }