vm: use ctx->push since unbox_array_size needs to peek at the stack.

db4
John Benediktsson 2013-03-22 09:19:36 -07:00
parent 5be15d7e3f
commit 17945addfe
1 changed files with 3 additions and 3 deletions

View File

@ -205,19 +205,19 @@ void factor_vm::primitive_fgetc()
void factor_vm::primitive_fread() void factor_vm::primitive_fread()
{ {
FILE *file = pop_file_handle(); FILE *file = pop_file_handle();
void *buf = (void*)alien_offset(ctx->peek()); void *buf = (void*)alien_offset(ctx->pop());
fixnum size = unbox_array_size(); fixnum size = unbox_array_size();
if(size == 0) if(size == 0)
{ {
ctx->replace(from_unsigned_cell(0)); ctx->push(from_unsigned_cell(0));
return; return;
} }
size_t c = safe_fread(buf,1,size,file); size_t c = safe_fread(buf,1,size,file);
if(c == 0 || feof(file)) if(c == 0 || feof(file))
clearerr(file); clearerr(file);
ctx->replace(from_unsigned_cell(c)); ctx->push(from_unsigned_cell(c));
} }
void factor_vm::primitive_fputc() void factor_vm::primitive_fputc()