Skip to content

Commit

Permalink
phobos 0.96
Browse files Browse the repository at this point in the history
  • Loading branch information
braddr committed Sep 10, 2007
1 parent 5a51fc0 commit 2fd7d60
Show file tree
Hide file tree
Showing 26 changed files with 1,475 additions and 107 deletions.
8 changes: 4 additions & 4 deletions internal/adi.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct Array
extern (C) Array _adReverse(Array a, int szelem)
out (result)
{
assert(result === a);
assert(result is a);
}
body
{
Expand Down Expand Up @@ -81,7 +81,7 @@ unittest
for (i = 0; i < 5; i++)
a[i] = i;
b = a.reverse;
assert(b === a);
assert(b is a);
for (i = 0; i < 5; i++)
assert(a[i] == 4 - i);

Expand All @@ -99,7 +99,7 @@ unittest
c[i].e = 10;
}
d = c.reverse;
assert(d === c);
assert(d is c);
for (i = 0; i < 5; i++)
{
assert(c[i].a == 4 - i);
Expand All @@ -114,7 +114,7 @@ unittest
extern (C) bit[] _adReverseBit(bit[] a)
out (result)
{
assert(result === a);
assert(result is a);
}
body
{
Expand Down
14 changes: 7 additions & 7 deletions internal/cast.d
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ Object _d_dynamic_cast(Object o, ClassInfo c)
int _d_isbaseof2(ClassInfo oc, ClassInfo c, inout uint offset)
{ int i;

if (oc === c)
if (oc is c)
return 1;
do
{
if (oc.base === c)
if (oc.base is c)
return 1;
for (i = 0; i < oc.interfaces.length; i++)
{
ClassInfo ic;

ic = oc.interfaces[i].classinfo;
if (ic === c)
if (ic is c)
{ offset = oc.interfaces[i].offset;
return 1;
}
Expand All @@ -82,18 +82,18 @@ int _d_isbaseof2(ClassInfo oc, ClassInfo c, inout uint offset)
int _d_isbaseof(ClassInfo oc, ClassInfo c)
{ int i;

if (oc === c)
if (oc is c)
return 1;
do
{
if (oc.base === c)
if (oc.base is c)
return 1;
for (i = 0; i < oc.interfaces.length; i++)
{
ClassInfo ic;

ic = oc.interfaces[i].classinfo;
if (ic === c || _d_isbaseof(ic, c))
if (ic is c || _d_isbaseof(ic, c))
return 1;
}
oc = oc.base;
Expand All @@ -119,7 +119,7 @@ void *_d_interface_vtbl(ClassInfo ic, Object o)
ClassInfo oic;

oic = oc.interfaces[i].classinfo;
if (oic === ic)
if (oic is ic)
{
return cast(void *)oc.interfaces[i].vtbl;
}
Expand Down
2 changes: 1 addition & 1 deletion internal/obj.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern (C):

int _d_obj_eq(Object o1, Object o2)
{
return o1 === o2 || (o1 && o1.opEquals(o2));
return o1 is o2 || (o1 && o1.opEquals(o2));
}


Expand Down
4 changes: 2 additions & 2 deletions internal/object.d
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Object

int opEquals(Object o)
{
return this === o;
return this is o;
}
}

Expand Down Expand Up @@ -93,7 +93,7 @@ class TypeInfo
* across DLL's. Therefore, comparing for a name match is
* sufficient.
*/
return this === o || this.classinfo.name == o.classinfo.name;
return this is o || this.classinfo.name == o.classinfo.name;
}

uint getHash(void *p) { return cast(uint)p; }
Expand Down
6 changes: 5 additions & 1 deletion linux.mak
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ OBJS= asserterror.o deh2.o switch.o complex.o gcstats.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 \
perf.o \
ti_wchar.o ti_uint.o ti_short.o ti_ushort.o \
ti_byte.o ti_ubyte.o ti_long.o ti_ulong.o ti_ptr.o \
ti_float.o ti_double.o ti_real.o ti_delegate.o \
Expand Down Expand Up @@ -95,7 +96,7 @@ SRC_STD= std/zlib.d std/zip.d std/stdint.d std/conv.d std/utf.d std/uri.d \
std/intrinsic.d std/array.d std/switcherr.d std/syserror.d \
std/regexp.d std/random.d std/stream.d std/process.d std/recls.d \
std/socket.d std/socketstream.d std/loader.d std/stdarg.d \
std/stdio.d std/format.d
std/stdio.d std/format.d std/perf.d

SRC_STD_C= std/c/process.d std/c/stdlib.d std/c/time.d std/c/stdio.d \
std/c/math.d std/c/stdarg.d
Expand Down Expand Up @@ -398,6 +399,9 @@ outofmemory.o : std/outofmemory.d
path.o : std/path.d
$(DMD) -c $(DFLAGS) std/path.d

perf.o : std/perf.d
$(DMD) -c $(DFLAGS) std/perf.d

process.o : std/process.d
$(DMD) -c $(DFLAGS) std/process.d

Expand Down
6 changes: 5 additions & 1 deletion std/c/linux/linux.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@

/* Written by Walter Bright
* www.digitalmars.com
* Placed into public domain.
*/

module std.c.linux.linux;

import std.c.linux.linuxextern;

alias int time_t;
alias int off_t;

enum : int
Expand Down
5 changes: 5 additions & 0 deletions std/c/time.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

/* Written by Walter Bright
* www.digitalmars.com
* Placed into public domain.
*/

module std.c.time;

extern (C):
Expand Down
7 changes: 6 additions & 1 deletion std/c/windows/windows.d
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ struct FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
}
alias FILETIME* PFILETIME;
alias FILETIME* PFILETIME, LPFILETIME;

struct WIN32_FIND_DATA {
DWORD dwFileAttributes;
Expand Down Expand Up @@ -872,6 +872,7 @@ enum
}

export HANDLE GetCurrentThread();
export BOOL GetProcessTimes(HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
export HANDLE GetCurrentProcess();
export BOOL DuplicateHandle (HANDLE sourceProcess, HANDLE sourceThread,
HANDLE targetProcessHandle, HANDLE *targetHandle, DWORD access,
Expand All @@ -880,6 +881,7 @@ export DWORD GetCurrentThreadId();
export BOOL SetThreadPriority(HANDLE hThread, int nPriority);
export BOOL SetThreadPriorityBoost(HANDLE hThread, BOOL bDisablePriorityBoost);
export BOOL GetThreadPriorityBoost(HANDLE hThread, PBOOL pDisablePriorityBoost);
export BOOL GetThreadTimes(HANDLE hThread, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
export int GetThreadPriority(HANDLE hThread);
export BOOL GetThreadContext(HANDLE hThread, CONTEXT* lpContext);
export BOOL SetThreadContext(HANDLE hThread, CONTEXT* lpContext);
Expand All @@ -889,6 +891,9 @@ export DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
export DWORD WaitForMultipleObjects(DWORD nCount, HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds);
export void Sleep(DWORD dwMilliseconds);

export BOOL QueryPerformanceCounter(long* lpPerformanceCount);
export BOOL QueryPerformanceFrequency(long* lpFrequency);

enum
{
WM_NOTIFY = 0x004E,
Expand Down
5 changes: 5 additions & 0 deletions std/compiler.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

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

// Identify the compiler used and its various features.

module std.compiler;
Expand Down
7 changes: 5 additions & 2 deletions std/date.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Date
int ms; // 0..999
int weekday; // 0: not specified
// 1..7: Sunday..Saturday
int tzcorrection = int.min; // -12..12 correction in hours
int tzcorrection = int.min; // -1200..1200 correction in hours

void parse(char[] s)
{
Expand Down Expand Up @@ -562,7 +562,10 @@ d_time parse(char[] s)
if (dp.tzcorrection == Date.tzcorrection.init)
time -= LocalTZA;
else
time += cast(d_time)dp.tzcorrection * msPerHour;
{
time += cast(d_time)(dp.tzcorrection / 100) * msPerHour +
cast(d_time)(dp.tzcorrection % 100) * msPerMinute;
}
day = MakeDay(dp.year, dp.month - 1, dp.day);
n = MakeDate(day,time);
n = TimeClip(n);
Expand Down
59 changes: 44 additions & 15 deletions std/dateparse.d
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@

// Copyright (c) 1999-2002 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// www.digitalmars.com
/*
* Copyright (C) 1999-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, 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 std.dateparse;

Expand All @@ -13,7 +31,7 @@ private
import std.date;
}

//debug=log;
//debug=dateparse;

class DateParseError : Error
{
Expand All @@ -34,7 +52,7 @@ struct DateParse
//else
//buffer = new char[s.length];

debug(log) printf("DateParse.parse('%.*s')\n", s);
debug(dateparse) printf("DateParse.parse('%.*s')\n", s);
if (!parseString(s))
{
goto Lerror;
Expand All @@ -45,7 +63,7 @@ struct DateParse
year = 0;
else
+/
debug(log)
debug(dateparse)
printf("year = %d, month = %d, day = %d\n%02d:%02d:%02d.%03d\nweekday = %d, tzcorrection = %d\n",
year, month, day,
hours, minutes, seconds, ms,
Expand All @@ -59,7 +77,7 @@ struct DateParse
(seconds < 0 || seconds > 59) ||
(tzcorrection != tzcorrection.init &&
((tzcorrection < -1200 || tzcorrection > 1200) ||
(tzcorrection % 100)))
(tzcorrection % 10)))
)
{
Lerror:
Expand All @@ -80,8 +98,8 @@ struct DateParse
}
}

if (tzcorrection != tzcorrection.init)
tzcorrection /= 100;
// if (tzcorrection != tzcorrection.init)
// tzcorrection /= 100;

if (year >= 0 && year <= 99)
year += 1900;
Expand Down Expand Up @@ -110,7 +128,7 @@ private:
int ampm; // 0: not specified
// 1: AM
// 2: PM
int tzcorrection = int.min; // -12..12 correction in hours
int tzcorrection = int.min; // -1200..1200 correction in hours

char[] s;
int si;
Expand Down Expand Up @@ -518,7 +536,7 @@ private:
int n3;
int dp;

debug(log) printf("DateParse.parseCalendarDate(%d)\n", n1);
debug(dateparse) printf("DateParse.parseCalendarDate(%d)\n", n1);
dp = nextToken();
if (dp == DP.month) // day/month
{
Expand Down Expand Up @@ -670,7 +688,7 @@ unittest
assert(d.second == 0);
assert(d.ms == 0);
assert(d.weekday == 0);
assert(d.tzcorrection == 8);
assert(d.tzcorrection == 800);

dp.parse("Tue Apr 02 02:04:57 GMT-0800 1996", d);
assert(d.year == 1996);
Expand All @@ -681,7 +699,7 @@ unittest
assert(d.second == 57);
assert(d.ms == 0);
assert(d.weekday == 3);
assert(d.tzcorrection == 8);
assert(d.tzcorrection == 800);

dp.parse("March 14, -1980 21:14:50", d);
assert(d.year == 1980);
Expand Down Expand Up @@ -749,7 +767,18 @@ unittest
assert(d.weekday == 0);
assert(d.tzcorrection == int.min);

debug(log) printf("year = %d, month = %d, day = %d\n%02d:%02d:%02d.%03d\nweekday = %d, tzcorrection = %d\n",
dp.parse("Tue, 20 May 2003 15:38:58 +0530", d);
assert(d.year == 2003);
assert(d.month == 5);
assert(d.day == 20);
assert(d.hour == 15);
assert(d.minute == 38);
assert(d.second == 58);
assert(d.ms == 0);
assert(d.weekday == 3);
assert(d.tzcorrection == -530);

debug(dateparse) printf("year = %d, month = %d, day = %d\n%02d:%02d:%02d.%03d\nweekday = %d, tzcorrection = %d\n",
d.year, d.month, d.day,
d.hour, d.minute, d.second, d.ms,
d.weekday, d.tzcorrection);
Expand Down
11 changes: 10 additions & 1 deletion std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
dchar[] sd = va_arg!(dchar[])(argptr);
s = toUTF8(sd);
Lputstr:
if (flags & FLprecision && precision > s.length)
if (flags & FLprecision && precision < s.length)
s = s[0 .. precision];
putstr(s);
break;
Expand Down Expand Up @@ -788,5 +788,14 @@ unittest

s = std.string.format("%0.0008f", 1e-05);
assert(s == "0.00001000");

s = "helloworld";
char[] r;
r = std.string.format("%.2s", s[0..5]);
assert(r == "he");
r = std.string.format("%.20s", s[0..5]);
assert(r == "hello");
r = std.string.format("%8s", s[0..5]);
assert(r == " hello");
}

Loading

0 comments on commit 2fd7d60

Please sign in to comment.