Skip to content
This repository was archived by the owner on Apr 23, 2024. It is now read-only.

Commit 4154159

Browse files
authored
Merge pull request #26 from zeGolem/cleaner-pkgmans
pkgman(): Create macro to add package counts.
2 parents 0b3dc44 + d74e395 commit 4154159

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

uwufetch.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,17 @@ int pkgman() { // this is just a function that returns the total of installed pa
106106
fscanf(file[6], "%d", &rpm);
107107
fscanf(file[7], "%d", &xbps);
108108
for (int i = 0; i < 8; i++) fclose(file[i]);
109-
110-
if (apt > 0) { total += apt; strcat(pkgman_name, "(apt)"); }
111-
if (dnf > 0) { total += dnf; strcat(pkgman_name, "(dnf)"); }
112-
if (emerge > 0) { total += emerge; strcat(pkgman_name, "(emerge)"); }
113-
if (flatpak > 0) { total += flatpak; strcat(pkgman_name, "(flatpak)"); }
114-
if (nix > 0) { total += nix; strcat(pkgman_name, "(nix)"); }
115-
if (pacman > 0) { total += pacman; strcat(pkgman_name, "(pacman)"); }
116-
if (rpm > 0) { total += rpm; strcat(pkgman_name, "(rpm)"); }
117-
if (xbps > 0) { total += xbps; strcat(pkgman_name, "(xbps)"); }
109+
110+
#define ADD_PACKAGES(package_count, pkgman_to_add) if (package_count > 0) { total += package_count; strcat(pkgman_name, pkgman_to_add); }
111+
ADD_PACKAGES(apt, "(apt)")
112+
ADD_PACKAGES(dnf, "(dnf)")
113+
ADD_PACKAGES(emerge, "(emerge)")
114+
ADD_PACKAGES(flatpak,"(flatpak)")
115+
ADD_PACKAGES(nix, "(nix)")
116+
ADD_PACKAGES(pacman, "(pacman)")
117+
ADD_PACKAGES(rpm, "(rpm)")
118+
ADD_PACKAGES(xbps, "(xbps)")
119+
#undef ADD_PACKAGES
118120

119121
return total;
120122
}
@@ -371,4 +373,4 @@ void uwu_name() { // changes distro name to uwufied(?) name
371373
// BSD
372374
else if (strcmp(version_name, "freebsd") == 0) sprintf(version_name, "%s", "FweeBSD");
373375
else if (strcmp(version_name, "openbsd") == 0) sprintf(version_name, "%s", "OwOpenBSD");
374-
}
376+
}

0 commit comments

Comments
 (0)