diff --git a/os/pl-file.c b/os/pl-file.c index deec99410..2acad86d8 100644 --- a/os/pl-file.c +++ b/os/pl-file.c @@ -3232,7 +3232,7 @@ PRED_IMPL("prompt1", 1, prompt1, 0) if ( PL_get_atom(A1, &a) ) { prompt1(a); } else if ( PL_get_text(A1, &txt, CVT_ALL|CVT_EXCEPTION) ) - { prompt1(textToAtom(&txt)); + { prompt1(YAP_SWIAtomFromAtom(textToAtom(&txt))); } else return FALSE; @@ -3373,7 +3373,7 @@ fn_to_atom(const char *fn) text.length = strlen(fn); text.canonical = FALSE; - a = textToAtom(&text); + a = YAP_SWIAtomFromAtom(textToAtom(&text)); PL_free_text(&text); return a; diff --git a/os/pl-files.c b/os/pl-files.c index 5f4a0f197..abebd19b6 100644 --- a/os/pl-files.c +++ b/os/pl-files.c @@ -969,7 +969,7 @@ PRED_IMPL("file_base_name", 2, file_base_name, 0) if ( !PL_get_chars(A1, &n, CVT_ALL|REP_FN|CVT_EXCEPTION) ) return FALSE; - + return PL_unify_chars(A2, PL_ATOM|REP_FN, -1, BaseName(n)); } @@ -981,8 +981,8 @@ PRED_IMPL("file_directory_name", 2, file_directory_name, 0) if ( !PL_get_chars(A1, &n, CVT_ALL|REP_FN|CVT_EXCEPTION) ) return FALSE; - - return PL_unify_chars(A2, PL_ATOM|REP_FN, -1, DirName(n, tmp)); + int out = PL_unify_chars(A2, PL_ATOM|REP_FN, -1, DirName(n, tmp)); + return out; } diff --git a/os/pl-prologflag.c b/os/pl-prologflag.c index 41856cd4a..543bc3bb8 100755 --- a/os/pl-prologflag.c +++ b/os/pl-prologflag.c @@ -198,7 +198,7 @@ setPrologFlag(const char *name, int flags, ...) text.length = strlen(text.text.t); text.canonical = FALSE; - f->value.a = textToAtom(&text); /* registered: ok */ + f->value.a = YAP_SWIAtomFromAtom(textToAtom(&text)); /* registered: ok */ PL_free_text(&text); diff --git a/os/pl-text.c b/os/pl-text.c index 77d6de178..29b2668db 100644 --- a/os/pl-text.c +++ b/os/pl-text.c @@ -354,16 +354,18 @@ error: } -atom_t +Atom textToAtom(PL_chars_t *text) { if ( !PL_canonise_text(text) ) return 0; + Atom w; if ( text->encoding == ENC_ISO_LATIN_1 ) - { return lookupAtom(text->text.t, text->length); + { w = lookupAtom(text->text.t, text->length); } else - { return lookupUCSAtom(text->text.w, text->length); + { w = lookupUCSAtom(text->text.w, text->length); } + return w ; } @@ -383,13 +385,14 @@ textToString(PL_chars_t *text) int PL_unify_text(term_t term, term_t tail, PL_chars_t *text, int type) { switch(type) - { case PL_ATOM: - { atom_t a = textToAtom(text); + { case PL_ATOM: + { Atom at = textToAtom(text); + Term a = MkAtomTerm(at); - if ( a ) + if ( a ) { int rval = _PL_unify_atomic(term, a); - PL_unregister_atom(a); + PL_unregister_atom(YAP_SWIAtomFromAtom(AtomOfTerm(a))); return rval; } return FALSE; diff --git a/os/pl-text.h b/os/pl-text.h index 375a84e61..11dd0b7a4 100644 --- a/os/pl-text.h +++ b/os/pl-text.h @@ -71,7 +71,7 @@ void PL_free_text(PL_chars_t *text); void PL_save_text(PL_chars_t *text, int flags); COMMON(int) PL_get_text__LD(term_t l, PL_chars_t *text, int flags ARG_LD); -COMMON(atom_t) textToAtom(PL_chars_t *text); +COMMON(Atom) textToAtom(PL_chars_t *text); COMMON(IOSTREAM *) Sopen_text(PL_chars_t *text, const char *mode); COMMON(void) PL_text_recode(PL_chars_t *text, IOENC encoding);