This commit is contained in:
Vítor Santos Costa 2018-03-26 15:01:21 +01:00
parent 7e0611b526
commit 3da111bd10
5 changed files with 20 additions and 11 deletions

View File

@ -333,6 +333,14 @@ void Yap_pushErrorContext(yap_error_descriptor_t *new_error) {
LOCAL_ActiveError = new_error; LOCAL_ActiveError = new_error;
} }
static void
reset_error_description(void) {
sigjmp_buf *bf = LOCAL_ActiveError->top_error;
memset(LOCAL_ActiveError, 0, sizeof(*LOCAL_ActiveError));
LOCAL_ActiveError->top_error = bf;
}
yap_error_descriptor_t *Yap_popErrorContext(bool pass) { yap_error_descriptor_t *Yap_popErrorContext(bool pass) {
if (pass && LOCAL_ActiveError->top_error->errorNo == YAP_NO_ERROR && if (pass && LOCAL_ActiveError->top_error->errorNo == YAP_NO_ERROR &&
LOCAL_ActiveError->errorNo != YAP_NO_ERROR) LOCAL_ActiveError->errorNo != YAP_NO_ERROR)
@ -361,6 +369,7 @@ void Yap_ThrowError__(const char *file, const char *function, int lineno,
} else { } else {
Yap_Error__(file, function, lineno, type, where); Yap_Error__(file, function, lineno, type, where);
} }
if (LOCAL_RestartEnv)
siglongjmp(*LOCAL_RestartEnv, 5); siglongjmp(*LOCAL_RestartEnv, 5);
} }
@ -474,7 +483,6 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
} }
va_end(ap); va_end(ap);
if (P == (yamop *)(FAILCODE)) { if (P == (yamop *)(FAILCODE)) {
memset(LOCAL_ActiveError, 0, sizeof(*LOCAL_ActiveError));
LOCAL_PrologMode &= ~InErrorMode; LOCAL_PrologMode &= ~InErrorMode;
return P; return P;
} }

View File

@ -315,7 +315,7 @@ static void Yap_set_locations(YAP_init_args *iap) {
/// BOOTPLDIR: where we can find Prolog bootstrap files /// BOOTPLDIR: where we can find Prolog bootstrap files
Yap_BOOTSTRAP = sel(true, iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true, Yap_BOOTSTRAP = sel(true, iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true,
#if __ANDROID__ #if __ANDROID__
"/assets/Yap/pl/boot,yap", "/assets/Yap/pl/boot.yap",
#else #else
join(getenv("DESTDIR"), YAP_BOOTSTRAP), join(getenv("DESTDIR"), YAP_BOOTSTRAP),
#endif #endif

View File

@ -60,15 +60,15 @@ Java_pt_up_yap_yapdroid_YAPDroid_loadAssetManager(JNIEnv *env, jclass clazz, job
static void * static void *
open_asset(VFS_t *me, int sno, const char *fname, const char *io_mode) { open_asset(VFS_t *me, const char *fname, const char *io_mode, int sno) {
int mode; int mode;
const void *buf; const void *buf;
AAsset *am = NULL; AAsset *am = NULL;
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", fname, io_mode); __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s-%s <%s>", fname, me->prefix,io_mode);
if (strchr(io_mode, 'B')) if (strchr(io_mode, 'B')) {
mode = AASSET_MODE_BUFFER; mode = AASSET_MODE_BUFFER;
else { } else {[lib]
mode = AASSET_MODE_UNKNOWN; mode = AASSET_MODE_UNKNOWN;
} }
GLOBAL_Stream[sno].name = Yap_LookupAtom(fname); GLOBAL_Stream[sno].name = Yap_LookupAtom(fname);
@ -78,6 +78,7 @@ open_asset(VFS_t *me, int sno, const char *fname, const char *io_mode) {
// strcpy(dir, fname); // strcpy(dir, fname);
// char *d = basename(dir); // char *d = basename(dir);
am = AAssetManager_open(Yap_assetManager(), fname, mode); am = AAssetManager_open(Yap_assetManager(), fname, mode);
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", fname, io_mode );
// while (dp) { // while (dp) {
// char *f = AAssetDir_getNextFileName(dp); // char *f = AAssetDir_getNextFileName(dp);
// __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", f, d); // __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", f, d);

View File

@ -337,7 +337,7 @@ void Yap_DefaultStreamOps(StreamDesc *st) {
st->stream_wputc = put_wchar; st->stream_wputc = put_wchar;
st->stream_wgetc = get_wchar; st->stream_wgetc = get_wchar;
if (st->vfs) { if (st->vfs && !st->file) {
st->stream_putc = st->vfs->put_char; st->stream_putc = st->vfs->put_char;
st->stream_wputc = st->vfs->put_char; st->stream_wputc = st->vfs->put_char;
st->stream_getc = st->vfs->get_char; st->stream_getc = st->vfs->get_char;
@ -1143,7 +1143,7 @@ bool Yap_initStream(int sno, FILE *fd, const char *name, const char *io_mode, Te
st->status = Binary_Stream_f|flags; st->status = Binary_Stream_f|flags;
} }
st->vfs = vfs; //st->vfs = vfs;
st->buf.on = false; st->buf.on = false;
st->charcount = 0; st->charcount = 0;
st->linecount = 1; st->linecount = 1;
@ -1598,7 +1598,7 @@ int Yap_OpenStream(const char *fname, const char* io_mode, Term user_name, encod
// read, write, append // read, write, append
user_name = st->user_name; user_name = st->user_name;
} else { } else {
fd = fopen(fname, io_mode); st->file = fopen(fname, io_mode);
if (fd == NULL) { if (fd == NULL) {
if (!strchr(io_mode, 'b') && binary_file(fname)) { if (!strchr(io_mode, 'b') && binary_file(fname)) {
UNLOCK(st->streamlock); UNLOCK(st->streamlock);
@ -1615,7 +1615,7 @@ int Yap_OpenStream(const char *fname, const char* io_mode, Term user_name, encod
return -1; return -1;
} }
} }
Yap_initStream(sno, fd, fname, io_mode, user_name, LOCAL_encoding, flags, vfsp); Yap_initStream(sno, st->file, fname, io_mode, user_name, LOCAL_encoding, flags, vfsp);
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exists %s <%d>", fname, __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exists %s <%d>", fname,
sno); sno);
return sno; return sno;

View File

@ -984,7 +984,7 @@ static void CloseStream(int sno) {
//fflush(NULL); //fflush(NULL);
VFS_t *me; VFS_t *me;
if ((me = GLOBAL_Stream[sno].vfs) != NULL) { if ((me = GLOBAL_Stream[sno].vfs) != NULL && GLOBAL_Stream[sno].file == NULL) {
if (me->close) { if (me->close) {
me->close(sno); me->close(sno);
} }