phobos 0.113

This commit is contained in:
Brad Roberts 2007-09-10 04:30:47 +00:00
parent dfb3c86aec
commit bc412e7c3f
19 changed files with 279 additions and 16 deletions

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2004 by Digital Mars, www.digitalmars.com
* Written by Walter Bright
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, in both source and binary form, subject to the following
* restrictions:
*
* o The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* o Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
* o This notice may not be removed or altered from any source
* distribution.
*/
/******************************************

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2004 by Digital Mars, www.digitalmars.com
* Written by Walter Bright
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, in both source and binary form, subject to the following
* restrictions:
*
* o The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* o Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
* o This notice may not be removed or altered from any source
* distribution.
*/
import object;
import std.string;

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2004 by Digital Mars, www.digitalmars.com
* Written by Walter Bright
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, in both source and binary form, subject to the following
* restrictions:
*
* o The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* o Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
* o This notice may not be removed or altered from any source
* distribution.
*/
import object;
import std.c.stdio;

View file

@ -1,3 +1,9 @@
/*
* Placed into the public domain.
* Written by Walter Bright
* www.digitalmars.com
*/
#include <math.h>

View file

@ -1,3 +1,8 @@
/*
* Placed into the Public Domain.
* written by Walter Bright
* www.digitalmars.com
*/
import object;
import std.c.stdio;

View file

@ -1,4 +1,10 @@
/*
* Placed into the Public Domain
* written by Walter Bright
* www.digitalmars.com
*/
void _d_invariant(Object o)
{ ClassInfo c;

View file

@ -1,4 +1,10 @@
/*
* Placed into the Public Domain
* written by Walter Bright
* www.digitalmars.com
*/
#if __cplusplus
extern "C" {
#endif

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2004 by Digital Mars, www.digitalmars.com
* Written by Walter Bright
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, in both source and binary form, subject to the following
* restrictions:
*
* o The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* o Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
* o This notice may not be removed or altered from any source
* distribution.
*/
extern (C)
{

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2004 by Digital Mars, www.digitalmars.com
* Written by Walter Bright
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, in both source and binary form, subject to the following
* restrictions:
*
* o The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* o Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
* o This notice may not be removed or altered from any source
* distribution.
*/
module object;

View file

@ -1,4 +1,5 @@
/*
Portions of this file are:
Copyright Prototronics, 1987
Totem Lake P.O. 8117
Kirkland, Washington 98034
@ -7,6 +8,9 @@
June 11, 1987 from Ray Gardner's
Denver, Colorado) public domain version
Use qsort2.d instead of this file if a redistributable version of
_adSort() is required.
*/

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2004 by Digital Mars, www.digitalmars.com
* Written by Walter Bright
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, in both source and binary form, subject to the following
* restrictions:
*
* o The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* o Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
* o This notice may not be removed or altered from any source
* distribution.
*/
import std.c.stdio;
import std.string;

View file

@ -52,7 +52,7 @@ OBJS= asserterror.o deh2.o switch.o complex.o gcstats.o \
cast.o path.o string.o memset.o math.o mmfile.o \
outbuffer.o ctype.o regexp.o random.o linux.o \
stream.o switcherr.o array.o gc.o \
qsort.o thread.o obj.o utf.o uri.o \
qsort.o qsort2.o thread.o obj.o utf.o uri.o \
crc32.o conv.o arraycast.o errno.o alloca.o cmath2.o \
process.o syserror.o \
socket.o socketstream.o stdarg.o stdio.o format.o \
@ -700,9 +700,9 @@ ti_bit.o : std/typeinfo/ti_bit.d
##########################################################333
zip : $(ALLSRCS) linux.mak win32.mak
zip : $(ALLSRCS) linux.mak win32.mak phoboslicense.txt
rm phobos.zip
zip phobos $(ALLSRCS) linux.mak win32.mak
zip phobos $(ALLSRCS) linux.mak win32.mak phoboslicense.txt
clean:
rm $(OBJS) unittest unittest.o

31
phoboslicense.txt Normal file
View file

@ -0,0 +1,31 @@
Unless otherwise marked within the file, each file in the source
to the Phobos library is under the following license:
/*
* Copyright (C) 2004 by Digital Mars, www.digitalmars.com
* Written by Walter Bright
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, in both source and binary form, subject to the following
* restrictions:
*
* o The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* o Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
* o This notice may not be removed or altered from any source
* distribution.
*/
By plainly marking modifications, something along the lines of adding to each
file that has been changed a "Modified by Foo Bar" line
underneath the "Written by" line would be adequate.

View file

@ -887,3 +887,22 @@ void listdir(char[] pathname, bool delegate(char[] filename) callback)
}
}
/***************************************************
* Copy a file.
*/
void copy(char[] from, char[] to)
{
void[] buffer;
/* If the file is very large, this won't work, but
* it's a good start.
*/
buffer = read(from);
write(to, buffer);
delete buffer;
}

View file

@ -46,6 +46,20 @@ private void toAStringz(char[][] a, char**az)
*az = null;
}
/* ========================================================== */
int spawnvp(int mode, char[] pathname, char[][] argv)
{
char** argv_ = cast(char**)alloca((char*).sizeof * (1 + argv.length));
toAStringz(argv, argv_);
return std.c.process.spawnvp(mode, toStringz(pathname), argv_);
}
/* ========================================================== */
int execv(char[] pathname, char[][] argv)
{
char** argv_ = cast(char**)alloca((char*).sizeof * (1 + argv.length));

View file

@ -208,20 +208,25 @@ char* toStringz(char[] string)
}
body
{
char* p;
char[] copy;
if (string.length == 0)
return "";
p = &string[0] + string.length;
/+ Unfortunately, this isn't reliable.
We could make this work if string literals are put
in read-only memory and we test if string[] is pointing into
that.
// Peek past end of string[], if it's 0, no conversion necessary.
// Note that the compiler will put a 0 past the end of static
// strings, and the storage allocator will put a 0 past the end
// of newly allocated char[]'s.
/* Peek past end of string[], if it's 0, no conversion necessary.
* Note that the compiler will put a 0 past the end of static
* strings, and the storage allocator will put a 0 past the end
* of newly allocated char[]'s.
*/
char* p = &string[0] + string.length;
if (*p == 0)
return string;
+/
// Need to make a copy
copy = new char[string.length + 1];

View file

@ -1,3 +1,25 @@
/*
* Copyright (C) 2004 by Digital Mars, www.digitalmars.com
* Written by Walter Bright
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, in both source and binary form, subject to the following
* restrictions:
*
* o The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* o Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
* o This notice may not be removed or altered from any source
* distribution.
*/
private import std.string;
@ -27,7 +49,7 @@ class TypeInfo_C : TypeInfo
int c = 0;
// Regard null references as always being "less than"
if (o1 != o2)
if (!(o1 is o2))
{
if (o1)
{ if (!o2)

View file

@ -66,6 +66,13 @@ printf("test2\n");
printf("args.length = %d\n", args.length);
for (int i = 0; i < args.length; i++)
printf("args[%d] = '%s'\n", i, cast(char *)args[i]);
int[3] x;
x[0] = 3;
x[1] = 45;
x[2] = -1;
x.sort;
printf("Success\n!");
return 0;
}

View file

@ -60,7 +60,7 @@ OBJS= asserterror.obj deh.obj switch.obj complex.obj gcstats.obj \
cast.obj syserror.obj path.obj string.obj memset.obj math.obj \
outbuffer.obj ctype.obj regexp.obj random.obj windows.obj \
stream.obj switcherr.obj com.obj array.obj gc.obj mmfile.obj \
qsort.obj math2.obj date.obj dateparse.obj thread.obj obj.obj \
qsort.obj qsort.2.d math2.obj date.obj dateparse.obj thread.obj obj.obj \
iunknown.obj crc32.obj conv.obj arraycast.obj utf.obj uri.obj \
Czlib.obj Dzlib.obj zip.obj process.obj registry.obj recls.obj \
socket.obj socketstream.obj loader.obj stdarg.obj format.obj stdio.obj \
@ -334,7 +334,7 @@ SRC_RECLS_NEW= \
phobos.lib : $(OBJS) minit.obj internal\gc\dmgc.lib etc\c\zlib\zlib.lib \
win32.mak etc\c\recls\recls.lib
lib -c phobos.lib $(OBJS) minit.obj internal\gc\dmgc.lib \
lib -c -p32 phobos.lib $(OBJS) minit.obj internal\gc\dmgc.lib \
etc\c\recls\recls.lib etc\c\zlib\zlib.lib
######################################################
@ -679,7 +679,7 @@ ti_int.obj : std\typeinfo\ti_int.d
######################################################
zip : win32.mak linux.mak $(SRC) \
zip : win32.mak linux.mak phoboslicense.txt $(SRC) \
$(SRC_STD) $(SRC_STD_C) $(SRC_TI) $(SRC_INT) $(SRC_STD_WIN) \
$(SRC_STDLINUX) $(SRC_ETC) $(SRC_ETC_C) $(SRC_ZLIB) $(SRC_GC)
del phobos.zip
@ -704,7 +704,7 @@ clean:
install:
$(CP) phobos.lib gcstub.obj \dmd\lib
$(CP) win32.mak linux.mak minit.obj \dmd\src\phobos
$(CP) win32.mak linux.mak phoboslicense.txt minit.obj \dmd\src\phobos
$(CP) $(SRC) \dmd\src\phobos
$(CP) $(SRC_STD) \dmd\src\phobos\std
$(CP) $(SRC_STD_C) \dmd\src\phobos\std\c