Appending char[] to char[][] has unexpected results

Steven Schveighoffer schveiguy at yahoo.com
Wed May 1 22:47:59 PDT 2013


On Wed, 01 May 2013 06:56:47 -0700, Tim Keating <mrtact at gmail.com> wrote:

> On Wednesday, 1 May 2013 at 04:33:28 UTC, anonymous wrote:
>> Just outBuf ~= buf.dup; works, too. Without .dup you're overwriting and  
>> appending the same chunk of memory again and again.
>> From the documentation on File.readln
>> (<http://dlang.org/phobos/std_stdio#readln>): "Note that reusing the  
>> buffer means that the previous contents of it has to be copied if  
>> needed."
>> I'm a bit puzzled as for why it behaves differently with dchar.
>
> Okay, that was obviously the bit I was missing. The dchar situation IS  
> baffling -- if that hadn't worked, I would have been more certain I was  
> simply doing something wrong.

Note that it could have worked even with utf8 depending on the input  
file.  Although I agree the library code is not ideal, this is not an  
excuse ;)

-Steve


More information about the Digitalmars-d mailing list