Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merge D2 pull #1049 & fix

  • Loading branch information...
commit 54db1644cfb58e2ec9a9f317e01e5d51db114336 1 parent 70f3875
@WalterBright WalterBright authored
View
2  src/doc.c
@@ -233,7 +233,7 @@ void Module::gendocfile()
// Override with the ddoc macro files from the command line
for (size_t i = 0; i < global.params.ddocfiles->dim; i++)
{
- FileName f((*global.params.ddocfiles)[i], 0);
+ FileName f((*global.params.ddocfiles)[i]);
File file(&f);
file.readv();
// BUG: convert file contents to UTF-8 before use
View
2  src/libelf.c
@@ -431,7 +431,7 @@ void LibElf::addObject(const char *module_name, void *buf, size_t buflen)
int fromfile = 0;
if (!buf)
{ assert(module_name[0]);
- FileName f((char *)module_name, 0);
+ FileName f((char *)module_name);
File file(&f);
file.readv();
buf = file.buffer;
View
2  src/libmach.c
@@ -496,7 +496,7 @@ void LibMach::addObject(const char *module_name, void *buf, size_t buflen)
int fromfile = 0;
if (!buf)
{ assert(module_name[0]);
- FileName f((char *)module_name, 0);
+ FileName f((char *)module_name);
File file(&f);
file.readv();
buf = file.buffer;
View
2  src/libomf.c
@@ -422,7 +422,7 @@ void LibOMF::addObject(const char *module_name, void *buf, size_t buflen)
#endif
if (!buf)
{ assert(module_name);
- FileName f((char *)module_name, 0);
+ FileName f((char *)module_name);
File file(&f);
file.readv();
buf = file.buffer;
View
6 src/module.c
@@ -155,7 +155,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
#endif
if (global.params.objname)
- objfilename = new FileName(argobj, 0);
+ objfilename = new FileName(argobj);
else
objfilename = FileName::forceExt(argobj, global.obj_ext);
@@ -193,7 +193,7 @@ void Module::setDocfile()
argdoc = FileName::combine(global.params.docdir, argdoc);
}
if (global.params.docname)
- docfilename = new FileName(argdoc, 0);
+ docfilename = new FileName(argdoc);
else
docfilename = FileName::forceExt(argdoc, global.doc_ext);
@@ -221,7 +221,7 @@ void Module::setHdrfile()
arghdr = FileName::combine(global.params.hdrdir, arghdr);
}
if (global.params.hdrname)
- hdrfilename = new FileName(arghdr, 0);
+ hdrfilename = new FileName(arghdr);
else
hdrfilename = FileName::forceExt(arghdr, global.hdr_ext);
View
8 src/root/port.c
@@ -1,10 +1,11 @@
-// Copyright (c) 1999-2011 by Digital Mars
+// Copyright (c) 1999-2012 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
#include "port.h"
+
#if __DMC__
#include <math.h>
#include <float.h>
@@ -12,6 +13,7 @@
#include <time.h>
#include <stdlib.h>
#include <string.h>
+#include <wchar.h>
double Port::nan = NAN;
double Port::infinity = INFINITY;
@@ -127,6 +129,7 @@ char *Port::strupr(char *s)
#include <errno.h>
#include <string.h>
#include <ctype.h>
+#include <wchar.h>
#include <stdlib.h>
#include <limits> // for std::numeric_limits
@@ -343,6 +346,7 @@ char *Port::strupr(char *s)
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
+#include <wchar.h>
#include <float.h>
#include <assert.h>
@@ -520,6 +524,7 @@ char *Port::strupr(char *s)
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
+#include <wchar.h>
#include <float.h>
#include <ieeefp.h>
@@ -648,4 +653,3 @@ char *Port::strupr(char *s)
}
#endif
-
View
17 src/root/port.h
@@ -1,5 +1,5 @@
-// Copyright (c) 1999-2009 by Digital Mars
+// Copyright (c) 1999-2012 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
@@ -12,26 +12,21 @@
#include "longdouble.h"
-#ifndef TYPEDEFS
-#define TYPEDEFS
-
-#include <wchar.h>
-
#if _MSC_VER
-typedef __int64 longlong;
-typedef unsigned __int64 ulonglong;
-
+#include <float.h> // for _isnan
+#include <malloc.h> // for alloca
// According to VC 8.0 docs, long double is the same as double
longdouble strtold(const char *p,char **endp);
#define strtof strtod
+#define isnan _isnan
+typedef __int64 longlong;
+typedef unsigned __int64 ulonglong;
#else
typedef long long longlong;
typedef unsigned long long ulonglong;
#endif
-#endif
-
typedef double d_time;
struct Port
View
107 src/root/root.c
@@ -56,68 +56,6 @@ extern "C" void __cdecl _assert(void *e, void *f, unsigned line)
#endif
-/*************************************
- * Convert wchar string to ascii string.
- */
-
-char *wchar2ascii(wchar_t *us)
-{
- return wchar2ascii(us, wcslen(us));
-}
-
-char *wchar2ascii(wchar_t *us, unsigned len)
-{
- unsigned i;
- char *p;
-
- p = (char *)mem.malloc(len + 1);
- for (i = 0; i <= len; i++)
- p[i] = (char) us[i];
- return p;
-}
-
-int wcharIsAscii(wchar_t *us)
-{
- return wcharIsAscii(us, wcslen(us));
-}
-
-int wcharIsAscii(wchar_t *us, unsigned len)
-{
- unsigned i;
-
- for (i = 0; i <= len; i++)
- {
- if (us[i] & ~0xFF) // if high bits set
- return 0; // it's not ascii
- }
- return 1;
-}
-
-
-/***********************************
- * Compare length-prefixed strings (bstr).
- */
-
-int bstrcmp(unsigned char *b1, unsigned char *b2)
-{
- return (*b1 == *b2 && memcmp(b1 + 1, b2 + 1, *b2) == 0) ? 0 : 1;
-}
-
-/***************************************
- * Convert bstr into a malloc'd string.
- */
-
-char *bstr2str(unsigned char *b)
-{
- char *s;
- unsigned len;
-
- len = *b;
- s = (char *) mem.malloc(len + 1);
- s[len] = 0;
- return (char *)memcpy(s,b + 1,len);
-}
-
/**************************************
* Print error message and exit.
*/
@@ -136,11 +74,6 @@ void error(const char *format, ...)
exit(EXIT_FAILURE);
}
-void error_mem()
-{
- error("out of memory");
-}
-
/**************************************
* Print warning message.
*/
@@ -200,10 +133,9 @@ void Object::mark()
/****************************** String ********************************/
-String::String(char *str, int ref)
+String::String(char *str)
+ : str(mem.strdup(str))
{
- this->str = ref ? str : mem.strdup(str);
- this->ref = ref;
}
String::~String()
@@ -291,8 +223,8 @@ void String::print()
/****************************** FileName ********************************/
-FileName::FileName(char *str, int ref)
- : String(str,ref)
+FileName::FileName(char *str)
+ : String(str)
{
}
@@ -326,11 +258,6 @@ char *FileName::combine(const char *path, const char *name)
return f;
}
-FileName::FileName(char *path, char *name)
- : String(combine(path,name),1)
-{
-}
-
// Split a path into an Array of paths
Strings *FileName::splitPath(const char *path)
{
@@ -678,7 +605,7 @@ FileName *FileName::defaultExt(const char *name, const char *ext)
e = FileName::ext(name);
if (e) // if already has an extension
- return new FileName((char *)name, 0);
+ return new FileName((char *)name);
len = strlen(name);
extlen = strlen(ext);
@@ -686,7 +613,7 @@ FileName *FileName::defaultExt(const char *name, const char *ext)
memcpy(s,name,len);
s[len] = '.';
memcpy(s + len + 1, ext, extlen + 1);
- return new FileName(s, 0);
+ return new FileName(s);
}
/***************************
@@ -708,7 +635,7 @@ FileName *FileName::forceExt(const char *name, const char *ext)
s = (char *)alloca(len + extlen + 1);
memcpy(s,name,len);
memcpy(s + len, ext, extlen + 1);
- return new FileName(s, 0);
+ return new FileName(s);
}
else
return defaultExt(name, ext); // doesn't have one
@@ -1008,7 +935,7 @@ File::File(char *n)
buffer = NULL;
len = 0;
touchtime = NULL;
- name = new FileName(n, 0);
+ name = new FileName(n);
}
File::~File()
@@ -1418,7 +1345,7 @@ void File::remove()
Files *File::match(char *n)
{
- return match(new FileName(n, 0));
+ return match(new FileName(n));
}
Files *File::match(FileName *n)
@@ -1866,6 +1793,7 @@ char *OutBuffer::toChars()
return (char *)data;
}
+// TODO: Remove (only used by disabled GC)
/********************************* Bits ****************************/
Bits::Bits()
@@ -1958,18 +1886,3 @@ void Bits::sub(Bits *b)
for (u = 0; u < allocdim; u++)
data[u] &= ~b->data[u];
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
View
41 src/root/root.h
@@ -15,6 +15,7 @@
#ifdef DEBUG
#include <assert.h>
#endif
+#include "port.h"
#if __DMC__
#pragma once
@@ -22,38 +23,6 @@
typedef size_t hash_t;
-#include "longdouble.h"
-
-char *wchar2ascii(wchar_t *);
-int wcharIsAscii(wchar_t *);
-char *wchar2ascii(wchar_t *, unsigned len);
-int wcharIsAscii(wchar_t *, unsigned len);
-
-int bstrcmp(unsigned char *s1, unsigned char *s2);
-char *bstr2str(unsigned char *b);
-
-#ifndef TYPEDEFS
-#define TYPEDEFS
-
-#if _MSC_VER
-#include <float.h> // for _isnan
-#include <malloc.h> // for alloca
-// According to VC 8.0 docs, long double is the same as double
-longdouble strtold(const char *p,char **endp);
-#define strtof strtod
-#define isnan _isnan
-
-typedef __int64 longlong;
-typedef unsigned __int64 ulonglong;
-#else
-typedef long long longlong;
-typedef unsigned long long ulonglong;
-#endif
-
-#endif
-
-longlong randomx();
-
/*
* Root of our class library.
*/
@@ -107,11 +76,9 @@ struct Object
struct String : Object
{
- int ref; // != 0 if this is a reference to someone else's string
char *str; // the string itself
- String(char *str, int ref = 1);
-
+ String(char *str);
~String();
static hash_t calcHash(const char *str, size_t len);
@@ -127,8 +94,7 @@ struct String : Object
struct FileName : String
{
- FileName(char *str, int ref);
- FileName(char *path, char *name);
+ FileName(char *str);
hash_t hashCode();
int equals(Object *obj);
static int equals(const char *name1, const char *name2);
@@ -378,6 +344,7 @@ struct ArrayBase : Array
}
};
+// TODO: Remove (only used by disabled GC)
struct Bits : Object
{
unsigned bitdim;
View
1  src/root/stringtable.c
@@ -17,6 +17,7 @@
#include "rmem.h" // mem
#include "stringtable.h"
+// TODO: Merge with root.String
hash_t calcHash(const char *str, size_t len)
{
hash_t hash = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.