mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Apply some touchups
This commit is contained in:
parent
9f149e1de3
commit
2f3bd90216
139 changed files with 1188 additions and 1154 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue