Skip to content

Commit

Permalink
Fix Issue 15964: The template constraints for std.uni.sicmp are too p…
Browse files Browse the repository at this point in the history
…ermissive
  • Loading branch information
JackStouffer committed Apr 28, 2016
1 parent 18dfffa commit 7922bc8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions std/uni.d
Original file line number Diff line number Diff line change
Expand Up @@ -6930,8 +6930,8 @@ unittest
than $(LREF icmp). However keep in mind the warning below.)
Params:
str1 = a string or a $(D ForwardRange) of $(D dchar)s
str2 = a string or a $(D ForwardRange) of $(D dchar)s
str1 = a string
str2 = a string
Returns:
An $(D int) that is 0 if the strings match,
Expand All @@ -6947,17 +6947,16 @@ unittest
$(LREF icmp)
$(XREF_PACK algorithm,comparison,cmp)
+/
int sicmp(S1, S2)(S1 str1, S2 str2)
if (isForwardRange!S1 && is(Unqual!(ElementType!S1) == dchar)
&& isForwardRange!S2 && is(Unqual!(ElementType!S2) == dchar))
int sicmp(S1, S2)(S1 str1, S2 str2) if (isSomeString!S1 && isSomeString!S2)
{
alias sTable = simpleCaseTable;
import std.utf : decode;

size_t ridx=0;
foreach (dchar lhs; str1)
{
if (ridx == str2.length)
return 1;
import std.utf : decode;
dchar rhs = decode(str2, ridx);
int diff = lhs - rhs;
if (!diff)
Expand Down Expand Up @@ -6991,7 +6990,8 @@ int sicmp(S1, S2)(S1 str1, S2 str2)
}

///
unittest{
unittest
{
assert(sicmp("Август", "авгусТ") == 0);
// Greek also works as long as there is no 1:M mapping in sight
assert(sicmp("ΌΎ", "όύ") == 0);
Expand Down

0 comments on commit 7922bc8

Please sign in to comment.