boot_fixes

This commit is contained in:
Vitor Santos Costa 2018-02-07 11:24:05 +00:00
parent 66db3d53f8
commit fadf853e96
3 changed files with 47 additions and 33 deletions

View File

@ -237,7 +237,8 @@ typedef struct config {
const char **dll;
const char **ss;
const char **oss;
const char **plbootdir;
const char **bootpldir;
const char **bootpl;
} config_t;
const char *gd_root[] = {"@RootDir", "[root]", "(execdir)/.."};
@ -245,12 +246,12 @@ const char *gd_lib[] = {"@LibDir", "[lib]", "(root)/lib"};
const char *gd_share[] = {"@ShareDir", "[share]", "(root)/share"};
const char *gd_include[] = {"@IncludeDir", "[include]", "(root)/include"};
const char *gd_dll[] = {"@DLLDir", "(lib)/Yap"};
const char *gd_pl[] = {"@PlDir", "(share)/Yap"};
const char *gd_pl[] = {"@PlDir", "(share)/Yap", "@BootPlDir/../library"};
const char *gd_commons[] = {"@CommonsDir", "(share)/PrologCommons"};
const char *gd_ss[] = {"(dll)"};
const char *gd_oss[] = {"."};
const char *gd_plbootdir[] = {"@BootPlDi",
"(pl)/pl"};
const char *gd_bootpldir[] = {"@BootPlDir", "@PrologBootFile/..", "(pl)/pl"};
const char *gd_bootpl[] = {"@PrologBootFile", "(bootpldir)/setup.yap"};
static config_t *gnu(config_t *i) {
i->root = gd_root;
@ -262,7 +263,8 @@ static config_t *gnu(config_t *i) {
i->commons = gd_commons;
i->ss = gd_ss;
i->oss = gd_oss;
i->plbootdir = gd_plbootdir;
i->bootpldir = gd_bootpldir;
i->bootpl = gd_bootpl;
return i;
}
@ -300,6 +302,14 @@ char *location(YAP_init_args *iap, const char *inp, char *out) {
Yap_PLDIR[0] != '\0') {
strcpy(out, Yap_PLDIR);
strcat(out, inp + strlen("(pl)"));
} else if (strstr(inp + 1, "bootpldir") == inp + 1 && Yap_BOOTPLDIR &&
Yap_BOOTPLDIR[0] != '\0') {
strcpy(out, Yap_BOOTPLDIR);
strcat(out, inp + strlen("(bootpldir)"));
} else if (strstr(inp + 1, "bootpl") == inp + 1 && Yap_BOOTFILE &&
Yap_BOOTFILE[0] != '\0') {
strcpy(out, Yap_BOOTFILE);
strcat(out, inp + strlen("(bootpl)"));
} else if (strstr(inp + 1, "execdir") == inp + 1) {
char *buf = Malloc(YAP_FILENAME_MAX + 1);
const char *ex = Yap_AbsoluteFile(Yap_FindExecutable(), buf, true);
@ -335,8 +345,8 @@ char *location(YAP_init_args *iap, const char *inp, char *out) {
const char *tmp = iap->PlDir;
if (tmp && tmp[0])
strcpy(out, tmp);
} else if (strstr(inp + 1, "PlBootDir") == inp + 1) {
const char *tmp = iap->PlBootDir;
} else if (strstr(inp + 1, "BootPlDir") == inp + 1) {
const char *tmp = iap->BootPlDir;
if (tmp && tmp[0])
strcpy(out, tmp);
} else if (strstr(inp + 1, "PrologBootFile") == inp + 1) {
@ -428,12 +438,9 @@ static const char *find_directory(YAP_init_args *iap, const char *paths[],
int lvl = push_text_stack();
char *out = Malloc(YAP_FILENAME_MAX + 1);
const char *inp;
char *full;
if (filename) {
strcpy(out, filename);
full = Malloc(YAP_FILENAME_MAX + 1);
if (Yap_IsAbsolutePath(out, true)) {
// out = Yap_AbsoluteFile(out, full, true);
if (Yap_IsAbsolutePath(out, false)) {
out = pop_output_text_stack(lvl, out);
return out;
}
@ -441,10 +448,11 @@ static const char *find_directory(YAP_init_args *iap, const char *paths[],
int i = 0;
while ((inp = paths[i++]) != NULL) {
out[0] = '\0';
char *o = location(iap, inp, out);
if (o && o[0] && Yap_isDirectory(o)) {
const char *o = location(iap, inp, out);
char qp[FILENAME_MAX + 1];
if (o && o[0] && (o = Yap_AbsoluteFile(o, qp, false)) &&
Yap_isDirectory(o)) {
if (filename) {
o = realpath(o, full);
strcat(o, "/");
strcat(o, filename);
}
@ -466,7 +474,8 @@ static void Yap_set_locations(YAP_init_args *iap) {
Yap_SHAREDIR = find_directory(iap, template->share, NULL);
Yap_DLLDIR = find_directory(iap, template->dll, NULL);
Yap_PLDIR = find_directory(iap, template->pl, NULL);
Yap_BOOTPLDIR = find_directory(iap, template->plbootdir, NULL);
Yap_BOOTPLDIR = find_directory(iap, template->bootpldir, NULL);
Yap_BOOTFILE = find_directory(iap, template->bootpldir, "setup.yap");
Yap_COMMONSDIR = find_directory(iap, template->commons, NULL);
if (iap->SavedState == NULL)
iap->SavedState = "startup.yss";
@ -476,7 +485,7 @@ static void Yap_set_locations(YAP_init_args *iap) {
Yap_OUTPUT_STARTUP = find_directory(iap, template->ss, iap->OutputSavedState);
if (iap->PrologBootFile == NULL)
iap->PrologBootFile = "boot.yap";
Yap_BOOTFILE = find_directory(iap, template->plbootdir, iap->PrologBootFile);
Yap_BOOTFILE = find_directory(iap, template->bootpldir, iap->PrologBootFile);
if (Yap_ROOTDIR)
setAtomicGlobalPrologFlag(HOME_FLAG,
MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR)));
@ -628,9 +637,9 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
case 'B':
iap->boot_file_type = YAP_BOOT_PL;
if (p[1])
iap->PlDir = p + 1;
iap->BootPlDir = p + 1;
else if (argv[1] && *argv[1] != '-') {
iap->PlDir = *++argv;
iap->BootPlDir = *++argv;
argc--;
}
iap->install = true;

View File

@ -109,12 +109,12 @@ public:
if (IsApplTerm(tgoal)) {
Functor f = FunctorOfTerm(tgoal);
if (!IsExtensionFunctor(f)) {
arity_t arity = ap->ArityOfPE;
if (arity) {
qt = RepAppl(tgoal) + 1;
for (arity_t i = 0; i < arity; i++)
XREGS[i + 1] = qt[i];
}
arity_t arity = ap->ArityOfPE;
if (arity) {
qt = RepAppl(tgoal) + 1;
for (arity_t i = 0; i < arity; i++)
XREGS[i + 1] = qt[i];
}
}
}
names = YAPPairTerm(tnames);
@ -244,6 +244,13 @@ public:
inline const char *getPrologBootFile() { return PrologBootFile; };
inline void setPrologBootDir(const char *fl) {
BootPlDir = (const char *)malloc(strlen(fl) + 1);
strcpy((char *)BootPlDir, fl);
};
inline const char *getPrologBootDir() { return BootPlDir; };
inline void setPrologGoal(const char *fl) { PrologGoal = fl; };
inline const char *getPrologGoal() { return PrologGoal; };
@ -252,9 +259,7 @@ public:
PrologTopLevelGoal = fl;
};
inline const char *getPrologTopLevelGoal() {
return PrologTopLevelGoal;
};
inline const char *getPrologTopLevelGoal() { return PrologTopLevelGoal; };
inline void setHaltAfterConsult(bool fl) { HaltAfterConsult = fl; };

View File

@ -434,7 +434,7 @@ static const char *expandVars(const char *spec, char *u) {
char *out;
// first pass, remove Unix style stuff
if ((out = unix2win(spec, u, YAP_FILENAME_MAX)) == NULL)
if (spec == NULL || (out = unix2win(spec, u, YAP_FILENAME_MAX)) == NULL)
return NULL;
spec = u;
#endif
@ -462,11 +462,11 @@ const char *Yap_AbsoluteFile(const char *spec, char *rc0, bool ok) {
const char *spec2;
char rc1[YAP_FILENAME_MAX + 1];
/// spec gothe original spec;
/// rc0 may be an outout buffer
/// rc1 the internal buffer
///
/// PlExpandVars
/// spec gothe original spec;
/// rc0 may be an outout buffer
/// rc1 the internal buffer
///
/// PlExpandVars
#if _WIN32
char rc2[YAP_FILENAME_MAX];