First merge of 2.064 beta.

This corresponds to DMD commit a913ce4bc59a94a022a27e390fc841f4aededffb.

Doesn't build Phobos yet.
This commit is contained in:
David Nadlinger
2013-10-19 23:21:53 +02:00
committed by Kai Nacke
parent c400d180d2
commit cb341586e3
130 changed files with 13566 additions and 9190 deletions

View File

@@ -98,42 +98,42 @@ void warning(const char *format, ...)
/****************************** Object ********************************/
int Object::equals(Object *o)
bool RootObject::equals(RootObject *o)
{
return o == this;
}
hash_t Object::hashCode()
hash_t RootObject::hashCode()
{
return (hash_t) this;
}
int Object::compare(Object *obj)
int RootObject::compare(RootObject *obj)
{
return this - obj;
}
void Object::print()
void RootObject::print()
{
printf("%s %p\n", toChars(), this);
}
char *Object::toChars()
char *RootObject::toChars()
{
return (char *)"Object";
}
int Object::dyncast()
int RootObject::dyncast()
{
return 0;
}
void Object::toBuffer(OutBuffer *b)
void RootObject::toBuffer(OutBuffer *b)
{
b->writestring("Object");
}
void Object::mark()
void RootObject::mark()
{
}
@@ -206,12 +206,12 @@ size_t String::len()
return strlen(str);
}
int String::equals(Object *obj)
bool String::equals(RootObject *obj)
{
return strcmp(str,((String *)obj)->str) == 0;
}
int String::compare(Object *obj)
int String::compare(RootObject *obj)
{
return strcmp(str,((String *)obj)->str);
}
@@ -279,7 +279,7 @@ Strings *FileName::splitPath(const char *path)
do
{ char instring = 0;
while (isspace((unsigned char)*p)) // skip leading whitespace
while (isspace((utf8_t)*p)) // skip leading whitespace
p++;
buf.reserve(strlen(p) + 1); // guess size of path
for (; ; p++)
@@ -345,7 +345,7 @@ hash_t FileName::hashCode()
// We need a different hashCode because it must be case-insensitive
size_t len = strlen(str);
hash_t hash = 0;
unsigned char *s = (unsigned char *)str;
utf8_t *s = (utf8_t *)str;
for (;;)
{
@@ -384,7 +384,7 @@ hash_t FileName::hashCode()
#endif
}
int FileName::compare(Object *obj)
int FileName::compare(RootObject *obj)
{
return compare(str, ((FileName *)obj)->str);
}
@@ -398,7 +398,7 @@ int FileName::compare(const char *name1, const char *name2)
#endif
}
int FileName::equals(Object *obj)
bool FileName::equals(RootObject *obj)
{
return compare(obj) == 0;
}
@@ -696,7 +696,7 @@ const char *FileName::searchPath(Strings *path, const char *name, int cwd)
for (size_t i = 0; i < path->dim; i++)
{
const char *p = path->tdata()[i];
const char *p = (*path)[i];
const char *n = combine(p, name);
if (exists(n))
@@ -756,7 +756,7 @@ const char *FileName::safeSearchPath(Strings *path, const char *name)
for (size_t i = 0; i < path->dim; i++)
{
const char *cname = NULL;
const char *cpath = canonicalName(path->tdata()[i]);
const char *cpath = canonicalName((*path)[i]);
//printf("FileName::safeSearchPath(): name=%s; path=%s; cpath=%s\n",
// name, (char *)path->data[i], cpath);
if (cpath == NULL)
@@ -829,7 +829,8 @@ void FileName::ensurePathExists(const char *path)
{
#if _WIN32
size_t len = strlen(path);
if (len > 2 && p[-1] == ':' && path + 2 == p)
if ((len > 2 && p[-1] == ':' && strcmp(path + 2, p) == 0) ||
len == strlen(p))
{ mem.free((void *)p);
return;
}
@@ -838,19 +839,20 @@ void FileName::ensurePathExists(const char *path)
mem.free((void *)p);
}
#if _WIN32
if (path[strlen(path) - 1] != '\\')
#endif
#if POSIX
if (path[strlen(path) - 1] != '\\')
char sep = '\\';
#elif POSIX
char sep = '/';
#endif
if (path[strlen(path) - 1] != sep)
{
//printf("mkdir(%s)\n", path);
#if _WIN32
if (_mkdir(path))
int r = _mkdir(path);
#endif
#if POSIX
if (mkdir(path, 0777))
int r = mkdir(path, 0777);
#endif
if (r)
{
/* Don't error out if another instance of dmd just created
* this directory
@@ -1017,7 +1019,7 @@ int File::read()
goto err2;
}
size = buf.st_size;
buffer = (unsigned char *) ::malloc(size + 2);
buffer = (utf8_t *) ::malloc(size + 2);
if (!buffer)
{
printf("\tmalloc error, errno = %d\n",errno);
@@ -1075,7 +1077,7 @@ err1:
ref = 0;
size = GetFileSize(h,NULL);
buffer = (unsigned char *) ::malloc(size + 2);
buffer = (utf8_t *) ::malloc(size + 2);
if (!buffer)
goto err2;
@@ -1151,7 +1153,7 @@ int File::mmread()
if (!ref)
mem.free(buffer);
ref = 2;
buffer = (unsigned char *)MapViewOfFileEx(hFileMap, FILE_MAP_READ,0,0,size,NULL);
buffer = (utf8_t *)MapViewOfFileEx(hFileMap, FILE_MAP_READ,0,0,size,NULL);
if (CloseHandle(hFileMap) != TRUE)
goto Lerr;
if (buffer == NULL) // mapping view failed
@@ -1359,7 +1361,7 @@ int File::exists()
void File::remove()
{
#if POSIX
::remove(this->name->toChars());
int dummy = ::remove(this->name->toChars());
#elif _WIN32
DeleteFileA(this->name->toChars());
#else
@@ -1469,7 +1471,7 @@ OutBuffer::OutBuffer()
doindent = 0;
level = 0;
linehead = 1;
notlinehead = 0;
}
OutBuffer::~OutBuffer()
@@ -1499,7 +1501,8 @@ void OutBuffer::reserve(size_t nbytes)
if (size - offset < nbytes)
{
size = (offset + nbytes) * 2;
data = (unsigned char *)mem.realloc(data, size);
size = (size + 15) & ~15;
data = (utf8_t *)mem.realloc(data, size);
}
}
@@ -1515,7 +1518,7 @@ void OutBuffer::setsize(size_t size)
void OutBuffer::write(const void *data, size_t nbytes)
{
if (doindent && linehead)
if (doindent && !notlinehead)
{
if (level)
{
@@ -1526,14 +1529,14 @@ void OutBuffer::write(const void *data, size_t nbytes)
offset++;
}
}
linehead = 0;
notlinehead = 1;
}
reserve(nbytes);
memcpy(this->data + offset, data, nbytes);
offset += nbytes;
}
void OutBuffer::writebstring(unsigned char *string)
void OutBuffer::writebstring(utf8_t *string)
{
write(string,*string + 1);
}
@@ -1560,12 +1563,12 @@ void OutBuffer::writenl()
writeByte('\n');
#endif
if (doindent)
linehead = 1;
notlinehead = 0;
}
void OutBuffer::writeByte(unsigned b)
{
if (doindent && linehead
if (doindent && !notlinehead
&& b != '\n')
{
if (level)
@@ -1577,7 +1580,7 @@ void OutBuffer::writeByte(unsigned b)
offset++;
}
}
linehead = 0;
notlinehead = 1;
}
reserve(1);
this->data[offset] = (unsigned char)b;
@@ -1655,12 +1658,13 @@ void OutBuffer::writewchar(unsigned w)
void OutBuffer::writeword(unsigned w)
{
if (doindent && linehead
#if _WIN32
&& w != 0x0A0D)
unsigned newline = 0x0A0D;
#else
&& w != '\n')
unsigned newline = '\n';
#endif
if (doindent && !notlinehead
&& w != newline)
{
if (level)
{
@@ -1671,7 +1675,7 @@ void OutBuffer::writeword(unsigned w)
offset++;
}
}
linehead = 0;
notlinehead = 1;
}
reserve(2);
*(unsigned short *)(this->data + offset) = (unsigned short)w;
@@ -1698,12 +1702,12 @@ void OutBuffer::writeUTF16(unsigned w)
void OutBuffer::write4(unsigned w)
{
if (doindent && linehead
#if _WIN32
&& w != 0x000A000D)
bool notnewline = w != 0x000A000D;
#else
)
bool notnewline = true;
#endif
if (doindent && !notlinehead && notnewline)
{
if (level)
{
@@ -1714,7 +1718,7 @@ void OutBuffer::write4(unsigned w)
offset++;
}
}
linehead = 0;
notlinehead = 1;
}
reserve(4);
*(unsigned *)(this->data + offset) = w;
@@ -1730,7 +1734,7 @@ void OutBuffer::write(OutBuffer *buf)
}
}
void OutBuffer::write(Object *obj)
void OutBuffer::write(RootObject *obj)
{
if (obj)
{