meta & kernel

This commit is contained in:
Vitor Santos Costa
2018-02-01 01:44:34 +00:00
parent aaadd51309
commit 1cafba0529
11 changed files with 1353 additions and 955 deletions

View File

@@ -337,28 +337,30 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos) {
else {
tm = MkStringTerm("syntax error");
}
if (GLOBAL_Stream[sno].status & Seekable_Stream_f) {
if (errpos && newpos >= 0) {
char o[128 + 1];
diff = errpos - startpos;
if (diff > 128) {
diff = 128;
startpos = errpos - diff;
char o[128 + 1];
diff = errpos - startpos;
if (diff > 128) {
diff = 128;
startpos = errpos - diff;
}
#if HAVE_FTELLO
Int curpos = ftello(GLOBAL_Stream[sno].file);
fseeko(GLOBAL_Stream[sno].file, startpos, SEEK_SET);
#else
Int curpos = ftell(GLOBAL_Stream[sno].file);
fseek(GLOBAL_Stream[sno].file, startpos, SEEK_SET);
#endif
fread(o, diff, 1, GLOBAL_Stream[sno].file);
#if HAVE_FTELLO
fseeko(GLOBAL_Stream[sno].file, curpos, SEEK_SET);
#else
fseek(GLOBAL_Stream[sno].file, curpos, SEEK_SET);
#endif
o[diff] = '\0';
tf[3] = MkStringTerm(o);
}
#if HAVE_FTELLO
Int curpos = ftello(GLOBAL_Stream[sno].file);
fseeko(GLOBAL_Stream[sno].file, startpos, SEEK_SET);
#else
Int curpos = ftell(GLOBAL_Stream[sno].file);
fseek(GLOBAL_Stream[sno].file, startpos, SEEK_SET);
#endif
fread(o, diff, 1, GLOBAL_Stream[sno].file);
#if HAVE_FTELLO
fseeko(GLOBAL_Stream[sno].file, curpos, SEEK_SET);
#else
fseek(GLOBAL_Stream[sno].file, curpos, SEEK_SET);
#endif
o[diff] = '\0';
tf[3] = MkStringTerm(o);
} else {
while (tok) {