This commit is contained in:
Vitor Santos Costa 2017-09-17 21:06:22 +01:00
parent 717aeb162a
commit b24dc4893d
3 changed files with 22 additions and 32 deletions

View File

@ -495,8 +495,10 @@ restart_aux:
Atom at; Atom at;
// verify if an atom, int, float or bignnum // verify if an atom, int, float or bignnum
at = Yap_StringSWIToAtom(t2 PASS_REGS); at = Yap_StringSWIToAtom(t2 PASS_REGS);
if (at) if (at) {
ReleaseAndReturn(Yap_unify(MkAtomTerm(at), t1)); ReleaseAndReturn(Yap_unify(MkAtomTerm(at), t1));
}
LOCAL_Error_TYPE = YAP_NO_ERROR;
// else // else
} else if (IsAtomTerm(t1)) { } else if (IsAtomTerm(t1)) {
Term t0 = Yap_AtomSWIToString(t1 PASS_REGS); Term t0 = Yap_AtomSWIToString(t1 PASS_REGS);
@ -1836,7 +1838,7 @@ static Int upcase_text_to_chars(USES_REGS1) {
static Int atom_split(USES_REGS1) { static Int atom_split(USES_REGS1) {
Term t1 = Deref(ARG1); Term t1 = Deref(ARG1);
Term t2 = Deref(ARG2); Term t2 = Deref(ARG2);
size_t len; size_t u_mid;
Term to1, to2; Term to1, to2;
Atom at; Atom at;
@ -1857,33 +1859,26 @@ static Int atom_split(USES_REGS1) {
Yap_Error(TYPE_ERROR_INTEGER, t2, "$atom_split/4"); Yap_Error(TYPE_ERROR_INTEGER, t2, "$atom_split/4");
ReleaseAndReturn((FALSE)); ReleaseAndReturn((FALSE));
} }
if ((Int)(len = IntOfTerm(t2)) < 0) { if ((Int)(u_mid = IntOfTerm(t2)) < 0) {
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "$atom_split/4"); Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "atom_split/4");
ReleaseAndReturn((FALSE)); ReleaseAndReturn((FALSE));
} }
at = AtomOfTerm(t1); at = AtomOfTerm(t1);
char *s; const char *s = RepAtom(at)->StrOfAE;
unsigned char *s1, *s10, *s0; const unsigned char *s0 = RepAtom(at)->UStrOfAE;
s = RepAtom(at)->StrOfAE; unsigned char *s1, *s10;
if (len > strlen(s)) size_t u_len = strlen_utf8(s0);
ReleaseAndReturn((FALSE)); if (u_mid > u_len) {
s1 = s10 = Malloc(len); ReleaseAndReturn(false);
s0 = RepAtom(at)->UStrOfAE;
if (s1 + len > (unsigned char *)ASP - 1024) {
if (!Yap_gc(2, ENV, gc_P(P, CP))) {
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
return FALSE;
} }
} size_t b_mid = skip_utf8(s0, u_mid)-s0;
size_t j; s1 = s10 = Malloc(b_mid +1);
for (j = 0; j < len; j++) { memcpy(s1, s, b_mid);
int32_t val; s1[b_mid] ='\0';
s0 += get_utf8(s0, 1, &val);
s1 += put_utf8(s1, val);
}
s1[0] = '\0';
to1 = MkAtomTerm(Yap_ULookupAtom(s10)); to1 = MkAtomTerm(Yap_ULookupAtom(s10));
to2 = MkAtomTerm(Yap_LookupAtom(s)); to2 = MkAtomTerm(Yap_ULookupAtom(s0+b_mid));
Yap_DebugPlWriteln(to1);
Yap_DebugPlWriteln(to2);
ReleaseAndReturn( ReleaseAndReturn(
(Yap_unify_constant(ARG3, to1) && Yap_unify_constant(ARG4, to2))); (Yap_unify_constant(ARG3, to1) && Yap_unify_constant(ARG4, to2)));
} }

View File

@ -41,12 +41,7 @@ bool Yap_Warning(const char *s, ...) {
const char *format; const char *format;
char tmpbuf[MAXPATHLEN]; char tmpbuf[MAXPATHLEN];
if (LOCAL_within_print_message) { LOCAL_DoingUndefp = true;
/* error within error */
fprintf(stderr, "%% WARNING WITHIN WARNING\n");
Yap_RestartYap(1);
}
LOCAL_DoingUndefp = true;
LOCAL_within_print_message = true; LOCAL_within_print_message = true;
pred = RepPredProp(PredPropByFunc(FunctorPrintMessage, pred = RepPredProp(PredPropByFunc(FunctorPrintMessage,
PROLOG_MODULE)); // PROCEDURE_print_message2 PROLOG_MODULE)); // PROCEDURE_print_message2

View File

@ -609,7 +609,7 @@ static void putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) {
wrputc('\'', stream); wrputc('\'', stream);
while (*s) { while (*s) {
int32_t ch; int32_t ch;
s += get_utf8(s, 1, &ch); s += get_utf8(s, -1, &ch);
write_quoted( ch, '\'', stream); write_quoted( ch, '\'', stream);
} }
wrputc('\'', stream); wrputc('\'', stream);