Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #970 (closed enhancement: fixed)

Opened 16 years ago

Last modified 16 years ago

foreach (line, delim; stream) (incl. code)

Reported by: Daniel919 Assigned to: kris
Priority: major Milestone: 0.99.6
Component: Core Functionality Version: 0.99.5 Jascha
Keywords: Cc:

Description

Hi, Kris brought up this nice solution for my task.

The problem with the current LineIterator? is that

foreach(line; new LineIterator(input))
    output.print(line).newline;

always adds an additional newline to the input.

The only way to get it right with the current implementation is

do {
    char[] line;
    more = iter.readln(line);
    output.print(line);
    if (more) output.newline;
} while(more);

With the patch, it can be written:

foreach(line,delim; LineIterator(input))
    output.print(line).print(delim);

Therefore I changed (based on tango-0.99.5-src.tar.gz) tango.text.stream.StreamIterator?, tango.text.stream.LineIterator? and tango.text.stream.RegexIterator?.

The patched files are attached.

Attachments

LineIterator.d (4.9 kB) - added by Daniel919 on 03/10/08 17:44:14.
RegexIterator.d (4.2 kB) - added by Daniel919 on 03/10/08 17:45:01.
StreamIterator.d (11.5 kB) - added by Daniel919 on 03/10/08 17:45:34.

Change History

03/10/08 17:44:14 changed by Daniel919

  • attachment LineIterator.d added.

03/10/08 17:45:01 changed by Daniel919

  • attachment RegexIterator.d added.

03/10/08 17:45:34 changed by Daniel919

  • attachment StreamIterator.d added.

03/20/08 16:59:36 changed by kris

  • owner changed from sean to kris.
  • status changed from new to assigned.

03/21/08 06:12:10 changed by kris

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [3385]) fixes #970 :: foreach (index, line, delim; stream)

Thanks, Daniel919