diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-26 17:55:27 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-26 17:55:27 +0000 |
commit | 54ae5bad68aa6c3d014c8ecdb59a4fbbaa3fe3fd (patch) | |
tree | 9d17a7547f0ae51ac7ed6f8661b898c2c80f85b9 /cgi.c | |
parent | 0de54681d3f7151e2b9b98b64fe36571d47f3658 (diff) | |
download | mandoc-54ae5bad68aa6c3d014c8ecdb59a4fbbaa3fe3fd.tar.gz |
Make the code sipler and more robust by always assigning a value
to q.manpath and dropping the (incomplete) later NULL checks.
Diffstat (limited to 'cgi.c')
-rw-r--r-- | cgi.c | 16 |
1 files changed, 5 insertions, 11 deletions
@@ -163,8 +163,7 @@ http_printquery(const struct req *req, const char *sep) printf("%sarch=", sep); http_print(req->q.arch); } - if (NULL != req->q.manpath && - strcmp(req->q.manpath, req->p[0])) { + if (strcmp(req->q.manpath, req->p[0])) { printf("%smanpath=", sep); http_print(req->q.manpath); } @@ -298,11 +297,6 @@ next: if (*qs != '\0') qs++; } - - /* Fall back to the default manpath. */ - - if (req->q.manpath == NULL) - req->q.manpath = mandoc_strdup(req->p[0]); } static void @@ -469,8 +463,7 @@ resp_searchform(const struct req *req) puts("<SELECT NAME=\"manpath\">"); for (i = 0; i < (int)req->psz; i++) { printf("<OPTION "); - if (NULL == req->q.manpath ? 0 == i : - 0 == strcmp(req->q.manpath, req->p[i])) + if (strcmp(req->q.manpath, req->p[i]) == 0) printf("SELECTED=\"selected\" "); printf("VALUE=\""); html_print(req->p[i]); @@ -1081,8 +1074,9 @@ main(void) if (NULL != (querystring = getenv("QUERY_STRING"))) http_parse(&req, querystring); - if ( ! (NULL == req.q.manpath || - validate_manpath(&req, req.q.manpath))) { + if (req.q.manpath == NULL) + req.q.manpath = mandoc_strdup(req.p[0]); + else if ( ! validate_manpath(&req, req.q.manpath)) { pg_error_badrequest( "You specified an invalid manpath."); return(EXIT_FAILURE); |