Commit 9fa27ed0 by Iain Buclaw

libphobos: Merge phobos upstream b022e552a

This removes updates the removal date of all deprecations in phobos.
Many of the marked functions have passed their end dates, and are now
absent in upstream.

Reviewed-on: https://github.com/dlang/phobos/pull/6828

From-SVN: r267788
parent 9ed7e53d
b022e552aaca84810e3dda3a18179440943c7096
The first line of this file holds the git revision number of the last
merge done from the dlang/phobos repository.
...@@ -76,7 +76,6 @@ Source: $(PHOBOSSRC std/_array.d) ...@@ -76,7 +76,6 @@ Source: $(PHOBOSSRC std/_array.d)
*/ */
module std.array; module std.array;
static import std.algorithm.iteration; // FIXME, remove with alias of splitter
import std.functional; import std.functional;
import std.meta; import std.meta;
import std.traits; import std.traits;
...@@ -1465,6 +1464,7 @@ if (isSomeString!S) ...@@ -1465,6 +1464,7 @@ if (isSomeString!S)
{ {
import std.ascii : isWhite; import std.ascii : isWhite;
import std.algorithm.comparison : equal; import std.algorithm.comparison : equal;
import std.algorithm.iteration : splitter;
string str = "Hello World!"; string str = "Hello World!";
assert(str.splitter!(isWhite).equal(["Hello", "World!"])); assert(str.splitter!(isWhite).equal(["Hello", "World!"]));
...@@ -1524,10 +1524,6 @@ if (isSomeString!S) ...@@ -1524,10 +1524,6 @@ if (isSomeString!S)
assert(a == [[1], [4, 5, 1], [4, 5]]); assert(a == [[1], [4, 5, 1], [4, 5]]);
} }
// Explicitly undocumented. It will be removed in January 2018. @@@DEPRECATED_2018-01@@@
deprecated("Please use std.algorithm.iteration.splitter instead.")
alias splitter = std.algorithm.iteration.splitter;
/++ /++
Eagerly splits $(D range) into an array, using $(D sep) as the delimiter. Eagerly splits $(D range) into an array, using $(D sep) as the delimiter.
......
...@@ -3865,20 +3865,10 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && ...@@ -3865,20 +3865,10 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) &&
string text(T...)(T args) string text(T...)(T args)
if (T.length > 0) { return textImpl!string(args); } if (T.length > 0) { return textImpl!string(args); }
// @@@DEPRECATED_2018-06@@@
deprecated("Calling `text` with 0 arguments is deprecated")
string text(T...)(T args)
if (T.length == 0) { return textImpl!string(args); }
///ditto ///ditto
wstring wtext(T...)(T args) wstring wtext(T...)(T args)
if (T.length > 0) { return textImpl!wstring(args); } if (T.length > 0) { return textImpl!wstring(args); }
// @@@DEPRECATED_2018-06@@@
deprecated("Calling `wtext` with 0 arguments is deprecated")
wstring wtext(T...)(T args)
if (T.length == 0) { return textImpl!wstring(args); }
///ditto ///ditto
dstring dtext(T...)(T args) dstring dtext(T...)(T args)
if (T.length > 0) { return textImpl!dstring(args); } if (T.length > 0) { return textImpl!dstring(args); }
...@@ -3891,10 +3881,24 @@ if (T.length > 0) { return textImpl!dstring(args); } ...@@ -3891,10 +3881,24 @@ if (T.length > 0) { return textImpl!dstring(args); }
assert(dtext(42, ' ', 1.5, ": xyz") == "42 1.5: xyz"d); assert(dtext(42, ' ', 1.5, ": xyz") == "42 1.5: xyz"d);
} }
// @@@DEPRECATED_2018-06@@@ @safe unittest
deprecated("Calling `dtext` with 0 arguments is deprecated") {
dstring dtext(T...)(T args) char c = 'h';
if (T.length == 0) { return textImpl!dstring(args); } wchar w = '你';
dchar d = 'እ';
assert( text(c, "ello", ' ', w, "好 ", d, "ው ሰላም ነው") == "hello 你好 እው ሰላም ነው"c);
assert(wtext(c, "ello", ' ', w, "好 ", d, "ው ሰላም ነው") == "hello 你好 እው ሰላም ነው"w);
assert(dtext(c, "ello", ' ', w, "好 ", d, "ው ሰላም ነው") == "hello 你好 እው ሰላም ነው"d);
string cs = "今日は";
wstring ws = "여보세요";
dstring ds = "Здравствуйте";
assert( text(cs, ' ', ws, " ", ds) == "今日は 여보세요 Здравствуйте"c);
assert(wtext(cs, ' ', ws, " ", ds) == "今日は 여보세요 Здравствуйте"w);
assert(dtext(cs, ' ', ws, " ", ds) == "今日は 여보세요 Здравствуйте"d);
}
private S textImpl(S, U...)(U args) private S textImpl(S, U...)(U args)
{ {
......
...@@ -403,10 +403,7 @@ Duration[fun.length] benchmark(fun...)(uint n) ...@@ -403,10 +403,7 @@ Duration[fun.length] benchmark(fun...)(uint n)
void f0() nothrow {} void f0() nothrow {}
void f1() nothrow { auto b = to!string(a); } void f1() nothrow { auto b = to!string(a); }
auto r = benchmark!(f0, f1)(1000); auto r = benchmark!(f0, f1)(1000);
version (GNU) assert(r[0] >= Duration.zero);
assert(r[0] >= Duration.zero);
else
assert(r[0] > Duration.zero);
assert(r[1] > Duration.zero); assert(r[1] > Duration.zero);
assert(r[1] > r[0]); assert(r[1] > r[0]);
assert(r[0] < seconds(1)); assert(r[0] < seconds(1));
......
...@@ -14,8 +14,7 @@ version (Windows): ...@@ -14,8 +14,7 @@ version (Windows):
import core.sys.windows.windows; import core.sys.windows.windows;
version (GNU) {} pragma(lib, "advapi32.lib");
else pragma(lib, "advapi32.lib");
immutable bool isWow64; immutable bool isWow64;
......
...@@ -1123,14 +1123,6 @@ if (isInputRange!T && !isInfinite!T && isSomeChar!(ElementEncodingType!T)) ...@@ -1123,14 +1123,6 @@ if (isInputRange!T && !isInfinite!T && isSomeChar!(ElementEncodingType!T))
return parseJSON!T(json, -1, options); return parseJSON!T(json, -1, options);
} }
deprecated(
"Please use the overload that takes a ref JSONValue rather than a pointer. This overload will "
~ "be removed in November 2017.")
string toJSON(in JSONValue* root, in bool pretty = false, in JSONOptions options = JSONOptions.none) @safe
{
return toJSON(*root, pretty, options);
}
/** /**
Takes a tree of JSON values and returns the serialized string. Takes a tree of JSON values and returns the serialized string.
......
...@@ -3966,8 +3966,7 @@ version (Windows) ...@@ -3966,8 +3966,7 @@ version (Windows)
{ {
import core.sys.windows.windows; import core.sys.windows.windows;
version (GNU) {} pragma(lib,"shell32.lib");
else pragma(lib,"shell32.lib");
void browse(const(char)[] url) void browse(const(char)[] url)
{ {
......
...@@ -1388,41 +1388,13 @@ This is because a narrow string's length does not reflect the number of ...@@ -1388,41 +1388,13 @@ This is because a narrow string's length does not reflect the number of
characters, but instead the number of encoding units, and as such is not useful characters, but instead the number of encoding units, and as such is not useful
with range-oriented algorithms. To use strings as random-access ranges with with range-oriented algorithms. To use strings as random-access ranges with
length, use $(REF representation, std, string) or $(REF byCodeUnit, std, utf). length, use $(REF representation, std, string) or $(REF byCodeUnit, std, utf).
Deprecation: Historically `hasLength!R` yielded `true` for types whereby
`R.length` returns other types convertible to `ulong`, such as `int`, `ushort`,
`const(size_t)`, user-defined types using `alias this`, or notably `ulong` on
32-bit systems. This behavior has been deprecated. After December 2017,
`hasLength` will yield `true` only if `R.length` yields the exact type `size_t`.
*/ */
template hasLength(R) template hasLength(R)
{ {
static if (is(typeof(((R* r) => r.length)(null)) Length)) static if (is(typeof(((R* r) => r.length)(null)) Length))
{ enum bool hasLength = is(Length == size_t) && !isNarrowString!R;
static if (is(Length == size_t))
{
enum bool hasLength = !isNarrowString!R;
}
else static if (is(Length : ulong))
{
// @@@DEPRECATED_2017-12@@@
// Uncomment the deprecated(...) message and take the pragma(msg)
// out once https://issues.dlang.org/show_bug.cgi?id=10181 is fixed.
pragma(msg, __FILE__ ~ "(" ~ __LINE__.stringof ~
"): Note: length must have type size_t on all systems" ~
", please update your code by December 2017.");
//deprecated("length must have type size_t on all systems")
enum bool hasLength = true;
}
else
{
enum bool hasLength = false;
}
}
else else
{
enum bool hasLength = false; enum bool hasLength = false;
}
} }
/// ///
...@@ -1432,12 +1404,41 @@ template hasLength(R) ...@@ -1432,12 +1404,41 @@ template hasLength(R)
static assert( hasLength!(int[])); static assert( hasLength!(int[]));
static assert( hasLength!(inout(int)[])); static assert( hasLength!(inout(int)[]));
struct A { ulong length; } struct A { size_t length() { return 0; } }
struct B { size_t length() { return 0; } } struct B { @property size_t length() { return 0; } }
struct C { @property size_t length() { return 0; } }
static assert( hasLength!(A)); static assert( hasLength!(A));
static assert( hasLength!(B)); static assert( hasLength!(B));
static assert( hasLength!(C)); }
// test combinations which are invalid on some platforms
unittest
{
struct A { ulong length; }
struct B { @property uint length() { return 0; } }
version (X86)
{
static assert(!hasLength!(A));
static assert(hasLength!(B));
}
else version(X86_64)
{
static assert(hasLength!(A));
static assert(!hasLength!(B));
}
}
// test combinations which are invalid on all platforms
unittest
{
struct A { long length; }
struct B { int length; }
struct C { ubyte length; }
struct D { char length; }
static assert(!hasLength!(A));
static assert(!hasLength!(B));
static assert(!hasLength!(C));
static assert(!hasLength!(D));
} }
/** /**
......
...@@ -57,12 +57,8 @@ import std.internal.cstring; ...@@ -57,12 +57,8 @@ import std.internal.cstring;
version (Windows) version (Windows)
{ {
version (GNU) {} pragma (lib, "ws2_32.lib");
else pragma (lib, "wsock32.lib");
{
pragma (lib, "ws2_32.lib");
pragma (lib, "wsock32.lib");
}
import core.sys.windows.windows, std.windows.syserror; import core.sys.windows.windows, std.windows.syserror;
public import core.sys.windows.winsock2; public import core.sys.windows.winsock2;
......
...@@ -5174,30 +5174,8 @@ body ...@@ -5174,30 +5174,8 @@ body
assert(buffer.data == "h5 rd"); assert(buffer.data == "h5 rd");
} }
//@@@DEPRECATED_2018-05@@@ //@@@DEPRECATED_2.086@@@
/*********************************************** deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
* $(RED This function is deprecated and will be removed May 2018.)
* Please use the functions in $(MREF std, regex) and $(MREF std, algorithm)
* instead. If you still need this function, it will be available in
* $(LINK2 https://github.com/dlang/undeaD, undeaD).
*
* See if character c is in the pattern.
* Patterns:
*
* A $(I pattern) is an array of characters much like a $(I character
* class) in regular expressions. A sequence of characters
* can be given, such as "abcde". The '-' can represent a range
* of characters, as "a-e" represents the same pattern as "abcde".
* "a-fA-F0-9" represents all the hex characters.
* If the first character of a pattern is '^', then the pattern
* is negated, i.e. "^0-9" means any character except a digit.
* The functions inPattern, $(B countchars), $(B removeschars),
* and $(B squeeze) use patterns.
*
* Note: In the future, the pattern syntax may be improved
* to be more like regular expression character classes.
*/
deprecated("This function is obsolete and will be removed May 2018. See the docs for more details")
bool inPattern(S)(dchar c, in S pattern) @safe pure @nogc bool inPattern(S)(dchar c, in S pattern) @safe pure @nogc
if (isSomeString!S) if (isSomeString!S)
{ {
...@@ -5262,16 +5240,8 @@ deprecated ...@@ -5262,16 +5240,8 @@ deprecated
}); });
} }
//@@@DEPRECATED_2018-05@@@ //@@@DEPRECATED_2.086@@@
/*********************************************** deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
* $(RED This function is deprecated and will be removed May 2018.)
* Please use the functions in $(MREF std, regex) and $(MREF std, algorithm)
* instead. If you still need this function, it will be available in
* $(LINK2 https://github.com/dlang/undeaD, undeaD).
*
* See if character c is in the intersection of the patterns.
*/
deprecated("This function is obsolete and will be removed May 2018. See the docs for more details")
bool inPattern(S)(dchar c, S[] patterns) @safe pure @nogc bool inPattern(S)(dchar c, S[] patterns) @safe pure @nogc
if (isSomeString!S) if (isSomeString!S)
{ {
...@@ -5285,16 +5255,8 @@ if (isSomeString!S) ...@@ -5285,16 +5255,8 @@ if (isSomeString!S)
return true; return true;
} }
//@@@DEPRECATED_2018-05@@@ //@@@DEPRECATED_2.086@@@
/******************************************** deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
* $(RED This function is deprecated and will be removed May 2018.)
* Please use the functions in $(MREF std, regex) and $(MREF std, algorithm)
* instead. If you still need this function, it will be available in
* $(LINK2 https://github.com/dlang/undeaD, undeaD).
*
* Count characters in s that match pattern.
*/
deprecated("This function is obsolete and will be removed May 2018. See the docs for more details")
size_t countchars(S, S1)(S s, in S1 pattern) @safe pure @nogc size_t countchars(S, S1)(S s, in S1 pattern) @safe pure @nogc
if (isSomeString!S && isSomeString!S1) if (isSomeString!S && isSomeString!S1)
{ {
...@@ -5319,16 +5281,8 @@ deprecated ...@@ -5319,16 +5281,8 @@ deprecated
}); });
} }
//@@@DEPRECATED_2018-05@@@ //@@@DEPRECATED_2.086@@@
/******************************************** deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
* $(RED This function is deprecated and will be removed May 2018.)
* Please use the functions in $(MREF std, regex) and $(MREF std, algorithm)
* instead. If you still need this function, it will be available in
* $(LINK2 https://github.com/dlang/undeaD, undeaD).
*
* Return string that is s with all characters removed that match pattern.
*/
deprecated("This function is obsolete and will be removed May 2018. See the docs for more details")
S removechars(S)(S s, in S pattern) @safe pure S removechars(S)(S s, in S pattern) @safe pure
if (isSomeString!S) if (isSomeString!S)
{ {
...@@ -5380,18 +5334,8 @@ deprecated ...@@ -5380,18 +5334,8 @@ deprecated
assert(removechars("abc", "x") == "abc"); assert(removechars("abc", "x") == "abc");
} }
//@@@DEPRECATED_2018-05@@@ //@@@DEPRECATED_2.086@@@
/*************************************************** deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
* $(RED This function is deprecated and will be removed May 2018.)
* Please use the functions in $(MREF std, regex) and $(MREF std, algorithm)
* instead. If you still need this function, it will be available in
* $(LINK2 https://github.com/dlang/undeaD, undeaD).
*
* Return string where sequences of a character in s[] from pattern[]
* are replaced with a single instance of that character.
* If pattern is null, it defaults to all characters.
*/
deprecated("This function is obsolete and will be removed May 2018. See the docs for more details")
S squeeze(S)(S s, in S pattern = null) S squeeze(S)(S s, in S pattern = null)
{ {
import std.utf : encode, stride; import std.utf : encode, stride;
...@@ -5456,24 +5400,8 @@ deprecated ...@@ -5456,24 +5400,8 @@ deprecated
}); });
} }
//@@@DEPRECATED_2018-05@@@ //@@@DEPRECATED_2.086@@@
/*************************************************************** deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
$(RED This function is deprecated and will be removed May 2018.)
Please use the functions in $(MREF std, regex) and $(MREF std, algorithm)
instead. If you still need this function, it will be available in
$(LINK2 https://github.com/dlang/undeaD, undeaD).
Finds the position $(D_PARAM pos) of the first character in $(D_PARAM
s) that does not match $(D_PARAM pattern) (in the terminology used by
$(REF inPattern, std,string)). Updates $(D_PARAM s =
s[pos..$]). Returns the slice from the beginning of the original
(before update) string up to, and excluding, $(D_PARAM pos).
The $(D_PARAM munch) function is mostly convenient for skipping
certain category of characters (e.g. whitespace) when parsing
strings. (In such cases, the return value is not used.)
*/
deprecated("This function is obsolete and will be removed May 2018. See the docs for more details")
S1 munch(S1, S2)(ref S1 s, S2 pattern) @safe pure @nogc S1 munch(S1, S2)(ref S1 s, S2 pattern) @safe pure @nogc
{ {
size_t j = s.length; size_t j = s.length;
......
...@@ -2699,14 +2699,6 @@ if (isSomeString!S) ...@@ -2699,14 +2699,6 @@ if (isSomeString!S)
}()); }());
} }
//@@@DEPRECATED_2017-10@@@
deprecated("To be removed November 2017. Please use std.utf.encode instead.")
char[] toUTF8(return out char[4] buf, dchar c) nothrow @nogc @safe pure
{
const sz = encode!(Yes.useReplacementDchar)(buf, c);
return buf[0 .. sz];
}
/** /**
* Encodes the elements of `s` to UTF-8 and returns a newly allocated * Encodes the elements of `s` to UTF-8 and returns a newly allocated
* string of the elements. * string of the elements.
...@@ -2748,14 +2740,6 @@ if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S)) ...@@ -2748,14 +2740,6 @@ if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S))
assert(r2.toUTF8.equal([0xF0, 0x90, 0x90, 0xB7])); assert(r2.toUTF8.equal([0xF0, 0x90, 0x90, 0xB7]));
} }
//@@@DEPRECATED_2017-10@@@
deprecated("To be removed November 2017. Please use std.utf.encode instead.")
wchar[] toUTF16(return ref wchar[2] buf, dchar c) nothrow @nogc @safe pure
{
const sz = encode!(Yes.useReplacementDchar)(buf, c);
return buf[0 .. sz];
}
/** /**
* Encodes the elements of `s` to UTF-16 and returns a newly GC allocated * Encodes the elements of `s` to UTF-16 and returns a newly GC allocated
* `wstring` of the elements. * `wstring` of the elements.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment