=================================================================== RCS file: /cvs/mandoc/cgi.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -p -r1.14 -r1.15 --- mandoc/cgi.c 2011/12/07 15:55:06 1.14 +++ mandoc/cgi.c 2011/12/07 16:08:55 1.15 @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.14 2011/12/07 15:55:06 kristaps Exp $ */ +/* $Id: cgi.c,v 1.15 2011/12/07 16:08:55 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -67,6 +67,7 @@ struct req { static int atou(const char *, unsigned *); static void catman(const char *); +static int cmp(const void *, const void *); static void format(const char *); static void html_print(const char *); static void html_putchar(char); @@ -423,7 +424,6 @@ static void resp_search(struct res *r, size_t sz, void *arg) { int i; - char *cp; if (1 == sz) { /* @@ -438,6 +438,8 @@ resp_search(struct res *r, size_t sz, void *arg) return; } + qsort(r, sz, sizeof(struct res), cmp); + resp_begin_html(200, NULL); resp_searchform((const struct req *)arg); @@ -454,8 +456,7 @@ resp_search(struct res *r, size_t sz, void *arg) printf("", r[i].volume, r[i].rec); - for (cp = r[i].title; '\0' != *cp; cp++) - html_putchar(toupper((unsigned char)*cp)); + html_print(r[i].title); putchar('('); html_print(r[i].cat); if (r[i].arch && '\0' != *r[i].arch) { @@ -752,7 +753,7 @@ pg_search(const struct manpaths *ps, const struct req cp = NULL; ep = NULL; sz = 0; - whatis = 0; + whatis = 1; memset(&opt, 0, sizeof(struct opts)); @@ -917,3 +918,12 @@ main(void) return(EXIT_SUCCESS); } + +static int +cmp(const void *p1, const void *p2) +{ + + return(strcasecmp(((const struct res *)p1)->title, + ((const struct res *)p2)->title)); +} +