Re: File append Limit

2011-08-06 Thread Kagamin
Joshua Niehus Wrote:

 That works, but I misrepresented the problem and found that the following
 may be the issue (this looks more like the code im using):
 
 import std.conv, std.stdio;
 
 void main()
 {
 string[] strArr;
 foreach(int i; 0 .. 257) {
 strArr ~= text(Line:  ~ to!string(i));
 }
 
 foreach(string e; strArr) {
 writeln(e);
 }
 }

Looks like the described problem. 256 strings on 32-bit architecture is an 
array 2kb long. Move strArr to global scope and see if the code works. If the 
stack is not scanned by GC, that's bad.


File append limit?

2011-08-05 Thread Joshua Niehus
Hello,

I am running a script that creates a file which lists all the folders in a
directory:

foreach (string name; dirEntries(/Users/josh/, SpanMode.shallow)) {
append(/Users/dirList.txt, name ~ \n);
}

But it seems to stop appending after 255 lines (this particular folder has
350 folders in all).
When trying to read the created file:

   auto f = File(/Users/dirList.txt, r);
   foreach (string line; lines(f)) {
   writeln(line);
   }
   f.close();

It writes out the lines, but after the last one I get Bus error: 10

Any thoughts on what im missing or doing wrong?

I am currently using D 2.054 on Mac OSX Lion
The script was working with D 2.053 on Mac OSX Snow Leopard

Thanks,
Josh


Re: File append limit?

2011-08-05 Thread Kagamin
Joshua Niehus Wrote:

 Hello,
 
 I am running a script that creates a file which lists all the folders in a
 directory:
 
 foreach (string name; dirEntries(/Users/josh/, SpanMode.shallow)) {
 append(/Users/dirList.txt, name ~ \n);
 }
 
 But it seems to stop appending after 255 lines (this particular folder has
 350 folders in all).

What if

foreach(i;0..512) {
  append(/Users/dirList.txt, text(line ,i,'\n'));
}


Re: File append limit?

2011-08-05 Thread Dmitry Olshansky

On 05.08.2011 19:35, Joshua Niehus wrote:

Hello,

I am running a script that creates a file which lists all the folders 
in a directory:

foreach (string name; dirEntries(/Users/josh/, SpanMode.shallow)) {
append(/Users/dirList.txt, name ~ \n);
}

But it seems to stop appending after 255 lines (this particular folder 
has 350 folders in all).

When trying to read the created file:

   auto f = File(/Users/dirList.txt, r);
   foreach (string line; lines(f)) {
   writeln(line);
   }
   f.close();

It writes out the lines, but after the last one I get Bus error: 10

Any thoughts on what im missing or doing wrong?
I am currently using D 2.054 on Mac OSX Lion
The script was working with D 2.053 on Mac OSX Snow Leopard

Thanks,
Josh


I'd suspect that it's a manifestation of a recently dsicovered (and 
fixed) bug with OSX Lion, more info here:

https://github.com/D-Programming-Language/druntime/pull/42

At any rate it's going to be into the next release, other then waiting 
for it you can manually build latest dmd/druntime from github.


--
Dmitry Olshansky



Re: File append Limit

2011-08-05 Thread Joshua Niehus
@Kagamin

 What if

 foreach(i;0..512) {
  append(/Users/dirList.txt, text(line ,i,'\n'));
 }

That works, but I misrepresented the problem and found that the following
may be the issue (this looks more like the code im using):

import std.conv, std.stdio;

void main()
{
string[] strArr;
foreach(int i; 0 .. 257) {
strArr ~= text(Line:  ~ to!string(i));
}

foreach(string e; strArr) {
writeln(e);
}
}

// OUTPUT for first 87 lines
Line: 2
?O
?O
`O
@O
 O

?N
?N
...
ect
...
?@
?@
`@
0@

Line: 88
 /* rest of output is as expected */

Changing 257 to 256 gives you what you would expect.

Josh