cmake support: first cut from David Vaz work.i
This commit is contained in:
@@ -2982,7 +2982,9 @@ Yap_absmi(int inp)
|
||||
PELOCK(5, ((PredEntry *)(PREG->y_u.Otapl.p)));
|
||||
PREG = (yamop *)(&(((PredEntry *)(PREG->y_u.Otapl.p))->OpcodeOfPred));
|
||||
UNLOCKPE(11,(PredEntry *)(PREG->y_u.Otapl.p));
|
||||
saveregs();
|
||||
spy_goal( PASS_REGS1 );
|
||||
setregs();
|
||||
ENDBOp();
|
||||
|
||||
/* try_and_mark Label,NArgs */
|
||||
|
@@ -341,15 +341,11 @@
|
||||
#include "Foreign.h"
|
||||
#include "attvar.h"
|
||||
#include "SWI-Stream.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
15
C/pl-yap.c
15
C/pl-yap.c
@@ -858,8 +858,9 @@ char *
|
||||
Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags)
|
||||
{
|
||||
CACHE_REGS
|
||||
Int l, CurSlot;
|
||||
|
||||
Int l, CurSlot;
|
||||
Int myASP = LCL0-ASP;
|
||||
|
||||
CurSlot = Yap_StartSlots( PASS_REGS1 );
|
||||
l = Yap_InitSlot(t PASS_REGS );
|
||||
|
||||
@@ -898,12 +899,17 @@ Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int
|
||||
/* found, just check if using local space */
|
||||
if (r == buf) {
|
||||
char *bf = malloc(*length+1);
|
||||
if (!bf)
|
||||
if (!bf) {
|
||||
LOCAL_CurSlot = CurSlot;
|
||||
ASP = LCL0-myASP;
|
||||
return NULL;
|
||||
}
|
||||
strncpy(bf,buf,*length+1);
|
||||
r = bf;
|
||||
}
|
||||
return r;
|
||||
LOCAL_CurSlot = CurSlot;
|
||||
ASP = LCL0-myASP;
|
||||
return r;
|
||||
} else
|
||||
{ Sclose(fd);
|
||||
}
|
||||
@@ -914,6 +920,7 @@ Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int
|
||||
}
|
||||
}
|
||||
LOCAL_CurSlot = CurSlot;
|
||||
ASP = LCL0-myASP;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -935,6 +935,7 @@ static Int init_current_predicate(USES_REGS1) {
|
||||
else
|
||||
cut_fail();
|
||||
}
|
||||
return FALSE;
|
||||
} else if (IsPairTerm(t3)) {
|
||||
f = FunctorDot;
|
||||
at = AtomDot;
|
||||
|
29
C/sysbits.c
29
C/sysbits.c
@@ -158,7 +158,7 @@ is_directory(const char *FileName)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
char s[YAP_FILENAME_MAX+1];
|
||||
const char *s0 = FileName;
|
||||
char *s0 = (char *)FileName;
|
||||
char *s1 = s;
|
||||
int ch;
|
||||
|
||||
@@ -192,7 +192,7 @@ is_directory(const char *FileName)
|
||||
} else if (ch == '/')
|
||||
s1[-1] = '\\';
|
||||
}
|
||||
if (ExpandEnvironmentStrings(s, FileName, YAP_FILENAME_MAX) == 0)
|
||||
if (ExpandEnvironmentStrings(s, (LPSTR)FileName, YAP_FILENAME_MAX) == 0)
|
||||
return FALSE;
|
||||
|
||||
DWORD dwAtts = GetFileAttributes( FileName );
|
||||
@@ -1774,7 +1774,7 @@ TrueFileName (char *source, char *root, char *result, int in_lib, int expand_roo
|
||||
{
|
||||
CACHE_REGS
|
||||
char *work;
|
||||
char ares1[YAP_FILENAME_MAX];
|
||||
char ares1[YAP_FILENAME_MAX+1];
|
||||
|
||||
result[0] = '\0';
|
||||
if (strlen(source) >= YAP_FILENAME_MAX) {
|
||||
@@ -2703,17 +2703,32 @@ p_yap_home( USES_REGS1 ) {
|
||||
static Int
|
||||
p_yap_paths( USES_REGS1 ) {
|
||||
Term out1, out2, out3;
|
||||
if (strlen(DESTDIR)) {
|
||||
out1 = MkAtomTerm(Yap_LookupAtom(DESTDIR "/" YAP_LIBDIR));
|
||||
out2 = MkAtomTerm(Yap_LookupAtom(DESTDIR "/" YAP_SHAREDIR));
|
||||
out3 = MkAtomTerm(Yap_LookupAtom(DESTDIR "/" YAP_BINDIR));
|
||||
const char *env_destdir = getenv("DESTDIR");
|
||||
char destdir[YAP_FILENAME_MAX+1];
|
||||
|
||||
if (env_destdir) {
|
||||
strncat(destdir, env_destdir, YAP_FILENAME_MAX );
|
||||
strncat(destdir, "/" YAP_LIBDIR, YAP_FILENAME_MAX );
|
||||
out1 = MkAtomTerm(Yap_LookupAtom(destdir));
|
||||
} else {
|
||||
out1 = MkAtomTerm(Yap_LookupAtom(YAP_LIBDIR));
|
||||
}
|
||||
if (env_destdir) {
|
||||
strncat(destdir, env_destdir, YAP_FILENAME_MAX );
|
||||
strncat(destdir, "/" YAP_SHAREDIR, YAP_FILENAME_MAX );
|
||||
out2 = MkAtomTerm(Yap_LookupAtom(destdir));
|
||||
} else {
|
||||
#if __ANDROID__
|
||||
out2 = MkAtomTerm(Yap_LookupAtom("/assets/share"));
|
||||
#else
|
||||
out2 = MkAtomTerm(Yap_LookupAtom(YAP_SHAREDIR));
|
||||
#endif
|
||||
}
|
||||
if (env_destdir) {
|
||||
strncat(destdir, env_destdir, YAP_FILENAME_MAX );
|
||||
strncat(destdir, "/" YAP_BINDIR, YAP_FILENAME_MAX );
|
||||
out3 = MkAtomTerm(Yap_LookupAtom(destdir));
|
||||
} else {
|
||||
out3 = MkAtomTerm(Yap_LookupAtom(YAP_BINDIR));
|
||||
}
|
||||
return(Yap_unify(out1,ARG1) &&
|
||||
|
55
C/yap-args.c
55
C/yap-args.c
@@ -35,6 +35,12 @@
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#if HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#if HAVE_DIRECT_H
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
void YAP_SetOutputMessage(void);
|
||||
int YAP_parse_yap_arguments(int argc, char *argv[], YAP_init_args *iap);
|
||||
@@ -459,8 +465,49 @@ YAP_parse_yap_arguments(int argc, char *argv[], YAP_init_args *iap)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
if ((*argv)[0] == '\0')
|
||||
case '-':
|
||||
if (!strcmp("-nosignals", p)) {
|
||||
iap->PrologShouldHandleInterrupts = FALSE;
|
||||
break;
|
||||
} else if (!strncmp("-home=",p,strlen("-home="))) {
|
||||
GLOBAL_Home = p+strlen("-home=");
|
||||
} else if (!strncmp("-cwd=",p,strlen("-cwd="))) {
|
||||
#if __WINDOWS__
|
||||
if (_chdir( p+strlen("-cwd=") ) < 0) {
|
||||
#else
|
||||
if (chdir( p+strlen("-cwd=") ) < 0) {
|
||||
#endif
|
||||
fprintf(stderr," [ YAP unrecoverable error in setting cwd: %s ]\n", strerror(errno));
|
||||
}
|
||||
} else if (!strncmp("-stack=",p,strlen("-stack="))) {
|
||||
ssize = &(iap->StackSize);
|
||||
p+=strlen("-stack=");
|
||||
goto GetSize;
|
||||
} else if (!strncmp("-trail=",p,strlen("-trail="))) {
|
||||
ssize = &(iap->TrailSize);
|
||||
p+=strlen("-trail=");
|
||||
goto GetSize;
|
||||
} else if (!strncmp("-heap=",p,strlen("-heap="))) {
|
||||
ssize = &(iap->HeapSize);
|
||||
p+=strlen("-heap=");
|
||||
goto GetSize;
|
||||
} else if (!strncmp("-goal=",p,strlen("-goal="))) {
|
||||
iap->YapPrologGoal = p+strlen("-goal=");
|
||||
} else if (!strncmp("-top-level=",p,strlen("-top-level="))) {
|
||||
iap->YapPrologTopLevelGoal = p+strlen("-top-level=");
|
||||
} else if (!strncmp("-table=",p,strlen("-table="))) {
|
||||
ssize = &(iap->MaxTableSpaceSize);
|
||||
p +=strlen( "-table=");
|
||||
goto GetSize;
|
||||
} else if (!strncmp("-",p,strlen("-="))) {
|
||||
ssize = &(iap->MaxTableSpaceSize);
|
||||
p +=strlen( "-table=");
|
||||
/* skip remaining arguments */
|
||||
argc = 1;
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
if ((*argv)[0] == '\0')
|
||||
iap->YapPrologAddPath = *argv;
|
||||
else {
|
||||
argc--;
|
||||
@@ -494,10 +541,6 @@ YAP_parse_yap_arguments(int argc, char *argv[], YAP_init_args *iap)
|
||||
break;
|
||||
}
|
||||
/* End preprocessor code */
|
||||
case '-':
|
||||
/* skip remaining arguments */
|
||||
argc = 1;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
fprintf(stderr,"[ YAP unrecoverable error: unknown switch -%c ]\n", *p);
|
||||
|
Reference in New Issue
Block a user