conv: Fix taking out of range chars for hex values

This commit is contained in:
Eugen Wissner 2018-08-11 14:42:09 +02:00
parent 918d8f5450
commit ba5833318b

View File

@ -308,11 +308,11 @@ do
{ {
digit = range.front - 'W'; digit = range.front - 'W';
} }
else if (range.front >= 'A') else if (range.front >= 'A' && range.front <= 'Z')
{ {
digit = range.front - '7'; digit = range.front - '7';
} }
else if (range.front >= '0') else if (range.front >= '0' && range.front <= '9')
{ {
digit = range.front - '0'; digit = range.front - '0';
} }
@ -360,6 +360,15 @@ do
return n; return n;
} }
// ':' is not a hex value
@nogc nothrow pure @safe unittest
{
string colon = ":";
auto actual = readIntegral!ubyte(colon, 16);
assert(actual == 0);
assert(colon.length == 1);
}
// reads ubyte.max // reads ubyte.max
@nogc nothrow pure @safe unittest @nogc nothrow pure @safe unittest
{ {