keep on fixing Paulo's tests
This commit is contained in:
@@ -700,7 +700,7 @@ restart_aux:
|
||||
if (IsNumTerm(t1)) {
|
||||
Term t2 = Deref(ARG2);
|
||||
Term t12 = Yap_NumberToListOfAtoms(t1 PASS_REGS);
|
||||
if (t12) {
|
||||
if (t12 && t2) {
|
||||
{
|
||||
pop_text_stack(l);
|
||||
return Yap_unify(t12, t2);
|
||||
|
14
C/errors.c
14
C/errors.c
@@ -785,12 +785,14 @@ yamop *Yap_Error__(bool throw, const char *file, const char *function,
|
||||
fprintf(stderr, "***** Processing Error %d (%x) %s***\n", type,
|
||||
LOCAL_PrologMode, fmt);
|
||||
#endif
|
||||
if (LOCAL_ActiveError->errorNo == SYNTAX_ERROR) {
|
||||
;
|
||||
LOCAL_ActiveError->errorClass = SYNTAX_ERROR_CLASS;
|
||||
return P;
|
||||
}
|
||||
if (type == INTERRUPT_EVENT) {
|
||||
if (LOCAL_ActiveError->errorNo == SYNTAX_ERROR) {
|
||||
LOCAL_ActiveError->errorClass = SYNTAX_ERROR_CLASS;
|
||||
return P;
|
||||
} else if (LOCAL_ActiveError->errorNo == SYNTAX_ERROR_NUMBER) {
|
||||
LOCAL_ActiveError->errorClass = SYNTAX_ERROR_CLASS;
|
||||
LOCAL_ActiveError->errorNo = SYNTAX_ERROR;
|
||||
}
|
||||
if (type == INTERRUPT_EVENT) {
|
||||
fprintf(stderr, "%% YAP exiting: cannot handle signal %d\n",
|
||||
(int)IntOfTerm(where));
|
||||
Yap_exit(1);
|
||||
|
46
C/text.c
46
C/text.c
@@ -249,42 +249,62 @@ static void *codes2buf(Term t0, void *b0, bool *get_codes USES_REGS) {
|
||||
while (IsPairTerm(t)) {
|
||||
Term hd = HeadOfTerm(t);
|
||||
if (IsVarTerm(hd)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t0, "scanning list of codes");
|
||||
Yap_ThrowError(INSTANTIATION_ERROR, hd, "scanning list of codes");
|
||||
return NULL;
|
||||
}
|
||||
if (!IsIntegerTerm(hd)) {
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t0, "scanning list of codes");
|
||||
Yap_ThrowError(TYPE_ERROR_CHARACTER_CODE, hd, "scanning list of codes");
|
||||
return NULL;
|
||||
}
|
||||
Int code = IntegerOfTerm(hd);
|
||||
if (code < 0) {
|
||||
Yap_Error(REPRESENTATION_ERROR_CHARACTER_CODE, t0,
|
||||
Yap_ThrowError(TYPE_ERROR_CHARACTER_CODE, hd,
|
||||
"scanning list of codes");
|
||||
return NULL;
|
||||
}
|
||||
length += put_utf8(ar, code);
|
||||
t = TailOfTerm(t);
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_ThrowError(INSTANTIATION_ERROR, t, "scanning list of codes");
|
||||
return NULL;
|
||||
}
|
||||
if (!IsPairTerm(t) && t != TermNil) {
|
||||
Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (IsPairTerm(t)) {
|
||||
Term hd = HeadOfTerm(t);
|
||||
if (IsVarTerm(hd)) {
|
||||
Yap_ThrowError(INSTANTIATION_ERROR, hd, "scanning list of codes");
|
||||
return NULL;
|
||||
}
|
||||
if (!IsAtomTerm(hd)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t0, "scanning list of atoms");
|
||||
Yap_ThrowError(TYPE_ERROR_CHARACTER, hd, "scanning list of atoms");
|
||||
return NULL;
|
||||
}
|
||||
const char *code = RepAtom(AtomOfTerm(hd))->StrOfAE;
|
||||
if (code < 0) {
|
||||
Yap_Error(REPRESENTATION_ERROR_CHARACTER, t0, "scanning list of atoms");
|
||||
Yap_ThrowError(TYPE_ERROR_CHARACTER, hd, "scanning list of atoms");
|
||||
return NULL;
|
||||
}
|
||||
length += strlen(code);
|
||||
t = TailOfTerm(t);
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_ThrowError(INSTANTIATION_ERROR, t, "scanning list of codes");
|
||||
return NULL;
|
||||
}
|
||||
if (!IsPairTerm(t) && t != TermNil) {
|
||||
Yap_ThrowError(TYPE_ERROR_LIST, t, "scanning list of codes");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsVarTerm(t)) {
|
||||
if (t != TermNil) {
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t0, "scanning list of codes");
|
||||
Yap_ThrowError(TYPE_ERROR_LIST, t0, "scanning list of codes");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -294,7 +314,6 @@ static void *codes2buf(Term t0, void *b0, bool *get_codes USES_REGS) {
|
||||
if (codes) {
|
||||
while (IsPairTerm(t)) {
|
||||
Term hd = HeadOfTerm(t);
|
||||
|
||||
Int code = IntegerOfTerm(hd);
|
||||
|
||||
st = st + put_utf8(st, code);
|
||||
@@ -736,7 +755,18 @@ static size_t write_length(const unsigned char *s0, seq_tv_t *out USES_REGS) {
|
||||
static Term write_number(unsigned char *s, seq_tv_t *out,
|
||||
bool error_on USES_REGS) {
|
||||
Term t;
|
||||
t = Yap_StringToNumberTerm((char *)s, &out->enc,true);
|
||||
yap_error_descriptor_t new_error;
|
||||
bool mdnew = true;
|
||||
Yap_pushErrorContext(error_on, &new_error);
|
||||
t = Yap_StringToNumberTerm((char *)s, &out->enc,error_on);
|
||||
Yap_popErrorContext(mdnew, true);
|
||||
if (error_on) {
|
||||
if (t == 0 && LOCAL_ActiveError->errorNo != YAP_NO_ERROR) {
|
||||
P = FAILCODE;
|
||||
Yap_HandleError("scanningx");
|
||||
}
|
||||
}
|
||||
Yap_ResetException(LOCAL_ActiveError);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user