Remove stream from phobos

did went through the deprecation cycle and is scheduled to be remove Oct 2016

forgot some places

another tiny fix

fixing win32/64 I hope

another unittest file removed
This commit is contained in:
Robert burner Schadek 2016-09-20 11:17:34 +02:00
parent b97f0050be
commit 871145fd4c
8 changed files with 4 additions and 3745 deletions

View file

@ -504,10 +504,7 @@ $(COMMENT
)
$(TR
$(TDNW
$(LINK2 std_cstream.html, std.cstream)$(BR)
$(LINK2 std_mmfile.html, std.mmfile)$(BR)
$(LINK2 std_socketstream.html, std.socketstream)$(BR)
$(LINK2 std_stream.html, std.stream)$(BR)
$(LINK2 std_typetuple.html, std.typetuple)$(BR)
)
$(TD

View file

@ -169,10 +169,10 @@ STD_PACKAGES = std $(addprefix std/,\
# Modules broken down per package
PACKAGE_std = array ascii base64 bigint bitmanip compiler complex concurrency \
conv cstream csv datetime demangle encoding exception file format \
conv csv datetime demangle encoding exception file format \
functional getopt json math mathspecial meta mmfile numeric \
outbuffer parallelism path process random signals socket socketstream stdint \
stdio stdiobase stream string system traits typecons typetuple uni \
outbuffer parallelism path process random signals socket stdint \
stdio stdiobase string system traits typecons typetuple uni \
uri utf uuid variant xml zip zlib
PACKAGE_std_experimental = typecons
PACKAGE_std_algorithm = comparison iteration mutation package searching setops \

View file

@ -1,252 +0,0 @@
// Written in the D programming language.
/**
* $(RED Deprecated: This module is considered out-dated and not up to Phobos'
* current standards. It will be remove in October 2016.)
*
* The std.cstream module bridges core.stdc.stdio (or std.stdio) and std.stream.
* Both core.stdc.stdio and std.stream are publicly imported by std.cstream.
*
* Copyright: Copyright Ben Hinkle 2007 - 2009.
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Ben Hinkle
* Source: $(PHOBOSSRC std/_cstream.d)
*/
/* Copyright Ben Hinkle 2007 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
deprecated(
"It will be removed from Phobos in October 2016. If you still need it, go to https://github.com/DigitalMars/undeaD"
) module std.cstream;
// @@@DEPRECATED_2016-10@@@
public import core.stdc.stdio;
public import std.stream;
version(unittest) import std.stdio;
import std.algorithm;
/**
* A Stream wrapper for a C file of type FILE*.
*/
class CFile : Stream {
protected FILE* cfile;
/**
* Create the stream wrapper for the given C file.
* Params:
* cfile = a valid C $(B FILE) pointer to wrap.
* mode = a bitwise combination of $(B FileMode.In) for a readable file
* and $(B FileMode.Out) for a writeable file.
* seekable = indicates if the stream should be _seekable.
*/
this(FILE* cfile, FileMode mode, bool seekable = false) {
super();
this.file = cfile;
readable = cast(bool)(mode & FileMode.In);
writeable = cast(bool)(mode & FileMode.Out);
this.seekable = seekable;
}
/**
* Closes the stream.
*/
~this() { close(); }
/**
* Property to get or set the underlying file for this stream.
* Setting the file marks the stream as open.
*/
@property FILE* file() { return cfile; }
/**
* Ditto
*/
@property void file(FILE* cfile) {
this.cfile = cfile;
isopen = true;
}
/**
* Overrides of the $(B Stream) methods to call the underlying $(B FILE*)
* C functions.
*/
override void flush() { fflush(cfile); }
/**
* Ditto
*/
override void close() {
if (isopen)
fclose(cfile);
isopen = readable = writeable = seekable = false;
}
/**
* Ditto
*/
override bool eof() {
return cast(bool)(readEOF || feof(cfile));
}
/**
* Ditto
*/
override char getc() {
return cast(char)fgetc(cfile);
}
/**
* Ditto
*/
override char ungetc(char c) {
return cast(char)core.stdc.stdio.ungetc(c,cfile);
}
/**
* Ditto
*/
override size_t readBlock(void* buffer, size_t size) {
size_t n = fread(buffer,1,size,cfile);
readEOF = cast(bool)(n == 0);
return n;
}
/**
* Ditto
*/
override size_t writeBlock(const void* buffer, size_t size) {
return fwrite(buffer,1,size,cfile);
}
/**
* Ditto
*/
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);
}
/**
* Ditto
*/
override void writeLine(const(char)[] s) {
writeString(s);
writeString("\n");
}
/**
* Ditto
*/
override void writeLineW(const(wchar)[] s) {
writeStringW(s);
writeStringW("\n");
}
// run a few tests
unittest
{
import std.file : deleteme;
import std.internal.cstring : tempCString;
auto stream_file = (deleteme ~ "-stream.txt").tempCString();
FILE* f = fopen(stream_file,"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 (Windows)
assert(file.position == 19 + 13 + 4);
version (Posix)
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_file,"r");
file = new CFile(f,FileMode.In,true);
// should be ok to read
assert(file.readable);
auto line = file.readLine();
auto exp = "Testing stream.d:";
assert(line[0] == 'T');
assert(line.length == exp.length);
assert(!std.algorithm.cmp(line, "Testing stream.d:"));
// jump over "Hello, "
file.seek(7, SeekPos.Current);
version (Windows)
assert(file.position == 19 + 7);
version (Posix)
assert(file.position == 18 + 7);
assert(!std.algorithm.cmp(file.readString(6), "world!"));
i = 0; file.read(i);
assert(i == 666);
// string#1 + string#2 + int should give exacly that
version (Windows)
assert(file.position == 19 + 13 + 4);
version (Posix)
assert(file.position == 18 + 13 + 4);
// we must be at the end of file
file.close();
f = fopen(stream_file,"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[cast(size_t)(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_file);
}
}
/**
* CFile wrapper of core.stdc.stdio.stdin (not seekable).
*/
__gshared CFile din;
/**
* CFile wrapper of core.stdc.stdio.stdout (not seekable).
*/
__gshared CFile dout;
/**
* CFile wrapper of core.stdc.stdio.stderr (not seekable).
*/
__gshared CFile derr;
shared static this() {
// open standard I/O devices
din = new CFile(core.stdc.stdio.stdin,FileMode.In);
dout = new CFile(core.stdc.stdio.stdout,FileMode.Out);
derr = new CFile(core.stdc.stdio.stderr,FileMode.Out);
}

View file

@ -1,147 +0,0 @@
// Written in the D programming language
/*
Copyright (C) 2004 Christopher E. Miller
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:
1. 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.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/**************
* $(RED Deprecated: This module is considered out-dated and not up to Phobos'
* current standards. It will be remove in October 2016.)
*
* $(D SocketStream) is a stream for a blocking,
* connected $(D Socket).
*
* Example:
* See $(SAMPLESRC htmlget.d)
* Authors: Christopher E. Miller
* References:
* $(MREF std, stream)
* Source: $(PHOBOSSRC std/_socketstream.d)
*/
deprecated("It will be removed from Phobos in October 2016. If you still need it, go to https://github.com/DigitalMars/undeaD") module std.socketstream;
// @@@DEPRECATED_2016-10@@@
private import std.stream;
private import std.socket;
/**************
* $(D SocketStream) is a stream for a blocking,
* connected $(D Socket).
*/
class SocketStream: Stream
{
private:
Socket sock;
public:
/**
* Constructs a SocketStream with the specified Socket and FileMode flags.
*/
this(Socket sock, FileMode mode)
{
if (mode & FileMode.In)
readable = true;
if (mode & FileMode.Out)
writeable = true;
this.sock = sock;
}
/**
* Uses mode $(D FileMode.In | FileMode.Out).
*/
this(Socket sock)
{
writeable = readable = true;
this.sock = sock;
}
/**
* Property to get the $(D Socket) that is being streamed.
*/
Socket socket()
{
return sock;
}
/**
* Attempts to read the entire block, waiting if necessary.
*/
override size_t readBlock(void* _buffer, size_t size)
{
ubyte* buffer = cast(ubyte*)_buffer;
assertReadable();
if (size == 0)
return size;
auto len = sock.receive(buffer[0 .. size]);
readEOF = cast(bool)(len == 0);
if (len == sock.ERROR)
len = 0;
return len;
}
/**
* Attempts to write the entire block, waiting if necessary.
*/
override size_t writeBlock(const void* _buffer, size_t size)
{
ubyte* buffer = cast(ubyte*)_buffer;
assertWriteable();
if (size == 0)
return size;
auto len = sock.send(buffer[0 .. size]);
readEOF = cast(bool)(len == 0);
if (len == sock.ERROR)
len = 0;
return len;
}
/**
* Socket streams do not support seeking. This disabled method throws
* a $(D SeekException).
*/
@disable override ulong seek(long offset, SeekPos whence)
{
throw new SeekException("Cannot seek a socket.");
}
/**
* Does not return the entire stream because that would
* require the remote connection to be closed.
*/
override string toString()
{
return sock.toString();
}
/**
* Close the $(D Socket).
*/
override void close()
{
sock.close();
super.close();
}
}

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,6 @@ public import std.compiler;
public import std.concurrency;
public import std.conv;
public import std.container;
public import std.cstream;
public import std.datetime;
public import std.demangle;
public import std.file;
@ -37,10 +36,8 @@ public import std.regex;
public import std.signals;
//public import std.slist;
public import std.socket;
public import std.socketstream;
public import std.stdint;
public import std.stdio;
public import std.stream;
public import std.string;
public import std.system;
public import std.traits;
@ -77,8 +74,6 @@ int main(string[] args)
reverse(a); // adi
sort(a); // qsort
Clock.currTime(); // datetime
Exception e = new ReadException(""); // stream
din.eof(); // cstream
cast(void)isValidDchar(cast(dchar)0); // utf
std.uri.ascii2hex(0); // uri
std.zlib.adler32(0,null); // D.zlib

View file

@ -159,12 +159,9 @@ SRC_STD_4= \
SRC_STD_6= \
std\variant.d \
std\zlib.d \
std\stream.d \
std\socket.d \
std\socketstream.d \
std\conv.d \
std\zip.d \
std\cstream.d
std\zip.d
SRC_STD_7= \
std\stdint.d \
@ -456,7 +453,6 @@ DOCS= \
$(DOC)\std_digest_hmac.html \
$(DOC)\std_digest_digest.html \
$(DOC)\std_digest_hmac.html \
$(DOC)\std_cstream.html \
$(DOC)\std_csv.html \
$(DOC)\std_datetime.html \
$(DOC)\std_demangle.html \
@ -483,10 +479,8 @@ DOCS= \
$(DOC)\std_regex.html \
$(DOC)\std_signals.html \
$(DOC)\std_socket.html \
$(DOC)\std_socketstream.html \
$(DOC)\std_stdint.html \
$(DOC)\std_stdio.html \
$(DOC)\std_stream.html \
$(DOC)\std_string.html \
$(DOC)\std_system.html \
$(DOC)\std_traits.html \
@ -664,9 +658,7 @@ cov : $(SRC_TO_COMPILE) $(LIB)
$(DMD) -conf= -cov=95 -unittest -main -run std\algorithm\sorting.d
$(DMD) -conf= -cov=83 -unittest -main -run std\variant.d
$(DMD) -conf= -cov=58 -unittest -main -run std\zlib.d
$(DMD) -conf= -cov=54 -unittest -main -run std\stream.d
$(DMD) -conf= -cov=53 -unittest -main -run std\socket.d
$(DMD) -conf= -cov=0 -unittest -main -run std\socketstream.d
$(DMD) -conf= -cov=95 -unittest -main -run std\container\array.d
$(DMD) -conf= -cov=68 -unittest -main -run std\container\binaryheap.d
$(DMD) -conf= -cov=91 -unittest -main -run std\container\dlist.d
@ -676,7 +668,6 @@ cov : $(SRC_TO_COMPILE) $(LIB)
$(DMD) -conf= -cov=100 -unittest -main -run std\container\package.d
$(DMD) -conf= -cov=90 -unittest -main -run std\conv.d
$(DMD) -conf= -cov=0 -unittest -main -run std\zip.d
$(DMD) -conf= -cov=92 -unittest -main -run std\cstream.d
$(DMD) -conf= -cov=77 -unittest -main -run std\regex\tests.d
$(DMD) -conf= -cov=92 -unittest -main -run std\json.d
$(DMD) -conf= -cov=87 -unittest -main -run std\parallelism.d
@ -842,9 +833,6 @@ $(DOC)\std_range_primitives.html : $(STDDOC) std\range\primitives.d
$(DOC)\std_range_interfaces.html : $(STDDOC) std\range\interfaces.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_range_interfaces.html $(STDDOC) std\range\interfaces.d
$(DOC)\std_cstream.html : $(STDDOC) std\cstream.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_cstream.html $(STDDOC) std\cstream.d
$(DOC)\std_csv.html : $(STDDOC) std\csv.d
$(DMD) -c -o- $(DFLAGS) -Df$(DOC)\std_csv.html $(STDDOC) std\csv.d
@ -914,18 +902,12 @@ $(DOC)\std_signals.html : $(STDDOC) std\signals.d
$(DOC)\std_socket.html : $(STDDOC) std\socket.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_socket.html $(STDDOC) std\socket.d
$(DOC)\std_socketstream.html : $(STDDOC) std\socketstream.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_socketstream.html $(STDDOC) std\socketstream.d
$(DOC)\std_stdint.html : $(STDDOC) std\stdint.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_stdint.html $(STDDOC) std\stdint.d
$(DOC)\std_stdio.html : $(STDDOC) std\stdio.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_stdio.html $(STDDOC) std\stdio.d
$(DOC)\std_stream.html : $(STDDOC) std\stream.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_stream.html $(STDDOC) std\stream.d
$(DOC)\std_string.html : $(STDDOC) std\string.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_string.html $(STDDOC) std\string.d

View file

@ -166,12 +166,9 @@ SRC_STD_4= \
SRC_STD_6a=std\variant.d
SRC_STD_6c=std\zlib.d
SRC_STD_6d=std\stream.d
SRC_STD_6e=std\socket.d
SRC_STD_6f=std\socketstream.d
SRC_STD_6h=std\conv.d
SRC_STD_6i=std\zip.d
SRC_STD_6j=std\cstream.d
SRC_STD_7= \
std\stdint.d \
@ -191,12 +188,9 @@ SRC_STD= \
$(SRC_STD_4) \
$(SRC_STD_6a) \
$(SRC_STD_6c) \
$(SRC_STD_6d) \
$(SRC_STD_6e) \
$(SRC_STD_6f) \
$(SRC_STD_6h) \
$(SRC_STD_6i) \
$(SRC_STD_6j) \
$(SRC_STD_7)
SRC_STD_ALGO_1= \
@ -478,7 +472,6 @@ DOCS= \
$(DOC)\std_digest_hmac.html \
$(DOC)\std_digest_digest.html \
$(DOC)\std_digest_hmac.html \
$(DOC)\std_cstream.html \
$(DOC)\std_csv.html \
$(DOC)\std_datetime.html \
$(DOC)\std_demangle.html \
@ -505,10 +498,8 @@ DOCS= \
$(DOC)\std_regex.html \
$(DOC)\std_signals.html \
$(DOC)\std_socket.html \
$(DOC)\std_socketstream.html \
$(DOC)\std_stdint.html \
$(DOC)\std_stdio.html \
$(DOC)\std_stream.html \
$(DOC)\std_string.html \
$(DOC)\std_system.html \
$(DOC)\std_traits.html \
@ -596,9 +587,7 @@ UNITTEST_OBJS= \
unittest5b.obj \
unittest6a.obj \
unittest6c.obj \
unittest6d.obj \
unittest6e.obj \
unittest6f.obj \
unittest6g.obj \
unittest6h.obj \
unittest6i.obj \
@ -627,13 +616,10 @@ unittest : $(LIB)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest5b.obj $(SRC_STD_ALGO_2)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest6a.obj $(SRC_STD_6a)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest6c.obj $(SRC_STD_6c)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest6d.obj $(SRC_STD_6d)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest6e.obj $(SRC_STD_6e)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest6f.obj $(SRC_STD_6f)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest6g.obj $(SRC_STD_CONTAINER)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest6h.obj $(SRC_STD_6h)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest6i.obj $(SRC_STD_6i)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest6j.obj $(SRC_STD_6j)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest7.obj $(SRC_STD_7) $(SRC_STD_EXP_LOGGER)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest8a.obj $(SRC_STD_REGEX)
$(DMD) $(UDFLAGS) -c -unittest -ofunittest8b.obj $(SRC_STD_NET)
@ -820,9 +806,6 @@ $(DOC)\std_range_primitives.html : $(STDDOC) std\range\primitives.d
$(DOC)\std_range_interfaces.html : $(STDDOC) std\range\interfaces.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_range_interfaces.html $(STDDOC) std\range\interfaces.d
$(DOC)\std_cstream.html : $(STDDOC) std\cstream.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_cstream.html $(STDDOC) std\cstream.d
$(DOC)\std_csv.html : $(STDDOC) std\csv.d
$(DMD) -c -o- $(DFLAGS) -Df$(DOC)\std_csv.html $(STDDOC) std\csv.d
@ -892,18 +875,12 @@ $(DOC)\std_signals.html : $(STDDOC) std\signals.d
$(DOC)\std_socket.html : $(STDDOC) std\socket.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_socket.html $(STDDOC) std\socket.d
$(DOC)\std_socketstream.html : $(STDDOC) std\socketstream.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_socketstream.html $(STDDOC) std\socketstream.d
$(DOC)\std_stdint.html : $(STDDOC) std\stdint.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_stdint.html $(STDDOC) std\stdint.d
$(DOC)\std_stdio.html : $(STDDOC) std\stdio.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_stdio.html $(STDDOC) std\stdio.d
$(DOC)\std_stream.html : $(STDDOC) std\stream.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_stream.html $(STDDOC) std\stream.d
$(DOC)\std_string.html : $(STDDOC) std\string.d
$(DMD) -c -o- $(DDOCFLAGS) -Df$(DOC)\std_string.html $(STDDOC) std\string.d