Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makemandb - Fix legacy mode to use like instead of ...



details:   https://anonhg.NetBSD.org/src/rev/e5d65e39e80e
branches:  trunk
changeset: 785770:e5d65e39e80e
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Mar 29 20:37:00 2013 +0000

description:
- Fix legacy mode to use like instead of match. This loses ranking.
- default to unlimited lines
- fix formatting of legacy mode

diffstat:

 usr.sbin/makemandb/apropos-utils.c |  22 ++++++++--------------
 usr.sbin/makemandb/apropos.1       |  17 +----------------
 usr.sbin/makemandb/apropos.c       |   8 ++++----
 3 files changed, 13 insertions(+), 34 deletions(-)

diffs (119 lines):

diff -r 0eb700bcef41 -r e5d65e39e80e usr.sbin/makemandb/apropos-utils.c
--- a/usr.sbin/makemandb/apropos-utils.c        Fri Mar 29 20:20:22 2013 +0000
+++ b/usr.sbin/makemandb/apropos-utils.c        Fri Mar 29 20:37:00 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apropos-utils.c,v 1.12 2013/03/29 20:07:31 christos Exp $      */
+/*     $NetBSD: apropos-utils.c,v 1.13 2013/03/29 20:37:00 christos Exp $      */
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos-utils.c,v 1.12 2013/03/29 20:07:31 christos Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.13 2013/03/29 20:37:00 christos Exp $");
 
 #include <sys/queue.h>
 #include <sys/stat.h>
@@ -550,27 +550,21 @@
                snippet_args = default_snippet_args;
        }
        if (args->legacy) {
+           char *wild;
+           easprintf(&wild, "%%%s%%", args->search_str);
            query = sqlite3_mprintf("SELECT section, name, name_desc, machine,"
-               " snippet(mandb, %Q, %Q, %Q, -1, 40 ),"
-               " rank_func(matchinfo(mandb, \"pclxn\")) AS rank"
+               " snippet(mandb, %Q, %Q, %Q, -1, 40 )"
                " FROM mandb"
-               " WHERE name MATCH %Q "
+               " WHERE name LIKE %Q OR name_desc LIKE %Q "
                "%s"
-               " UNION SELECT section, name, name_desc, machine,"
-               " snippet(mandb, %Q, %Q, %Q, -1, 40 ),"
-               " rank_func(matchinfo(mandb, \"pclxn\")) AS rank"
-               " FROM mandb"
-               " WHERE name_desc MATCH %Q "
-               "%s"
-               " ORDER BY rank DESC"
                "%s",
                snippet_args[0], snippet_args[1], snippet_args[2],
-               args->search_str,
+               wild,
                section_clause ? section_clause : "",
                snippet_args[0], snippet_args[1], snippet_args[2],
-               args->search_str,
                section_clause ? section_clause : "",
                limit_clause ? limit_clause : "");
+               free(wild);
        } else {
            query = sqlite3_mprintf("SELECT section, name, name_desc, machine,"
                " snippet(mandb, %Q, %Q, %Q, -1, 40 ),"
diff -r 0eb700bcef41 -r e5d65e39e80e usr.sbin/makemandb/apropos.1
--- a/usr.sbin/makemandb/apropos.1      Fri Mar 29 20:20:22 2013 +0000
+++ b/usr.sbin/makemandb/apropos.1      Fri Mar 29 20:37:00 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: apropos.1,v 1.9 2013/03/29 20:17:19 christos Exp $
+.\" $NetBSD: apropos.1,v 1.10 2013/03/29 20:37:00 christos Exp $
 .\"
 .\" Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
 .\" All rights reserved.
@@ -77,21 +77,6 @@
 .It Fl l
 Legacy mode: Only searches name and name description.
 Does not print context, or escape format the text.
-Note that this still does not behave exactly like the old
-.Nm
-did because FTS can only search for words, not partial words.
-For example
-.Nm
-used to return
-.Dq xlsfonts
-when searching for
-.Dq ls ,
-but now it cannot.
-One can approximate the behavior better by searching for
-.Dq ls*
-and this works because the index is sorted, but unfortunately
-.Dq *ls*
-does not work.
 .It Fl n
 Output up to the specified number of search results.
 The default limit is infinity.
diff -r 0eb700bcef41 -r e5d65e39e80e usr.sbin/makemandb/apropos.c
--- a/usr.sbin/makemandb/apropos.c      Fri Mar 29 20:20:22 2013 +0000
+++ b/usr.sbin/makemandb/apropos.c      Fri Mar 29 20:37:00 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apropos.c,v 1.13 2013/03/29 20:07:31 christos Exp $    */
+/*     $NetBSD: apropos.c,v 1.14 2013/03/29 20:37:00 christos Exp $    */
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos.c,v 1.13 2013/03/29 20:07:31 christos Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.14 2013/03/29 20:37:00 christos Exp $");
 
 #include <err.h>
 #include <search.h>
@@ -204,7 +204,7 @@
        args.search_str = query;
        args.sec_nums = aflags.sec_nums;
        args.legacy = aflags.legacy;
-       args.nrec = aflags.nresults ? aflags.nresults : 10;
+       args.nrec = aflags.nresults ? aflags.nresults : -1;
        args.offset = 0;
        args.machine = aflags.machine;
        args.callback = &query_callback;
@@ -252,7 +252,7 @@
        callback_data *cbdata = (callback_data *) data;
        FILE *out = cbdata->out;
        cbdata->count++;
-       fprintf(out, cbdata->aflags->legacy ? "%s(%s)\t- %s\n" :
+       fprintf(out, cbdata->aflags->legacy ? "%s(%s) - %s\n" :
            "%s (%s)\t%s\n", name, section, name_desc);
 
        if (cbdata->aflags->no_context == 0)



Home | Main Index | Thread Index | Old Index