Re: formattedRead whitespace quirks (compared to scanf)

2013-12-25 Thread Gordon
On Thursday, 26 December 2013 at 00:22:14 UTC, Andrei Alexandrescu wrote: Yah, that's intentional. scanf has its usefulness slashed to a fraction because of the way it handles strings. People added %[...] to compensate for that; I chose to just fix it. I like the fixes, it just that the in

Re: formattedRead whitespace quirks (compared to scanf)

2013-12-25 Thread Andrei Alexandrescu
On 12/25/13 1:06 PM, Ali Çehreli wrote: On 12/25/2013 12:43 PM, Gordon wrote: > -- in C -- > char a[100] = {0}; > chat *input = "hello world 42"; > sscanf(input, "%s", &a); > -- in D -- > string a; > string input = "hello world 42"; > formattedRead(input,"%s", &a); > --- > > I

Re: formattedRead whitespace quirks (compared to scanf)

2013-12-25 Thread Gordon
On Wednesday, 25 December 2013 at 21:06:46 UTC, Ali Çehreli wrote: On 12/25/2013 12:43 PM, Gordon wrote: > In "C", the variable "a" would contain only "hello"; > In "D", the variable "a" would contain "hello world 42"; > That is by design. Since a string can contain space characters, the normal

Re: formattedRead whitespace quirks (compared to scanf)

2013-12-25 Thread Ali Çehreli
On 12/25/2013 12:43 PM, Gordon wrote: > -- in C -- > char a[100] = {0}; > chat *input = "hello world 42"; > sscanf(input, "%s", &a); > -- in D -- > string a; > string input = "hello world 42"; > formattedRead(input,"%s", &a); > --- > > In "C", the variable "a" would contain only "hello";

formattedRead whitespace quirks (compared to scanf)

2013-12-25 Thread Gordon
Hello, Trying to use "std.file.slurp" as generic file loader, I encountered a quirk in the way formattedRead works compared to the (standard?) scanf. It seems using "%s" format does not stop at whitespace if the "%s" is the last item in the format string. A simple comparison would be: -- i