Thread overview
Bug in split?
Sep 06, 2004
mcl
Sep 06, 2004
Andy Friesen
Sep 06, 2004
mcl
Sep 06, 2004
Ivan Senji
September 06, 2004
std.string.split and std.string.splitlines don't seem to be stopping at the delimiters for substrings.

Here's an example:
char[] str1 = "A B C D";
char[][] str2 = split(str1);

Will result with str2 equal to:
"A B C D"
"B C D"
"C D"
"D"


September 06, 2004
mcl wrote:
> std.string.split and std.string.splitlines don't seem to be stopping at the
> delimiters for substrings.  
> 
> Here's an example:
> char[] str1 = "A B C D";
> char[][] str2 = split(str1);
> 
> Will result with str2 equal to:
> "A B C D"
> "B C D"
> "C D"
> "D"

This is probably because you're using printf instead of writef. :)

str2's elements point inside str1, but never modifies them, so there is only ever one terminating null.

 -- andy
September 06, 2004
It works for me. Maybe there is something else wrong in your code. Post the entire (but as small as possible) example that has this behaviour.

"mcl" <mcl_member@pathlink.com> wrote in message news:chgvft$116p$1@digitaldaemon.com...
> std.string.split and std.string.splitlines don't seem to be stopping at
the
> delimiters for substrings.
>
> Here's an example:
> char[] str1 = "A B C D";
> char[][] str2 = split(str1);
>
> Will result with str2 equal to:
> "A B C D"
> "B C D"
> "C D"
> "D"
>
>


September 06, 2004
In article <chh0ae$11da$1@digitaldaemon.com>, Andy Friesen says...
>This is probably because you're using printf instead of writef. :)
>
>str2's elements point inside str1, but never modifies them, so there is only ever one terminating null.
>
>  -- andy

D'oh!  I completely forgot about writef.  From now on I'm going to switch over to streams from stdio.  But first I need to get some sleep.