diff --git a/C/c_interface.c b/C/c_interface.c index 6be273a56..115294d49 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -1514,12 +1514,10 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) } else if (val == 1) { /* TRUE */ cut_succeed(); } else { - /* - if ((val & REDO_PTR) == REDO_PTR) + if ((val & REDO_PTR) == REDO_PTR) ctx->context = (int *)(val & ~REDO_PTR); - else + else ctx->context = (int *)((val & ~REDO_PTR)>>FRG_REDO_BITS); - */ return TRUE; } } else { diff --git a/library/dialect/swi/fli/blobs.c b/library/dialect/swi/fli/blobs.c index 48b88e6f2..ef35c7a21 100644 --- a/library/dialect/swi/fli/blobs.c +++ b/library/dialect/swi/fli/blobs.c @@ -24,6 +24,12 @@ #include "swi.h" +static PL_blob_t unregistered_blob_atom = +{ PL_BLOB_MAGIC, + PL_BLOB_NOCOPY|PL_BLOB_TEXT, + "unregistered" +}; + PL_EXPORT(int) PL_is_blob(term_t t, PL_blob_t **type) @@ -75,13 +81,13 @@ PL_blob_data(atom_t a, size_t *len, struct PL_blob_t **type) if ( len ) *len = wcslen(x->WStrOfAE); if ( type ) - *type = SWI_Blobs; + *type = &unregistered_blob_atom; return x->WStrOfAE; } if ( len ) *len = strlen(x->StrOfAE); if ( type ) - *type = SWI_Blobs; + *type = &unregistered_blob_atom; return x->StrOfAE; } if ( len ) @@ -112,7 +118,7 @@ YAP_find_blob_type(YAP_Atom at) { AtomEntry *a = RepAtom((Atom)at); if (!IsBlob(a)) { - return SWI_Blobs; + return &unregistered_blob_atom; } return RepBlobProp(a->PropsOfAE)->blob_t; } diff --git a/library/dialect/swi/fli/swi.c b/library/dialect/swi/fli/swi.c index d759c8644..d912e93ef 100755 --- a/library/dialect/swi/fli/swi.c +++ b/library/dialect/swi/fli/swi.c @@ -2115,11 +2115,9 @@ X_API int PL_recorded(record_t db, term_t ts) { Term t = YAP_Recorded((void *)db); - fprintf(stderr,"PL_recorded %ld\n", t); if (t == ((CELL)0)) return FALSE; Yap_PutInSlot(ts,t); - fprintf(stderr,"PL_recorded\n"); return TRUE; } diff --git a/packages/PLStream/pl-ctype.c b/packages/PLStream/pl-ctype.c index baf65463f..9498bf74a 100644 --- a/packages/PLStream/pl-ctype.c +++ b/packages/PLStream/pl-ctype.c @@ -419,7 +419,6 @@ do_char_type(term_t chr, term_t class, control_t h, int how) default: succeed; } - if ( !(fid = PL_open_foreign_frame()) ) goto error; @@ -800,11 +799,11 @@ PRED_IMPL("setlocale", 3, setlocale, 0) *******************************/ BeginPredDefs(ctype) - PRED_DEF("swi_char_type", 2, char_type, PL_FA_NONDETERMINISTIC) - PRED_DEF("swi_code_type", 2, code_type, PL_FA_NONDETERMINISTIC) - PRED_DEF("swi_setlocale", 3, setlocale, 0) - PRED_DEF("swi_downcase_atom", 2, downcase_atom, 0) - PRED_DEF("swi_upcase_atom", 2, upcase_atom, 0) + PRED_DEF("char_type", 2, char_type, PL_FA_NONDETERMINISTIC) + PRED_DEF("code_type", 2, code_type, PL_FA_NONDETERMINISTIC) + PRED_DEF("setlocale", 3, setlocale, 0) + PRED_DEF("downcase_atom", 2, downcase_atom, 0) + PRED_DEF("upcase_atom", 2, upcase_atom, 0) PRED_DEF("swi_normalize_space", 2, normalize_space, 0) EndPredDefs diff --git a/packages/PLStream/pl-text.c b/packages/PLStream/pl-text.c index b554f6320..37c8e0b12 100644 --- a/packages/PLStream/pl-text.c +++ b/packages/PLStream/pl-text.c @@ -126,7 +126,7 @@ PL_get_text__LD(term_t l, PL_chars_t *text, int flags ARG_LD) { word w = valHandle(l); if ( (flags & CVT_ATOM) && isAtom(w) ) - { if ( !get_atom_text(w, text) ) + { if ( !get_atom_text(atomFromTerm(w), text) ) goto maybe_write; } else if ( (flags & CVT_STRING) && isString(w) ) { if ( !get_string_text(w, text PASS_LD) ) diff --git a/packages/PLStream/pl-yap.c b/packages/PLStream/pl-yap.c index 38f69a801..be38caceb 100755 --- a/packages/PLStream/pl-yap.c +++ b/packages/PLStream/pl-yap.c @@ -222,6 +222,9 @@ _PL_unify_atomic(term_t t, PL_atomic_t a) word lookupAtom(const char *s, size_t len) { + /* dirty trick to ensure s is null terminated */ + char *st = (char *)s; + st[len] = '\0'; if (len >= strlen(s)) { return (word)YAP_LookupAtom(s); } else { diff --git a/packages/PLStream/pl-yap.h b/packages/PLStream/pl-yap.h index 615ba0939..10be296c8 100644 --- a/packages/PLStream/pl-yap.h +++ b/packages/PLStream/pl-yap.h @@ -121,7 +121,8 @@ PL_blob_t* YAP_find_blob_type(YAP_Atom at); #define valReal(w) YAP_FloatOfTerm((w)) #define valFloat(w) YAP_FloatOfTerm((w)) #define AtomLength(w) YAP_AtomNameLength(w) -#define atomValue(atom) YAP_AtomOfTerm(atom) +#define atomValue(atom) YAP_AtomFromSWIAtom(atom) +#define atomFromTerm(term) YAP_AtomOfTerm(term) #define atomName(atom) ((char *)YAP_AtomName(atom)) #define nameOfAtom(atom) ((char *)YAP_AtomName(atom)) #define atomLength(atom) YAP_AtomNameLength(atom)