mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 06:00: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)
|
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;
|
import std.range.primitives : empty, front, popFront;
|
||||||
|
|
||||||
switch (spec.spec)
|
switch (spec.spec)
|
||||||
|
@ -33,6 +33,9 @@ void skipData(Range, Char)(ref Range input, scope const ref FormatSpec!Char spec
|
||||||
case 'd':
|
case 'd':
|
||||||
if (input.front == '+' || input.front == '-') input.popFront();
|
if (input.front == '+' || input.front == '-') input.popFront();
|
||||||
goto case 'u';
|
goto case 'u';
|
||||||
|
case 's':
|
||||||
|
while (!input.empty && !isWhite(input.front)) input.popFront();
|
||||||
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
while (!input.empty && isDigit(input.front)) input.popFront();
|
while (!input.empty && isDigit(input.front)) input.popFront();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -377,6 +377,16 @@ if (!isType!fmt && isSomeString!(typeof(fmt)))
|
||||||
assert(t[0] == 1 && t[1] == 2.125);
|
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
|
// https://issues.dlang.org/show_bug.cgi?id=23600
|
||||||
@safe pure unittest
|
@safe pure unittest
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue