From ccca051c48a9629b7c5030733e5afa111a1167d7 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Wed, 14 Apr 2010 23:47:01 +0100 Subject: [PATCH] avoid using ftell: it can be very slow on NFS. --- C/iopreds.c | 20 ++++++-------------- C/stdpreds.c | 4 ++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/C/iopreds.c b/C/iopreds.c index cc5fd51c8..b8600ace9 100755 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -3994,11 +3994,7 @@ static Int if (Stream[inp_stream].status & InMemory_Stream_f) { cpos = Stream[inp_stream].u.mem_string.pos; } else { -#if HAVE_FGETPOS - fgetpos(Stream[inp_stream].u.file.file, &rpos); -#else - cpos = ftell(Stream[inp_stream].u.file.file); -#endif + cpos = Stream[inp_stream].charcount; } } /* Scans the term using stack space */ @@ -4356,16 +4352,12 @@ static Term StreamPosition(int sno) { Term sargs[5]; - if (Stream[sno].status & (Tty_Stream_f|Socket_Stream_f|Pipe_Stream_f|InMemory_Stream_f)) - sargs[0] = MkIntTerm (Stream[sno].charcount); - else if (Stream[sno].status & Null_Stream_f) - sargs[0] = MkIntTerm (Stream[sno].charcount); - else { - if (Stream[sno].stream_getc == PlUnGetc) - sargs[0] = MkIntTerm (YP_ftell (Stream[sno].u.file.file) - 1); - else - sargs[0] = MkIntTerm (YP_ftell (Stream[sno].u.file.file)); + Int cpos; + cpos = Stream[sno].charcount; + if (Stream[sno].stream_getc == PlUnGetc) { + cpos--; } + sargs[0] = MkIntegerTerm (cpos); sargs[1] = MkIntegerTerm (StartLine = Stream[sno].linecount); sargs[2] = MkIntegerTerm (Stream[sno].linepos); sargs[3] = sargs[4] = MkIntTerm (0); diff --git a/C/stdpreds.c b/C/stdpreds.c index 715f21e5d..ffd7ce58b 100755 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -3857,8 +3857,8 @@ p_set_yap_flags(void) break; case QUIET_MODE_FLAG: if (value != 0 && value != 1) - return(FALSE); - yap_flags[VARS_CAN_HAVE_QUOTE_FLAG] = value; + return FALSE; + yap_flags[QUIET_MODE_FLAG] = value; break; default: return(FALSE);