diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-10-13 12:39:17 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-10-13 12:39:17 +0100 |
commit | c198d1135a80d607161c62ec43c1d1182f62bbf7 (patch) | |
tree | ad979bf1166f6c6d07283e6be74e12bb66fb3bd9 /command_line/CmdLine/Src/OSLib/Generic.c | |
parent | bdf2608f1d72f3b0705e783c1870d5d31a53a2d7 (diff) | |
download | MWCC-c198d1135a80d607161c62ec43c1d1182f62bbf7.tar.gz MWCC-c198d1135a80d607161c62ec43c1d1182f62bbf7.zip |
finish OSLib/MacSpecs.c and use OS_PATHSEP in more places
Diffstat (limited to '')
-rw-r--r-- | command_line/CmdLine/Src/OSLib/Generic.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/command_line/CmdLine/Src/OSLib/Generic.c b/command_line/CmdLine/Src/OSLib/Generic.c index a4e9fed..f2c2ac9 100644 --- a/command_line/CmdLine/Src/OSLib/Generic.c +++ b/command_line/CmdLine/Src/OSLib/Generic.c @@ -48,7 +48,7 @@ int WildCardMatch(char *wild, char *name) { } } - return !name[0] || (name[0] == '/' && !name[1]); + return !name[0] || (name[0] == OS_PATHSEP && !name[1]); } OSSpec *OS_MatchPath(const char *path) { @@ -58,7 +58,7 @@ OSSpec *OS_MatchPath(const char *path) { const char *nptr; if (path) { - nptr = strrchr(path, '/'); + nptr = strrchr(path, OS_PATHSEP); if (!nptr) { nptr = path; strcpyn(wilddir, ".", -1, 256); @@ -89,7 +89,7 @@ OSSpec *OS_MatchPath(const char *path) { char *OS_GetFileNamePtr(char *path) { char *ptr; - ptr = strrchr(path, '/'); + ptr = strrchr(path, OS_PATHSEP); return !ptr ? path : (ptr + 1); } @@ -102,12 +102,12 @@ char *OS_GetDirName(const OSPathSpec *spec, char *buf, int size) { path = OS_PathSpecToString(spec, STSbuf, 256); pptr = path + strlen(path) - 1; - if (pptr > path && *pptr == '/') { + if (pptr > path && *pptr == OS_PATHSEP) { *pptr = 0; --pptr; } - while (pptr >= path && *pptr != '/') + while (pptr >= path && *pptr != OS_PATHSEP) pptr--; strncpy(buf, pptr, size - 1); @@ -133,8 +133,8 @@ int OS_MakeSpec2(const char *path, const char *filename, OSSpec *spec) { strncpy(bpath, path, pthlen); eptr = bpath + pthlen; - if (eptr[-1] != '/') - *(eptr++) = '/'; + if (eptr[-1] != OS_PATHSEP) + *(eptr++) = OS_PATHSEP; strcpy(eptr, filename); return OS_MakeSpec(bpath, spec, 0); @@ -323,7 +323,7 @@ char *OS_SpecToStringRelative(const OSSpec *spec, const OSPathSpec *cwdspec, cha while (cwd > cwdbuf) { cwd--; full--; - if (*cwd == '/') + if (*cwd == OS_PATHSEP) break; } @@ -334,7 +334,7 @@ char *OS_SpecToStringRelative(const OSSpec *spec, const OSPathSpec *cwdspec, cha if (*(++cwd)) { pptr = path; while (*cwd) { - if (*cwd == '/') + if (*cwd == OS_PATHSEP) pptr += sprintf(pptr, "../"); ++cwd; } @@ -390,7 +390,7 @@ int OS_FindProgram(const char *filename, OSSpec *spec) { strncpy(temp, filename, 256); temp[255] = 0; - if (!strchr(temp, '/')) { + if (!strchr(temp, OS_PATHSEP)) { plist = getenv("PATH"); err = OS_FindFileInPath(temp, plist, spec); if (!err) |