mIRC Home    About    Download    Register    News    Help

Print Thread
bread -t beyond EOF #266446 11/12/19 11:22 AM
Joined: Jan 2004
Posts: 1,260
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,260
If removing the -t switch, it correctly returns null-length variable due to start position being beyond EOF. But with -t switch it gives:

* /bread: error allocating memory

I assume it's running out of memory trying to reach a condition that never happens

//bset &v 1 233 13 10 233 | bwrite -c test.dat 0 &v | bread -t test.dat 4 9 &v2 | echo -a result: $bvar(&v2) $bvar(&v2,0)

Re: bread -t beyond EOF [Re: maroon] #266449 12/12/19 09:39 AM
Joined: Dec 2002
Posts: 4,639
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,639
Thanks for your bug report. The issue is due to a file read error due to the invalid parameters, not a memory error. This has been changed in the next beta to report a file error.

Re: bread -t beyond EOF [Re: Khaled] #266451 12/12/19 08:10 PM
Joined: Jan 2004
Posts: 1,260
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,260
Are you intending it to remain a halting error as it is now, or do like /bread does without the -t and fill the binvar with null?

Or like /fseek does where it reports the error message, but the script continues with file position set to the EOF and causes the next $fread as null? This is effectively what $read does, returning $null and setting $readn to $lines(file) + 1

//bset &v 1 233 13 10 233 | bwrite -c test.dat 0 &v | bread test.dat 4 9 &v2 | fclose test* | fopen test test.dat | fseek -l test 44 | echo 3 -a bread: $bvar(&v2) $bvar(&v2,0) read: $read(test.dat,nt,3) readn: $readn fopen.pos: $fopen(test).pos fseek: $fread(test)

Re: bread -t beyond EOF [Re: maroon] #266454 13/12/19 11:47 AM
Joined: Dec 2002
Posts: 4,639
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,639
Quote
Are you intending it to remain a halting error as it is now, or do like /bread does without the -t and fill the binvar with null?

Both /bread with and without -t will report errors if any of the Windows API calls they make return errors.

/bread without -t is a far simpler routine, so there is less chance of it returning errors.

/bread with -t is a more complicated routine that makes far more Windows API calls and, in this case, one of the calls returns an error.