Apply some touchups

This commit is contained in:
Justine Tunney 2021-02-07 06:11:44 -08:00
parent 9f149e1de3
commit 2f3bd90216
139 changed files with 1188 additions and 1154 deletions

View file

@ -19,7 +19,8 @@
#include "libc/fmt/conv.h"
#include "libc/str/str.h"
#define ISDELIM(c) (c == '/' || c == '\\' || c == '.')
#define ISSLASH(c) (c == '/' || c == '\\')
#define ISDELIM(c) (ISSLASH(c) || c == '.')
/**
* Returns directory portion of path.
@ -30,7 +31,7 @@ char *dirname(char *s) {
if (!(n = strlen(s))) return s;
while (n && ISDELIM(s[n - 1])) --n;
if (n) {
while (n && !ISDELIM(s[n - 1])) --n;
while (n && !ISSLASH(s[n - 1])) --n;
if (n) {
while (n && ISDELIM(s[n - 1])) --n;
if (!n) ++n;