Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 42 additions & 10 deletions std/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -5230,8 +5230,13 @@ body
assert(buffer.data == "h5 rd");
}


//@@@DEPRECATED_2018-05@@@
/***********************************************
* $(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:
*
Expand All @@ -5248,7 +5253,7 @@ body
* 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
if (isSomeString!S)
{
Expand Down Expand Up @@ -5314,11 +5319,16 @@ if (isSomeString!S)
});
}


//@@@DEPRECATED_2018-05@@@
/***********************************************
* $(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
if (isSomeString!S)
{
Expand All @@ -5332,11 +5342,16 @@ if (isSomeString!S)
return true;
}


//@@@DEPRECATED_2018-05@@@
/********************************************
* $(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
if (isSomeString!S && isSomeString!S1)
{
Expand All @@ -5362,11 +5377,16 @@ if (isSomeString!S && isSomeString!S1)
});
}


//@@@DEPRECATED_2018-05@@@
/********************************************
* $(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
if (isSomeString!S)
{
Expand Down Expand Up @@ -5418,13 +5438,18 @@ if (isSomeString!S)
assert(removechars("abc", "x") == "abc");
}


//@@@DEPRECATED_2018-05@@@
/***************************************************
* $(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)
{
import std.utf : encode, stride;
Expand Down Expand Up @@ -5490,7 +5515,13 @@ S squeeze(S)(S s, in S pattern = null)
});
}

//@@@DEPRECATED_2018-05@@@
/***************************************************************
$(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 =
Expand All @@ -5501,6 +5532,7 @@ 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
{
size_t j = s.length;
Expand Down
63 changes: 44 additions & 19 deletions std/xml.d
Original file line number Diff line number Diff line change
Expand Up @@ -1056,27 +1056,42 @@ class Tag
*/
private this(ref string s, bool dummy) @safe pure
{
import std.ascii : whitespace;
import std.string : munch;
import std.algorithm.searching : countUntil;
import std.ascii : isWhite;
import std.utf : byCodeUnit;

tagString = s;
try
{
reqc(s,'<');
if (optc(s,'/')) type = TagType.END;
name = munch(s,"^/>"~whitespace);
munch(s,whitespace);
ptrdiff_t i = s.byCodeUnit.countUntil(">", "/>", " ", "\t", "\v", "\r", "\n", "\f");
name = s[0 .. i];
s = s[i .. $];

i = s.byCodeUnit.countUntil!(a => !isWhite(a));
s = s[i .. $];

while (s.length > 0 && s[0] != '>' && s[0] != '/')
{
string key = munch(s,"^="~whitespace);
munch(s,whitespace);
i = s.byCodeUnit.countUntil("=", " ", "\t", "\v", "\r", "\n", "\f");
string key = s[0 .. i];
s = s[i .. $];

i = s.byCodeUnit.countUntil!(a => !isWhite(a));
s = s[i .. $];
reqc(s,'=');
munch(s,whitespace);
i = s.byCodeUnit.countUntil!(a => !isWhite(a));
s = s[i .. $];

immutable char quote = requireOneOf(s,"'\"");
char[2] notQuote = ['^', quote];
string val = decode(munch(s,notQuote[]), DecodeMode.LOOSE);
i = s.byCodeUnit.countUntil(quote);
string val = decode(s[0 .. i], DecodeMode.LOOSE);
s = s[i .. $];
reqc(s,quote);
munch(s,whitespace);

i = s.byCodeUnit.countUntil!(a => !isWhite(a));
s = s[i .. $];
attr[key] = val;
}
if (optc(s,'/'))
Expand Down Expand Up @@ -2194,10 +2209,16 @@ private

void checkSpace(ref string s) @safe pure // rule 3
{
import std.string : munch;
import std.algorithm.searching : countUntil;
import std.ascii : isWhite;
import std.utf : byCodeUnit;

mixin Check!("Whitespace");
munch(s,"\u0020\u0009\u000A\u000D");
ptrdiff_t i = s.byCodeUnit.countUntil!(a => !isWhite(a));
if (i == -1 && s.length > 0 && isWhite(s[0]))
s = s[$ .. $];
else if (i > -1)
s = s[i .. $];
if (s is old) fail();
}

Expand All @@ -2222,7 +2243,8 @@ private

void checkAttValue(ref string s) @safe pure // rule 10
{
import std.string : munch;
import std.algorithm.searching : countUntil;
import std.utf : byCodeUnit;

mixin Check!("AttValue");

Expand All @@ -2233,7 +2255,7 @@ private
s = s[1..$];
for (;;)
{
munch(s,"^<&"~c);
s = s[s.byCodeUnit.countUntil(c) .. $];
if (s.length == 0) fail("unterminated attribute value");
if (s[0] == '<') fail("< found in attribute value");
if (s[0] == c) break;
Expand Down Expand Up @@ -2356,11 +2378,12 @@ private

void checkVersionNum(ref string s) @safe pure // rule 26
{
import std.string : munch;
import std.algorithm.searching : countUntil;
import std.utf : byCodeUnit;

mixin Check!("VersionNum");

munch(s,"a-zA-Z0-9_.:-");
s = s[s.byCodeUnit.countUntil('\"') .. $];
if (s is old) fail();
}

Expand Down Expand Up @@ -2583,13 +2606,15 @@ private

void checkEncName(ref string s) @safe pure // rule 81
{
import std.string : munch;
import std.algorithm.searching : countUntil;
import std.ascii : isAlpha;
import std.utf : byCodeUnit;

mixin Check!("EncName");

munch(s,"a-zA-Z");
s = s[s.byCodeUnit.countUntil!(a => !isAlpha(a)) .. $];
if (s is old) fail();
munch(s,"a-zA-Z0-9_.-");
s = s[s.byCodeUnit.countUntil('\"', '\'') .. $];
}

void checkEncodingDecl(ref string s) @safe pure // rule 80
Expand Down