1
0

Formatting commit :(

I know formatting commits suck... And I try to avoid them.

But this commit was absolutely necessary... The coding style in this
program was not ok and not the same over the whole program.

The commit is hard to read, but this is what I changed:
- Tabs for indentation instead of spaces
- Same style over the whole program (suckless style)
This commit is contained in:
Aaron Marcher 2016-08-16 11:41:43 +02:00 committed by Aaron Marcher (drkhsh)
parent ec35376127
commit ad8ab20c63
5 changed files with 471 additions and 477 deletions

View File

@ -1,4 +1,4 @@
Contributing
============
If you want to contribute, please use [the suckless coding style](http://suckless.org/coding_style) and 4 spaces for indentation.
If you want to contribute, please use [the suckless coding style](http://suckless.org/coding_style).

View File

@ -44,8 +44,9 @@ smprintf(const char *fmt, ...)
char *ret = NULL;
va_start(fmtargs, fmt);
if (vasprintf(&ret, fmt, fmtargs) < 0)
if (vasprintf(&ret, fmt, fmtargs) < 0) {
return NULL;
}
va_end(fmtargs);
return ret;
@ -74,7 +75,7 @@ battery_perc(const char *battery)
/* open battery now file */
if (!(fp = fopen(batterynowfile, "r"))) {
fprintf(stderr, "Error opening battery file.%s",batterynowfile);
fprintf(stderr, "Error opening battery file.%s", batterynowfile);
return smprintf("n/a");
}
@ -160,7 +161,7 @@ datetime(const char *timeformat)
/* get time in format */
time(&tm);
setlocale(LC_TIME, "");
if(!strftime(buf, bufsize, timeformat, localtime(&tm))) {
if (!strftime(buf, bufsize, timeformat, localtime(&tm))) {
setlocale(LC_TIME, "C");
free(buf);
fprintf(stderr, "Strftime failed.\n");
@ -313,24 +314,21 @@ ip(const char *interface)
char host[NI_MAXHOST];
/* check if getting ip address works */
if (getifaddrs(&ifaddr) == -1)
{
if (getifaddrs(&ifaddr) == -1) {
fprintf(stderr, "Error getting IP address.");
return smprintf("n/a");
}
/* get the ip address */
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
if (ifa->ifa_addr == NULL)
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
if (ifa->ifa_addr == NULL) {
continue;
}
s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
if ((strcmp(ifa->ifa_name, interface) == 0) && (ifa->ifa_addr->sa_family == AF_INET))
{
if (s != 0)
{
if ((strcmp(ifa->ifa_name, interface) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) {
if (s != 0) {
fprintf(stderr, "Error getting IP address.");
return smprintf("n/a");
}
@ -465,13 +463,13 @@ run_command(const char* command)
}
/* get command output text, save it to buffer */
fgets(buffer, sizeof(buffer)-1, fp);
fgets(buffer, sizeof(buffer) - 1, fp);
/* close it again */
pclose(fp);
/* add nullchar at the end */
for (int i = 0 ; i != sizeof(buffer) ; i++) {
for (int i = 0 ; i != sizeof(buffer); i++) {
if (buffer[i] == '\0') {
good = 1;
break;
@ -516,14 +514,13 @@ username(const char *null)
register uid_t uid;
/* get the values */
uid = geteuid ();
pw = getpwuid (uid);
uid = geteuid();
pw = getpwuid(uid);
/* if it worked, return */
if (pw) {
return smprintf("%s", pw->pw_name);
}
else {
} else {
fprintf(stderr, "Could not get username.\n");
return smprintf("n/a");
}
@ -538,13 +535,12 @@ uid(const char *null)
register uid_t uid;
/* get the values */
uid = geteuid ();
uid = geteuid();
/* if it worked, return */
if (uid) {
return smprintf("%d", uid);
}
else {
} else {
fprintf(stderr, "Could not get uid.\n");
return smprintf("n/a");
}
@ -601,8 +597,7 @@ vol_perc(const char *soundcard)
/* return the string (mute) */
if (!mute) {
return smprintf("mute");
}
else {
} else {
return smprintf("%d%%", (vol * 100) / max);
}
}
@ -639,7 +634,7 @@ wifi_perc(const char *wificard)
fclose(fp);
/* check if interface down */
if(strcmp(status, "up\n") != 0){
if(strcmp(status, "up\n") != 0) {
return smprintf("n/a");
}
@ -696,8 +691,7 @@ wifi_essid(const char *wificard)
/* return the essid */
if (strcmp((char *)wreq.u.essid.pointer, "") == 0) {
return smprintf("n/a");
}
else {
} else {
return smprintf("%s", (char *)wreq.u.essid.pointer);
}
}