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:
parent
5585b98ac6
commit
0a2abb3f3d
12
NEWS
12
NEWS
@ -1,4 +1,14 @@
|
||||
xbps-0.9.0 (???):
|
||||
xbps-0.9.1 (???):
|
||||
|
||||
* xbps-repo(8): the 'search' target now matches patterns in
|
||||
case insensitive mode.
|
||||
|
||||
* A bug has been fixed while updating a package and another package
|
||||
providing a virtual package with a greater version was available
|
||||
in repositories. Only accept this if the virtual package is explicitly
|
||||
enabled in the "virtual-packages" section in the configuration file.
|
||||
|
||||
xbps-0.9.0 (2011-07-08):
|
||||
|
||||
* configure doesn't require a zlib package with a pkg-config file, to
|
||||
workaround some distribution that don't provide it (hi Ubuntu!). Rather
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
38
configure
vendored
38
configure
vendored
@ -315,10 +315,42 @@ else
|
||||
fi
|
||||
echo "$VASPRINTF."
|
||||
rm -f _$func.c _$func
|
||||
if [ "$VASPRINTF" = "yes" ]; then
|
||||
if [ "$VASPRINTF" = "no" ]; then
|
||||
echo "COMPAT_SRCS+= compat/vasprintf.o" >>$CONFIG_MK
|
||||
echo "#include \"compat.h\"" >>$CONFIG_H
|
||||
else
|
||||
echo "CPPFLAGS += -DHAVE_VASPRINTF" >> $CONFIG_MK
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for strcasestr().
|
||||
#
|
||||
func=strcasestr
|
||||
printf "Checking for $func() ..."
|
||||
cat <<EOF >_$func.c
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
int main(void) {
|
||||
const char *h = "NEEDCOFEE";
|
||||
const char *n = "IneedCoffee";
|
||||
strcasestr(n, h);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
if $XCC _$func.c -o _$func 2>/dev/null; then
|
||||
STRCASESTR=yes
|
||||
else
|
||||
STRCASESTR=no
|
||||
fi
|
||||
echo "$STRCASESTR."
|
||||
rm -f _$func _$func.c
|
||||
if [ "$STRCASESTR" = no ]; then
|
||||
echo "COMPAT_SRCS += compat/strcasestr.o" >>$CONFIG_MK
|
||||
echo "#include \"compat.h\"" >>$CONFIG_H
|
||||
else
|
||||
echo "CPPFLAGS += -DHAVE_STRCASESTR" >>$CONFIG_MK
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for strlcpy().
|
||||
#
|
||||
@ -342,7 +374,7 @@ echo "$STRLCPY."
|
||||
rm -f _$func.c _$func
|
||||
if [ "$STRLCPY" = no ]; then
|
||||
echo "COMPAT_SRCS += compat/strlcpy.o" >>$CONFIG_MK
|
||||
echo "#include \"strlcpy.h\"" >>$CONFIG_H
|
||||
echo "#include \"compat.h\"" >>$CONFIG_H
|
||||
else
|
||||
echo "CPPFLAGS += -DHAVE_STRLCPY" >> $CONFIG_MK
|
||||
fi
|
||||
@ -369,7 +401,7 @@ echo "$STRLCAT."
|
||||
rm -f _$func.c _$func
|
||||
if [ "$STRLCAT" = no ]; then
|
||||
echo "COMPAT_SRCS += compat/strlcat.o" >>$CONFIG_MK
|
||||
echo "#include \"strlcat.h\"" >>$CONFIG_H
|
||||
echo "#include \"compat.h\"" >>$CONFIG_H
|
||||
else
|
||||
echo "CPPFLAGS += -DHAVE_STRLCAT" >>$CONFIG_MK
|
||||
fi
|
||||
|
18
include/compat.h
Normal file
18
include/compat.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef COMPAT_H
|
||||
#define COMPAT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
size_t strlcat(char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASESTR
|
||||
char *strcasestr(const char *, const char *);
|
||||
#endif
|
||||
|
||||
#endif /* COMPAT_H */
|
@ -1,10 +0,0 @@
|
||||
#ifndef STRLCAT_H
|
||||
#define STRLCAT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
size_t strlcat(char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,10 +0,0 @@
|
||||
#ifndef STRLCPY_H
|
||||
#define STRLCPY_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
#endif
|
@ -35,9 +35,8 @@
|
||||
#include <archive_entry.h>
|
||||
|
||||
#include <xbps_api.h>
|
||||
#include "compat.h"
|
||||
#include "queue.h"
|
||||
#include "strlcpy.h"
|
||||
#include "strlcat.h"
|
||||
#include "fetch.h"
|
||||
|
||||
#define ARCHIVE_READ_BLOCKSIZE 10240
|
||||
|
64
lib/compat/strcasestr.c
Normal file
64
lib/compat/strcasestr.c
Normal file
@ -0,0 +1,64 @@
|
||||
/* $NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Chris Torek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Find the first occurrence of find in s, ignore case.
|
||||
*/
|
||||
char *
|
||||
strcasestr(const char *s, const char *find)
|
||||
{
|
||||
char c, sc;
|
||||
size_t len;
|
||||
|
||||
assert(s != NULL);
|
||||
assert(find != NULL);
|
||||
|
||||
if ((c = *find++) != 0) {
|
||||
c = tolower((unsigned char)c);
|
||||
len = strlen(find);
|
||||
do {
|
||||
do {
|
||||
if ((sc = *s++) == 0)
|
||||
return (NULL);
|
||||
} while ((char)tolower((unsigned char)sc) != c);
|
||||
} while (strncasecmp(s, find, len) != 0);
|
||||
s--;
|
||||
}
|
||||
return __UNCONST(s);
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "strlcat.h"
|
||||
#include "compat.h"
|
||||
|
||||
/*
|
||||
* Appends src to string dst of size siz (unlike strncat, siz is the
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
#include "compat.h"
|
||||
|
||||
/*
|
||||
* Copy src to string dst of size siz. At most siz-1 characters
|
||||
|
50
lib/compat/vasprintf.c
Normal file
50
lib/compat/vasprintf.c
Normal file
@ -0,0 +1,50 @@
|
||||
/*-
|
||||
* Copyright (c) 2008-2011 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
char *
|
||||
xbps_xasprintf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap, aq;
|
||||
size_t len;
|
||||
int res;
|
||||
char *buf;
|
||||
|
||||
va_start(aq, fmt);
|
||||
va_copy(ap, aq);
|
||||
len = vsnprintf(NULL, 0, fmt, aq) + 1;
|
||||
if ((buf = malloc(len)) == NULL) {
|
||||
va_end(ap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
res = vsnprintf(buf, len, fmt, ap);
|
||||
if (res < 0 || res >= (int)len) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
37
lib/util.c
37
lib/util.c
@ -25,14 +25,9 @@
|
||||
|
||||
#ifdef HAVE_VASPRINTF
|
||||
# define _GNU_SOURCE /* for vasprintf(3) */
|
||||
# ifdef _XOPEN_SOURCE
|
||||
# undef _XOPEN_SOURCE
|
||||
# endif
|
||||
# include <stdio.h>
|
||||
# undef _GNU_SOURCE
|
||||
#else
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
@ -440,30 +435,4 @@ xbps_xasprintf(const char *fmt, ...)
|
||||
|
||||
return buf;
|
||||
}
|
||||
#else
|
||||
char *
|
||||
xbps_xasprintf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap, aq;
|
||||
size_t len;
|
||||
int res;
|
||||
char *buf;
|
||||
|
||||
va_start(aq, fmt);
|
||||
va_copy(ap, aq);
|
||||
len = vsnprintf(NULL, 0, fmt, aq) + 1;
|
||||
if ((buf = malloc(len)) == NULL) {
|
||||
va_end(ap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
res = vsnprintf(buf, len, fmt, ap);
|
||||
if (res < 0 || res >= (int)len) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
#endif /* !HAVE_VASPRINTF */
|
||||
#endif /* HAVE_VASPRINTF */
|
||||
|
Loading…
Reference in New Issue
Block a user