mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 14:10:30 +03:00
Fixed wrong C library lookups
This commit is contained in:
parent
0ee6a1afbd
commit
703f612973
3 changed files with 24 additions and 23 deletions
26
std/file.d
26
std/file.d
|
@ -1942,8 +1942,8 @@ version (Posix) string getcwd()
|
|||
{
|
||||
auto p = cenforce(core.sys.posix.unistd.getcwd(null, 0),
|
||||
"cannot get cwd");
|
||||
scope(exit) std.c.stdlib.free(p);
|
||||
return p[0 .. std.c.string.strlen(p)].idup;
|
||||
scope(exit) core.stdc.stdlib.free(p);
|
||||
return p[0 .. core.stdc.string.strlen(p)].idup;
|
||||
}
|
||||
|
||||
unittest
|
||||
|
@ -2657,14 +2657,14 @@ void copy(in char[] from, in char[] to)
|
|||
{
|
||||
scope(failure) core.sys.posix.unistd.close(fdw);
|
||||
auto BUFSIZ = 4096u * 16;
|
||||
auto buf = std.c.stdlib.malloc(BUFSIZ);
|
||||
auto buf = core.stdc.stdlib.malloc(BUFSIZ);
|
||||
if (!buf)
|
||||
{
|
||||
BUFSIZ = 4096;
|
||||
buf = std.c.stdlib.malloc(BUFSIZ);
|
||||
buf = core.stdc.stdlib.malloc(BUFSIZ);
|
||||
buf || assert(false, "Out of memory in std.file.copy");
|
||||
}
|
||||
scope(exit) std.c.stdlib.free(buf);
|
||||
scope(exit) core.stdc.stdlib.free(buf);
|
||||
|
||||
for (auto size = statbuf.st_size; size; )
|
||||
{
|
||||
|
@ -3040,8 +3040,8 @@ private struct DirIteratorImpl
|
|||
return false;
|
||||
}
|
||||
}
|
||||
while( std.c.string.strcmp(findinfo.cFileName.ptr, ".") == 0
|
||||
|| std.c.string.strcmp(findinfo.cFileName.ptr, "..") == 0)
|
||||
while( core.stdc.string.strcmp(findinfo.cFileName.ptr, ".") == 0
|
||||
|| core.stdc.string.strcmp(findinfo.cFileName.ptr, "..") == 0)
|
||||
if(FindNextFileA(_stack.data[$-1].h, findinfo) == FALSE)
|
||||
{
|
||||
popDirStack();
|
||||
|
@ -3091,8 +3091,8 @@ private struct DirIteratorImpl
|
|||
for(dirent* fdata; (fdata = readdir(_stack.data[$-1].h)) != null; )
|
||||
{
|
||||
// Skip "." and ".."
|
||||
if(std.c.string.strcmp(fdata.d_name.ptr, ".") &&
|
||||
std.c.string.strcmp(fdata.d_name.ptr, "..") )
|
||||
if(core.stdc.string.strcmp(fdata.d_name.ptr, ".") &&
|
||||
core.stdc.string.strcmp(fdata.d_name.ptr, "..") )
|
||||
{
|
||||
_cur._init(_stack.data[$-1].dirpath, fdata);
|
||||
return true;
|
||||
|
@ -3831,8 +3831,8 @@ version(Windows)
|
|||
do
|
||||
{
|
||||
// Skip "." and ".."
|
||||
if(std.c.string.strcmp(fileinfo.cFileName.ptr, ".") == 0 ||
|
||||
std.c.string.strcmp(fileinfo.cFileName.ptr, "..") == 0)
|
||||
if(core.stdc.string.strcmp(fileinfo.cFileName.ptr, ".") == 0 ||
|
||||
core.stdc.string.strcmp(fileinfo.cFileName.ptr, "..") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -3858,8 +3858,8 @@ else version(Posix)
|
|||
for(dirent* fdata; (fdata = readdir(h)) != null; )
|
||||
{
|
||||
// Skip "." and ".."
|
||||
if(!std.c.string.strcmp(fdata.d_name.ptr, ".") ||
|
||||
!std.c.string.strcmp(fdata.d_name.ptr, ".."))
|
||||
if(!core.stdc.string.strcmp(fdata.d_name.ptr, ".") ||
|
||||
!core.stdc.string.strcmp(fdata.d_name.ptr, ".."))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
10
std/path.d
10
std/path.d
|
@ -2588,7 +2588,7 @@ string expandTilde(string inputPath)
|
|||
assert(char_pos >= 0);
|
||||
|
||||
// Search end of C string
|
||||
size_t end = std.c.string.strlen(c_path);
|
||||
size_t end = core.stdc.string.strlen(c_path);
|
||||
|
||||
// Remove trailing path separator, if any
|
||||
if (end && isDirSeparator(c_path[end - 1]))
|
||||
|
@ -2646,7 +2646,7 @@ string expandTilde(string inputPath)
|
|||
|
||||
while (1)
|
||||
{
|
||||
extra_memory = std.c.stdlib.malloc(extra_memory_size);
|
||||
extra_memory = core.stdc.stdlib.malloc(extra_memory_size);
|
||||
if (extra_memory == null)
|
||||
goto Lerror;
|
||||
|
||||
|
@ -2667,20 +2667,20 @@ string expandTilde(string inputPath)
|
|||
goto Lerror;
|
||||
|
||||
// extra_memory isn't large enough
|
||||
std.c.stdlib.free(extra_memory);
|
||||
core.stdc.stdlib.free(extra_memory);
|
||||
extra_memory_size *= 2;
|
||||
}
|
||||
|
||||
path = combineCPathWithDPath(result.pw_dir, path, last_char);
|
||||
|
||||
Lnotfound:
|
||||
std.c.stdlib.free(extra_memory);
|
||||
core.stdc.stdlib.free(extra_memory);
|
||||
return path;
|
||||
|
||||
Lerror:
|
||||
// Errors are going to be caused by running out of memory
|
||||
if (extra_memory)
|
||||
std.c.stdlib.free(extra_memory);
|
||||
core.stdc.stdlib.free(extra_memory);
|
||||
onOutOfMemoryError();
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ module std.process;
|
|||
|
||||
|
||||
import core.stdc.stdlib;
|
||||
import std.c.stdlib;
|
||||
import core.stdc.errno;
|
||||
import core.thread;
|
||||
import std.c.process;
|
||||
|
@ -277,7 +278,7 @@ version(Posix)
|
|||
{
|
||||
// No, so must traverse PATHs, looking for first match
|
||||
string[] envPaths = std.string.split(
|
||||
to!string(std.c.stdlib.getenv("PATH")), ":");
|
||||
to!string(core.stdc.stdlib.getenv("PATH")), ":");
|
||||
int iRet = 0;
|
||||
|
||||
// Note: if any call to execve() succeeds, this process will cease
|
||||
|
@ -388,7 +389,7 @@ string getenv(in char[] name)
|
|||
{
|
||||
// Cache the last call's result
|
||||
static string lastResult;
|
||||
auto p = std.c.stdlib.getenv(toStringz(name));
|
||||
auto p = core.stdc.stdlib.getenv(toStringz(name));
|
||||
if (!p) return null;
|
||||
auto value = p[0 .. strlen(p)];
|
||||
if (value == lastResult) return lastResult;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue