xbps-repo(8): 'search' target is now case insensitive.

Along with this change, compat code has been added (from NetBSD)
for systems that don't have it. The compat code has been reorganized
to be in a common place and its prototypes in compat.h.

The configure scripts checks if strcasestr() is available, and
uses compat code if not found.

This fixes issue #2 on github.com/vanilla/xbps.
This commit is contained in:
Juan RP
2011-07-09 10:50:44 +02:00
parent 5585b98ac6
commit 0a2abb3f3d
15 changed files with 198 additions and 70 deletions

View File

@@ -34,7 +34,7 @@
#include <limits.h>
#include <xbps_api.h>
#include "strlcpy.h"
#include "compat.h"
#include "defs.h"
#include "../xbps-repo/defs.h"

View File

@@ -34,7 +34,7 @@
#include <unistd.h>
#include <xbps_api.h>
#include "strlcpy.h"
#include "compat.h"
#include "defs.h"
#include "../xbps-repo/defs.h"

View File

@@ -23,16 +23,20 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_STRCASESTR
# define _GNU_SOURCE /* for strcasestr(3) */
#endif
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fnmatch.h>
#include <assert.h>
#include <string.h>
#include <strings.h>
#include <xbps_api.h>
#include "strlcpy.h"
#include "compat.h"
#include "defs.h"
#include "../xbps-repo/defs.h"
@@ -190,8 +194,9 @@ show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done)
if ((xbps_pkgpattern_match(pkgver, rsd->pattern) == 1) ||
(xbps_pkgpattern_match(desc, rsd->pattern) == 1) ||
(strcmp(pkgname, rsd->pattern) == 0) ||
(strstr(pkgver, rsd->pattern)) || (strstr(desc, rsd->pattern))) {
(strcasecmp(pkgname, rsd->pattern) == 0) ||
(strcasestr(pkgver, rsd->pattern)) ||
(strcasestr(desc, rsd->pattern))) {
tmp = calloc(1, rsd->pkgver_len + 1);
if (tmp == NULL)
return errno;

View File

@@ -1,4 +1,4 @@
.TH "XBPS\-REPO" "8" "06/20/2011" "\ \&" "\ \&"
.TH "XBPS\-REPO" "8" "07/09/2011" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
@@ -93,7 +93,8 @@ Search for packages containing the shell
\fBpkgname\fR
or
\fBdescription\fR
values in repository pool\&.
values in repository pool\&. Please note that patterns are matched in case
insensitive mode.
.RE
.PP
\fBshow \fR\fB\fIpkgname\fR\fR