mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-18 13:53:14 +01:00
Merge dmd-1.074 into ldc.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright (c) 1999-2011 by Digital Mars
|
||||
// Copyright (c) 1999-2011 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
@@ -8,7 +8,7 @@
|
||||
// See the included readme.txt for details.
|
||||
|
||||
#ifndef POSIX
|
||||
#define POSIX (linux || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun&&__SVR4)
|
||||
#define POSIX (linux || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun&&__SVR4)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -35,7 +35,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef __HAIKU__
|
||||
#include <iostream>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#if POSIX
|
||||
@@ -364,21 +364,21 @@ FileName::FileName(char *path, char *name)
|
||||
}
|
||||
|
||||
// Split a path into an Array of paths
|
||||
Strings *FileName::splitPath(const char *path)
|
||||
Strings *FileName::splitPath(const char *path)
|
||||
{
|
||||
char c = 0; // unnecessary initializer is for VC /W4
|
||||
const char *p;
|
||||
OutBuffer buf;
|
||||
Strings *array;
|
||||
Strings *array;
|
||||
|
||||
array = new Strings();
|
||||
array = new Strings();
|
||||
if (path)
|
||||
{
|
||||
p = path;
|
||||
do
|
||||
{ char instring = 0;
|
||||
|
||||
while (isspace((unsigned char)*p)) // skip leading whitespace
|
||||
while (isspace((unsigned char)*p)) // skip leading whitespace
|
||||
p++;
|
||||
buf.reserve(strlen(p) + 1); // guess size of path
|
||||
// LDC remember first character
|
||||
@@ -799,7 +799,7 @@ void FileName::CopyTo(FileName *to)
|
||||
* cwd if !=0, search current directory before searching path
|
||||
*/
|
||||
|
||||
char *FileName::searchPath(Strings *path, const char *name, int cwd)
|
||||
char *FileName::searchPath(Strings *path, const char *name, int cwd)
|
||||
{
|
||||
if (absolute(name))
|
||||
{
|
||||
@@ -815,7 +815,7 @@ char *FileName::searchPath(Strings *path, const char *name, int cwd)
|
||||
|
||||
for (i = 0; i < path->dim; i++)
|
||||
{
|
||||
char *p = path->tdata()[i];
|
||||
char *p = path->tdata()[i];
|
||||
char *n = combine(p, name);
|
||||
|
||||
if (exists(n))
|
||||
@@ -839,7 +839,7 @@ char *FileName::searchPath(Strings *path, const char *name, int cwd)
|
||||
* !=NULL mem.malloc'd file name
|
||||
*/
|
||||
|
||||
char *FileName::safeSearchPath(Strings *path, const char *name)
|
||||
char *FileName::safeSearchPath(Strings *path, const char *name)
|
||||
{
|
||||
#if _WIN32
|
||||
/* Disallow % / \ : and .. in name characters
|
||||
@@ -876,7 +876,7 @@ char *FileName::safeSearchPath(Strings *path, const char *name)
|
||||
for (i = 0; i < path->dim; i++)
|
||||
{
|
||||
char *cname = NULL;
|
||||
char *cpath = canonicalName(path->tdata()[i]);
|
||||
char *cpath = canonicalName(path->tdata()[i]);
|
||||
//printf("FileName::safeSearchPath(): name=%s; path=%s; cpath=%s\n",
|
||||
// name, (char *)path->data[i], cpath);
|
||||
if (cpath == NULL)
|
||||
@@ -966,7 +966,7 @@ void FileName::ensurePathExists(const char *path)
|
||||
{
|
||||
//printf("mkdir(%s)\n", path);
|
||||
#if _WIN32
|
||||
if (_mkdir(path))
|
||||
if (_mkdir(path))
|
||||
#endif
|
||||
#if POSIX
|
||||
if (mkdir(path, 0777))
|
||||
@@ -1088,13 +1088,13 @@ int File::read()
|
||||
//printf("File::read('%s')\n",name);
|
||||
fd = open(name, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
{
|
||||
//printf("\topen error, errno = %d\n",errno);
|
||||
goto err1;
|
||||
}
|
||||
|
||||
if (!ref)
|
||||
::free(buffer);
|
||||
::free(buffer);
|
||||
ref = 0; // we own the buffer now
|
||||
|
||||
//printf("\tfile opened\n");
|
||||
@@ -1104,7 +1104,7 @@ int File::read()
|
||||
goto err2;
|
||||
}
|
||||
size = buf.st_size;
|
||||
buffer = (unsigned char *) ::malloc(size + 2);
|
||||
buffer = (unsigned char *) ::malloc(size + 2);
|
||||
if (!buffer)
|
||||
{
|
||||
printf("\tmalloc error, errno = %d\n",errno);
|
||||
@@ -1137,7 +1137,7 @@ int File::read()
|
||||
err2:
|
||||
close(fd);
|
||||
err:
|
||||
::free(buffer);
|
||||
::free(buffer);
|
||||
buffer = NULL;
|
||||
len = 0;
|
||||
|
||||
@@ -1158,11 +1158,11 @@ err1:
|
||||
goto err1;
|
||||
|
||||
if (!ref)
|
||||
::free(buffer);
|
||||
::free(buffer);
|
||||
ref = 0;
|
||||
|
||||
size = GetFileSize(h,NULL);
|
||||
buffer = (unsigned char *) ::malloc(size + 2);
|
||||
buffer = (unsigned char *) ::malloc(size + 2);
|
||||
if (!buffer)
|
||||
goto err2;
|
||||
|
||||
@@ -1191,7 +1191,7 @@ err1:
|
||||
err2:
|
||||
CloseHandle(h);
|
||||
err:
|
||||
::free(buffer);
|
||||
::free(buffer);
|
||||
buffer = NULL;
|
||||
len = 0;
|
||||
|
||||
@@ -1454,23 +1454,23 @@ void File::remove()
|
||||
#endif
|
||||
}
|
||||
|
||||
Files *File::match(char *n)
|
||||
Files *File::match(char *n)
|
||||
{
|
||||
return match(new FileName(n, 0));
|
||||
}
|
||||
|
||||
Files *File::match(FileName *n)
|
||||
Files *File::match(FileName *n)
|
||||
{
|
||||
#if POSIX
|
||||
return NULL;
|
||||
#elif _WIN32
|
||||
HANDLE h;
|
||||
WIN32_FIND_DATAA fileinfo;
|
||||
Files *a;
|
||||
Files *a;
|
||||
char *c;
|
||||
char *name;
|
||||
|
||||
a = new Files();
|
||||
a = new Files();
|
||||
c = n->toChars();
|
||||
name = n->name();
|
||||
h = FindFirstFileA(c,&fileinfo);
|
||||
@@ -1540,7 +1540,7 @@ void File::stat()
|
||||
void File::checkoffset(size_t offset, size_t nbytes)
|
||||
{
|
||||
if (offset > len || offset + nbytes > len)
|
||||
error("Corrupt file '%s': offset x%zx off end of file",toChars(),offset);
|
||||
error("Corrupt file '%s': offset x%llx off end of file",toChars(),(ulonglong)offset);
|
||||
}
|
||||
|
||||
char *File::toChars()
|
||||
@@ -1563,11 +1563,11 @@ OutBuffer::~OutBuffer()
|
||||
mem.free(data);
|
||||
}
|
||||
|
||||
char *OutBuffer::extractData()
|
||||
char *OutBuffer::extractData()
|
||||
{
|
||||
char *p;
|
||||
char *p;
|
||||
|
||||
p = (char *)data;
|
||||
p = (char *)data;
|
||||
data = NULL;
|
||||
offset = 0;
|
||||
size = 0;
|
||||
@@ -1813,7 +1813,7 @@ void OutBuffer::align(unsigned size)
|
||||
// The compiler shipped with Visual Studio 2005 (and possible
|
||||
// other versions) does not support C99 printf format specfiers
|
||||
// such as %z and %j
|
||||
#if _MSC_VER || __MINGW32__
|
||||
#if 0 && _MSC_VER
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
|
||||
@@ -1832,7 +1832,7 @@ search_and_replace(S& str, const S& what, const S& replacement)
|
||||
#define WORKAROUND_C99_SPECIFIERS_BUG(S,tmp,f) \
|
||||
S tmp = f; \
|
||||
search_and_replace(fmt, S("%z"), S("%l")); \
|
||||
search_and_replace(fmt, S("%j"), S("%i")); \
|
||||
search_and_replace(fmt, S("%j"), S("%l")); \
|
||||
f = tmp.c_str();
|
||||
#else
|
||||
#define WORKAROUND_C99_SPECIFIERS_BUG(S,tmp,f)
|
||||
|
||||
Reference in New Issue
Block a user