diff --git a/libc/calls/getprogramexecutablename.greg.c b/libc/calls/getprogramexecutablename.greg.c index 452362947..1aa6cd276 100644 --- a/libc/calls/getprogramexecutablename.greg.c +++ b/libc/calls/getprogramexecutablename.greg.c @@ -25,11 +25,11 @@ #include "libc/errno.h" #include "libc/fmt/libgen.h" #include "libc/intrin/getenv.internal.h" -#include "libc/serialize.h" #include "libc/limits.h" #include "libc/macros.internal.h" #include "libc/nt/runtime.h" #include "libc/runtime/runtime.h" +#include "libc/serialize.h" #include "libc/str/str.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/consts/ok.h" @@ -38,12 +38,13 @@ #define KERN_PROC 14 #define KERN_PROC_PATHNAME_FREEBSD 12 #define KERN_PROC_PATHNAME_NETBSD 5 -#define DevFd() \ - (IsBsd() ? "/dev/fd/" : IsLinux() ? "/proc/self/fd/" : 0) -#define StrlenDevFd() \ - ((IsBsd() ? sizeof("/dev/fd/") : \ - IsLinux() ? sizeof("/proc/self/fd/") : 0) \ - - 1) + +#define DevFd() (IsBsd() ? "/dev/fd/" : IsLinux() ? "/proc/self/fd/" : 0) +#define StrlenDevFd() \ + ((IsBsd() ? sizeof("/dev/fd/") \ + : IsLinux() ? sizeof("/proc/self/fd/") \ + : 0) - \ + 1) static struct { atomic_uint once; @@ -60,11 +61,21 @@ static inline int IsAlpha(int c) { static inline int AllNumDot(const char *s) { while (true) { switch (*s++) { - default: return 0; - case 0: return 1; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': case '.': - ; /* continue */ + default: + return 0; + case 0: + return 1; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '.':; /* continue */ } } } @@ -74,8 +85,7 @@ static inline int AllNumDot(const char *s) { static int OldApeLoader(char *s) { char *b; return !strcmp(s, "/usr/bin/ape") || - (!strncmp((b = basename(s)), ".ape-", 5) && - AllNumDot(b + 5)); + (!strncmp((b = basename(s)), ".ape-", 5) && AllNumDot(b + 5)); } // if q exists then turn it into an absolute path. we also try adding