summaryrefslogtreecommitdiff
path: root/pkgtools/pkgfind
diff options
context:
space:
mode:
authorjschauma <jschauma>2005-01-27 20:42:23 +0000
committerjschauma <jschauma>2005-01-27 20:42:23 +0000
commit5fcaae66bc83694f4bfbe8a94a00de710c23537b (patch)
tree57ed0b92d3821ba9c0eeef6891740a0bd12abd8d /pkgtools/pkgfind
parent3893542183e88c2abfe2d9f3afd72c268404870f (diff)
downloadpkgsrc-5fcaae66bc83694f4bfbe8a94a00de710c23537b.tar.gz
Make this a bit more portable:
- get rid of asprintf - use libnbcompat if necessary - while here, get rid of unused variable Bump date. ok peter@, tv@ Non-NetBSD platforms may need to test this and adjust following the IRIX example.
Diffstat (limited to 'pkgtools/pkgfind')
-rw-r--r--pkgtools/pkgfind/Makefile10
-rw-r--r--pkgtools/pkgfind/files/pkgfind.c33
2 files changed, 26 insertions, 17 deletions
diff --git a/pkgtools/pkgfind/Makefile b/pkgtools/pkgfind/Makefile
index a9ce70eeb9f..c2d9b93d00d 100644
--- a/pkgtools/pkgfind/Makefile
+++ b/pkgtools/pkgfind/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.7 2005/01/25 23:39:30 cube Exp $
+# $NetBSD: Makefile,v 1.8 2005/01/27 20:42:23 jschauma Exp $
-DISTNAME= pkgfind-20050125
+DISTNAME= pkgfind-20050127
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
@@ -34,8 +34,10 @@ SUBST_MESSAGE.path= "Adjusting pkgsrc directory."
.include "../../mk/bsd.prefs.mk"
-.if ${OPSYS} == "Interix"
-. include "../../devel/libiberty/application.mk" # need asprintf(3)
+.if ${OPSYS} == "IRIX"
+CFLAGS+= -DNEED_LIBNBCOMPAT
+LDFLAGS+= -lnbcompat
+. include "../../pkgtools/libnbcompat/buildlink3.mk" # need err(1), warn(1)
.endif
.include "../../mk/bsd.pkg.mk"
diff --git a/pkgtools/pkgfind/files/pkgfind.c b/pkgtools/pkgfind/files/pkgfind.c
index 06013d4b4be..b4b12327647 100644
--- a/pkgtools/pkgfind/files/pkgfind.c
+++ b/pkgtools/pkgfind/files/pkgfind.c
@@ -38,8 +38,13 @@
#include <sys/param.h>
#include <sys/stat.h>
-#include <ctype.h>
+#ifdef NEED_LIBNBCOMPAT
+#include <nbcompat.h>
+#else
#include <err.h>
+#endif
+
+#include <ctype.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
@@ -63,7 +68,7 @@ static void usage(void);
static int (*search)(const char *, const char *);
-static int Cflag, cflag, qflag, xflag;
+static int Cflag, cflag, qflag;
int
main(int argc, char *argv[])
@@ -71,10 +76,12 @@ main(int argc, char *argv[])
const char *path;
int ch;
+ setprogname("pkgfind");
+
/* default searches have partial matches */
search = partialmatch;
- Cflag = cflag = qflag = xflag = 0;
+ Cflag = cflag = qflag = 0;
while ((ch = getopt(argc, argv, "Ccqx")) != -1) {
switch (ch) {
@@ -165,18 +172,20 @@ static void
showpkg(const char *path, const char *cat, const char *pkg)
{
char *mk, *comment = NULL;
+ size_t len;
+
+ len = strlen(path) + strlen(cat) + strlen(pkg) + strlen("Makefile") + 3 + 1;
if (!qflag) {
- (void)asprintf(&mk, "%s/%s/%s/Makefile", path, cat, pkg);
- if (mk == NULL)
- err(EXIT_FAILURE, "asprintf");
+ if ((mk = malloc(len)) == NULL)
+ err(EXIT_FAILURE, "malloc");
+ (void)snprintf(mk, len, "%s/%s/%s/Makefile", path, cat, pkg);
if (getcomment(mk, &comment) == 0) {
- free(mk);
- (void)asprintf(&mk, "%s/%s/%s/Makefile.common",
+ if ((mk = realloc(mk, len + 7)) == NULL)
+ err(EXIT_FAILURE, "malloc");
+ (void)snprintf(mk, len+7, "%s/%s/%s/Makefile.common",
path, cat, pkg);
- if (mk == NULL)
- err(EXIT_FAILURE, "asprintf");
(void)getcomment(mk, &comment);
}
free(mk);
@@ -259,8 +268,6 @@ exactmatch(const char *s, const char *find)
static void
usage(void)
{
- extern char *__progname;
-
- (void)fprintf(stderr, "Usage: %s [-Ccqx] keyword [...]\n", __progname);
+ (void)fprintf(stderr, "Usage: %s [-Ccqx] keyword [...]\n", getprogname());
exit(EXIT_FAILURE);
}