From 4cbf3387e1d53dde82e79f31750e6af638f01066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Mon, 5 Oct 2015 10:34:32 +0100 Subject: [PATCH] PLIOError should return file number, where --- os/iopreds.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/os/iopreds.h b/os/iopreds.h index b13f438da..58bae1cde 100644 --- a/os/iopreds.h +++ b/os/iopreds.h @@ -252,9 +252,9 @@ GetCurInpPos (StreamDesc * inp_stream) return (inp_stream->linecount); } -#define PlIOError(type, culprit,...) PlIOError__(__FUNCTION__, __LINE__,__FILE__, type, culprit, __VA_ARGS__) +#define PlIOError(type, culprit,...) PlIOError__(__FILE__, __FUNCTION__, __LINE__, type, culprit, __VA_ARGS__) -Int PlIOError__( const char *, int, const char *, yap_error_number, Term, ...); +Int PlIOError__( const char *, const char *, int, yap_error_number, Term, ...); int GetFreeStreamD(void); Term Yap_MkStream (int n); @@ -415,14 +415,14 @@ console_count_output_char(int ch, StreamDesc *s) inline static Term StreamPosition(int sno) { -CACHE_REGS + CACHE_REGS Term sargs[5]; Int cpos; cpos = GLOBAL_Stream[sno].charcount; if (GLOBAL_Stream[sno].stream_getc == PlUnGetc) { cpos--; } - sargs[0] = MkIntegerTerm (cpos); + sargs[0] = MkIntegerTerm (LOCAL_StartCharCount = cpos); sargs[1] = MkIntegerTerm (LOCAL_StartLineCount = GLOBAL_Stream[sno].linecount); sargs[2] = MkIntegerTerm (LOCAL_StartLinePos = GLOBAL_Stream[sno].linepos); sargs[3] = sargs[4] = MkIntTerm (0); @@ -430,6 +430,21 @@ CACHE_REGS } +inline static Term +CurrentPositionToTerm(void) +{ + CACHE_REGS + Term sargs[5]; + sargs[0] = MkIntegerTerm (LOCAL_StartCharCount); + sargs[1] = MkIntegerTerm (LOCAL_StartLineCount ); + sargs[2] = MkIntegerTerm (LOCAL_StartLinePos ); + sargs[3] = sargs[4] = MkIntTerm (0); + return Yap_MkApplTerm (FunctorStreamPos, 5, sargs); +} + + + + extern FILE *Yap_stdin; extern FILE *Yap_stdout;