mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-07-29 02:20:04 +02:00
Merge of DMD 2.062.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright (c) 1999-2010 by Digital Mars
|
||||
// Copyright (c) 1999-2013 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
@@ -9,35 +9,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if defined (__sun)
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
#if _MSC_VER || __MINGW32__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#if IN_GCC
|
||||
#include "gdc_alloca.h"
|
||||
#endif
|
||||
|
||||
#if _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#endif
|
||||
|
||||
#include "port.h"
|
||||
#include "root.h"
|
||||
#include "rmem.h"
|
||||
@@ -181,25 +155,19 @@ void Array::remove(size_t i)
|
||||
|
||||
char *Array::toChars()
|
||||
{
|
||||
size_t len;
|
||||
size_t u;
|
||||
char **buf;
|
||||
char *str;
|
||||
char *p;
|
||||
|
||||
buf = (char **)malloc(dim * sizeof(char *));
|
||||
char **buf = (char **)malloc(dim * sizeof(char *));
|
||||
assert(buf);
|
||||
len = 2;
|
||||
for (u = 0; u < dim; u++)
|
||||
size_t len = 2;
|
||||
for (size_t u = 0; u < dim; u++)
|
||||
{
|
||||
buf[u] = ((Object *)data[u])->toChars();
|
||||
len += strlen(buf[u]) + 1;
|
||||
}
|
||||
str = (char *)mem.malloc(len);
|
||||
char *str = (char *)mem.malloc(len);
|
||||
|
||||
str[0] = '[';
|
||||
p = str + 1;
|
||||
for (u = 0; u < dim; u++)
|
||||
char *p = str + 1;
|
||||
for (size_t u = 0; u < dim; u++)
|
||||
{
|
||||
if (u)
|
||||
*p++ = ',';
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
|
||||
// Copyright (c) 2009-2012 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
// License for redistribution is by either the Artistic License
|
||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||
// See the included readme.txt for details.
|
||||
|
||||
// Put functions in here missing from gnu C
|
||||
|
||||
#include "gnuc.h"
|
||||
|
||||
int memicmp(const char *s1, const char *s2, int n)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{ char c1 = s1[i];
|
||||
char c2 = s2[i];
|
||||
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
{
|
||||
if ('A' <= c1 && c1 <= 'Z')
|
||||
c1 += 'a' - 'A';
|
||||
if ('A' <= c2 && c2 <= 'Z')
|
||||
c2 += 'a' - 'A';
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int stricmp(const char *s1, const char *s2)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
for (;;)
|
||||
{ char c1 = *s1;
|
||||
char c2 = *s2;
|
||||
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
{
|
||||
if ('A' <= c1 && c1 <= 'Z')
|
||||
c1 += 'a' - 'A';
|
||||
if ('A' <= c2 && c2 <= 'Z')
|
||||
c2 += 'a' - 'A';
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
if (!c1)
|
||||
break;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
// Copyright (c) 2009-2012 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
// License for redistribution is by either the Artistic License
|
||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||
// See the included readme.txt for details.
|
||||
|
||||
#ifndef _GNUC_H
|
||||
#define _GNUC_H 1
|
||||
|
||||
int memicmp(const char *s1, const char *s2, int n);
|
||||
int stricmp(const char *s1, const char *s2);
|
||||
|
||||
#endif
|
||||
@@ -116,6 +116,16 @@ char *Port::strupr(char *s)
|
||||
return ::strupr(s);
|
||||
}
|
||||
|
||||
int Port::memicmp(const char *s1, const char *s2, int n)
|
||||
{
|
||||
return ::memicmp(s1, s2, n);
|
||||
}
|
||||
|
||||
int Port::stricmp(const char *s1, const char *s2)
|
||||
{
|
||||
return ::stricmp(s1, s2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if _MSC_VER
|
||||
@@ -328,6 +338,16 @@ char *Port::strupr(char *s)
|
||||
return ::strupr(s);
|
||||
}
|
||||
|
||||
int Port::memicmp(const char *s1, const char *s2, int n)
|
||||
{
|
||||
return ::memicmp(s1, s2, n);
|
||||
}
|
||||
|
||||
int Port::stricmp(const char *s1, const char *s2)
|
||||
{
|
||||
return ::stricmp(s1, s2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if linux || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __HAIKU__ || __MINGW32__
|
||||
@@ -524,6 +544,48 @@ char *Port::strupr(char *s)
|
||||
return t;
|
||||
}
|
||||
|
||||
int Port::memicmp(const char *s1, const char *s2, int n)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{ char c1 = s1[i];
|
||||
char c2 = s2[i];
|
||||
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
{
|
||||
result = toupper(c1) - toupper(c2);
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int Port::stricmp(const char *s1, const char *s2)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
for (;;)
|
||||
{ char c1 = *s1;
|
||||
char c2 = *s2;
|
||||
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
{
|
||||
result = toupper(c1) - toupper(c2);
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
if (!c1)
|
||||
break;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if __sun
|
||||
@@ -670,18 +732,3 @@ char *Port::strupr(char *s)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if IN_LLVM
|
||||
#if __MINGW32__
|
||||
longdouble Port::strtold(const char *str, char **pend)
|
||||
{
|
||||
return __mingw_strtold(str, pend);
|
||||
}
|
||||
#else
|
||||
longdouble Port::strtold(const char *str, char **pend)
|
||||
{
|
||||
return ::strtold(str, pend);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -61,9 +61,6 @@ struct Port
|
||||
static longdouble fmodl(longdouble x, longdouble y);
|
||||
|
||||
static ulonglong strtoull(const char *p, char **pend, int base);
|
||||
#if IN_LLVM
|
||||
static longdouble strtold(const char *str, char **pend);
|
||||
#endif
|
||||
|
||||
static char *ull_to_string(char *buffer, ulonglong ull);
|
||||
static wchar_t *ull_to_string(wchar_t *buffer, ulonglong ull);
|
||||
@@ -76,6 +73,9 @@ struct Port
|
||||
static const wchar_t *wlist_separator();
|
||||
|
||||
static char *strupr(char *);
|
||||
|
||||
static int memicmp(const char *s1, const char *s2, int n);
|
||||
static int stricmp(const char *s1, const char *s2);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Written by Walter Bright
|
||||
/*
|
||||
* This source file is made available for personal use
|
||||
* only. The license is in /dmd/src/dmd/backendlicense.txt
|
||||
* only. The license is in backendlicense.txt
|
||||
* For any other uses, please contact Digital Mars.
|
||||
*/
|
||||
|
||||
|
||||
176
dmd2/root/root.c
176
dmd2/root/root.c
@@ -139,19 +139,19 @@ void Object::mark()
|
||||
|
||||
/****************************** String ********************************/
|
||||
|
||||
String::String(char *str)
|
||||
String::String(const char *str)
|
||||
: str(mem.strdup(str))
|
||||
{
|
||||
}
|
||||
|
||||
String::~String()
|
||||
{
|
||||
mem.free(str);
|
||||
mem.free((void *)str);
|
||||
}
|
||||
|
||||
void String::mark()
|
||||
{
|
||||
mem.mark(str);
|
||||
mem.mark((void *)str);
|
||||
}
|
||||
|
||||
hash_t String::calcHash(const char *str, size_t len)
|
||||
@@ -218,7 +218,7 @@ int String::compare(Object *obj)
|
||||
|
||||
char *String::toChars()
|
||||
{
|
||||
return str;
|
||||
return (char *)str; // toChars() should really be const
|
||||
}
|
||||
|
||||
void String::print()
|
||||
@@ -229,12 +229,12 @@ void String::print()
|
||||
|
||||
/****************************** FileName ********************************/
|
||||
|
||||
FileName::FileName(char *str)
|
||||
FileName::FileName(const char *str)
|
||||
: String(str)
|
||||
{
|
||||
}
|
||||
|
||||
char *FileName::combine(const char *path, const char *name)
|
||||
const char *FileName::combine(const char *path, const char *name)
|
||||
{ char *f;
|
||||
size_t pathlen;
|
||||
size_t namelen;
|
||||
@@ -431,12 +431,11 @@ int FileName::absolute(const char *name)
|
||||
* If there isn't one, return NULL.
|
||||
*/
|
||||
|
||||
char *FileName::ext(const char *str)
|
||||
const char *FileName::ext(const char *str)
|
||||
{
|
||||
char *e;
|
||||
size_t len = strlen(str);
|
||||
|
||||
e = (char *)str + len;
|
||||
const char *e = str + len;
|
||||
for (;;)
|
||||
{
|
||||
switch (*e)
|
||||
@@ -462,7 +461,7 @@ char *FileName::ext(const char *str)
|
||||
}
|
||||
}
|
||||
|
||||
char *FileName::ext()
|
||||
const char *FileName::ext()
|
||||
{
|
||||
return ext(str);
|
||||
}
|
||||
@@ -471,7 +470,7 @@ char *FileName::ext()
|
||||
* Return mem.malloc'd filename with extension removed.
|
||||
*/
|
||||
|
||||
char *FileName::removeExt(const char *str)
|
||||
const char *FileName::removeExt(const char *str)
|
||||
{
|
||||
const char *e = ext(str);
|
||||
if (e)
|
||||
@@ -488,12 +487,11 @@ char *FileName::removeExt(const char *str)
|
||||
* Return filename name excluding path (read-only).
|
||||
*/
|
||||
|
||||
char *FileName::name(const char *str)
|
||||
const char *FileName::name(const char *str)
|
||||
{
|
||||
char *e;
|
||||
size_t len = strlen(str);
|
||||
|
||||
e = (char *)str + len;
|
||||
const char *e = str + len;
|
||||
for (;;)
|
||||
{
|
||||
switch (*e)
|
||||
@@ -525,7 +523,7 @@ char *FileName::name(const char *str)
|
||||
}
|
||||
}
|
||||
|
||||
char *FileName::name()
|
||||
const char *FileName::name()
|
||||
{
|
||||
return name(str);
|
||||
}
|
||||
@@ -535,10 +533,9 @@ char *FileName::name()
|
||||
* Path will does not include trailing path separator.
|
||||
*/
|
||||
|
||||
char *FileName::path(const char *str)
|
||||
const char *FileName::path(const char *str)
|
||||
{
|
||||
char *n = name(str);
|
||||
char *path;
|
||||
const char *n = name(str);
|
||||
size_t pathlen;
|
||||
|
||||
if (n > str)
|
||||
@@ -554,7 +551,7 @@ char *FileName::path(const char *str)
|
||||
#endif
|
||||
}
|
||||
pathlen = n - str;
|
||||
path = (char *)mem.malloc(pathlen + 1);
|
||||
char *path = (char *)mem.malloc(pathlen + 1);
|
||||
memcpy(path, str, pathlen);
|
||||
path[pathlen] = 0;
|
||||
return path;
|
||||
@@ -565,20 +562,19 @@ char *FileName::path(const char *str)
|
||||
*/
|
||||
|
||||
const char *FileName::replaceName(const char *path, const char *name)
|
||||
{ char *f;
|
||||
char *n;
|
||||
{
|
||||
size_t pathlen;
|
||||
size_t namelen;
|
||||
|
||||
if (absolute(name))
|
||||
return name;
|
||||
|
||||
n = FileName::name(path);
|
||||
const char *n = FileName::name(path);
|
||||
if (n == path)
|
||||
return name;
|
||||
pathlen = n - path;
|
||||
namelen = strlen(name);
|
||||
f = (char *)mem.malloc(pathlen + 1 + namelen + 1);
|
||||
char *f = (char *)mem.malloc(pathlen + 1 + namelen + 1);
|
||||
memcpy(f, path, pathlen);
|
||||
#if POSIX
|
||||
if (path[pathlen - 1] != '/')
|
||||
@@ -600,48 +596,40 @@ const char *FileName::replaceName(const char *path, const char *name)
|
||||
}
|
||||
|
||||
/***************************
|
||||
* Free returned value with FileName::free()
|
||||
*/
|
||||
|
||||
FileName *FileName::defaultExt(const char *name, const char *ext)
|
||||
const char *FileName::defaultExt(const char *name, const char *ext)
|
||||
{
|
||||
char *e;
|
||||
char *s;
|
||||
size_t len;
|
||||
size_t extlen;
|
||||
|
||||
e = FileName::ext(name);
|
||||
const char *e = FileName::ext(name);
|
||||
if (e) // if already has an extension
|
||||
return new FileName((char *)name);
|
||||
return mem.strdup(name);
|
||||
|
||||
len = strlen(name);
|
||||
extlen = strlen(ext);
|
||||
s = (char *)alloca(len + 1 + extlen + 1);
|
||||
size_t len = strlen(name);
|
||||
size_t extlen = strlen(ext);
|
||||
char *s = (char *)mem.malloc(len + 1 + extlen + 1);
|
||||
memcpy(s,name,len);
|
||||
s[len] = '.';
|
||||
memcpy(s + len + 1, ext, extlen + 1);
|
||||
return new FileName(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
/***************************
|
||||
* Free returned value with FileName::free()
|
||||
*/
|
||||
|
||||
FileName *FileName::forceExt(const char *name, const char *ext)
|
||||
const char *FileName::forceExt(const char *name, const char *ext)
|
||||
{
|
||||
char *e;
|
||||
char *s;
|
||||
size_t len;
|
||||
size_t extlen;
|
||||
|
||||
e = FileName::ext(name);
|
||||
const char *e = FileName::ext(name);
|
||||
if (e) // if already has an extension
|
||||
{
|
||||
len = e - name;
|
||||
extlen = strlen(ext);
|
||||
size_t len = e - name;
|
||||
size_t extlen = strlen(ext);
|
||||
|
||||
s = (char *)alloca(len + extlen + 1);
|
||||
char *s = (char *)mem.malloc(len + extlen + 1);
|
||||
memcpy(s,name,len);
|
||||
memcpy(s + len, ext, extlen + 1);
|
||||
return new FileName(s);
|
||||
return s;
|
||||
}
|
||||
else
|
||||
return defaultExt(name, ext); // doesn't have one
|
||||
@@ -652,20 +640,18 @@ FileName *FileName::forceExt(const char *name, const char *ext)
|
||||
*/
|
||||
|
||||
int FileName::equalsExt(const char *ext)
|
||||
{ const char *e;
|
||||
{
|
||||
return equalsExt(str, ext);
|
||||
}
|
||||
|
||||
e = FileName::ext();
|
||||
int FileName::equalsExt(const char *name, const char *ext)
|
||||
{
|
||||
const char *e = FileName::ext(name);
|
||||
if (!e && !ext)
|
||||
return 1;
|
||||
if (!e || !ext)
|
||||
return 0;
|
||||
#if POSIX
|
||||
return strcmp(e,ext) == 0;
|
||||
#elif _WIN32
|
||||
return stricmp(e,ext) == 0;
|
||||
#else
|
||||
assert(0);
|
||||
#endif
|
||||
return FileName::compare(e, ext) == 0;
|
||||
}
|
||||
|
||||
/*************************************
|
||||
@@ -694,24 +680,24 @@ void FileName::CopyTo(FileName *to)
|
||||
* cwd if !=0, search current directory before searching path
|
||||
*/
|
||||
|
||||
char *FileName::searchPath(Strings *path, const char *name, int cwd)
|
||||
const char *FileName::searchPath(Strings *path, const char *name, int cwd)
|
||||
{
|
||||
if (absolute(name))
|
||||
{
|
||||
return exists(name) ? (char *)name : NULL;
|
||||
return exists(name) ? name : NULL;
|
||||
}
|
||||
if (cwd)
|
||||
{
|
||||
if (exists(name))
|
||||
return (char *)name;
|
||||
return name;
|
||||
}
|
||||
if (path)
|
||||
{ unsigned i;
|
||||
{
|
||||
|
||||
for (i = 0; i < path->dim; i++)
|
||||
for (size_t i = 0; i < path->dim; i++)
|
||||
{
|
||||
char *p = path->tdata()[i];
|
||||
char *n = combine(p, name);
|
||||
const char *p = path->tdata()[i];
|
||||
const char *n = combine(p, name);
|
||||
|
||||
if (exists(n))
|
||||
return n;
|
||||
@@ -734,7 +720,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)
|
||||
const char *FileName::safeSearchPath(Strings *path, const char *name)
|
||||
{
|
||||
#if _WIN32
|
||||
/* Disallow % / \ : and .. in name characters
|
||||
@@ -763,15 +749,14 @@ char *FileName::safeSearchPath(Strings *path, const char *name)
|
||||
}
|
||||
|
||||
if (path)
|
||||
{ unsigned i;
|
||||
|
||||
{
|
||||
/* Each path is converted to a cannonical name and then a check is done to see
|
||||
* that the searched name is really a child one of the the paths searched.
|
||||
*/
|
||||
for (i = 0; i < path->dim; i++)
|
||||
for (size_t i = 0; i < path->dim; i++)
|
||||
{
|
||||
char *cname = NULL;
|
||||
char *cpath = canonicalName(path->tdata()[i]);
|
||||
const char *cname = NULL;
|
||||
const 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)
|
||||
@@ -786,16 +771,16 @@ char *FileName::safeSearchPath(Strings *path, const char *name)
|
||||
// exists and name is *really* a "child" of path
|
||||
if (exists(cname) && strncmp(cpath, cname, strlen(cpath)) == 0)
|
||||
{
|
||||
free(cpath);
|
||||
char *p = mem.strdup(cname);
|
||||
free(cname);
|
||||
::free((void *)cpath);
|
||||
const char *p = mem.strdup(cname);
|
||||
::free((void *)cname);
|
||||
return p;
|
||||
}
|
||||
cont:
|
||||
if (cpath)
|
||||
free(cpath);
|
||||
::free((void *)cpath);
|
||||
if (cname)
|
||||
free(cname);
|
||||
::free((void *)cname);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -839,18 +824,18 @@ void FileName::ensurePathExists(const char *path)
|
||||
{
|
||||
if (!exists(path))
|
||||
{
|
||||
char *p = FileName::path(path);
|
||||
const char *p = FileName::path(path);
|
||||
if (*p)
|
||||
{
|
||||
#if _WIN32
|
||||
size_t len = strlen(path);
|
||||
if (len > 2 && p[-1] == ':' && path + 2 == p)
|
||||
{ mem.free(p);
|
||||
{ mem.free((void *)p);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
ensurePathExists(p);
|
||||
mem.free(p);
|
||||
mem.free((void *)p);
|
||||
}
|
||||
#if _WIN32
|
||||
if (path[strlen(path) - 1] != '\\')
|
||||
@@ -878,12 +863,20 @@ void FileName::ensurePathExists(const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
void FileName::ensurePathToNameExists(const char *name)
|
||||
{
|
||||
const char *pt = path(name);
|
||||
if (*pt)
|
||||
ensurePathExists(pt);
|
||||
free(pt);
|
||||
}
|
||||
|
||||
|
||||
/******************************************
|
||||
* Return canonical version of name in a malloc'd buffer.
|
||||
* This code is high risk.
|
||||
*/
|
||||
char *FileName::canonicalName(const char *name)
|
||||
const char *FileName::canonicalName(const char *name)
|
||||
{
|
||||
#if linux
|
||||
// Lovely glibc extension to do it for us
|
||||
@@ -922,7 +915,7 @@ char *FileName::canonicalName(const char *name)
|
||||
result = GetFullPathName(name, result, buf, NULL);
|
||||
if (result == 0)
|
||||
{
|
||||
free(buf);
|
||||
::free(buf);
|
||||
return NULL;
|
||||
}
|
||||
return buf;
|
||||
@@ -934,19 +927,31 @@ char *FileName::canonicalName(const char *name)
|
||||
#endif
|
||||
}
|
||||
|
||||
/********************************
|
||||
* Free memory allocated by FileName routines
|
||||
*/
|
||||
void FileName::free(const char *str)
|
||||
{
|
||||
if (str)
|
||||
{ assert(str[0] != 0xAB);
|
||||
memset((void *)str, 0xAB, strlen(str) + 1); // stomp
|
||||
}
|
||||
mem.free((void *)str);
|
||||
}
|
||||
|
||||
|
||||
/****************************** File ********************************/
|
||||
|
||||
File::File(FileName *n)
|
||||
File::File(const FileName *n)
|
||||
{
|
||||
ref = 0;
|
||||
buffer = NULL;
|
||||
len = 0;
|
||||
touchtime = NULL;
|
||||
name = n;
|
||||
name = (FileName *)n;
|
||||
}
|
||||
|
||||
File::File(char *n)
|
||||
File::File(const char *n)
|
||||
{
|
||||
ref = 0;
|
||||
buffer = NULL;
|
||||
@@ -1372,13 +1377,10 @@ Files *File::match(FileName *n)
|
||||
#elif _WIN32
|
||||
HANDLE h;
|
||||
WIN32_FIND_DATAA fileinfo;
|
||||
Files *a;
|
||||
char *c;
|
||||
char *name;
|
||||
|
||||
a = new Files();
|
||||
c = n->toChars();
|
||||
name = n->name();
|
||||
Files *a = new Files();
|
||||
const char *c = n->toChars();
|
||||
const char *name = n->name();
|
||||
h = FindFirstFileA(c,&fileinfo);
|
||||
if (h != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
||||
@@ -76,9 +76,9 @@ struct Object
|
||||
|
||||
struct String : Object
|
||||
{
|
||||
char *str; // the string itself
|
||||
const char *str; // the string itself
|
||||
|
||||
String(char *str);
|
||||
String(const char *str);
|
||||
~String();
|
||||
|
||||
static hash_t calcHash(const char *str, size_t len);
|
||||
@@ -94,33 +94,38 @@ struct String : Object
|
||||
|
||||
struct FileName : String
|
||||
{
|
||||
FileName(char *str);
|
||||
FileName(const char *str);
|
||||
hash_t hashCode();
|
||||
int equals(Object *obj);
|
||||
static int equals(const char *name1, const char *name2);
|
||||
int compare(Object *obj);
|
||||
static int compare(const char *name1, const char *name2);
|
||||
static int absolute(const char *name);
|
||||
static char *ext(const char *);
|
||||
char *ext();
|
||||
static char *removeExt(const char *str);
|
||||
static char *name(const char *);
|
||||
char *name();
|
||||
static char *path(const char *);
|
||||
static const char *ext(const char *);
|
||||
const char *ext();
|
||||
static const char *removeExt(const char *str);
|
||||
static const char *name(const char *);
|
||||
const char *name();
|
||||
static const char *path(const char *);
|
||||
static const char *replaceName(const char *path, const char *name);
|
||||
|
||||
static char *combine(const char *path, const char *name);
|
||||
static const char *combine(const char *path, const char *name);
|
||||
static Strings *splitPath(const char *path);
|
||||
static FileName *defaultExt(const char *name, const char *ext);
|
||||
static FileName *forceExt(const char *name, const char *ext);
|
||||
static const char *defaultExt(const char *name, const char *ext);
|
||||
static const char *forceExt(const char *name, const char *ext);
|
||||
static int equalsExt(const char *name, const char *ext);
|
||||
|
||||
int equalsExt(const char *ext);
|
||||
|
||||
void CopyTo(FileName *to);
|
||||
static char *searchPath(Strings *path, const char *name, int cwd);
|
||||
static char *safeSearchPath(Strings *path, const char *name);
|
||||
static const char *searchPath(Strings *path, const char *name, int cwd);
|
||||
static const char *safeSearchPath(Strings *path, const char *name);
|
||||
static int exists(const char *name);
|
||||
static void ensurePathExists(const char *path);
|
||||
static char *canonicalName(const char *name);
|
||||
static void ensurePathToNameExists(const char *name);
|
||||
static const char *canonicalName(const char *name);
|
||||
|
||||
static void free(const char *str);
|
||||
};
|
||||
|
||||
struct File : Object
|
||||
@@ -132,8 +137,8 @@ struct File : Object
|
||||
|
||||
FileName *name; // name of our file
|
||||
|
||||
File(char *);
|
||||
File(FileName *);
|
||||
File(const char *);
|
||||
File(const FileName *);
|
||||
~File();
|
||||
|
||||
void mark();
|
||||
@@ -271,7 +276,7 @@ struct OutBuffer : Object
|
||||
char *extractString();
|
||||
};
|
||||
|
||||
struct Array : Object
|
||||
struct Array
|
||||
{
|
||||
size_t dim;
|
||||
void **data;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright (c) 1999-2011 by Digital Mars
|
||||
// Copyright (c) 1999-2013 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
|
||||
Reference in New Issue
Block a user