Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Implement case insensitive matching against pkg-name.
Andrej Zverev committed 11 years ago
commit 1912ee779da50ba9d625b846ecae413065c32a08
parent aed4529
2 files changed +19 -4
modified docs/pkg-updating.8
@@ -23,11 +23,13 @@
.Nd display UPDATING entries of software packages
.Sh SYNOPSIS
.Nm
+
.Op Fl i
.Op Fl d Ar date
.Op Fl f Ar file
.Op Ar pkg-name ...
.Pp
.Nm
+
.Op Cm --case-insensitive
.Op Cm --date Ar date
.Op Cm --file Ar file
.Op Ar pkg-name ...
@@ -43,6 +45,8 @@ The following options are supported by
.Bl -tag -width file
.It Ar pkg-name ...
UPDATING entries for the named packages are displayed.
+
.It Fl i, Cm --case-insensitive
+
Matching against pkg-name case insensitive.
.It Fl d Ar date , Cm --date Ar date
Only entries newer than
.Ar date
modified src/updating.c
@@ -55,7 +55,7 @@ struct installed_ports {
void
usage_updating(void)
{
-
	fprintf(stderr, "Usage: pkg updating [-d YYYYMMDD] [-f file] [portname ...]\n");
+
	fprintf(stderr, "Usage: pkg updating [-i] [-d YYYYMMDD] [-f file] [portname ...]\n");
	fprintf(stderr, "For more information see 'pkg help updating'.\n");

}
@@ -66,6 +66,7 @@ exec_updating(int argc, char **argv)
	char			*date = NULL;
	char			*dateline = NULL;
	char			*updatingfile = NULL;
+
	bool			caseinsensitive = false;
	struct installed_ports	*port;
	SLIST_HEAD(,installed_ports) origins;
	int			 ch;
@@ -87,10 +88,11 @@ exec_updating(int argc, char **argv)
	struct option longopts[] = {
		{ "date",	required_argument,	NULL,	'd' },
		{ "file",	required_argument,	NULL,	'f' },
+
		{ "case-insensitive",	no_argument,	NULL,	'i' },
		{ NULL,		0,			NULL,	0   },
	};

-
	while ((ch = getopt_long(argc, argv, "+d:f:", longopts, NULL)) != -1) {
+
	while ((ch = getopt_long(argc, argv, "+d:f:i", longopts, NULL)) != -1) {
		switch (ch) {
		case 'd':
			date = optarg;
@@ -98,6 +100,9 @@ exec_updating(int argc, char **argv)
		case 'f':
			updatingfile = optarg;
			break;
+
		case 'i':
+
			caseinsensitive = true;
+
			break;
		default:
			usage_updating();
			return (EX_USAGE);
@@ -182,8 +187,14 @@ exec_updating(int argc, char **argv)
		if (found == 0) {
			if (strstr(line, "AFFECTS") != NULL) {
				SLIST_FOREACH(port, &origins, next) {
-
					if ((tmp = strstr(line, port->origin)) != NULL) {
-
						break;
+
					if (caseinsensitive) {
+
						if ((tmp = strcasestr(line, port->origin)) != NULL) {
+
							break;
+
						}
+
					} else {
+
						if ((tmp = strstr(line, port->origin)) != NULL) {
+
							break;
+
						}
					}
				}
				if (tmp != NULL) {