libphobos: Merge upstream phobos 7948e0967.
Removes deprecated functions from std.string module. Reviewed-on: https://github.com/dlang/phobos/pull/7694 libphobos/ChangeLog: * src/MERGE: Merge upstream phobos 7948e0967.
This commit is contained in:
parent
ba009860ae
commit
4c4dfe21df
2 changed files with 1 additions and 268 deletions
|
@ -1,4 +1,4 @@
|
|||
021ae0df76727a32809a29887095ab7093489ea3
|
||||
7948e096735adbc093333da789fc28feadce24b0
|
||||
|
||||
The first line of this file holds the git revision number of the last
|
||||
merge done from the dlang/phobos repository.
|
||||
|
|
|
@ -5174,273 +5174,6 @@ body
|
|||
assert(buffer.data == "h5 rd");
|
||||
}
|
||||
|
||||
//@@@DEPRECATED_2.086@@@
|
||||
deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
|
||||
bool inPattern(S)(dchar c, in S pattern) @safe pure @nogc
|
||||
if (isSomeString!S)
|
||||
{
|
||||
bool result = false;
|
||||
int range = 0;
|
||||
dchar lastc;
|
||||
|
||||
foreach (size_t i, dchar p; pattern)
|
||||
{
|
||||
if (p == '^' && i == 0)
|
||||
{
|
||||
result = true;
|
||||
if (i + 1 == pattern.length)
|
||||
return (c == p); // or should this be an error?
|
||||
}
|
||||
else if (range)
|
||||
{
|
||||
range = 0;
|
||||
if (lastc <= c && c <= p || c == p)
|
||||
return !result;
|
||||
}
|
||||
else if (p == '-' && i > result && i + 1 < pattern.length)
|
||||
{
|
||||
range = 1;
|
||||
continue;
|
||||
}
|
||||
else if (c == p)
|
||||
return !result;
|
||||
lastc = p;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
deprecated
|
||||
@safe pure @nogc unittest
|
||||
{
|
||||
import std.conv : to;
|
||||
import std.exception : assertCTFEable;
|
||||
|
||||
assertCTFEable!(
|
||||
{
|
||||
assert(inPattern('x', "x") == 1);
|
||||
assert(inPattern('x', "y") == 0);
|
||||
assert(inPattern('x', string.init) == 0);
|
||||
assert(inPattern('x', "^y") == 1);
|
||||
assert(inPattern('x', "yxxy") == 1);
|
||||
assert(inPattern('x', "^yxxy") == 0);
|
||||
assert(inPattern('x', "^abcd") == 1);
|
||||
assert(inPattern('^', "^^") == 0);
|
||||
assert(inPattern('^', "^") == 1);
|
||||
assert(inPattern('^', "a^") == 1);
|
||||
assert(inPattern('x', "a-z") == 1);
|
||||
assert(inPattern('x', "A-Z") == 0);
|
||||
assert(inPattern('x', "^a-z") == 0);
|
||||
assert(inPattern('x', "^A-Z") == 1);
|
||||
assert(inPattern('-', "a-") == 1);
|
||||
assert(inPattern('-', "^A-") == 0);
|
||||
assert(inPattern('a', "z-a") == 1);
|
||||
assert(inPattern('z', "z-a") == 1);
|
||||
assert(inPattern('x', "z-a") == 0);
|
||||
});
|
||||
}
|
||||
|
||||
//@@@DEPRECATED_2.086@@@
|
||||
deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
|
||||
bool inPattern(S)(dchar c, S[] patterns) @safe pure @nogc
|
||||
if (isSomeString!S)
|
||||
{
|
||||
foreach (string pattern; patterns)
|
||||
{
|
||||
if (!inPattern(c, pattern))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//@@@DEPRECATED_2.086@@@
|
||||
deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
|
||||
size_t countchars(S, S1)(S s, in S1 pattern) @safe pure @nogc
|
||||
if (isSomeString!S && isSomeString!S1)
|
||||
{
|
||||
size_t count;
|
||||
foreach (dchar c; s)
|
||||
{
|
||||
count += inPattern(c, pattern);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
deprecated
|
||||
@safe pure @nogc unittest
|
||||
{
|
||||
import std.conv : to;
|
||||
import std.exception : assertCTFEable;
|
||||
|
||||
assertCTFEable!(
|
||||
{
|
||||
assert(countchars("abc", "a-c") == 3);
|
||||
assert(countchars("hello world", "or") == 3);
|
||||
});
|
||||
}
|
||||
|
||||
//@@@DEPRECATED_2.086@@@
|
||||
deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
|
||||
S removechars(S)(S s, in S pattern) @safe pure
|
||||
if (isSomeString!S)
|
||||
{
|
||||
import std.utf : encode;
|
||||
|
||||
Unqual!(typeof(s[0]))[] r;
|
||||
bool changed = false;
|
||||
|
||||
foreach (size_t i, dchar c; s)
|
||||
{
|
||||
if (inPattern(c, pattern))
|
||||
{
|
||||
if (!changed)
|
||||
{
|
||||
changed = true;
|
||||
r = s[0 .. i].dup;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (changed)
|
||||
{
|
||||
encode(r, c);
|
||||
}
|
||||
}
|
||||
if (changed)
|
||||
return r;
|
||||
else
|
||||
return s;
|
||||
}
|
||||
|
||||
deprecated
|
||||
@safe pure unittest
|
||||
{
|
||||
import std.conv : to;
|
||||
import std.exception : assertCTFEable;
|
||||
|
||||
assertCTFEable!(
|
||||
{
|
||||
assert(removechars("abc", "a-c").length == 0);
|
||||
assert(removechars("hello world", "or") == "hell wld");
|
||||
assert(removechars("hello world", "d") == "hello worl");
|
||||
assert(removechars("hah", "h") == "a");
|
||||
});
|
||||
}
|
||||
|
||||
deprecated
|
||||
@safe pure unittest
|
||||
{
|
||||
assert(removechars("abc", "x") == "abc");
|
||||
}
|
||||
|
||||
//@@@DEPRECATED_2.086@@@
|
||||
deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
|
||||
S squeeze(S)(S s, in S pattern = null)
|
||||
{
|
||||
import std.utf : encode, stride;
|
||||
|
||||
Unqual!(typeof(s[0]))[] r;
|
||||
dchar lastc;
|
||||
size_t lasti;
|
||||
int run;
|
||||
bool changed;
|
||||
|
||||
foreach (size_t i, dchar c; s)
|
||||
{
|
||||
if (run && lastc == c)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
else if (pattern is null || inPattern(c, pattern))
|
||||
{
|
||||
run = 1;
|
||||
if (changed)
|
||||
{
|
||||
if (r is null)
|
||||
r = s[0 .. lasti].dup;
|
||||
encode(r, c);
|
||||
}
|
||||
else
|
||||
lasti = i + stride(s, i);
|
||||
lastc = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
run = 0;
|
||||
if (changed)
|
||||
{
|
||||
if (r is null)
|
||||
r = s[0 .. lasti].dup;
|
||||
encode(r, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed ? ((r is null) ? s[0 .. lasti] : cast(S) r) : s;
|
||||
}
|
||||
|
||||
deprecated
|
||||
@system pure unittest
|
||||
{
|
||||
import std.conv : to;
|
||||
import std.exception : assertCTFEable;
|
||||
|
||||
assertCTFEable!(
|
||||
{
|
||||
string s;
|
||||
|
||||
assert(squeeze("hello") == "helo");
|
||||
|
||||
s = "abcd";
|
||||
assert(squeeze(s) is s);
|
||||
s = "xyzz";
|
||||
assert(squeeze(s).ptr == s.ptr); // should just be a slice
|
||||
|
||||
assert(squeeze("hello goodbyee", "oe") == "hello godbye");
|
||||
});
|
||||
}
|
||||
|
||||
//@@@DEPRECATED_2.086@@@
|
||||
deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.")
|
||||
S1 munch(S1, S2)(ref S1 s, S2 pattern) @safe pure @nogc
|
||||
{
|
||||
size_t j = s.length;
|
||||
foreach (i, dchar c; s)
|
||||
{
|
||||
if (!inPattern(c, pattern))
|
||||
{
|
||||
j = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
scope(exit) s = s[j .. $];
|
||||
return s[0 .. j];
|
||||
}
|
||||
|
||||
///
|
||||
deprecated
|
||||
@safe pure @nogc unittest
|
||||
{
|
||||
string s = "123abc";
|
||||
string t = munch(s, "0123456789");
|
||||
assert(t == "123" && s == "abc");
|
||||
t = munch(s, "0123456789");
|
||||
assert(t == "" && s == "abc");
|
||||
}
|
||||
|
||||
deprecated
|
||||
@safe pure @nogc unittest
|
||||
{
|
||||
string s = "123€abc";
|
||||
string t = munch(s, "0123456789");
|
||||
assert(t == "123" && s == "€abc");
|
||||
t = munch(s, "0123456789");
|
||||
assert(t == "" && s == "€abc");
|
||||
t = munch(s, "£$€¥");
|
||||
assert(t == "€" && s == "abc");
|
||||
}
|
||||
|
||||
|
||||
/**********************************************
|
||||
* Return string that is the 'successor' to s[].
|
||||
* If the rightmost character is a-zA-Z0-9, it is incremented within
|
||||
|
|
Loading…
Add table
Reference in a new issue