mostly indenting
This commit is contained in:
parent
a95b3e4fcd
commit
7885433ab5
93
C/errors.c
93
C/errors.c
@ -1,4 +1,3 @@
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Yap Prolog *
|
||||
@ -89,15 +88,49 @@ void Yap_PrintPredName(PredEntry *ap) {
|
||||
#endif
|
||||
|
||||
bool Yap_Warning(const char *s, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, s);
|
||||
fprintf(stderr, "warning: %s\n", s);
|
||||
va_end(args);
|
||||
CACHE_REGS
|
||||
va_list ap;
|
||||
PredEntry *pred;
|
||||
bool rc;
|
||||
Term ts[2];
|
||||
const char *format;
|
||||
char tmpbuf[MAXPATHLEN];
|
||||
|
||||
if (LOCAL_within_print_message) {
|
||||
/* error within error */
|
||||
fprintf(stderr, "%% WARNING WITHIN WARNING\n");
|
||||
Yap_RestartYap(1);
|
||||
}
|
||||
LOCAL_DoingUndefp = true;
|
||||
LOCAL_within_print_message = true;
|
||||
pred = RepPredProp(PredPropByFunc(FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2
|
||||
if (pred->OpcodeOfPred == UNDEF_OPCODE) {
|
||||
//fprintf(stderr, "warning message:\n");
|
||||
//Yap_DebugPlWrite(twarning);
|
||||
//fprintf(stderr, "\n");
|
||||
LOCAL_DoingUndefp = false;
|
||||
LOCAL_within_print_message = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
va_start(ap, s);
|
||||
format = va_arg(ap, char *);
|
||||
if (format != NULL) {
|
||||
#if HAVE_VSNPRINTF
|
||||
vsnprintf(tmpbuf, MAXPATHLEN-1, format, ap);
|
||||
#else
|
||||
(void)vsprintf(tmpbuf, format, ap);
|
||||
#endif
|
||||
} else
|
||||
return false;
|
||||
va_end(ap);
|
||||
ts[0] = MkAtomTerm(AtomWarning);
|
||||
ts[1] = MkAtomTerm(Yap_LookupAtom(tmpbuf));
|
||||
rc = Yap_execute_pred(pred, ts, true PASS_REGS);
|
||||
LOCAL_within_print_message = false;
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool Yap_PrintWarning(Term twarning) {
|
||||
CACHE_REGS
|
||||
PredEntry *pred = RepPredProp(PredPropByFunc(
|
||||
@ -113,9 +146,9 @@ bool Yap_PrintWarning(Term twarning) {
|
||||
LOCAL_DoingUndefp = true;
|
||||
LOCAL_within_print_message = true;
|
||||
if (pred->OpcodeOfPred == UNDEF_OPCODE) {
|
||||
fprintf(stderr, "warning message:\n");
|
||||
Yap_DebugPlWrite(twarning);
|
||||
fprintf(stderr, "\n");
|
||||
//fprintf(stderr, "warning message:\n");
|
||||
//Yap_DebugPlWrite(twarning);
|
||||
//fprintf(stderr, "\n");
|
||||
LOCAL_DoingUndefp = false;
|
||||
LOCAL_within_print_message = false;
|
||||
return true;
|
||||
@ -291,7 +324,7 @@ static char tmpbuf[YAP_BUF_SIZE];
|
||||
#include "YapErrors.h"
|
||||
|
||||
/**
|
||||
* @brief Yap_Errorp
|
||||
* @brief Yap_Error
|
||||
* This function handles errors in the C code. Check errors.yap for the
|
||||
*corresponding Prolog code.
|
||||
*
|
||||
@ -330,6 +363,8 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
Functor fun;
|
||||
bool serious;
|
||||
Term tf, error_t, comment, culprit;
|
||||
char *format;
|
||||
char s[MAXPATHLEN];
|
||||
|
||||
/* disallow recursive error handling */
|
||||
if (LOCAL_PrologMode & InErrorMode) {
|
||||
@ -371,6 +406,21 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
fprintf(stderr, "%% Continuation: %s\n", (char *)HR);
|
||||
error_exit_yap(1);
|
||||
}
|
||||
va_start(ap, where);
|
||||
format = va_arg(ap, char *);
|
||||
if (format != NULL) {
|
||||
#if HAVE_VSNPRINTF
|
||||
(void)vsnprintf(s, MAXPATHLEN-1, format, ap);
|
||||
#else
|
||||
(void)vsprintf(s, format, ap);
|
||||
#endif
|
||||
//fprintf(stderr, "warning: ");
|
||||
comment = MkAtomTerm(Yap_LookupAtom(s));
|
||||
} else if (LOCAL_ErrorSay && LOCAL_ErrorSay[0])
|
||||
comment = MkAtomTerm(Yap_LookupAtom( LOCAL_ErrorSay ) );
|
||||
else
|
||||
comment = TermNil;
|
||||
va_end(ap);
|
||||
if (P == (yamop *)(FAILCODE))
|
||||
return P;
|
||||
/* PURE_ABORT may not have set where correctly, BootMode may not have the data
|
||||
@ -400,23 +450,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
where = TermNil;
|
||||
}
|
||||
}
|
||||
{
|
||||
char *format;
|
||||
va_start(ap, where);
|
||||
format = va_arg(ap, char *);
|
||||
if (format != NULL) {
|
||||
#if HAVE_VSNPRINTF
|
||||
(void)vsnprintf(tmpbuf, YAP_BUF_SIZE, format, ap);
|
||||
#else
|
||||
(void)vsprintf(tmpbuf, format, ap);
|
||||
#endif
|
||||
comment = MkAtomTerm(Yap_LookupAtom(tmpbuf));
|
||||
} else {
|
||||
tmpbuf[0] = '\0';
|
||||
comment = TermNil;
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
if (LOCAL_PrologMode & BootMode) {
|
||||
/* crash in flames! */
|
||||
fprintf(stderr, "%% YAP Fatal Error: %s exiting....\n", tmpbuf);
|
||||
@ -494,10 +528,6 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
MAX_ERROR_MSG_SIZE);
|
||||
LOCAL_ErrorMessage = LOCAL_ErrorSay;
|
||||
}
|
||||
if (LOCAL_ErrorSay && LOCAL_ErrorSay[0])
|
||||
comment = MkAtomTerm(Yap_LookupAtom( LOCAL_ErrorSay ) );
|
||||
else
|
||||
comment = TermNil;
|
||||
}
|
||||
switch (type) {
|
||||
case RESOURCE_ERROR_HEAP:
|
||||
@ -523,7 +553,6 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
nt[1] = MkPairTerm(MkPairTerm(MkAtomTerm(Yap_LookupAtom("e")),culprit), nt[1]);
|
||||
}
|
||||
}
|
||||
Yap_DebugPlWrite(nt[1]);
|
||||
/* disable active signals at this point */
|
||||
LOCAL_Signals = 0;
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
|
Reference in New Issue
Block a user