This commit is contained in:
Vitor Santos Costa 2017-11-30 01:14:26 +00:00
parent 3688819ea2
commit 690f1d3830
4 changed files with 20 additions and 28 deletions

View File

@ -2133,7 +2133,7 @@ X_API int YAP_InitConsult(int mode, const char *fname, char *full,
return -1; return -1;
} }
Yap_init_consult(consulted, bfp); Yap_init_consult(consulted, bfp);
sno = Yap_OpenStream(fl, AtomRead); sno = Yap_OpenStream(fl,"r");
*osnop = Yap_CheckAlias(AtomLoopStream); *osnop = Yap_CheckAlias(AtomLoopStream);
if (!Yap_AddAlias(AtomLoopStream, sno)) { if (!Yap_AddAlias(AtomLoopStream, sno)) {
Yap_CloseStream(sno); Yap_CloseStream(sno);

View File

@ -934,12 +934,6 @@ void YAPEngine::doInit(YAP_file_type_t BootMode)
} }
/* Begin preprocessor code */ /* Begin preprocessor code */
/* live */ /* live */
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "initialize_prolog");
#if __ANDROID__
Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096);
Yap_AndroidBufp[0] = '\0';
Yap_AndroidSz = 0;
#endif
//yerror = YAPError(); //yerror = YAPError();
#if YAP_PYTHON #if YAP_PYTHON
do_init_python(); do_init_python();
@ -1015,9 +1009,11 @@ YAPEngine::YAPEngine(int argc, char *argv[],
else if (IsPairTerm(t)) else if (IsPairTerm(t))
{ {
Term ts[2]; Term ts[2];
ts[0] = t; Functor FunctorConsult = Yap_MkFunctor(Yap_LookupAtom("consult"), 1);
ts[1] = m; ts[1] = t;
t = Yap_MkApplTerm(FunctorCsult, 2, ts); ts[0] = m;
t = Yap_MkApplTerm(FunctorModule, 2, ts);
t = Yap_MkApplTerm(FunctorConsult, 1, &t);
tt.put(t); tt.put(t);
outp = RepAppl(t) + 1; outp = RepAppl(t) + 1;
} }

View File

@ -170,12 +170,15 @@ bool exists_a(VFS_t *me, const char *dirName) {
} }
extern char virtual_cwd[YAP_FILENAME_MAX + 1];
static bool set_cwd(VFS_t *me, const char *dirName) { static bool set_cwd(VFS_t *me, const char *dirName) {
chdir("/assets"); chdir("/assets");
if (!me->virtual_cwd) strcpy(virtual_cwd, dirName);
me->virtual_cwd = malloc(YAP_FILENAME_MAX + 1); __android_log_print(ANDROID_LOG_INFO, "YAPDroid",
strcpy(me->virtual_cwd, dirName); "chdir %s", virtual_cwd);
Yap_do_low_level_trace = true;
return true; return true;
} }
@ -210,7 +213,6 @@ Yap_InitAssetManager(void) {
me->enc = ENC_ISO_UTF8; /// how the file is encoded. me->enc = ENC_ISO_UTF8; /// how the file is encoded.
me->parsers = NULL; /// a set of parsers that can read the stream and generate a term me->parsers = NULL; /// a set of parsers that can read the stream and generate a term
me->writers = NULL; me->writers = NULL;
me->virtual_cwd = NULL;
LOCK(BGL); LOCK(BGL);
me->next = GLOBAL_VFS; me->next = GLOBAL_VFS;
GLOBAL_VFS = me; GLOBAL_VFS = me;

View File

@ -34,13 +34,6 @@ static void FileError(yap_error_number type, Term where, const char *format,
} }
} }
/// Allocate a temporary buffer
static char *getFileNameBuffer(void) {
return Yap_AllocAtomSpace(YAP_FILENAME_MAX);
}
static void freeFileNameBuffer(char *s) { Yap_FreeCodeSpace(s); }
static Int p_sh(USES_REGS1); static Int p_sh(USES_REGS1);
static Int p_shell(USES_REGS1); static Int p_shell(USES_REGS1);
@ -345,6 +338,8 @@ static char *PrologPath(const char *Y, char *X) { return (char *)Y; }
#define HAVE_REALPATH 1 #define HAVE_REALPATH 1
#endif #endif
char virtual_cwd[YAP_FILENAME_MAX + 1];
bool Yap_ChDir(const char *path) { bool Yap_ChDir(const char *path) {
bool rc = false; bool rc = false;
char qp[FILENAME_MAX + 1]; char qp[FILENAME_MAX + 1];
@ -1136,13 +1131,12 @@ static int volume_header(char *file) {
int Yap_volume_header(char *file) { return volume_header(file); } int Yap_volume_header(char *file) { return volume_header(file); }
const char *Yap_getcwd(const char *cwd, size_t cwdlen) { const char *Yap_getcwd(const char *cwd, size_t cwdlen) {
VFS_t *me = GLOBAL_VFS; if (virtual_cwd[0]) {
while(me) { if (!cwd) {
if (me->virtual_cwd) { cwd = malloc(cwdlen+1);
strcpy(cwd, me->virtual_cwd);
return cwd;
} }
me = me->next; strcpy( cwd, virtual_cwd);
return cwd;
} }
#if _WIN32 || defined(__MINGW32__) #if _WIN32 || defined(__MINGW32__)
if (GetCurrentDirectory(cwdlen, (char *)cwd) == 0) { if (GetCurrentDirectory(cwdlen, (char *)cwd) == 0) {