mirror of
https://github.com/dlang/phobos.git
synced 2025-05-03 08:30:33 +03:00
phobos 0.126
This commit is contained in:
parent
eb9c6b12e3
commit
ccbb884d7d
21 changed files with 739 additions and 604 deletions
|
@ -232,6 +232,47 @@ void *_aaGet(aaA*[] *aa, TypeInfo keyti, int valuesize, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
* Get pointer to value in associative array indexed by key.
|
||||||
|
* Returns null if it is not already there.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void *_aaGetRvalue(aaA*[] aa, TypeInfo keyti, int valuesize, ...)
|
||||||
|
{
|
||||||
|
void *pkey = cast(void *)(&valuesize + 1);
|
||||||
|
uint key_hash;
|
||||||
|
uint i;
|
||||||
|
aaA *e;
|
||||||
|
aaA **pe;
|
||||||
|
int keysize = keyti.tsize();
|
||||||
|
|
||||||
|
if (aa.length)
|
||||||
|
{
|
||||||
|
key_hash = keyti.getHash(pkey);
|
||||||
|
//printf("hash = %d\n", key_hash);
|
||||||
|
i = (key_hash % (aa.length - 1)) + 1;
|
||||||
|
pe = &aa[i];
|
||||||
|
while ((e = *pe) != null)
|
||||||
|
{ int c;
|
||||||
|
|
||||||
|
c = key_hash - e.hash;
|
||||||
|
if (c == 0)
|
||||||
|
{
|
||||||
|
c = keyti.compare(pkey, e + 1);
|
||||||
|
if (c == 0)
|
||||||
|
return cast(void *)(e + 1) + keysize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c < 0)
|
||||||
|
pe = &e.left;
|
||||||
|
else
|
||||||
|
pe = &e.right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null; // not found, caller will throw exception
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************
|
/*************************************************
|
||||||
* Determine if key is in aa.
|
* Determine if key is in aa.
|
||||||
* Returns:
|
* Returns:
|
||||||
|
|
|
@ -77,7 +77,22 @@ int os_mem_unmap(void *base, uint nbytes)
|
||||||
|
|
||||||
void *os_query_stackBottom()
|
void *os_query_stackBottom()
|
||||||
{
|
{
|
||||||
|
version (none)
|
||||||
|
{ // See discussion: http://autopackage.org/forums/viewtopic.php?t=22
|
||||||
|
static void** libc_stack_end;
|
||||||
|
|
||||||
|
if (libc_stack_end == libc_stack_end.init)
|
||||||
|
{
|
||||||
|
void* handle = dlopen(null, RTLD_NOW);
|
||||||
|
libc_stack_end = cast(void **)dlsym(handle, "__libc_stack_end");
|
||||||
|
dlclose(handle);
|
||||||
|
}
|
||||||
|
return *libc_stack_end;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // This doesn't resolve on all versions of Linux
|
||||||
return __libc_stack_end;
|
return __libc_stack_end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ void _d_invariant(Object o)
|
||||||
//printf("__d_invariant(%p)\n", o);
|
//printf("__d_invariant(%p)\n", o);
|
||||||
|
|
||||||
// BUG: needs to be filename/line of caller, not library routine
|
// BUG: needs to be filename/line of caller, not library routine
|
||||||
assert(o !== null); // just do null check, not invariant check
|
assert(o !is null); // just do null check, not invariant check
|
||||||
|
|
||||||
c = o.classinfo;
|
c = o.classinfo;
|
||||||
do
|
do
|
||||||
|
|
|
@ -354,7 +354,7 @@ else
|
||||||
fprintf(fplog,"%7d\t%3lld.%07lld\t%3lld.%07lld\t%3lld.%07lld\t%.*s\n",
|
fprintf(fplog,"%7d\t%3lld.%07lld\t%3lld.%07lld\t%3lld.%07lld\t%.*s\n",
|
||||||
calls,tl,tr,fl,fr,pl,pr,id);
|
calls,tl,tr,fl,fr,pl,pr,id);
|
||||||
}
|
}
|
||||||
if (id !== s.Sident)
|
if (id !is s.Sident)
|
||||||
free(id);
|
free(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ OBJS= asserterror.o deh2.o switch.o complex.o gcstats.o \
|
||||||
compiler.o system.o moduleinit.o md5.o base64.o \
|
compiler.o system.o moduleinit.o md5.o base64.o \
|
||||||
cast.o path.o string.o memset.o math.o mmfile.o \
|
cast.o path.o string.o memset.o math.o mmfile.o \
|
||||||
outbuffer.o ctype.o regexp.o random.o linux.o linuxsocket.o \
|
outbuffer.o ctype.o regexp.o random.o linux.o linuxsocket.o \
|
||||||
stream.o switcherr.o array.o gc.o \
|
stream.o cstream.o switcherr.o array.o gc.o \
|
||||||
qsort.o thread.o obj.o utf.o uri.o \
|
qsort.o thread.o obj.o utf.o uri.o \
|
||||||
crc32.o conv.o arraycast.o errno.o alloca.o cmath2.o \
|
crc32.o conv.o arraycast.o errno.o alloca.o cmath2.o \
|
||||||
process.o syserror.o \
|
process.o syserror.o \
|
||||||
|
@ -99,7 +99,7 @@ SRC_STD= std/zlib.d std/zip.d std/stdint.d std/conv.d std/utf.d std/uri.d \
|
||||||
std/regexp.d std/random.d std/stream.d std/process.d std/recls.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/socket.d std/socketstream.d std/loader.d std/stdarg.d \
|
||||||
std/stdio.d std/format.d std/perf.d std/openrj.d std/uni.d \
|
std/stdio.d std/format.d std/perf.d std/openrj.d std/uni.d \
|
||||||
std/boxer.d
|
std/boxer.d std/cstream.d
|
||||||
|
|
||||||
SRC_STD_C= std/c/process.d std/c/stdlib.d std/c/time.d std/c/stdio.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 std/c/stddef.d
|
std/c/math.d std/c/stdarg.d std/c/stddef.d
|
||||||
|
@ -481,6 +481,9 @@ compiler.o : std/compiler.d
|
||||||
conv.o : std/conv.d
|
conv.o : std/conv.d
|
||||||
$(DMD) -c $(DFLAGS) std/conv.d
|
$(DMD) -c $(DFLAGS) std/conv.d
|
||||||
|
|
||||||
|
cstream.o : std/cstream.d
|
||||||
|
$(DMD) -c $(DFLAGS) std/cstream.d
|
||||||
|
|
||||||
ctype.o : std/ctype.d
|
ctype.o : std/ctype.d
|
||||||
$(DMD) -c $(DFLAGS) std/ctype.d
|
$(DMD) -c $(DFLAGS) std/ctype.d
|
||||||
|
|
||||||
|
@ -551,7 +554,7 @@ stdio.o : std/stdio.d
|
||||||
$(DMD) -c $(DFLAGS) std/stdio.d
|
$(DMD) -c $(DFLAGS) std/stdio.d
|
||||||
|
|
||||||
stream.o : std/stream.d
|
stream.o : std/stream.d
|
||||||
$(DMD) -c $(DFLAGS) std/stream.d
|
$(DMD) -c $(DFLAGS) -d std/stream.d
|
||||||
|
|
||||||
string.o : std/string.d
|
string.o : std/string.d
|
||||||
$(DMD) -c $(DFLAGS) std/string.d
|
$(DMD) -c $(DFLAGS) std/string.d
|
||||||
|
|
|
@ -75,7 +75,8 @@ body
|
||||||
sp = &str[0];
|
sp = &str[0];
|
||||||
for(stri = 0; stri != strmax; stri++)
|
for(stri = 0; stri != strmax; stri++)
|
||||||
{
|
{
|
||||||
x = (*sp++ << 16) | (*sp++ << 8) | (*sp++);
|
x = (sp[0] << 16) | (sp[1] << 8) | (sp[2]);
|
||||||
|
sp+= 3;
|
||||||
*bp++ = array[(x & 0b11111100_00000000_00000000) >> 18];
|
*bp++ = array[(x & 0b11111100_00000000_00000000) >> 18];
|
||||||
*bp++ = array[(x & 0b00000011_11110000_00000000) >> 12];
|
*bp++ = array[(x & 0b00000011_11110000_00000000) >> 12];
|
||||||
*bp++ = array[(x & 0b00000000_00001111_11000000) >> 6];
|
*bp++ = array[(x & 0b00000000_00001111_11000000) >> 6];
|
||||||
|
@ -85,7 +86,8 @@ body
|
||||||
switch(strleft)
|
switch(strleft)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
x = (*sp++ << 16) | (*sp++ << 8);
|
x = (sp[0] << 16) | (sp[1] << 8);
|
||||||
|
sp += 2;
|
||||||
*bp++ = array[(x & 0b11111100_00000000_00000000) >> 18];
|
*bp++ = array[(x & 0b11111100_00000000_00000000) >> 18];
|
||||||
*bp++ = array[(x & 0b00000011_11110000_00000000) >> 12];
|
*bp++ = array[(x & 0b00000011_11110000_00000000) >> 12];
|
||||||
*bp++ = array[(x & 0b00000000_00001111_11000000) >> 6];
|
*bp++ = array[(x & 0b00000000_00001111_11000000) >> 6];
|
||||||
|
@ -180,7 +182,8 @@ body
|
||||||
bp = &buf[0];
|
bp = &buf[0];
|
||||||
for(estri = 0; estri != estrmax; estri++)
|
for(estri = 0; estri != estrmax; estri++)
|
||||||
{
|
{
|
||||||
x = arrayIndex(*sp++) << 18 | arrayIndex(*sp++) << 12;
|
x = arrayIndex(sp[0]) << 18 | arrayIndex(sp[1]) << 12;
|
||||||
|
sp += 2;
|
||||||
|
|
||||||
ch = *sp++;
|
ch = *sp++;
|
||||||
if(ch == '=')
|
if(ch == '=')
|
||||||
|
|
28
std/boxer.d
28
std/boxer.d
|
@ -136,11 +136,11 @@ struct Box
|
||||||
|
|
||||||
TypeInfo_Class ca = cast(TypeInfo_Class) type, cb = cast(TypeInfo_Class) test;
|
TypeInfo_Class ca = cast(TypeInfo_Class) type, cb = cast(TypeInfo_Class) test;
|
||||||
|
|
||||||
if (ca !== null && cb !== null)
|
if (ca !is null && cb !is null)
|
||||||
{
|
{
|
||||||
ClassInfo ia = (*cast(Object *) data).classinfo, ib = cb.info;
|
ClassInfo ia = (*cast(Object *) data).classinfo, ib = cb.info;
|
||||||
|
|
||||||
for ( ; ia !== null; ia = ia.base)
|
for ( ; ia !is null; ia = ia.base)
|
||||||
if (ia is ib)
|
if (ia is ib)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -320,7 +320,7 @@ body
|
||||||
Box box(TypeInfo type, void* data)
|
Box box(TypeInfo type, void* data)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(type !== null);
|
assert(type !is null);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -407,7 +407,7 @@ private template unboxCastReal(T)
|
||||||
{
|
{
|
||||||
T unboxCastReal(Box value)
|
T unboxCastReal(Box value)
|
||||||
{
|
{
|
||||||
assert (value.type !== null);
|
assert (value.type !is null);
|
||||||
|
|
||||||
if (value.type is typeid(float))
|
if (value.type is typeid(float))
|
||||||
return cast(T) *cast(float*) value.data;
|
return cast(T) *cast(float*) value.data;
|
||||||
|
@ -424,7 +424,7 @@ private template unboxCastInteger(T)
|
||||||
{
|
{
|
||||||
T unboxCastInteger(Box value)
|
T unboxCastInteger(Box value)
|
||||||
{
|
{
|
||||||
assert (value.type !== null);
|
assert (value.type !is null);
|
||||||
|
|
||||||
if (value.type is typeid(int))
|
if (value.type is typeid(int))
|
||||||
return cast(T) *cast(int*) value.data;
|
return cast(T) *cast(int*) value.data;
|
||||||
|
@ -453,7 +453,7 @@ private template unboxCastComplex(T)
|
||||||
{
|
{
|
||||||
T unboxCastComplex(Box value)
|
T unboxCastComplex(Box value)
|
||||||
{
|
{
|
||||||
assert (value.type !== null);
|
assert (value.type !is null);
|
||||||
|
|
||||||
if (value.type is typeid(cfloat))
|
if (value.type is typeid(cfloat))
|
||||||
return cast(T) *cast(cfloat*) value.data;
|
return cast(T) *cast(cfloat*) value.data;
|
||||||
|
@ -476,7 +476,7 @@ private template unboxCastImaginary(T)
|
||||||
{
|
{
|
||||||
T unboxCastImaginary(Box value)
|
T unboxCastImaginary(Box value)
|
||||||
{
|
{
|
||||||
assert (value.type !== null);
|
assert (value.type !is null);
|
||||||
|
|
||||||
if (value.type is typeid(ifloat))
|
if (value.type is typeid(ifloat))
|
||||||
return cast(T) *cast(ifloat*) value.data;
|
return cast(T) *cast(ifloat*) value.data;
|
||||||
|
@ -499,7 +499,7 @@ template unbox(T)
|
||||||
{
|
{
|
||||||
T unbox(Box value)
|
T unbox(Box value)
|
||||||
{
|
{
|
||||||
assert (value.type !== null);
|
assert (value.type !is null);
|
||||||
|
|
||||||
if (typeid(T) is value.type)
|
if (typeid(T) is value.type)
|
||||||
return *cast(T*) value.data;
|
return *cast(T*) value.data;
|
||||||
|
@ -529,7 +529,7 @@ template unbox(T : Object)
|
||||||
{
|
{
|
||||||
T unbox(Box value)
|
T unbox(Box value)
|
||||||
{
|
{
|
||||||
assert (value.type !== null);
|
assert (value.type !is null);
|
||||||
|
|
||||||
if (typeid(T) == value.type || cast(TypeInfo_Class) value.type)
|
if (typeid(T) == value.type || cast(TypeInfo_Class) value.type)
|
||||||
{
|
{
|
||||||
|
@ -553,7 +553,7 @@ template unbox(T : T[])
|
||||||
{
|
{
|
||||||
T[] unbox(Box value)
|
T[] unbox(Box value)
|
||||||
{
|
{
|
||||||
assert (value.type !== null);
|
assert (value.type !is null);
|
||||||
|
|
||||||
if (typeid(T[]) is value.type)
|
if (typeid(T[]) is value.type)
|
||||||
return *cast(T[]*) value.data;
|
return *cast(T[]*) value.data;
|
||||||
|
@ -567,7 +567,7 @@ template unbox(T : T*)
|
||||||
{
|
{
|
||||||
T* unbox(Box value)
|
T* unbox(Box value)
|
||||||
{
|
{
|
||||||
assert (value.type !== null);
|
assert (value.type !is null);
|
||||||
|
|
||||||
if (typeid(T*) is value.type)
|
if (typeid(T*) is value.type)
|
||||||
return *cast(T**) value.data;
|
return *cast(T**) value.data;
|
||||||
|
@ -584,7 +584,7 @@ template unbox(T : void*)
|
||||||
{
|
{
|
||||||
T unbox(Box value)
|
T unbox(Box value)
|
||||||
{
|
{
|
||||||
assert (value.type !== null);
|
assert (value.type !is null);
|
||||||
|
|
||||||
if (cast(TypeInfo_Pointer) value.type)
|
if (cast(TypeInfo_Pointer) value.type)
|
||||||
return *cast(void**) value.data;
|
return *cast(void**) value.data;
|
||||||
|
@ -689,7 +689,7 @@ unittest
|
||||||
assert(array.length == 3);
|
assert(array.length == 3);
|
||||||
assert(unboxTest!(int)(array[0]) == 16);
|
assert(unboxTest!(int)(array[0]) == 16);
|
||||||
assert(unboxTest!(char[])(array[1]) == "foobar");
|
assert(unboxTest!(char[])(array[1]) == "foobar");
|
||||||
assert(unboxTest!(Object)(array[2]) !== null);
|
assert(unboxTest!(Object)(array[2]) !is null);
|
||||||
|
|
||||||
/* Convert the box array back into arguments. */
|
/* Convert the box array back into arguments. */
|
||||||
TypeInfo[] array_types;
|
TypeInfo[] array_types;
|
||||||
|
@ -724,7 +724,7 @@ unittest
|
||||||
assert (box(1) == box(true));
|
assert (box(1) == box(true));
|
||||||
|
|
||||||
/* Assert that unboxing to an object works properly. */
|
/* Assert that unboxing to an object works properly. */
|
||||||
assert (unboxTest!(B)(box(cast(A)new B)) !== null);
|
assert (unboxTest!(B)(box(cast(A)new B)) !is null);
|
||||||
|
|
||||||
/* Assert that illegal object casting fails properly. */
|
/* Assert that illegal object casting fails properly. */
|
||||||
assert (fails(delegate void() { unboxTest!(B)(box(new A)); }));
|
assert (fails(delegate void() { unboxTest!(B)(box(new A)); }));
|
||||||
|
|
|
@ -323,3 +323,17 @@ extern(C)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern (C)
|
||||||
|
{
|
||||||
|
/* From <dlfcn.h>
|
||||||
|
* See http://www.opengroup.org/onlinepubs/007908799/xsh/dlsym.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
const int RTLD_NOW = 0x00002; // Correct for Red Hat 8
|
||||||
|
|
||||||
|
void* dlopen(char* file, int mode);
|
||||||
|
int dlclose(void* handle);
|
||||||
|
void* dlsym(void* handle, char* name);
|
||||||
|
char* dlerror();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
147
std/cstream.d
Normal file
147
std/cstream.d
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
// Written by Ben Hinkle and put in the public domain.
|
||||||
|
|
||||||
|
import std.stream;
|
||||||
|
import std.c.stdio;
|
||||||
|
|
||||||
|
// wraps a FILE* in a stream class
|
||||||
|
class CFile : Stream {
|
||||||
|
FILE* cfile;
|
||||||
|
|
||||||
|
// Construct a CFile from the given FILE* with mode and optional seekable state
|
||||||
|
this(FILE* cfile, FileMode mode, bool seekable = false) {
|
||||||
|
super();
|
||||||
|
this.file = cfile;
|
||||||
|
readable = cast(bit)(mode & FileMode.In);
|
||||||
|
writeable = cast(bit)(mode & FileMode.Out);
|
||||||
|
this.seekable = seekable;
|
||||||
|
}
|
||||||
|
|
||||||
|
~this() { close(); }
|
||||||
|
|
||||||
|
FILE* file() { return cfile; }
|
||||||
|
void file(FILE* cfile) {
|
||||||
|
this.cfile = cfile;
|
||||||
|
isopen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
override void flush() { fflush(cfile); }
|
||||||
|
override void close() {
|
||||||
|
if (isopen)
|
||||||
|
fclose(cfile);
|
||||||
|
isopen = readable = writeable = seekable = false;
|
||||||
|
}
|
||||||
|
override bool eof() {
|
||||||
|
return cast(bool)(readEOF || feof(cfile));
|
||||||
|
}
|
||||||
|
override char getc() {
|
||||||
|
return cast(char)fgetc(cfile);
|
||||||
|
}
|
||||||
|
override char ungetc(char c) {
|
||||||
|
return cast(char)std.c.stdio.ungetc(c,cfile);
|
||||||
|
}
|
||||||
|
override size_t readBlock(void* buffer, size_t size) {
|
||||||
|
size_t n = fread(buffer,1,size,cfile);
|
||||||
|
readEOF = cast(bit)(n == 0);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
override size_t writeBlock(void* buffer, size_t size) {
|
||||||
|
return fwrite(buffer,1,size,cfile);
|
||||||
|
}
|
||||||
|
override ulong seek(long offset, SeekPos rel) {
|
||||||
|
readEOF = false;
|
||||||
|
if (fseek(cfile,cast(int)offset,rel) != 0)
|
||||||
|
throw new SeekException("unable to move file pointer");
|
||||||
|
return ftell(cfile);
|
||||||
|
}
|
||||||
|
override void writeLine(char[] s) {
|
||||||
|
writeString(s);
|
||||||
|
writeString("\n");
|
||||||
|
}
|
||||||
|
override void writeLineW(wchar[] s) {
|
||||||
|
writeStringW(s);
|
||||||
|
writeStringW("\n");
|
||||||
|
}
|
||||||
|
// run a few tests
|
||||||
|
unittest {
|
||||||
|
FILE* f = fopen("stream.txt","w");
|
||||||
|
assert(f !is null);
|
||||||
|
CFile file = new CFile(f,FileMode.Out);
|
||||||
|
int i = 666;
|
||||||
|
// should be ok to write
|
||||||
|
assert(file.writeable);
|
||||||
|
file.writeLine("Testing stream.d:");
|
||||||
|
file.writeString("Hello, world!");
|
||||||
|
file.write(i);
|
||||||
|
// string#1 + string#2 + int should give exacly that
|
||||||
|
version (Win32)
|
||||||
|
assert(file.position() == 19 + 13 + 4);
|
||||||
|
version (linux)
|
||||||
|
assert(file.position() == 18 + 13 + 4);
|
||||||
|
file.close();
|
||||||
|
// no operations are allowed when file is closed
|
||||||
|
assert(!file.readable && !file.writeable && !file.seekable);
|
||||||
|
f = fopen("stream.txt","r");
|
||||||
|
file = new CFile(f,FileMode.In,true);
|
||||||
|
// should be ok to read
|
||||||
|
assert(file.readable);
|
||||||
|
char[] line = file.readLine();
|
||||||
|
char[] exp = "Testing stream.d:";
|
||||||
|
assert(line[0] == 'T');
|
||||||
|
assert(line.length == exp.length);
|
||||||
|
assert(!std.string.cmp(line, "Testing stream.d:"));
|
||||||
|
// jump over "Hello, "
|
||||||
|
file.seek(7, SeekPos.Current);
|
||||||
|
version (Win32)
|
||||||
|
assert(file.position() == 19 + 7);
|
||||||
|
version (linux)
|
||||||
|
assert(file.position() == 18 + 7);
|
||||||
|
assert(!std.string.cmp(file.readString(6), "world!"));
|
||||||
|
i = 0; file.read(i);
|
||||||
|
assert(i == 666);
|
||||||
|
// string#1 + string#2 + int should give exacly that
|
||||||
|
version (Win32)
|
||||||
|
assert(file.position() == 19 + 13 + 4);
|
||||||
|
version (linux)
|
||||||
|
assert(file.position() == 18 + 13 + 4);
|
||||||
|
// we must be at the end of file
|
||||||
|
file.close();
|
||||||
|
f = fopen("stream.txt","w+");
|
||||||
|
file = new CFile(f,FileMode.In|FileMode.Out,true);
|
||||||
|
file.writeLine("Testing stream.d:");
|
||||||
|
file.writeLine("Another line");
|
||||||
|
file.writeLine("");
|
||||||
|
file.writeLine("That was blank");
|
||||||
|
file.position = 0;
|
||||||
|
char[][] lines;
|
||||||
|
foreach(char[] line; file) {
|
||||||
|
lines ~= line.dup;
|
||||||
|
}
|
||||||
|
assert( lines.length == 5 );
|
||||||
|
assert( lines[0] == "Testing stream.d:");
|
||||||
|
assert( lines[1] == "Another line");
|
||||||
|
assert( lines[2] == "");
|
||||||
|
assert( lines[3] == "That was blank");
|
||||||
|
file.position = 0;
|
||||||
|
lines = new char[][5];
|
||||||
|
foreach(ulong n, char[] line; file) {
|
||||||
|
lines[n-1] = line.dup;
|
||||||
|
}
|
||||||
|
assert( lines[0] == "Testing stream.d:");
|
||||||
|
assert( lines[1] == "Another line");
|
||||||
|
assert( lines[2] == "");
|
||||||
|
assert( lines[3] == "That was blank");
|
||||||
|
file.close();
|
||||||
|
remove("stream.txt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// standard IO devices
|
||||||
|
CFile din, dout, derr;
|
||||||
|
|
||||||
|
static this() {
|
||||||
|
// open standard I/O devices
|
||||||
|
din = new CFile(std.c.stdio.stdin,FileMode.In);
|
||||||
|
dout = new CFile(std.c.stdio.stdout,FileMode.Out);
|
||||||
|
derr = new CFile(std.c.stdio.stderr,FileMode.Out);
|
||||||
|
}
|
||||||
|
|
52
std/loader.d
52
std/loader.d
|
@ -210,7 +210,7 @@ version(Windows)
|
||||||
private HXModule ExeModule_Load_(in char[] moduleName)
|
private HXModule ExeModule_Load_(in char[] moduleName)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== moduleName);
|
assert(null !is moduleName);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -227,7 +227,7 @@ version(Windows)
|
||||||
private HXModule ExeModule_AddRef_(in HXModule hModule)
|
private HXModule ExeModule_AddRef_(in HXModule hModule)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== hModule);
|
assert(null !is hModule);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -237,7 +237,7 @@ version(Windows)
|
||||||
private void ExeModule_Release_(inout HXModule hModule)
|
private void ExeModule_Release_(inout HXModule hModule)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== hModule);
|
assert(null !is hModule);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -251,7 +251,7 @@ version(Windows)
|
||||||
private void *ExeModule_GetSymbol_(inout HXModule hModule, in char[] symbolName)
|
private void *ExeModule_GetSymbol_(inout HXModule hModule, in char[] symbolName)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== hModule);
|
assert(null !is hModule);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -332,13 +332,13 @@ else version(linux)
|
||||||
private HXModule ExeModule_Load_(in char[] moduleName)
|
private HXModule ExeModule_Load_(in char[] moduleName)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== moduleName);
|
assert(null !is moduleName);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
ExeModuleInfo mi = s_modules[moduleName];
|
ExeModuleInfo mi = s_modules[moduleName];
|
||||||
|
|
||||||
if(null !== mi)
|
if(null !is mi)
|
||||||
{
|
{
|
||||||
return (++mi.m_cRefs, cast(HXModule)mi);
|
return (++mi.m_cRefs, cast(HXModule)mi);
|
||||||
}
|
}
|
||||||
|
@ -366,21 +366,21 @@ else version(linux)
|
||||||
private HXModule ExeModule_AddRef_(in HXModule hModule)
|
private HXModule ExeModule_AddRef_(in HXModule hModule)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== hModule);
|
assert(null !is hModule);
|
||||||
|
|
||||||
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
||||||
|
|
||||||
assert(0 < mi.m_cRefs);
|
assert(0 < mi.m_cRefs);
|
||||||
assert(null !== mi.m_hmod);
|
assert(null !is mi.m_hmod);
|
||||||
assert(null !== mi.m_name);
|
assert(null !is mi.m_name);
|
||||||
assert(null !== s_modules[mi.m_name]);
|
assert(null !is s_modules[mi.m_name]);
|
||||||
assert(mi is s_modules[mi.m_name]);
|
assert(mi is s_modules[mi.m_name]);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
||||||
|
|
||||||
if(null !== mi)
|
if(null !is mi)
|
||||||
{
|
{
|
||||||
return (++mi.m_cRefs, hModule);
|
return (++mi.m_cRefs, hModule);
|
||||||
}
|
}
|
||||||
|
@ -393,14 +393,14 @@ else version(linux)
|
||||||
private void ExeModule_Release_(inout HXModule hModule)
|
private void ExeModule_Release_(inout HXModule hModule)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== hModule);
|
assert(null !is hModule);
|
||||||
|
|
||||||
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
||||||
|
|
||||||
assert(0 < mi.m_cRefs);
|
assert(0 < mi.m_cRefs);
|
||||||
assert(null !== mi.m_hmod);
|
assert(null !is mi.m_hmod);
|
||||||
assert(null !== mi.m_name);
|
assert(null !is mi.m_name);
|
||||||
assert(null !== s_modules[mi.m_name]);
|
assert(null !is s_modules[mi.m_name]);
|
||||||
assert(mi is s_modules[mi.m_name]);
|
assert(mi is s_modules[mi.m_name]);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
|
@ -425,14 +425,14 @@ else version(linux)
|
||||||
private void *ExeModule_GetSymbol_(inout HXModule hModule, in char[] symbolName)
|
private void *ExeModule_GetSymbol_(inout HXModule hModule, in char[] symbolName)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== hModule);
|
assert(null !is hModule);
|
||||||
|
|
||||||
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
||||||
|
|
||||||
assert(0 < mi.m_cRefs);
|
assert(0 < mi.m_cRefs);
|
||||||
assert(null !== mi.m_hmod);
|
assert(null !is mi.m_hmod);
|
||||||
assert(null !== mi.m_name);
|
assert(null !is mi.m_name);
|
||||||
assert(null !== s_modules[mi.m_name]);
|
assert(null !is s_modules[mi.m_name]);
|
||||||
assert(mi is s_modules[mi.m_name]);
|
assert(mi is s_modules[mi.m_name]);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
|
@ -456,14 +456,14 @@ else version(linux)
|
||||||
private char[] ExeModule_GetPath_(HXModule hModule)
|
private char[] ExeModule_GetPath_(HXModule hModule)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== hModule);
|
assert(null !is hModule);
|
||||||
|
|
||||||
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
ExeModuleInfo mi = cast(ExeModuleInfo)hModule;
|
||||||
|
|
||||||
assert(0 < mi.m_cRefs);
|
assert(0 < mi.m_cRefs);
|
||||||
assert(null !== mi.m_hmod);
|
assert(null !is mi.m_hmod);
|
||||||
assert(null !== mi.m_name);
|
assert(null !is mi.m_name);
|
||||||
assert(null !== s_modules[mi.m_name]);
|
assert(null !is s_modules[mi.m_name]);
|
||||||
assert(mi is s_modules[mi.m_name]);
|
assert(mi is s_modules[mi.m_name]);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
|
@ -509,7 +509,7 @@ public:
|
||||||
this(in HXModule hModule, boolean bTakeOwnership)
|
this(in HXModule hModule, boolean bTakeOwnership)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== hModule);
|
assert(null !is hModule);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -538,7 +538,7 @@ public:
|
||||||
this(char[] moduleName)
|
this(char[] moduleName)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== moduleName);
|
assert(null !is moduleName);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -574,7 +574,7 @@ public:
|
||||||
/// calls do not result in an error, and are simply ignored.
|
/// calls do not result in an error, and are simply ignored.
|
||||||
void close()
|
void close()
|
||||||
{
|
{
|
||||||
if(null !== m_hModule)
|
if(null !is m_hModule)
|
||||||
{
|
{
|
||||||
version (Windows)
|
version (Windows)
|
||||||
{
|
{
|
||||||
|
|
|
@ -334,9 +334,10 @@ SC17: fprem1 ;
|
||||||
jp SC17 ;
|
jp SC17 ;
|
||||||
fstp ST(1) ; // remove pi from stack
|
fstp ST(1) ; // remove pi from stack
|
||||||
jmp SC18 ;
|
jmp SC18 ;
|
||||||
}
|
|
||||||
|
|
||||||
trigerr:
|
trigerr:
|
||||||
|
fstp ST(0) ; // dump theta
|
||||||
|
}
|
||||||
return real.nan;
|
return real.nan;
|
||||||
|
|
||||||
Lret:
|
Lret:
|
||||||
|
|
26
std/openrj.d
26
std/openrj.d
|
@ -354,8 +354,8 @@ private:
|
||||||
this(char[] name, char[] value/* , Record record */)
|
this(char[] name, char[] value/* , Record record */)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== name);
|
assert(null !is name);
|
||||||
assert(null !== value);
|
assert(null !is value);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -390,7 +390,7 @@ public:
|
||||||
{
|
{
|
||||||
Field f = cast(Field)(rhs);
|
Field f = cast(Field)(rhs);
|
||||||
|
|
||||||
if(null === f)
|
if(null is f)
|
||||||
{
|
{
|
||||||
throw new InvalidTypeException("Attempt to compare a Field with an instance of another type");
|
throw new InvalidTypeException("Attempt to compare a Field with an instance of another type");
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ public:
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if(this === rhs)
|
if(this is rhs)
|
||||||
{
|
{
|
||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
|
@ -499,13 +499,13 @@ public:
|
||||||
Field getField(char[] fieldName)
|
Field getField(char[] fieldName)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== fieldName);
|
assert(null !is fieldName);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
Field field = findField(fieldName);
|
Field field = findField(fieldName);
|
||||||
|
|
||||||
if(null === field)
|
if(null is field)
|
||||||
{
|
{
|
||||||
throw new InvalidKeyException("field not found");
|
throw new InvalidKeyException("field not found");
|
||||||
}
|
}
|
||||||
|
@ -516,18 +516,18 @@ public:
|
||||||
Field findField(char[] fieldName)
|
Field findField(char[] fieldName)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== fieldName);
|
assert(null !is fieldName);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
Field *pfield = (fieldName in m_values);
|
Field *pfield = (fieldName in m_values);
|
||||||
|
|
||||||
return (null === pfield) ? null : *pfield;
|
return (null is pfield) ? null : *pfield;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hasField(char[] fieldName)
|
int hasField(char[] fieldName)
|
||||||
{
|
{
|
||||||
return null !== findField(fieldName);
|
return null !is findField(fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Database database()
|
Database database()
|
||||||
|
@ -799,7 +799,7 @@ public:
|
||||||
|
|
||||||
foreach(Record record; m_records)
|
foreach(Record record; m_records)
|
||||||
{
|
{
|
||||||
if(null !== record.findField(fieldName))
|
if(null !is record.findField(fieldName))
|
||||||
{
|
{
|
||||||
records ~= record;
|
records ~= record;
|
||||||
}
|
}
|
||||||
|
@ -817,7 +817,7 @@ public:
|
||||||
{
|
{
|
||||||
Field field = record.findField(fieldName);
|
Field field = record.findField(fieldName);
|
||||||
|
|
||||||
if(null !== field)
|
if(null !is field)
|
||||||
{
|
{
|
||||||
// Since there can be more than one field with the same name in
|
// Since there can be more than one field with the same name in
|
||||||
// the same record, we need to search all fields in this record
|
// the same record, we need to search all fields in this record
|
||||||
|
@ -829,7 +829,7 @@ public:
|
||||||
int res = cmp(field.name, fieldName);
|
int res = cmp(field.name, fieldName);
|
||||||
|
|
||||||
if( 0 == res &&
|
if( 0 == res &&
|
||||||
( null === fieldValue ||
|
( null is fieldValue ||
|
||||||
field.value == fieldValue))
|
field.value == fieldValue))
|
||||||
{
|
{
|
||||||
records ~= record;
|
records ~= record;
|
||||||
|
@ -847,7 +847,7 @@ public:
|
||||||
foreach(Field field; record)
|
foreach(Field field; record)
|
||||||
{
|
{
|
||||||
if( field.name == fieldName &&
|
if( field.name == fieldName &&
|
||||||
( null === fieldValue ||
|
( null is fieldValue ||
|
||||||
field.value == fieldValue))
|
field.value == fieldValue))
|
||||||
{
|
{
|
||||||
records ~= record;
|
records ~= record;
|
||||||
|
|
|
@ -44,7 +44,7 @@ auto class PerformanceCounterScope(T)
|
||||||
this(T counter)
|
this(T counter)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== counter);
|
assert(null !is counter);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
|
76
std/recls.d
76
std/recls.d
|
@ -344,7 +344,7 @@ public char[] Search_GetErrorString(in recls_rc_t rc)
|
||||||
public char[] Search_GetEntryPath(in recls_info_t entry)
|
public char[] Search_GetEntryPath(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -363,7 +363,7 @@ version(Windows)
|
||||||
public char Search_GetEntryDrive(in recls_info_t entry)
|
public char Search_GetEntryDrive(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -376,7 +376,7 @@ body
|
||||||
public char[] Search_GetEntryDirectory(in recls_info_t entry)
|
public char[] Search_GetEntryDirectory(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -393,7 +393,7 @@ body
|
||||||
public char[] Search_GetEntryDirectoryPath(in recls_info_t entry)
|
public char[] Search_GetEntryDirectoryPath(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -410,7 +410,7 @@ body
|
||||||
public char[] Search_GetEntryFile(in recls_info_t entry)
|
public char[] Search_GetEntryFile(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -427,7 +427,7 @@ body
|
||||||
public char[] Search_GetEntryShortFile(in recls_info_t entry)
|
public char[] Search_GetEntryShortFile(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -444,7 +444,7 @@ body
|
||||||
public char[] Search_GetEntryFileName(in recls_info_t entry)
|
public char[] Search_GetEntryFileName(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -461,7 +461,7 @@ body
|
||||||
public char[] Search_GetEntryFileExt(in recls_info_t entry)
|
public char[] Search_GetEntryFileExt(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -478,7 +478,7 @@ body
|
||||||
public char[][] Search_GetEntryDirectoryParts(in recls_info_t entry)
|
public char[][] Search_GetEntryDirectoryParts(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -503,7 +503,7 @@ body
|
||||||
public boolean Search_IsEntryReadOnly(in recls_info_t entry)
|
public boolean Search_IsEntryReadOnly(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -513,7 +513,7 @@ body
|
||||||
public boolean Search_IsEntryDirectory(in recls_info_t entry)
|
public boolean Search_IsEntryDirectory(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -523,7 +523,7 @@ body
|
||||||
public boolean Search_IsEntryLink(in recls_info_t entry)
|
public boolean Search_IsEntryLink(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -533,7 +533,7 @@ body
|
||||||
public recls_filesize_t Search_GetEntrySize(in recls_info_t entry)
|
public recls_filesize_t Search_GetEntrySize(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -545,7 +545,7 @@ body
|
||||||
public recls_time_t Search_GetEntryCreationTime(in recls_info_t entry)
|
public recls_time_t Search_GetEntryCreationTime(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -555,7 +555,7 @@ body
|
||||||
public recls_time_t Search_GetEntryModificationTime(in recls_info_t entry)
|
public recls_time_t Search_GetEntryModificationTime(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -565,7 +565,7 @@ body
|
||||||
public recls_time_t Search_GetEntryLastAccessTime(in recls_info_t entry)
|
public recls_time_t Search_GetEntryLastAccessTime(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -575,7 +575,7 @@ body
|
||||||
public recls_time_t Search_GetEntryLastStatusChangeTime(in recls_info_t entry)
|
public recls_time_t Search_GetEntryLastStatusChangeTime(in recls_info_t entry)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -630,7 +630,7 @@ public:
|
||||||
Entry CurrentEntry()
|
Entry CurrentEntry()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_hSrch);
|
assert(null !is m_hSrch);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -797,7 +797,7 @@ public class Entry
|
||||||
// we just add a reference, and then release it
|
// we just add a reference, and then release it
|
||||||
recls_info_t entry = Search_CopyEntry(m_entry);
|
recls_info_t entry = Search_CopyEntry(m_entry);
|
||||||
|
|
||||||
assert(null !== entry);
|
assert(null !is entry);
|
||||||
|
|
||||||
Recls_CloseDetails(entry);
|
Recls_CloseDetails(entry);
|
||||||
}
|
}
|
||||||
|
@ -834,7 +834,7 @@ private:
|
||||||
}
|
}
|
||||||
~this()
|
~this()
|
||||||
{
|
{
|
||||||
if(null !== m_entry)
|
if(null !is m_entry)
|
||||||
{
|
{
|
||||||
Search_CloseEntry(m_entry);
|
Search_CloseEntry(m_entry);
|
||||||
}
|
}
|
||||||
|
@ -847,7 +847,7 @@ public:
|
||||||
char[] GetPath()
|
char[] GetPath()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -859,7 +859,7 @@ public:
|
||||||
char[] Path()
|
char[] Path()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -873,7 +873,7 @@ version(Windows)
|
||||||
char Drive()
|
char Drive()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -886,7 +886,7 @@ version(Windows)
|
||||||
char[] Directory()
|
char[] Directory()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -898,7 +898,7 @@ version(Windows)
|
||||||
char[] DirectoryPath()
|
char[] DirectoryPath()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -910,7 +910,7 @@ version(Windows)
|
||||||
char[][] DirectoryParts()
|
char[][] DirectoryParts()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -922,7 +922,7 @@ version(Windows)
|
||||||
char[] File()
|
char[] File()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -934,7 +934,7 @@ version(Windows)
|
||||||
char[] ShortFile()
|
char[] ShortFile()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -946,7 +946,7 @@ version(Windows)
|
||||||
char[] FileName()
|
char[] FileName()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -958,7 +958,7 @@ version(Windows)
|
||||||
char[] FileExt()
|
char[] FileExt()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -969,7 +969,7 @@ version(Windows)
|
||||||
recls_time_t CreationTime()
|
recls_time_t CreationTime()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -979,7 +979,7 @@ version(Windows)
|
||||||
recls_time_t ModificationTime()
|
recls_time_t ModificationTime()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -989,7 +989,7 @@ version(Windows)
|
||||||
recls_time_t LastAccessTime()
|
recls_time_t LastAccessTime()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -999,7 +999,7 @@ version(Windows)
|
||||||
recls_time_t LastStatusChangeTime()
|
recls_time_t LastStatusChangeTime()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -1010,7 +1010,7 @@ version(Windows)
|
||||||
recls_filesize_t Size()
|
recls_filesize_t Size()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -1021,7 +1021,7 @@ version(Windows)
|
||||||
boolean IsReadOnly()
|
boolean IsReadOnly()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -1031,7 +1031,7 @@ version(Windows)
|
||||||
boolean IsDirectory()
|
boolean IsDirectory()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
@ -1041,7 +1041,7 @@ version(Windows)
|
||||||
boolean IsLink()
|
boolean IsLink()
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(null !== m_entry);
|
assert(null !is m_entry);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
|
|
|
@ -1339,12 +1339,12 @@ class Socket
|
||||||
//make sure none of the SocketSet's are the same object
|
//make sure none of the SocketSet's are the same object
|
||||||
if(checkRead)
|
if(checkRead)
|
||||||
{
|
{
|
||||||
assert(checkRead !== checkWrite);
|
assert(checkRead !is checkWrite);
|
||||||
assert(checkRead !== checkError);
|
assert(checkRead !is checkError);
|
||||||
}
|
}
|
||||||
if(checkWrite)
|
if(checkWrite)
|
||||||
{
|
{
|
||||||
assert(checkWrite !== checkError);
|
assert(checkWrite !is checkError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
|
|
|
@ -24,15 +24,11 @@ module std.socketstream;
|
||||||
private import std.stream;
|
private import std.stream;
|
||||||
private import std.socket;
|
private import std.socket;
|
||||||
|
|
||||||
|
|
||||||
class SocketStream: Stream
|
class SocketStream: Stream
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bit prevCr = false;
|
|
||||||
bit atEof = false;
|
|
||||||
Socket sock;
|
Socket sock;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
this(Socket sock, FileMode mode)
|
this(Socket sock, FileMode mode)
|
||||||
{
|
{
|
||||||
|
@ -44,187 +40,61 @@ class SocketStream: Stream
|
||||||
this.sock = sock;
|
this.sock = sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this(Socket sock)
|
this(Socket sock)
|
||||||
{
|
{
|
||||||
writeable = readable = true;
|
writeable = readable = true;
|
||||||
this.sock = sock;
|
this.sock = sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Socket socket()
|
Socket socket()
|
||||||
{
|
{
|
||||||
return sock;
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override uint readBlock(void* _buffer, uint size)
|
override uint readBlock(void* _buffer, uint size)
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(readable);
|
|
||||||
}
|
|
||||||
body
|
|
||||||
{
|
{
|
||||||
ubyte* buffer = cast(ubyte*)_buffer;
|
ubyte* buffer = cast(ubyte*)_buffer;
|
||||||
int len;
|
int len;
|
||||||
uint need = size;
|
uint need = size;
|
||||||
|
assertReadable();
|
||||||
|
|
||||||
for(;;)
|
if(size == 0)
|
||||||
{
|
|
||||||
if(!need)
|
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
len = sock.receive(buffer[0 .. need]);
|
len = sock.receive(buffer[0 .. size]);
|
||||||
if(len <= 0)
|
readEOF = cast(bit)(len == 0);
|
||||||
{
|
if(len < 0)
|
||||||
if(!len)
|
len = 0;
|
||||||
atEof = true;
|
return len;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer += len;
|
|
||||||
need -= len;
|
|
||||||
}
|
|
||||||
return size - need;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override char getc()
|
|
||||||
{
|
|
||||||
char ch;
|
|
||||||
|
|
||||||
if(prevCr)
|
|
||||||
{
|
|
||||||
prevCr = false;
|
|
||||||
ch = super.getc();
|
|
||||||
if(ch != '\n')
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getc();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override wchar getcw()
|
|
||||||
{
|
|
||||||
wchar ch;
|
|
||||||
|
|
||||||
if(prevCr)
|
|
||||||
{
|
|
||||||
prevCr = false;
|
|
||||||
ch = super.getcw();
|
|
||||||
if(ch != '\n')
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getcw();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override char[] readLine()
|
|
||||||
{
|
|
||||||
char[] result;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
char ch = getc();
|
|
||||||
switch(ch)
|
|
||||||
{
|
|
||||||
case '\r':
|
|
||||||
prevCr = true;
|
|
||||||
case '\n':
|
|
||||||
return result;
|
|
||||||
|
|
||||||
default:
|
|
||||||
result ~= ch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(ReadError re)
|
|
||||||
{
|
|
||||||
if(!eof())
|
|
||||||
throw re;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override wchar[] readLineW()
|
|
||||||
{
|
|
||||||
wchar[] result;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
char ch = getcw();
|
|
||||||
switch(ch)
|
|
||||||
{
|
|
||||||
case '\r':
|
|
||||||
prevCr = true;
|
|
||||||
case '\n':
|
|
||||||
return result;
|
|
||||||
|
|
||||||
default:
|
|
||||||
result ~= ch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(ReadError re)
|
|
||||||
{
|
|
||||||
if(!eof())
|
|
||||||
throw re;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override uint writeBlock(void* _buffer, uint size)
|
override uint writeBlock(void* _buffer, uint size)
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(writeable);
|
|
||||||
}
|
|
||||||
body
|
|
||||||
{
|
{
|
||||||
ubyte* buffer = cast(ubyte*)_buffer;
|
ubyte* buffer = cast(ubyte*)_buffer;
|
||||||
int len;
|
int len;
|
||||||
uint need = size;
|
assertWriteable();
|
||||||
|
|
||||||
for(;;)
|
if(size == 0)
|
||||||
{
|
|
||||||
if(!need)
|
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
len = sock.send(buffer[0 .. need]);
|
len = sock.send(buffer[0 .. size]);
|
||||||
if(len <= 0)
|
readEOF = cast(bit)(len == 0);
|
||||||
break;
|
if(len < 0)
|
||||||
|
len = 0;
|
||||||
buffer += len;
|
return len;
|
||||||
need -= len;
|
|
||||||
}
|
}
|
||||||
return size - need;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override ulong seek(long offset, SeekPos whence)
|
override ulong seek(long offset, SeekPos whence)
|
||||||
{
|
{
|
||||||
throw new SeekError("Cannot seek a socket.");
|
throw new SeekException("Cannot seek a socket.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override char[] toString()
|
override char[] toString()
|
||||||
{
|
{
|
||||||
return sock.toString();
|
return sock.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override bit eof()
|
|
||||||
{
|
|
||||||
return atEof;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override void close()
|
override void close()
|
||||||
{
|
{
|
||||||
sock.close();
|
sock.close();
|
||||||
|
|
140
std/stream.d
140
std/stream.d
|
@ -63,12 +63,8 @@ enum SeekPos {
|
||||||
End
|
End
|
||||||
}
|
}
|
||||||
|
|
||||||
import std.format;
|
|
||||||
alias std.format.va_list va_list;
|
|
||||||
private import std.c.stdio;
|
|
||||||
alias std.c.stdio.va_list c_va_list;
|
|
||||||
|
|
||||||
private {
|
private {
|
||||||
|
import std.format;
|
||||||
import std.system; // for Endian enumeration
|
import std.system; // for Endian enumeration
|
||||||
import std.intrinsic; // for bswap
|
import std.intrinsic; // for bswap
|
||||||
import std.utf;
|
import std.utf;
|
||||||
|
@ -150,10 +146,12 @@ interface InputStream {
|
||||||
|
|
||||||
// reads and returns next character from the stream,
|
// reads and returns next character from the stream,
|
||||||
// handles characters pushed back by ungetc()
|
// handles characters pushed back by ungetc()
|
||||||
|
// return char.init on EOF
|
||||||
char getc();
|
char getc();
|
||||||
|
|
||||||
// reads and returns next Unicode character from the
|
// reads and returns next Unicode character from the
|
||||||
// stream, handles characters pushed back by ungetc()
|
// stream, handles characters pushed back by ungetc()
|
||||||
|
// return wchar.init on EOF
|
||||||
wchar getcw();
|
wchar getcw();
|
||||||
|
|
||||||
// pushes back character c into the stream; only has
|
// pushes back character c into the stream; only has
|
||||||
|
@ -164,7 +162,7 @@ interface InputStream {
|
||||||
// has effect on further calls to getc() and getcw()
|
// has effect on further calls to getc() and getcw()
|
||||||
wchar ungetcw(wchar c);
|
wchar ungetcw(wchar c);
|
||||||
|
|
||||||
int vscanf(char[] fmt, c_va_list args);
|
int vscanf(char[] fmt, va_list args);
|
||||||
|
|
||||||
int scanf(char[] format, ...);
|
int scanf(char[] format, ...);
|
||||||
|
|
||||||
|
@ -226,7 +224,7 @@ interface OutputStream {
|
||||||
|
|
||||||
// writes data to stream using vprintf() syntax,
|
// writes data to stream using vprintf() syntax,
|
||||||
// returns number of bytes written
|
// returns number of bytes written
|
||||||
size_t vprintf(char[] format, c_va_list args);
|
size_t vprintf(char[] format, va_list args);
|
||||||
|
|
||||||
// writes data to stream using printf() syntax,
|
// writes data to stream using printf() syntax,
|
||||||
// returns number of bytes written
|
// returns number of bytes written
|
||||||
|
@ -257,6 +255,9 @@ class Stream : InputStream, OutputStream {
|
||||||
// flag that last readBlock resulted in eof
|
// flag that last readBlock resulted in eof
|
||||||
protected bit readEOF = false;
|
protected bit readEOF = false;
|
||||||
|
|
||||||
|
// flag that last getc got \r
|
||||||
|
protected bit prevCr = false;
|
||||||
|
|
||||||
this() {}
|
this() {}
|
||||||
|
|
||||||
// reads block of data of specified size,
|
// reads block of data of specified size,
|
||||||
|
@ -331,17 +332,19 @@ class Stream : InputStream, OutputStream {
|
||||||
// allocates a new string
|
// allocates a new string
|
||||||
char[] readLine(char[] result) {
|
char[] readLine(char[] result) {
|
||||||
size_t strlen = 0;
|
size_t strlen = 0;
|
||||||
try {
|
|
||||||
char ch = getc();
|
char ch = getc();
|
||||||
while (readable) {
|
while (readable) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '\r': {
|
case '\r':
|
||||||
|
if (seekable) {
|
||||||
ch = getc();
|
ch = getc();
|
||||||
if (ch != '\n')
|
if (ch != '\n')
|
||||||
ungetc(ch);
|
ungetc(ch);
|
||||||
|
} else {
|
||||||
|
prevCr = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
|
case char.init:
|
||||||
result.length = strlen;
|
result.length = strlen;
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -355,12 +358,6 @@ class Stream : InputStream, OutputStream {
|
||||||
}
|
}
|
||||||
ch = getc();
|
ch = getc();
|
||||||
}
|
}
|
||||||
} catch (ReadException e) {
|
|
||||||
// either this is end of stream, which is okay,
|
|
||||||
// or something bad occured while reading
|
|
||||||
if (!eof())
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
result.length = strlen;
|
result.length = strlen;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -377,17 +374,19 @@ class Stream : InputStream, OutputStream {
|
||||||
// fills supplied buffer if line fits and otherwise allocates a new string.
|
// fills supplied buffer if line fits and otherwise allocates a new string.
|
||||||
wchar[] readLineW(wchar[] result) {
|
wchar[] readLineW(wchar[] result) {
|
||||||
size_t strlen = 0;
|
size_t strlen = 0;
|
||||||
try {
|
|
||||||
wchar c = getcw();
|
wchar c = getcw();
|
||||||
while (readable) {
|
while (readable) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\r': {
|
case '\r':
|
||||||
|
if (seekable) {
|
||||||
c = getcw();
|
c = getcw();
|
||||||
if (c != '\n')
|
if (c != '\n')
|
||||||
ungetcw(c);
|
ungetcw(c);
|
||||||
|
} else {
|
||||||
|
prevCr = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
|
case wchar.init:
|
||||||
result.length = strlen;
|
result.length = strlen;
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -401,12 +400,6 @@ class Stream : InputStream, OutputStream {
|
||||||
}
|
}
|
||||||
c = getcw();
|
c = getcw();
|
||||||
}
|
}
|
||||||
} catch (ReadException e) {
|
|
||||||
// either this is end of stream, which is okay,
|
|
||||||
// or something bad occured while reading
|
|
||||||
if (!eof())
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
result.length = strlen;
|
result.length = strlen;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -485,26 +478,43 @@ class Stream : InputStream, OutputStream {
|
||||||
|
|
||||||
// reads and returns next character from the stream,
|
// reads and returns next character from the stream,
|
||||||
// handles characters pushed back by ungetc()
|
// handles characters pushed back by ungetc()
|
||||||
|
// returns char.init on eof.
|
||||||
char getc() {
|
char getc() {
|
||||||
char c;
|
char c;
|
||||||
|
if (prevCr) {
|
||||||
|
prevCr = false;
|
||||||
|
c = getc();
|
||||||
|
if (c != '\n')
|
||||||
|
return c;
|
||||||
|
}
|
||||||
if (unget.length > 1) {
|
if (unget.length > 1) {
|
||||||
c = unget[unget.length - 1];
|
c = unget[unget.length - 1];
|
||||||
unget.length = unget.length - 1;
|
unget.length = unget.length - 1;
|
||||||
} else {
|
} else {
|
||||||
read(c);
|
readBlock(&c,1);
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reads and returns next Unicode character from the
|
// reads and returns next Unicode character from the
|
||||||
// stream, handles characters pushed back by ungetc()
|
// stream, handles characters pushed back by ungetc()
|
||||||
|
// returns wchar.init on eof.
|
||||||
wchar getcw() {
|
wchar getcw() {
|
||||||
wchar c;
|
wchar c;
|
||||||
|
if (prevCr) {
|
||||||
|
prevCr = false;
|
||||||
|
c = getcw();
|
||||||
|
if (c != '\n')
|
||||||
|
return c;
|
||||||
|
}
|
||||||
if (unget.length > 1) {
|
if (unget.length > 1) {
|
||||||
c = unget[unget.length - 1];
|
c = unget[unget.length - 1];
|
||||||
unget.length = unget.length - 1;
|
unget.length = unget.length - 1;
|
||||||
} else {
|
} else {
|
||||||
read(c);
|
void* buf = &c;
|
||||||
|
size_t n = readBlock(buf,2);
|
||||||
|
if (n == 1 && readBlock(buf+1,1) == 0)
|
||||||
|
throw new ReadException("not enough data in stream");
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -512,6 +522,7 @@ class Stream : InputStream, OutputStream {
|
||||||
// pushes back character c into the stream; only has
|
// pushes back character c into the stream; only has
|
||||||
// effect on further calls to getc() and getcw()
|
// effect on further calls to getc() and getcw()
|
||||||
char ungetc(char c) {
|
char ungetc(char c) {
|
||||||
|
if (c == c.init) return c;
|
||||||
// first byte is a dummy so that we never set length to 0
|
// first byte is a dummy so that we never set length to 0
|
||||||
if (unget.length == 0)
|
if (unget.length == 0)
|
||||||
unget.length = 1;
|
unget.length = 1;
|
||||||
|
@ -522,6 +533,7 @@ class Stream : InputStream, OutputStream {
|
||||||
// pushes back Unicode character c into the stream; only
|
// pushes back Unicode character c into the stream; only
|
||||||
// has effect on further calls to getc() and getcw()
|
// has effect on further calls to getc() and getcw()
|
||||||
wchar ungetcw(wchar c) {
|
wchar ungetcw(wchar c) {
|
||||||
|
if (c == c.init) return c;
|
||||||
// first byte is a dummy so that we never set length to 0
|
// first byte is a dummy so that we never set length to 0
|
||||||
if (unget.length == 0)
|
if (unget.length == 0)
|
||||||
unget.length = 1;
|
unget.length = 1;
|
||||||
|
@ -529,12 +541,11 @@ class Stream : InputStream, OutputStream {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vscanf(char[] fmt, c_va_list args) {
|
int vscanf(char[] fmt, va_list args) {
|
||||||
void** arg = cast(void**) args;
|
void** arg = cast(void**) args;
|
||||||
int count = 0, i = 0;
|
int count = 0, i = 0;
|
||||||
try {
|
|
||||||
char c = getc();
|
char c = getc();
|
||||||
while (i < fmt.length) {
|
while (i < fmt.length && !eof()) {
|
||||||
if (fmt[i] == '%') { // a field
|
if (fmt[i] == '%') { // a field
|
||||||
i++;
|
i++;
|
||||||
bit suppress = false;
|
bit suppress = false;
|
||||||
|
@ -758,7 +769,7 @@ class Stream : InputStream, OutputStream {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
char[] s;
|
char[] s;
|
||||||
while (!iswhite(c)) {
|
while (!iswhite(c) && c != char.init) {
|
||||||
s ~= c;
|
s ~= c;
|
||||||
c = getc();
|
c = getc();
|
||||||
count++;
|
count++;
|
||||||
|
@ -781,7 +792,7 @@ class Stream : InputStream, OutputStream {
|
||||||
c = getc();
|
c = getc();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
while (width--) {
|
while (width-- && !eof()) {
|
||||||
*(s++) = c;
|
*(s++) = c;
|
||||||
c = getc();
|
c = getc();
|
||||||
count++;
|
count++;
|
||||||
|
@ -811,18 +822,12 @@ class Stream : InputStream, OutputStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ungetc(c);
|
ungetc(c);
|
||||||
} catch (ReadException e) {
|
|
||||||
// either this is end of stream, which is okay,
|
|
||||||
// or something bad occured while reading
|
|
||||||
if (!eof())
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int scanf(char[] format, ...) {
|
int scanf(char[] format, ...) {
|
||||||
c_va_list ap;
|
va_list ap;
|
||||||
ap = cast(c_va_list) &format;
|
ap = cast(va_list) &format;
|
||||||
ap += format.sizeof;
|
ap += format.sizeof;
|
||||||
return vscanf(format, ap);
|
return vscanf(format, ap);
|
||||||
}
|
}
|
||||||
|
@ -837,7 +842,14 @@ class Stream : InputStream, OutputStream {
|
||||||
// writes block of data of specified size,
|
// writes block of data of specified size,
|
||||||
// throws WriteException on error
|
// throws WriteException on error
|
||||||
void writeExact(void* buffer, size_t size) {
|
void writeExact(void* buffer, size_t size) {
|
||||||
if (writeBlock(buffer, size) != size)
|
for(;;) {
|
||||||
|
if (!size) return;
|
||||||
|
size_t writesize = writeBlock(buffer, size);
|
||||||
|
if (writesize == 0) break;
|
||||||
|
buffer += writesize;
|
||||||
|
size -= writesize;
|
||||||
|
}
|
||||||
|
if (size != 0)
|
||||||
throw new WriteException("unable to write to stream");
|
throw new WriteException("unable to write to stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,7 +928,7 @@ class Stream : InputStream, OutputStream {
|
||||||
|
|
||||||
// writes data to stream using vprintf() syntax,
|
// writes data to stream using vprintf() syntax,
|
||||||
// returns number of bytes written
|
// returns number of bytes written
|
||||||
size_t vprintf(char[] format, c_va_list args) {
|
size_t vprintf(char[] format, va_list args) {
|
||||||
// shamelessly stolen from OutBuffer,
|
// shamelessly stolen from OutBuffer,
|
||||||
// by Walter's permission
|
// by Walter's permission
|
||||||
char[1024] buffer;
|
char[1024] buffer;
|
||||||
|
@ -950,8 +962,8 @@ class Stream : InputStream, OutputStream {
|
||||||
// writes data to stream using printf() syntax,
|
// writes data to stream using printf() syntax,
|
||||||
// returns number of bytes written
|
// returns number of bytes written
|
||||||
size_t printf(char[] format, ...) {
|
size_t printf(char[] format, ...) {
|
||||||
c_va_list ap;
|
va_list ap;
|
||||||
ap = cast(c_va_list) &format;
|
ap = cast(va_list) &format;
|
||||||
ap += format.sizeof;
|
ap += format.sizeof;
|
||||||
return vprintf(format, ap);
|
return vprintf(format, ap);
|
||||||
}
|
}
|
||||||
|
@ -1161,7 +1173,7 @@ class BufferedStream : Stream {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateAttribs() {
|
void updateAttribs() {
|
||||||
if (s !== null) {
|
if (s !is null) {
|
||||||
readable = s.readable;
|
readable = s.readable;
|
||||||
writeable = s.writeable;
|
writeable = s.writeable;
|
||||||
seekable = s.seekable;
|
seekable = s.seekable;
|
||||||
|
@ -1349,6 +1361,7 @@ class BufferedStream : Stream {
|
||||||
}
|
}
|
||||||
flush();
|
flush();
|
||||||
size_t res = s.readBlock(buffer,buffer.length);
|
size_t res = s.readBlock(buffer,buffer.length);
|
||||||
|
readEOF = res == 0;
|
||||||
if(!res) break L0; // EOF
|
if(!res) break L0; // EOF
|
||||||
bufferSourcePos = bufferLen = res;
|
bufferSourcePos = bufferLen = res;
|
||||||
streamPos += res;
|
streamPos += res;
|
||||||
|
@ -1580,15 +1593,6 @@ class File: Stream {
|
||||||
open(filename, mode | FileMode.OutNew);
|
open(filename, mode | FileMode.OutNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
override void flush() {
|
|
||||||
super.flush();
|
|
||||||
version (Win32) {
|
|
||||||
if (isopen && this !== .stdout) {
|
|
||||||
FlushFileBuffers(hFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// closes file, if it is open; otherwise, does nothing
|
// closes file, if it is open; otherwise, does nothing
|
||||||
override void close() {
|
override void close() {
|
||||||
if (isopen) {
|
if (isopen) {
|
||||||
|
@ -1972,6 +1976,27 @@ class EndianStream : Stream {
|
||||||
void read(out wchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
|
void read(out wchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
|
||||||
void read(out dchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
|
void read(out dchar x) { readExact(&x, x.sizeof); fixBO(&x,x.sizeof); }
|
||||||
|
|
||||||
|
wchar getcw() {
|
||||||
|
wchar c;
|
||||||
|
if (prevCr) {
|
||||||
|
prevCr = false;
|
||||||
|
c = getcw();
|
||||||
|
if (c != '\n')
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (unget.length > 1) {
|
||||||
|
c = unget[unget.length - 1];
|
||||||
|
unget.length = unget.length - 1;
|
||||||
|
} else {
|
||||||
|
void* buf = &c;
|
||||||
|
size_t n = readBlock(buf,2);
|
||||||
|
if (n == 1 && readBlock(buf+1,1) == 0)
|
||||||
|
throw new ReadException("not enough data in stream");
|
||||||
|
fixBO(&c,c.sizeof);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
wchar[] readStringW(size_t length) {
|
wchar[] readStringW(size_t length) {
|
||||||
wchar[] result = new wchar[length];
|
wchar[] result = new wchar[length];
|
||||||
readExact(result, result.length * wchar.sizeof);
|
readExact(result, result.length * wchar.sizeof);
|
||||||
|
@ -2378,7 +2403,7 @@ class SliceStream : Stream {
|
||||||
// set the base stream and the low offset but leave the high unbounded.
|
// set the base stream and the low offset but leave the high unbounded.
|
||||||
this (Stream base, ulong low)
|
this (Stream base, ulong low)
|
||||||
in {
|
in {
|
||||||
assert (base !== null);
|
assert (base !is null);
|
||||||
assert (low <= base.size ());
|
assert (low <= base.size ());
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
|
@ -2396,7 +2421,7 @@ class SliceStream : Stream {
|
||||||
// set the base stream, the low offset, and the high offset.
|
// set the base stream, the low offset, and the high offset.
|
||||||
this (Stream base, ulong low, ulong high)
|
this (Stream base, ulong low, ulong high)
|
||||||
in {
|
in {
|
||||||
assert (base !== null);
|
assert (base !is null);
|
||||||
assert (low <= high);
|
assert (low <= high);
|
||||||
assert (high <= base.size ());
|
assert (high <= base.size ());
|
||||||
}
|
}
|
||||||
|
@ -2583,12 +2608,11 @@ private bit ishexdigit(char c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard IO devices
|
// standard IO devices
|
||||||
File stdin, stdout, stderr;
|
deprecated File stdin, stdout, stderr;
|
||||||
|
|
||||||
version (Win32) {
|
version (Win32) {
|
||||||
// API imports
|
// API imports
|
||||||
private extern(Windows) {
|
private extern(Windows) {
|
||||||
private import std.c.windows.windows;
|
|
||||||
HANDLE GetStdHandle(DWORD);
|
HANDLE GetStdHandle(DWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
std/string.d
12
std/string.d
|
@ -199,12 +199,6 @@ deprecated char* toCharz(char[] string)
|
||||||
char* toStringz(char[] string)
|
char* toStringz(char[] string)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
if (string)
|
|
||||||
{
|
|
||||||
// No embedded 0's
|
|
||||||
for (uint i = 0; i < string.length; i++)
|
|
||||||
assert(string[i] != 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
out (result)
|
out (result)
|
||||||
{
|
{
|
||||||
|
@ -902,7 +896,7 @@ unittest
|
||||||
|
|
||||||
s2 = toupper(s1);
|
s2 = toupper(s1);
|
||||||
assert(cmp(s2, "FOL") == 0);
|
assert(cmp(s2, "FOL") == 0);
|
||||||
assert(s2 !== s1);
|
assert(s2 !is s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -958,7 +952,7 @@ unittest
|
||||||
|
|
||||||
s2 = capitalize(s1);
|
s2 = capitalize(s1);
|
||||||
assert(cmp(s2, "Fol") == 0);
|
assert(cmp(s2, "Fol") == 0);
|
||||||
assert(s2 !== s1);
|
assert(s2 !is s1);
|
||||||
|
|
||||||
s2 = capitalize(s1[0 .. 2]);
|
s2 = capitalize(s1[0 .. 2]);
|
||||||
assert(cmp(s2, "Fo") == 0);
|
assert(cmp(s2, "Fo") == 0);
|
||||||
|
@ -967,7 +961,7 @@ unittest
|
||||||
s1 = "fOl";
|
s1 = "fOl";
|
||||||
s2 = capitalize(s1);
|
s2 = capitalize(s1);
|
||||||
assert(cmp(s2, "Fol") == 0);
|
assert(cmp(s2, "Fol") == 0);
|
||||||
assert(s2 !== s1);
|
assert(s2 !is s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
25
std/thread.d
25
std/thread.d
|
@ -228,7 +228,7 @@ class Thread
|
||||||
{ Thread t;
|
{ Thread t;
|
||||||
|
|
||||||
t = allThreads[i];
|
t = allThreads[i];
|
||||||
if (t && t !== tthis && t.state == TS.RUNNING)
|
if (t && t !is tthis && t.state == TS.RUNNING)
|
||||||
t.pause();
|
t.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ class Thread
|
||||||
{ Thread t;
|
{ Thread t;
|
||||||
|
|
||||||
t = allThreads[i];
|
t = allThreads[i];
|
||||||
if (t && t !== tthis && t.state == TS.RUNNING)
|
if (t && t !is tthis && t.state == TS.RUNNING)
|
||||||
t.resume();
|
t.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -664,7 +664,7 @@ class Thread
|
||||||
{ Thread t;
|
{ Thread t;
|
||||||
|
|
||||||
t = allThreads[i];
|
t = allThreads[i];
|
||||||
if (t && t !== tthis && t.state == TS.RUNNING)
|
if (t && t !is tthis && t.state == TS.RUNNING)
|
||||||
{ int result;
|
{ int result;
|
||||||
|
|
||||||
result = pthread_kill(t.id, SIGUSR1);
|
result = pthread_kill(t.id, SIGUSR1);
|
||||||
|
@ -693,7 +693,7 @@ class Thread
|
||||||
{ Thread t;
|
{ Thread t;
|
||||||
|
|
||||||
t = allThreads[i];
|
t = allThreads[i];
|
||||||
if (t && t !== tthis && t.state == TS.RUNNING)
|
if (t && t !is tthis && t.state == TS.RUNNING)
|
||||||
t.resume();
|
t.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -776,7 +776,24 @@ class Thread
|
||||||
|
|
||||||
t.state = TS.RUNNING;
|
t.state = TS.RUNNING;
|
||||||
t.id = pthread_self();
|
t.id = pthread_self();
|
||||||
|
|
||||||
|
version (none)
|
||||||
|
{
|
||||||
|
// See discussion: http://autopackage.org/forums/viewtopic.php?t=22
|
||||||
|
static void** libc_stack_end;
|
||||||
|
|
||||||
|
if (libc_stack_end == libc_stack_end.init)
|
||||||
|
{
|
||||||
|
void* handle = dlopen(null, RTLD_NOW);
|
||||||
|
libc_stack_end = cast(void **)dlsym(handle, "__libc_stack_end");
|
||||||
|
dlclose(handle);
|
||||||
|
}
|
||||||
|
t.stackBottom = *libc_stack_end;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
t.stackBottom = cast(void*)__libc_stack_end;
|
t.stackBottom = cast(void*)__libc_stack_end;
|
||||||
|
}
|
||||||
|
|
||||||
assert(!allThreads[0]);
|
assert(!allThreads[0]);
|
||||||
allThreads[0] = t;
|
allThreads[0] = t;
|
||||||
|
|
|
@ -37,6 +37,7 @@ import std.regexp;
|
||||||
import std.random;
|
import std.random;
|
||||||
import std.date;
|
import std.date;
|
||||||
import std.dateparse;
|
import std.dateparse;
|
||||||
|
import std.cstream;
|
||||||
import std.stream;
|
import std.stream;
|
||||||
import std.utf;
|
import std.utf;
|
||||||
import std.uri;
|
import std.uri;
|
||||||
|
@ -67,7 +68,8 @@ printf("test2\n");
|
||||||
a.reverse; // adi
|
a.reverse; // adi
|
||||||
a.sort; // qsort
|
a.sort; // qsort
|
||||||
std.date.getUTCtime(); // date
|
std.date.getUTCtime(); // date
|
||||||
StreamError se = new StreamError(""); // stream
|
Exception e = new ReadException(""); // stream
|
||||||
|
din.eof(); // cstream
|
||||||
isValidDchar(cast(dchar)0); // utf
|
isValidDchar(cast(dchar)0); // utf
|
||||||
std.uri.ascii2hex(0); // uri
|
std.uri.ascii2hex(0); // uri
|
||||||
std.zlib.adler32(0,null); // D.zlib
|
std.zlib.adler32(0,null); // D.zlib
|
||||||
|
|
10
win32.mak
10
win32.mak
|
@ -65,7 +65,7 @@ OBJS= asserterror.obj deh.obj switch.obj complex.obj gcstats.obj \
|
||||||
Czlib.obj Dzlib.obj zip.obj process.obj registry.obj recls.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 \
|
socket.obj socketstream.obj loader.obj stdarg.obj format.obj stdio.obj \
|
||||||
perf.obj openrj.obj uni.obj winsock.obj oldsyserror.obj \
|
perf.obj openrj.obj uni.obj winsock.obj oldsyserror.obj \
|
||||||
errno.obj boxer.obj \
|
errno.obj boxer.obj cstream.obj \
|
||||||
ti_Aa.obj ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \
|
ti_Aa.obj ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \
|
||||||
ti_wchar.obj ti_uint.obj ti_short.obj ti_ushort.obj \
|
ti_wchar.obj ti_uint.obj ti_short.obj ti_ushort.obj \
|
||||||
ti_byte.obj ti_ubyte.obj ti_long.obj ti_ulong.obj ti_ptr.obj \
|
ti_byte.obj ti_ubyte.obj ti_long.obj ti_ulong.obj ti_ptr.obj \
|
||||||
|
@ -90,7 +90,8 @@ 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\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\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\format.d \
|
std\socket.d std\socketstream.d std\loader.d std\stdarg.d std\format.d \
|
||||||
std\stdio.d std\perf.d std\openrj.d std\uni.d std\boxer.d
|
std\stdio.d std\perf.d std\openrj.d std\uni.d std\boxer.d \
|
||||||
|
std\cstream.d
|
||||||
|
|
||||||
SRC_STD_C= std\c\process.d std\c\stdlib.d std\c\time.d std\c\stdio.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 std\c\stddef.d
|
std\c\math.d std\c\stdarg.d std\c\stddef.d
|
||||||
|
@ -445,6 +446,9 @@ compiler.obj : std\compiler.d
|
||||||
conv.obj : std\conv.d
|
conv.obj : std\conv.d
|
||||||
$(DMD) -c $(DFLAGS) std\conv.d
|
$(DMD) -c $(DFLAGS) std\conv.d
|
||||||
|
|
||||||
|
cstream.obj : std\cstream.d
|
||||||
|
$(DMD) -c $(DFLAGS) std\cstream.d
|
||||||
|
|
||||||
ctype.obj : std\ctype.d
|
ctype.obj : std\ctype.d
|
||||||
$(DMD) -c $(DFLAGS) std\ctype.d
|
$(DMD) -c $(DFLAGS) std\ctype.d
|
||||||
|
|
||||||
|
@ -521,7 +525,7 @@ stdio.obj : std\stdio.d
|
||||||
$(DMD) -c $(DFLAGS) std\stdio.d
|
$(DMD) -c $(DFLAGS) std\stdio.d
|
||||||
|
|
||||||
stream.obj : std\stream.d
|
stream.obj : std\stream.d
|
||||||
$(DMD) -c $(DFLAGS) std\stream.d
|
$(DMD) -c $(DFLAGS) -d std\stream.d
|
||||||
|
|
||||||
string.obj : std\string.d
|
string.obj : std\string.d
|
||||||
$(DMD) -c $(DFLAGS) std\string.d
|
$(DMD) -c $(DFLAGS) std\string.d
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue