[Issue 24557] New: File.readln does not properly handle case where last character in terminator is repeated

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 20 14:01:52 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24557

          Issue ID: 24557
           Summary: File.readln does not properly handle case where last
                    character in terminator is repeated
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: zopsicle at use.startmail.com

Consider the following program:

-----
import std.stdio : readln, writefln;

void main()
{
    char[] buf;
    readln(buf, "ABA");
    writefln!"%(%s%)"([buf]);
}
-----

Compiled and run as follows:

-----
$ dmd example.d
$ printf 'XABAY' | ./example
-----

Expected output: "XABA"
Actual output: "XABAY"

readln does not properly handle the case where the last character of the
terminator (in this case A) appears multiple times in the terminator (in this
case, A also appears at the front of the terminator).

--


More information about the Digitalmars-d-bugs mailing list