CurrentModule needs to be set correctly,

This commit is contained in:
Vítor Santos Costa 2016-01-31 10:16:02 +00:00
parent 9444c36ff4
commit f5c493507e

View File

@ -115,17 +115,17 @@ bool Yap_Warning(const char *s, ...) {
} else } else
return false; return false;
va_end(ap); va_end(ap);
if (pred->OpcodeOfPred == UNDEF_OPCODE) { if (pred->OpcodeOfPred == UNDEF_OPCODE||
pred->OpcodeOfPred == FAIL_OPCODE) {
fprintf(stderr, "warning message: %s\n", tmpbuf); fprintf(stderr, "warning message: %s\n", tmpbuf);
LOCAL_DoingUndefp = false; LOCAL_DoingUndefp = false;
LOCAL_within_print_message = false; LOCAL_within_print_message = false;
return true; return false;
} }
ts[1] = MkAtomTerm(AtomWarning); ts[1] = MkAtomTerm(AtomWarning);
ts[0] = MkAtomTerm(Yap_LookupAtom(tmpbuf)); ts[0] = MkAtomTerm(Yap_LookupAtom(tmpbuf));
rc = Yap_execute_pred(pred, ts, true PASS_REGS); rc = Yap_execute_pred(pred, ts, true PASS_REGS);
LOCAL_within_print_message = false;
return rc; return rc;
} }
@ -133,6 +133,7 @@ bool Yap_PrintWarning(Term twarning) {
CACHE_REGS CACHE_REGS
PredEntry *pred = RepPredProp(PredPropByFunc( PredEntry *pred = RepPredProp(PredPropByFunc(
FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2; FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2;
Term cmod = CurrentModule;
bool rc; bool rc;
Term ts[2]; Term ts[2];
@ -143,13 +144,16 @@ bool Yap_PrintWarning(Term twarning) {
} }
LOCAL_DoingUndefp = true; LOCAL_DoingUndefp = true;
LOCAL_within_print_message = true; LOCAL_within_print_message = true;
if (pred->OpcodeOfPred == UNDEF_OPCODE) { if (pred->OpcodeOfPred == UNDEF_OPCODE ||
pred->OpcodeOfPred == FAIL_OPCODE
) {
fprintf(stderr, "warning message:\n"); fprintf(stderr, "warning message:\n");
Yap_DebugPlWrite(twarning); Yap_DebugPlWrite(twarning);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
LOCAL_DoingUndefp = false; LOCAL_DoingUndefp = false;
LOCAL_within_print_message = false; LOCAL_within_print_message = false;
return true; CurrentModule = cmod;
return false;
} }
ts[1] = twarning; ts[1] = twarning;
ts[0] = MkAtomTerm(AtomWarning); ts[0] = MkAtomTerm(AtomWarning);