Rename macro for print-format handling of strings

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2023-09-06 17:23:28 +10:00
parent e210634982
commit e7d7433b4b

View file

@ -61,7 +61,7 @@ enum {
CELL_FREE = (1 << 3) CELL_FREE = (1 << 3)
}; };
#define VAL_FROM_FORMAT_STR(temp, format, func) \ #define PRINT_FORMAT_STRING(temp, format, func) \
if(strstr(temp, format)) { \ if(strstr(temp, format)) { \
string = strreplace(temp, format, func(pkg)); \ string = strreplace(temp, format, func(pkg)); \
free(temp); \ free(temp); \
@ -1208,23 +1208,23 @@ void print_packages(const alpm_list_t *packages)
} }
} }
/* %d : description */ /* %d : description */
VAL_FROM_FORMAT_STR(temp, "%d", alpm_pkg_get_desc) PRINT_FORMAT_STRING(temp, "%d", alpm_pkg_get_desc)
/* %e : pkgbase */ /* %e : pkgbase */
VAL_FROM_FORMAT_STR(temp, "%e", alpm_pkg_get_base) PRINT_FORMAT_STRING(temp, "%e", alpm_pkg_get_base)
/* %f : filename */ /* %f : filename */
VAL_FROM_FORMAT_STR(temp, "%f", alpm_pkg_get_filename) PRINT_FORMAT_STRING(temp, "%f", alpm_pkg_get_filename)
/* %g : base64 encoded PGP signature */ /* %g : base64 encoded PGP signature */
VAL_FROM_FORMAT_STR(temp, "%g", alpm_pkg_get_base64_sig) PRINT_FORMAT_STRING(temp, "%g", alpm_pkg_get_base64_sig)
/* %h : sha25sum */ /* %h : sha25sum */
VAL_FROM_FORMAT_STR(temp, "%h", alpm_pkg_get_sha256sum) PRINT_FORMAT_STRING(temp, "%h", alpm_pkg_get_sha256sum)
/* %n : pkgname */ /* %n : pkgname */
VAL_FROM_FORMAT_STR(temp, "%n", alpm_pkg_get_name) PRINT_FORMAT_STRING(temp, "%n", alpm_pkg_get_name)
/* %p : packager */ /* %p : packager */
VAL_FROM_FORMAT_STR(temp, "%p", alpm_pkg_get_packager) PRINT_FORMAT_STRING(temp, "%p", alpm_pkg_get_packager)
/* %v : pkgver */ /* %v : pkgver */
VAL_FROM_FORMAT_STR(temp, "%v", alpm_pkg_get_version) PRINT_FORMAT_STRING(temp, "%v", alpm_pkg_get_version)
/* %m : md5sum */ /* %m : md5sum */
VAL_FROM_FORMAT_STR(temp, "%m", alpm_pkg_get_md5sum) PRINT_FORMAT_STRING(temp, "%m", alpm_pkg_get_md5sum)
/* %l : location */ /* %l : location */
if(strstr(temp, "%l")) { if(strstr(temp, "%l")) {
char *pkgloc = pkg_get_location(pkg); char *pkgloc = pkg_get_location(pkg);
@ -1253,7 +1253,7 @@ void print_packages(const alpm_list_t *packages)
free(temp); free(temp);
} }
/* %u : url */ /* %u : url */
VAL_FROM_FORMAT_STR(temp, "%u", alpm_pkg_get_url) PRINT_FORMAT_STRING(temp, "%u", alpm_pkg_get_url)
/* %C : checkdepends */ /* %C : checkdepends */
if(strstr(temp, "%C")) { if(strstr(temp, "%C")) {
alpm_list_t *lst = alpm_pkg_get_checkdepends(pkg); alpm_list_t *lst = alpm_pkg_get_checkdepends(pkg);