Fixed wrong C library lookups

This commit is contained in:
Andrei Alexandrescu 2011-11-12 21:55:22 -06:00
parent 0ee6a1afbd
commit 703f612973
3 changed files with 24 additions and 23 deletions

View file

@ -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;
}

View file

@ -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;
}
@ -2782,12 +2782,12 @@ version(Windows)
enum string linesep = "\r\n"; // / String used to separate lines.
enum string curdir = "."; // / String representing the current directory.
enum string pardir = ".."; // / String representing the parent directory.
static assert(sep.length == 1 && altsep.length == 1);
private bool isSep(dchar ch) {
return ch == sep[0] || ch == altsep[0];
}
private bool isSepOrDriveSep(dchar ch) {
return isSep(ch) || ch == ':';
}
@ -2808,7 +2808,7 @@ version(Posix)
enum string linesep = "\n";
enum string curdir = "."; // / String representing the current directory.
enum string pardir = ".."; // / String representing the parent directory.
static assert(sep.length == 1 && altsep.length == 0);
private bool isSep(dchar ch) {
return ch == sep[0];

View file

@ -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;