diff --git a/C/c_interface.c b/C/c_interface.c index 755bbaceb..61703273d 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -2105,7 +2105,7 @@ X_API int YAP_InitConsult(int mode, const char *fname, char **full, int *osnop) CACHE_REGS int sno; BACKUP_MACHINE_REGS(); - char *fl = NULL; + const char *fl = NULL; int lvl = push_text_stack(); if (mode == YAP_BOOT_MODE) { mode = YAP_CONSULT_MODE; } @@ -2126,10 +2126,12 @@ X_API int YAP_InitConsult(int mode, const char *fname, char **full, int *osnop) } lvl = push_text_stack(); - bool consulted = (mode == YAP_CONSULT_MODE); + char *d = Malloc(strlen(fl)+1); + strcpy(d,fl); + bool consulted = (mode == YAP_CONSULT_MODE); sno = Yap_OpenStream(MkStringTerm(fl), "r", MkAtomTerm(Yap_LookupAtom(fl)), LOCAL_encoding); - if (sno < 0 || - !Yap_ChDir(dirname((char *)fl))) { + if (sno < 0 || + !Yap_ChDir(dirname((char *)d))) { pop_text_stack(lvl); *full = NULL; return -1; @@ -2167,12 +2169,16 @@ X_API FILE *YAP_TermToStream(Term t) { X_API void YAP_EndConsult(int sno, int *osnop, const char *full) { BACKUP_MACHINE_REGS(); Yap_CloseStream(sno); - Yap_ChDir(dirname(full)); + int lvl = push_text_stack(); + char *d = Malloc(strlen(full)+1); + strcpy(d,full); + Yap_ChDir(dirname(d)); if (osnop >= 0) Yap_AddAlias(AtomLoopStream, *osnop); Yap_end_consult(); __android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " closing %s(%d), %d", full, *osnop, sno); // LOCAL_CurSlot); + pop_text_stack(lvl); RECOVER_MACHINE_REGS(); } diff --git a/C/compiler.c b/C/compiler.c index d7e2d1145..cb307bb43 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -3575,7 +3575,7 @@ yamop *Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, cglobs.space_op->rnd1 = cglobs.space_used; #ifdef DEBUG - if (GLOBAL_Option['g' - 96] || true) + if (GLOBAL_Option['g' - 96] ) Yap_ShowCode(&cglobs.cint); #endif } else { @@ -3609,7 +3609,7 @@ yamop *Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, if (LOCAL_ErrorMessage) return (0); #ifdef DEBUG - if (GLOBAL_Option['g' - 96]||true) + if (GLOBAL_Option['g' - 96]) Yap_ShowCode(&cglobs.cint); #endif /* phase 2: classify variables and optimize temporaries */ @@ -3625,7 +3625,7 @@ yamop *Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, /* eliminate superfluous pop's and unify_var's */ c_optimize(cglobs.cint.CodeStart); #ifdef DEBUG - if (GLOBAL_Option['f' - 96]||true) + if (GLOBAL_Option['f' - 96]) Yap_ShowCode(&cglobs.cint); #endif diff --git a/C/errors.c b/C/errors.c index 8d3b0348a..4469893d0 100755 --- a/C/errors.c +++ b/C/errors.c @@ -969,6 +969,7 @@ bool Yap_RaiseException(void) { LOCAL_ActiveError->errorNo == YAP_NO_ERROR) return false; Yap_RestartYap(5); + return false; //return Yap_JumpToEnv(); } diff --git a/C/exec.c b/C/exec.c index 583d65e7c..56987beb8 100755 --- a/C/exec.c +++ b/C/exec.c @@ -2115,8 +2115,8 @@ static Int jump_env(USES_REGS1) { "throw/1 must be called instantiated"); } // Yap_DebugPlWriteln(t); - char *buf = Yap_TermToBuffer(t, ENC_ISO_UTF8, - Quote_illegal_f | Ignore_ops_f | Unfold_cyclics_f); + // char *buf = Yap_TermToBuffer(t, ENC_ISO_UTF8, + // Quote_illegal_f | Ignore_ops_f | Unfold_cyclics_f); // __android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " throw(%s)", buf); LOCAL_ActiveError = Yap_UserError(t0, LOCAL_ActiveError); bool out = JumpToEnv(PASS_REGS1); diff --git a/C/text.c b/C/text.c index 4be5818fb..3c60c68a5 100644 --- a/C/text.c +++ b/C/text.c @@ -437,7 +437,7 @@ unsigned char *Yap_readText(seq_tv_t *inp USES_REGS) { LOCAL_Error_TYPE = TYPE_ERROR_TEXT; } } - LOCAL_ActiveError->errorRawTerm = MkStringTerm(inp->val.uc); + LOCAL_ActiveError->errorRawTerm = MkUStringTerm(inp->val.uc); } if (LOCAL_Error_TYPE != YAP_NO_ERROR) { Yap_ThrowError(LOCAL_Error_TYPE, LOCAL_ActiveError->errorRawTerm, "Converting to text from term "); diff --git a/os/iopreds.c b/os/iopreds.c index 6c9ec85ab..938028fea 100644 --- a/os/iopreds.c +++ b/os/iopreds.c @@ -1169,7 +1169,8 @@ bool Yap_initStream(int sno, FILE *fd, const char *name, const char *io_mode, st->user_name = file_name; st->file = fd; st->linepos = 0; - return true; + Yap_DefaultStreamOps(st); + return true; } static bool open_header(int sno, Atom open_mode) { @@ -1667,7 +1668,7 @@ int Yap_OpenStream(Term tin, const char *io_mode, Term user_name, // fname = Yap_VF(fname); - if (fill_stream(sno, st, tin,io_mode,user_name,enc)) + if (fill_stream(sno, st, tin,io_mode,user_name,enc)) return sno; return -1; } diff --git a/packages/myddas/sqlite3/myddas_sqlite3.c b/packages/myddas/sqlite3/myddas_sqlite3.c index 51f81c018..363cc5a9e 100644 --- a/packages/myddas/sqlite3/myddas_sqlite3.c +++ b/packages/myddas/sqlite3/myddas_sqlite3.c @@ -672,7 +672,7 @@ static void Yap_InitBackMYDDAS_SQLITE3Preds(void) { } X_API void init_sqlite3(void) { - Term cm = CurrentModule; + //Term cm = CurrentModule; //CurrentModule = MkAtomTerm(Yap_LookupAtom("myddas_sqlite3")); Yap_InitMYDDAS_SQLITE3Preds();