Skip to content

Commit

Permalink
rename STRCMP macro to STREQ (did not actually compare, only checked …
Browse files Browse the repository at this point in the history
…equality)
  • Loading branch information
woodruffw committed Dec 17, 2014
1 parent 68ff391 commit f512a84
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 133 deletions.
154 changes: 77 additions & 77 deletions src/disp.c

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,29 +161,29 @@ int main(int argc, char **argv)
detect_mem(mem_str);

/* if the user specifies an asterisk, fill the data in for them */
if (STRCMP(distro_str, "*"))
if (STREQ(distro_str, "*"))
detect_distro(distro_str);
if (STRCMP(arch_str, "*"))
if (STREQ(arch_str, "*"))
detect_arch(arch_str);
if (STRCMP(host_str, "*"))
if (STREQ(host_str, "*"))
detect_host(host_str);
if (STRCMP(kernel_str, "*"))
if (STREQ(kernel_str, "*"))
detect_kernel(kernel_str);
if (STRCMP(cpu_str, "*"))
if (STREQ(cpu_str, "*"))
detect_cpu(cpu_str);
if (STRCMP(gpu_str, "*"))
if (STREQ(gpu_str, "*"))
detect_gpu(gpu_str);
if (STRCMP(shell_str, "*"))
if (STREQ(shell_str, "*"))
detect_shell(shell_str);
if (STRCMP(res_str, "*"))
if (STREQ(res_str, "*"))
detect_res(res_str);
if (STRCMP(de_str, "*"))
if (STREQ(de_str, "*"))
detect_de(de_str);
if (STRCMP(wm_str, "*"))
if (STREQ(wm_str, "*"))
detect_wm(wm_str);
if (STRCMP(wm_theme_str, "*"))
if (STREQ(wm_theme_str, "*"))
detect_wm_theme(wm_theme_str, wm_str);
if (STRCMP(gtk_str, "*"))
if (STREQ(gtk_str, "*"))
detect_gtk(gtk_str);
}

Expand Down Expand Up @@ -211,7 +211,7 @@ int main(int argc, char **argv)
}

/* if the user specified a different OS to display, set distro_set to it */
if (!STRCMP(given_distro_str, "Unknown"))
if (!STREQ(given_distro_str, "Unknown"))
safe_strncpy(distro_str, given_distro_str, MAX_STRLEN);

if (verbose)
Expand Down
2 changes: 1 addition & 1 deletion src/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define GB (MB * KB)
#define MAX_STRLEN 128
#define SET_GIVEN_DISTRO(str) (safe_strncpy(given_distro_str, str, MAX_STRLEN))
#define STRCMP(x, y) (!strcmp(x, y))
#define STREQ(x, y) (!strcmp(x, y))
#define FILE_EXISTS(file) (!access(file, F_OK))

#endif /* SCREENFETCH_C_MISC_H */
8 changes: 4 additions & 4 deletions src/plat/bsd/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void detect_shell(char *str)
return;
}

if (STRCMP(shell_name, "/bin/sh"))
if (STREQ(shell_name, "/bin/sh"))
{
safe_strncpy(str, "POSIX sh", MAX_STRLEN);
}
Expand Down Expand Up @@ -339,7 +339,7 @@ void detect_res(char *str)
fgets(str, MAX_STRLEN, res_file);
pclose(res_file);

if (STRCMP(str, "Unknown"))
if (STREQ(str, "Unknown"))
{
safe_strncpy(str, "No X Server", MAX_STRLEN);
}
Expand Down Expand Up @@ -450,10 +450,10 @@ void detect_gtk(char *str)
fscanf(gtk_file, "%s%s%s%s", gtk2_str, gtk3_str, gtk_icons_str, font_str);
pclose(gtk_file);

if (STRCMP(gtk3_str, "Unknown"))
if (STREQ(gtk3_str, "Unknown"))
snprintf(str, MAX_STRLEN, "%s (GTK2), %s (Icons)", gtk2_str,
gtk_icons_str);
else if (STRCMP(gtk2_str, "Unknown"))
else if (STREQ(gtk2_str, "Unknown"))
snprintf(str, MAX_STRLEN, "%s (GTK3), %s (Icons)", gtk3_str,
gtk_icons_str);
else
Expand Down
2 changes: 1 addition & 1 deletion src/plat/darwin/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void detect_shell(char *str)
return;
}

if (STRCMP(shell_name, "/bin/sh"))
if (STREQ(shell_name, "/bin/sh"))
{
safe_strncpy(str, "POSIX sh", MAX_STRLEN);
}
Expand Down
66 changes: 33 additions & 33 deletions src/plat/linux/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
void detect_distro(char *str)
{
/* if distro_str was NOT set by the -D flag or manual mode */
if (STRCMP(str, "Unknown") || STRCMP(str, "*"))
if (STREQ(str, "Unknown") || STREQ(str, "*"))
{
FILE *distro_file;

Expand All @@ -62,23 +62,23 @@ void detect_distro(char *str)
fscanf(distro_file, "%4s", distro_name_str);
fclose(distro_file);

if (STRCMP(distro_name_str, "Back"))
if (STREQ(distro_name_str, "Back"))
{
safe_strncpy(str, "Backtrack Linux", MAX_STRLEN);
detected = true;
}
else if (STRCMP(distro_name_str, "Crun"))
else if (STREQ(distro_name_str, "Crun"))
{
safe_strncpy(str, "CrunchBang", MAX_STRLEN);
detected = true;
}
else if (STRCMP(distro_name_str, "LMDE"))
else if (STREQ(distro_name_str, "LMDE"))
{
safe_strncpy(str, "LMDE", MAX_STRLEN);
detected = true;
}
else if (STRCMP(distro_name_str, "Debi")
|| STRCMP(distro_name_str, "Rasp"))
else if (STREQ(distro_name_str, "Debi")
|| STREQ(distro_name_str, "Rasp"))
{
safe_strncpy(str, "Debian", MAX_STRLEN);
detected = true;
Expand Down Expand Up @@ -232,9 +232,9 @@ void detect_pkgs(char *str, const char *distro_str)
int packages = 0;
glob_t gl;

if (STRCMP(distro_str, "Arch Linux")
|| STRCMP(distro_str, "ParabolaGNU/Linux-libre")
|| STRCMP(distro_str, "Chakra") || STRCMP(distro_str, "Manjaro"))
if (STREQ(distro_str, "Arch Linux")
|| STREQ(distro_str, "ParabolaGNU/Linux-libre")
|| STREQ(distro_str, "Chakra") || STREQ(distro_str, "Manjaro"))
{
if (glob("/var/lib/pacman/local/*", GLOB_NOSORT, NULL, &gl) == 0)
{
Expand All @@ -248,29 +248,29 @@ void detect_pkgs(char *str, const char *distro_str)
globfree(&gl);
}

else if (STRCMP(distro_str, "Frugalware"))
else if (STREQ(distro_str, "Frugalware"))
{
pkgs_file = popen("pacman-g2 -Q 2> /dev/null | wc -l", "r");
fscanf(pkgs_file, "%d", &packages);
pclose(pkgs_file);
}

else if (STRCMP(distro_str, "Ubuntu") || STRCMP(distro_str, "Lubuntu")
|| STRCMP(distro_str, "Xubuntu") || STRCMP(distro_str, "LinuxMint")
|| STRCMP(distro_str, "SolusOS") || STRCMP(distro_str, "Debian")
|| STRCMP(distro_str, "LMDE") || STRCMP(distro_str, "CrunchBang")
|| STRCMP(distro_str, "Peppermint")
|| STRCMP(distro_str, "LinuxDeepin")
|| STRCMP(distro_str, "Trisquel")
|| STRCMP(distro_str, "elementary OS")
|| STRCMP(distro_str, "Backtrack Linux"))
else if (STREQ(distro_str, "Ubuntu") || STREQ(distro_str, "Lubuntu")
|| STREQ(distro_str, "Xubuntu") || STREQ(distro_str, "LinuxMint")
|| STREQ(distro_str, "SolusOS") || STREQ(distro_str, "Debian")
|| STREQ(distro_str, "LMDE") || STREQ(distro_str, "CrunchBang")
|| STREQ(distro_str, "Peppermint")
|| STREQ(distro_str, "LinuxDeepin")
|| STREQ(distro_str, "Trisquel")
|| STREQ(distro_str, "elementary OS")
|| STREQ(distro_str, "Backtrack Linux"))
{
pkgs_file = popen("dpkg --get-selections | wc -l", "r");
fscanf(pkgs_file, "%d", &packages);
pclose(pkgs_file);
}

else if (STRCMP(distro_str, "Slackware"))
else if (STREQ(distro_str, "Slackware"))
{
if (glob("/var/log/packages/*", GLOB_NOSORT, NULL, &gl) == 0)
{
Expand All @@ -284,34 +284,34 @@ void detect_pkgs(char *str, const char *distro_str)
globfree(&gl);
}

else if (STRCMP(distro_str, "Gentoo") || STRCMP(distro_str, "Sabayon")
|| STRCMP(distro_str, "Funtoo"))
else if (STREQ(distro_str, "Gentoo") || STREQ(distro_str, "Sabayon")
|| STREQ(distro_str, "Funtoo"))
{
pkgs_file = popen("ls -d /var/db/pkg/*/* 2> /dev/null | wc -l", "r");
fscanf(pkgs_file, "%d", &packages);
pclose(pkgs_file);
}

else if (STRCMP(distro_str, "Fuduntu") || STRCMP(distro_str, "Fedora")
|| STRCMP(distro_str, "OpenSUSE")
|| STRCMP(distro_str, "Red Hat Linux")
|| STRCMP(distro_str, "Mandriva") || STRCMP(distro_str, "Mandrake")
|| STRCMP(distro_str, "Mageia") || STRCMP(distro_str, "Viperr"))
else if (STREQ(distro_str, "Fuduntu") || STREQ(distro_str, "Fedora")
|| STREQ(distro_str, "OpenSUSE")
|| STREQ(distro_str, "Red Hat Linux")
|| STREQ(distro_str, "Mandriva") || STREQ(distro_str, "Mandrake")
|| STREQ(distro_str, "Mageia") || STREQ(distro_str, "Viperr"))
{
pkgs_file = popen("rpm -qa 2> /dev/null | wc -l", "r");
fscanf(pkgs_file, "%d", &packages);
pclose(pkgs_file);
}

else if (STRCMP(distro_str, "Angstrom"))
else if (STREQ(distro_str, "Angstrom"))
{
pkgs_file = popen("opkg list-installed 2> /dev/null | wc -l", "r");
fscanf(pkgs_file, "%d", &packages);
pclose(pkgs_file);
}

/* if linux disto detection failed */
else if (STRCMP(distro_str, "Linux"))
else if (STREQ(distro_str, "Linux"))
{
safe_strncpy(str, "Not Found", MAX_STRLEN);

Expand Down Expand Up @@ -339,7 +339,7 @@ void detect_cpu(char *str)
fgets(str, MAX_STRLEN, cpu_file);
pclose(cpu_file);

if (STRCMP(str, "ARMv6-compatible processor rev 7 (v6l)"))
if (STREQ(str, "ARMv6-compatible processor rev 7 (v6l)"))
{
safe_strncpy(str, "BCM2708 (Raspberry Pi)", MAX_STRLEN);
}
Expand Down Expand Up @@ -470,7 +470,7 @@ void detect_shell(char *str)
return;
}

if (STRCMP(shell_name, "/bin/sh"))
if (STREQ(shell_name, "/bin/sh"))
{
safe_strncpy(str, "POSIX sh", MAX_STRLEN);
}
Expand Down Expand Up @@ -675,10 +675,10 @@ void detect_gtk(char *str)
fscanf(gtk_file, "%s%s%s%s", gtk2_str, gtk3_str, gtk_icons_str, font_str);
pclose(gtk_file);

if (STRCMP(gtk3_str, "Unknown"))
if (STREQ(gtk3_str, "Unknown"))
snprintf(str, MAX_STRLEN, "%s (GTK2), %s (Icons)", gtk2_str,
gtk_icons_str);
else if (STRCMP(gtk2_str, "Unknown"))
else if (STREQ(gtk2_str, "Unknown"))
snprintf(str, MAX_STRLEN, "%s (GTK3), %s (Icons)", gtk3_str,
gtk_icons_str);
else
Expand Down
4 changes: 2 additions & 2 deletions src/plat/sun/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void detect_uptime(char *str)

while ((ent = getutxent()))
{
if (STRCMP("system boot", ent->ut_line))
if (STREQ("system boot", ent->ut_line))
{
boottime = ent->ut_tv.tv_sec;
}
Expand Down Expand Up @@ -241,7 +241,7 @@ void detect_shell(char *str)
return;
}

if (STRCMP(shell_name, "/bin/sh"))
if (STREQ(shell_name, "/bin/sh"))
{
safe_strncpy(str, "POSIX sh", MAX_STRLEN);
}
Expand Down
4 changes: 2 additions & 2 deletions src/plat/win32/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern int pclose(FILE *stream);
void detect_distro(char *str)
{
/* if distro_str was NOT set by the -D flag or manual mode */
if (STRCMP(str, "Unknown") || STRCMP(str, "*"))
if (STREQ(str, "Unknown") || STREQ(str, "*"))
{
#if defined(NTDDI_WIN7)
safe_strncpy(str, "Microsoft Windows 7", MAX_STRLEN);
Expand Down Expand Up @@ -302,7 +302,7 @@ void detect_shell(char *str)
return;
}

if (STRCMP(shell_name, "/bin/sh"))
if (STREQ(shell_name, "/bin/sh"))
{
safe_strncpy(str, "POSIX sh", MAX_STRLEN);
}
Expand Down

0 comments on commit f512a84

Please sign in to comment.