Merge /home/vsc/yap
This commit is contained in:
commit
3e5cd4b4f1
@ -1351,6 +1351,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
|
||||
p = NULL; /* Just to make lint happy */
|
||||
ch = getchr(st);
|
||||
while (chtype(ch) == BS) {
|
||||
och=ch;
|
||||
ch = getchr(st);
|
||||
}
|
||||
*tposp = Yap_StreamPosition(st - GLOBAL_Stream);
|
||||
|
29
C/stack.c
29
C/stack.c
@ -1796,7 +1796,7 @@ void Yap_dump_stack(void) {
|
||||
/* check if handled */
|
||||
if (handled_exception(PASS_REGS1))
|
||||
return;
|
||||
#if DEBUG
|
||||
#if DEBU
|
||||
fprintf(stderr, "%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n",
|
||||
P, CP, ASP, HR, TR, HeapTop);
|
||||
#endif
|
||||
@ -1804,11 +1804,11 @@ void Yap_dump_stack(void) {
|
||||
fprintf(stderr, "%% \n%% =====================================\n%%\n");
|
||||
fprintf(stderr, "%% \n%% YAP Status:\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
yap_error_number errnb = LOCAL_Error_TYPE;
|
||||
yap_error_class_number classno = Yap_errorClass(errnb);
|
||||
yap_error_number errnbr = LOCAL_Error_TYPE;
|
||||
yap_error_class_number classno = Yap_errorClass(errnbr);
|
||||
|
||||
fprintf(stderr, "%% Error STATUS: %s/%s\n\n", Yap_errorName(errnb),
|
||||
Yap_errorClassName(classno));
|
||||
fprintf(stderr, "%% Error STATUS: %s/%s\n\n", Yap_errorName(errnbr),
|
||||
Yap_errorName(classno));
|
||||
|
||||
fprintf(stderr, "%% Execution mode\n");
|
||||
if (LOCAL_PrologMode & BootMode)
|
||||
@ -1846,22 +1846,24 @@ void Yap_dump_stack(void) {
|
||||
if (LOCAL_PrologMode & SystemMode)
|
||||
fprintf(stderr, "%% Prolog Internals\n");
|
||||
if (LOCAL_PrologMode & AsyncIntMode)
|
||||
fprintf(stderr, "%% Async Interrupt mode\n");
|
||||
fprintf(stderr, "%% Async Interruot mode\n");
|
||||
if (LOCAL_PrologMode & InReadlineMode)
|
||||
fprintf(stderr, "%% Readline Console\n");
|
||||
if (LOCAL_PrologMode & TopGoalMode)
|
||||
fprintf(stderr, "%% Creating new query\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% \n%% YAP Program :\n");
|
||||
fprintf(stderr, "%% \n%% YAP Program:\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% Program Position\n\n");
|
||||
Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, 256);
|
||||
fprintf(stderr, "%% Program Position: %s\n\n", Yap_errorName(errno) );
|
||||
fprintf(stderr, "%% PC: %s\n", (char *)HR);
|
||||
Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, 256);
|
||||
fprintf(stderr, "%% Continuation: %s\n", (char *)HR);
|
||||
fprintf(stderr, "%% Continuation: %s\n", (char *)HR);
|
||||
Yap_detect_bug_location(B->cp_ap, FIND_PRED_FROM_ANYWHERE, 256);
|
||||
fprintf(stderr, "%% Alternative: %s\n", (char *)HR);
|
||||
fprintf(stderr, "%% Alternative: %s\n", (char *)HR);
|
||||
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% \n%% YAP Stack Usage:\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
if (HR > ASP || HR > LCL0) {
|
||||
fprintf(stderr, "%% YAP ERROR: Global Collided against Local (%p--%p)\n",
|
||||
HR, ASP);
|
||||
@ -1906,6 +1908,9 @@ void Yap_dump_stack(void) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% \n%% YAP Stack:\n");
|
||||
fprintf(stderr, "%% \n%% -------------------------------------\n%%\n");
|
||||
fprintf(stderr, "%% All Active Calls and\n");
|
||||
fprintf(stderr, "%% Goals With Alternatives Open (Global In "
|
||||
"Use--Local In Use)\n%%\n");
|
||||
@ -1927,7 +1932,7 @@ void Yap_dump_stack(void) {
|
||||
}
|
||||
if (b_ptr) {
|
||||
if (!max_count--) {
|
||||
fprintf(stderr, "%% \\** .....\n");
|
||||
fprintf(stderr, "\** .....\n");
|
||||
return;
|
||||
}
|
||||
if (b_ptr->cp_ap && /* tabling */
|
||||
|
12
C/yap-args.c
12
C/yap-args.c
@ -33,9 +33,9 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#undef HAVE_UNISTD_H
|
||||
@ -158,13 +158,15 @@ static void consult(const char *b_file USES_REGS) {
|
||||
Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"), 1);
|
||||
Functor functor_command1 = Yap_MkFunctor(Yap_LookupAtom(":-"), 1);
|
||||
Functor functor_compile2 = Yap_MkFunctor(Yap_LookupAtom("c_compile"), 1);
|
||||
char *full;
|
||||
|
||||
/* consult in C */
|
||||
int lvl = push_text_stack();
|
||||
char *full = Malloc(YAP_FILENAME_MAX + 1);
|
||||
full[0] = '\0';
|
||||
/* the consult mode does not matter here, really */
|
||||
if ((osno = Yap_CheckAlias(AtomLoopStream)) < 0)
|
||||
if ((osno = Yap_CheckAlias(AtomLoopStream)) < 0) {
|
||||
osno = 0;
|
||||
}
|
||||
c_stream = YAP_InitConsult(YAP_BOOT_MODE, b_file, &full, &oactive);
|
||||
if (c_stream < 0) {
|
||||
fprintf(stderr, "[ FATAL ERROR: could not open file %s ]\n", b_file);
|
||||
@ -1044,6 +1046,7 @@ X_API void YAP_Init(YAP_init_args *yap_init) {
|
||||
init_globals(yap_init);
|
||||
|
||||
start_modules();
|
||||
if (yap_init->install && Yap_OUTPUT_STARTUP) {
|
||||
setAtomicGlobalPrologFlag(RESOURCE_DATABASE_FLAG,
|
||||
MkAtomTerm(Yap_LookupAtom(Yap_INPUT_STARTUP)));
|
||||
setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, true);
|
||||
@ -1052,11 +1055,12 @@ X_API void YAP_Init(YAP_init_args *yap_init) {
|
||||
|
||||
if (yap_init->install && Yap_OUTPUT_STARTUP) {
|
||||
Term t = MkAtomTerm(Yap_LookupAtom(Yap_OUTPUT_STARTUP));
|
||||
Term g = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("qsave_program"), 1),
|
||||
Term g = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("qsave_program"), 1),
|
||||
1, &t);
|
||||
|
||||
YAP_RunGoalOnce(g);
|
||||
}
|
||||
}
|
||||
end_init(yap_init);
|
||||
}
|
||||
|
||||
|
@ -101,9 +101,9 @@ protected:
|
||||
/// Just do nothing.
|
||||
inline YAPPredicate() {
|
||||
}
|
||||
|
||||
YAPPredicate(Term &to, Term &tmod, CELL * &ts, const char *pname);
|
||||
|
||||
|
||||
/// Term constructor for predicates
|
||||
///
|
||||
/// It is just a call to getPred
|
||||
|
@ -152,6 +152,11 @@ E(SYSTEM_ERROR_FATAL, SYSTEM_ERROR_CLASS, "fatal")
|
||||
E(SYSTEM_ERROR_GET_FAILED, SYSTEM_ERROR_CLASS, "get_failed")
|
||||
E(SYSTEM_ERROR_PUT_FAILED, SYSTEM_ERROR_CLASS, "put_failed")
|
||||
E(SYSTEM_ERROR_JIT_NOT_AVAILABLE, SYSTEM_ERROR_CLASS, "jit_not_available")
|
||||
E(SYSTEM_ERROR_RUNTIME_ANDROID, SYSTEM_ERROR_CLASS, "android_runtime error")
|
||||
E(SYSTEM_ERROR_RUNTIME_JAVA, SYSTEM_ERROR_CLASS, "java_runtime error")
|
||||
E(SYSTEM_ERROR_RUNTIME_JS, SYSTEM_ERROR_CLASS, "javascript_runtime error")
|
||||
E(SYSTEM_ERROR_RUNTIME_PYTHON, SYSTEM_ERROR_CLASS, "python_runtime error")
|
||||
E(SYSTEM_ERROR_RUNTIME_R, SYSTEM_ERROR_CLASS, "r_runtime error")
|
||||
E(SYSTEM_ERROR_OPERATING_SYSTEM, SYSTEM_ERROR_CLASS, "operating_system_error")
|
||||
E(SYSTEM_ERROR_SAVED_STATE, SYSTEM_ERROR_CLASS, "saved_state_error")
|
||||
|
||||
|
@ -132,13 +132,9 @@ static bool py_close(int sno) {
|
||||
static bool getLine(StreamDesc *rl_iostream, int sno) {
|
||||
char *myrl_line = NULL;
|
||||
term_t ctk = python_acquire_GIL();
|
||||
Py_ssize_t size;
|
||||
PyObject *prompt = PyUnicode_FromString("?- "),
|
||||
*msg = PyUnicode_FromString(" **input** "),
|
||||
*o = PyObject_GetAttrString(rl_iostream->u.private_data, "read");
|
||||
|
||||
/* window of vulnerability opened */
|
||||
myrl_line = PyUnicode_AsUTF8AndSize(
|
||||
PyObject_CallFunctionObjArgs(o, msg, prompt, NULL), &size);
|
||||
myrl_line = PyUnicode_AsUTF8(PyObject_CallFunctionObjArgs(rl_iostream->u.private_data, NULL));
|
||||
python_release_GIL(ctk);
|
||||
PyObject *err;
|
||||
if ((err = PyErr_Occurred())) {
|
||||
@ -147,6 +143,7 @@ static bool getLine(StreamDesc *rl_iostream, int sno) {
|
||||
"Error in getLine\n");
|
||||
Yap_ThrowError(SYSTEM_ERROR_GET_FAILED, YAP_MkIntTerm(sno), err);
|
||||
}
|
||||
size_t size = strlen (myrl_line)+1;
|
||||
rl_iostream->u.irl.ptr = rl_iostream->u.irl.buf =
|
||||
(const unsigned char *)malloc(size);
|
||||
memcpy((void *)rl_iostream->u.irl.buf, myrl_line, size);
|
||||
|
Reference in New Issue
Block a user