mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 13:10:35 +03:00
Fix %*s handling by formattedRead() (#10654)
This commit is contained in:
parent
4b39202045
commit
0d724aa0c8
2 changed files with 14 additions and 1 deletions
|
@ -24,7 +24,7 @@ package(std.format):
|
|||
|
||||
void skipData(Range, Char)(ref Range input, scope const ref FormatSpec!Char spec)
|
||||
{
|
||||
import std.ascii : isDigit;
|
||||
import std.ascii : isDigit, isWhite;
|
||||
import std.range.primitives : empty, front, popFront;
|
||||
|
||||
switch (spec.spec)
|
||||
|
@ -33,6 +33,9 @@ void skipData(Range, Char)(ref Range input, scope const ref FormatSpec!Char spec
|
|||
case 'd':
|
||||
if (input.front == '+' || input.front == '-') input.popFront();
|
||||
goto case 'u';
|
||||
case 's':
|
||||
while (!input.empty && !isWhite(input.front)) input.popFront();
|
||||
break;
|
||||
case 'u':
|
||||
while (!input.empty && isDigit(input.front)) input.popFront();
|
||||
break;
|
||||
|
|
|
@ -377,6 +377,16 @@ if (!isType!fmt && isSomeString!(typeof(fmt)))
|
|||
assert(t[0] == 1 && t[1] == 2.125);
|
||||
}
|
||||
|
||||
@safe pure unittest
|
||||
{
|
||||
string hello;
|
||||
string world;
|
||||
|
||||
assert("hello ignore world".formattedRead("%s %*s %s", hello, world) == 2);
|
||||
assert(hello == "hello");
|
||||
assert(world == "world");
|
||||
}
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=23600
|
||||
@safe pure unittest
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue