Skip to content

Commit

Permalink
phobos 0.113
Browse files Browse the repository at this point in the history
  • Loading branch information
braddr committed Sep 10, 2007
1 parent dfb3c86 commit bc412e7
Show file tree
Hide file tree
Showing 19 changed files with 280 additions and 17 deletions.
23 changes: 23 additions & 0 deletions internal/arraycast.d
Original file line number Diff line number Diff line change
@@ -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.
*/



/******************************************
Expand Down
23 changes: 23 additions & 0 deletions internal/arraycat.d
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
23 changes: 23 additions & 0 deletions internal/cast.d
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 6 additions & 0 deletions internal/complex.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Placed into the public domain.
* Written by Walter Bright
* www.digitalmars.com
*/


#include <math.h>

Expand Down
5 changes: 5 additions & 0 deletions internal/dmain2.d
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Placed into the Public Domain.
* written by Walter Bright
* www.digitalmars.com
*/

import object;
import std.c.stdio;
Expand Down
6 changes: 6 additions & 0 deletions internal/invariant.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

/*
* Placed into the Public Domain
* written by Walter Bright
* www.digitalmars.com
*/

void _d_invariant(Object o)
{ ClassInfo c;

Expand Down
6 changes: 6 additions & 0 deletions internal/mars.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

/*
* Placed into the Public Domain
* written by Walter Bright
* www.digitalmars.com
*/

#if __cplusplus
extern "C" {
#endif
Expand Down
23 changes: 23 additions & 0 deletions internal/memset.d
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down
23 changes: 23 additions & 0 deletions internal/object.d
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 4 additions & 0 deletions internal/qsort.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Portions of this file are:
Copyright Prototronics, 1987
Totem Lake P.O. 8117
Kirkland, Washington 98034
Expand All @@ -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.
*/


Expand Down
23 changes: 23 additions & 0 deletions internal/switch.d
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions linux.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 changes: 31 additions & 0 deletions phoboslicense.txt
Original file line number Diff line number Diff line change
@@ -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.

19 changes: 19 additions & 0 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}



14 changes: 14 additions & 0 deletions std/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
23 changes: 14 additions & 9 deletions std/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,25 @@ char* toStringz(char[] string)
}
body
{
char* p;
char[] copy;

if (string.length == 0)
return "";

p = &string[0] + string.length;

// 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.
if (*p == 0)
return string;
/+ 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.
*/
char* p = &string[0] + string.length;
if (*p == 0)
return string;
+/

// Need to make a copy
copy = new char[string.length + 1];
Expand Down
24 changes: 23 additions & 1 deletion std/typeinfo/ti_C.d
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions unittest.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading

0 comments on commit bc412e7

Please sign in to comment.