all repos — slstatus @ e79d4932ea413c277425ff92c456741e0730c3d6

my build of slstatus (tools.suckless.org/slstatus/)

More robust preprocessor switches

Replace #ifdef with #if defined() and #elif with #elif defined() as it
should only test if it is defined or not.
Aaron Marcher me@drkhsh.at
Wed, 21 Mar 2018 12:21:37 +0100
commit

e79d4932ea413c277425ff92c456741e0730c3d6

parent

fc5d23212fdaec8c242db9b25770f290dd287212

M components/battery.ccomponents/battery.c

@@ -1,10 +1,10 @@

/* See LICENSE file for copyright and license details. */ #include <err.h> #include <stdio.h> -#ifdef __linux__ +#if defined(__linux__) #include <limits.h> #include <string.h> -#elif __OpenBSD__ +#elif defined(__OpenBSD__) #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h>

@@ -16,14 +16,14 @@

const char * battery_perc(const char *bat) { -#ifdef __linux__ +#if defined(__linux__) int perc; char path[PATH_MAX]; snprintf(path, sizeof(path), "%s%s%s", "/sys/class/power_supply/", bat, "/capacity"); return (pscanf(path, "%i", &perc) == 1) ? bprintf("%d", perc) : NULL; -#elif __OpenBSD__ +#elif defined(__OpenBSD__) struct apm_power_info apm_info; int fd;

@@ -44,7 +44,7 @@ return bprintf("%d", apm_info.battery_life);

#endif } -#ifdef __linux__ +#if defined(__linux__) const char * battery_power(const char *bat) {
M components/cpu.ccomponents/cpu.c

@@ -1,5 +1,5 @@

/* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <stdio.h> #include <string.h>
M components/entropy.ccomponents/entropy.c

@@ -1,5 +1,5 @@

/* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <stdio.h> #include "../util.h"
M components/ip.ccomponents/ip.c

@@ -1,5 +1,5 @@

/* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <err.h> #include <ifaddrs.h> #include <netdb.h>
M components/ram.ccomponents/ram.c

@@ -1,5 +1,5 @@

/* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <stdio.h> #include "../util.h"
M components/swap.ccomponents/swap.c

@@ -1,5 +1,5 @@

/* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <err.h> #include <stdio.h> #include <string.h>
M components/temperature.ccomponents/temperature.c

@@ -1,5 +1,5 @@

/* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <stdio.h> #include "../util.h"
M components/uptime.ccomponents/uptime.c

@@ -1,8 +1,8 @@

/* See LICENSE file for copyright and license details. */ #include <stdio.h> -#ifdef __linux__ +#if defined(__linux__) #include <sys/sysinfo.h> -#elif __OpenBSD__ +#elif defined(__OpenBSD__) #include <sys/sysctl.h> #include <sys/time.h> #endif

@@ -15,12 +15,12 @@ {

int h; int m; int uptime = 0; -#ifdef __linux__ +#if defined(__linux__) struct sysinfo info; sysinfo(&info); uptime = info.uptime; -#elif __OpenBSD__ +#elif defined(__OpenBSD__) int mib[2]; size_t size; time_t now;
M components/volume.ccomponents/volume.c

@@ -1,5 +1,5 @@

/* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <err.h> #include <fcntl.h> #include <sys/soundcard.h>
M components/wifi.ccomponents/wifi.c

@@ -1,5 +1,5 @@

/* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <err.h> #include <ifaddrs.h> #include <linux/wireless.h>