I've done some more testings on this (and edited my above post).
dbenham wrote:First off, there is no pipe - JScript is reading redirected stdin - a very basic OS function
Right: I was wrong naming "redirected input" "piped input";
i've added an edit (note) in my above post why i've written about pipes.
My (too hasty; sry i'd not much time that day) conclusions are wrong, too:
I must apologise for that.
dbenham wrote:Second, the issue cannot be strictly size based, as I have successfully used REPL.BAT on many files that had hundreds of megabytes.
It is not strictly sized based: I've only treated such files containing at minimum one NUL character.
But if there is a NUL character then this is a size based issue.
But it not realates to one fixed size; the size of 261 characters (/file bytes) is only the minimal size, where the issue occurs.
All my tests have the same result (Win xp home version):
The data is divided in parts P_1 ... P_n (|P_1|=260, |P_i|=256; i in setN_>1).
All data in P_n is as it should be, and
all data in parts P_1, ... P_n-1 is only ok up to the first NUL byte.
The content of my test files is (in regular expression): 'x'* NUL 'x'* '@' (("123456789" NUL)^24) "12345".
I now think the following is happening.
JScript reads the input from the stdIn text stream to an internal buffer (B1).
If the input exceeds an given size (B.crit in {260+256*i| i in setN_0} ), then a new buffer (B2) is created to hold the data.
Then the (old) data (string) is copied from B1 to B2 assuming it holds a NUL terminated string, so the data between the first NUL character and the first character in P_n gets corrupted.
penpen
Edit: It seems, that instead of "str1 += WScript.StdIn.ReadLine();" ( or ...ReadAll...), you could use:
Code: Select all
while (!WScript.StdIn.AtEndOfLine) {
str1 += WScript.StdIn.Read(1);
}
BUT this is very slow (especially for big files).