avoid silly seek

This commit is contained in:
Vitor Santos Costa 2016-09-21 14:43:18 -05:00
parent f35f0584eb
commit f6d434e314

View File

@ -204,7 +204,7 @@ int Yap_open_buf_write_stream(encoding_t enc, memBufSource src) {
if (sno < 0) if (sno < 0)
return -1; return -1;
st = GLOBAL_Stream + sno; st = GLOBAL_Stream + sno;
st->status = Output_Stream_f | InMemory_Stream_f|FreeOnClose_Stream_f; st->status = Output_Stream_f | InMemory_Stream_f | FreeOnClose_Stream_f;
st->linepos = 0; st->linepos = 0;
st->charcount = 0; st->charcount = 0;
st->linecount = 1; st->linecount = 1;
@ -267,8 +267,8 @@ char *Yap_MemExportStreamPtr(int sno) {
#if MAY_WRITE #if MAY_WRITE
char *s; char *s;
if (fflush(GLOBAL_Stream[sno].file) == 0) { if (fflush(GLOBAL_Stream[sno].file) == 0) {
fseek(GLOBAL_Stream[sno].file, 0, SEEK_END);
s = GLOBAL_Stream[sno].nbuf; s = GLOBAL_Stream[sno].nbuf;
// s[fseek(GLOBAL_Stream[sno].file, 0, SEEK_END)] = '\0';
return s; return s;
} }
return NULL; return NULL;
@ -282,8 +282,7 @@ char *Yap_MemExportStreamPtr(int sno) {
static Int peek_mem_write_stream( static Int peek_mem_write_stream(
USES_REGS1) { /* '$peek_mem_write_stream'(+GLOBAL_Stream,?S0,?S) */ USES_REGS1) { /* '$peek_mem_write_stream'(+GLOBAL_Stream,?S0,?S) */
Int sno = Int sno =
Yap_CheckStream(ARG1, (Output_Stream_f | Yap_CheckStream(ARG1, (Output_Stream_f | InMemory_Stream_f), "close/2");
InMemory_Stream_f), "close/2");
Int i; Int i;
Term tf = ARG2; Term tf = ARG2;
CELL *HI; CELL *HI;