- c = sqlite3_create_function(db, "match", 2,
- SQLITE_ANY, NULL, sql_match, NULL, NULL);
- assert(SQLITE_OK == c);
- c = sqlite3_create_function(db, "regexp", 2,
- SQLITE_ANY, NULL, sql_regexp, NULL, NULL);
- assert(SQLITE_OK == c);
-
- j = 1;
- c = sqlite3_prepare_v2(db, sql, -1, &s, NULL);
- if (SQLITE_OK != c)
- fprintf(stderr, "%s\n", sqlite3_errmsg(db));
-
- if (NULL != search->arch)
- SQL_BIND_TEXT(db, s, j, search->arch);
- if (NULL != search->sec)
- SQL_BIND_TEXT(db, s, j, search->sec);
-
- for (ep = e; NULL != ep; ep = ep->next) {
- if (NULL == ep->substr) {
- SQL_BIND_BLOB(db, s, j, ep->regexp);
- } else
- SQL_BIND_TEXT(db, s, j, ep->substr);
- SQL_BIND_INT64(db, s, j, ep->bits);
- }
+ if (cur && search->firstmatch)
+ break;
+ }
+ if (res != NULL)
+ qsort(*res, cur, sizeof(struct manpage), manpage_compare);
+ if (chdir_status && getcwd_status && chdir(buf) == -1)
+ warn("%s", buf);
+ exprfree(e);
+ *sz = cur;
+ return res != NULL || cur;
+}