xbps-query(8): --search --property now works with <number> objects.

For example to find a package where its binpkg file is bigger than 1GB:

	$ xbps-query --regex -s [0-9][0-9][0-9][0-9]MB -p filename-size
This commit is contained in:
Juan RP 2014-08-02 12:11:28 +02:00
parent 766cbcf683
commit 0b116a0f3f
2 changed files with 24 additions and 0 deletions

4
NEWS
View File

@ -1,5 +1,9 @@
xbps-0.38 (???):
* xbps-query(8): --search --property now works with <number> objects, i.e:
$ xbps-query -s '' -p filename-size
* xbps-remove(8): -O/--clean-cache no longer triggers an assertion when the
cache directory is empty.

View File

@ -162,6 +162,26 @@ search_array_cb(struct xbps_handle *xhp _unused,
}
}
}
} else if (xbps_object_type(obj2) == XBPS_TYPE_NUMBER) {
/* property is a number */
char size[8];
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
if (xbps_humanize_number(size, xbps_number_integer_value(obj2)) == -1)
exit(EXIT_FAILURE);
if (sd->regex) {
if (regcomp(&regex, sd->pat, REG_EXTENDED|REG_NOSUB) != 0)
return errno;
if (regexec(&regex, size, 0, 0, 0) == 0) {
printf("%s: %s (%s)\n", pkgver, size, sd->repourl);
}
regfree(&regex);
} else {
if (strcasestr(size, sd->pat)) {
printf("%s: %s (%s)\n", pkgver, size, sd->repourl);
}
}
} else if (xbps_object_type(obj2) == XBPS_TYPE_BOOL) {
/* property is a bool */
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);