improve string support
fix non-thread compilation.
This commit is contained in:
@@ -4672,6 +4672,7 @@ EndPredDefs
|
||||
|
||||
#if __YAP_PROLOG__
|
||||
|
||||
static int
|
||||
pl_get_time(term_t t)
|
||||
{ return PL_unify_float(t, WallTime());
|
||||
}
|
||||
@@ -4728,10 +4729,12 @@ struct PL_local_data *Yap_InitThreadIO(int wid)
|
||||
Yap_Error(OUT_OF_HEAP_ERROR, 0L, "Creating thread %d\n", wid);
|
||||
return p;
|
||||
}
|
||||
#if THREADS
|
||||
if (wid) {
|
||||
/* copy from other worker */
|
||||
memcpy(p, Yap_WLocal[worker_id]->Yap_ld_, sizeof(struct PL_local_data));
|
||||
}
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@@ -597,9 +597,11 @@ extern void PL_cleanup_fork(void);
|
||||
extern int PL_rethrow(void);
|
||||
extern void PL_get_number(term_t l, number *n);
|
||||
extern int PL_unify_atomic(term_t t, PL_atomic_t a);
|
||||
extern int _PL_unify_atomic(term_t t, PL_atomic_t a);
|
||||
extern int _PL_unify_string(term_t t, word w);
|
||||
|
||||
#define _PL_get_arg(X,Y,Z) PL_get_arg(X,Y,Z)
|
||||
#define _PL_unify_atomic PL_unify_atomic
|
||||
|
||||
extern IOSTREAM ** /* provide access to Suser_input, */
|
||||
_PL_streams(void); /* Suser_output and Suser_error */
|
||||
|
||||
|
@@ -353,7 +353,7 @@ PL_unify_text(term_t term, term_t tail, PL_chars_t *text, int type)
|
||||
{ word w = textToString(text);
|
||||
|
||||
if ( w )
|
||||
return _PL_unify_atomic(term, w);
|
||||
return _PL_unify_string(term, w);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
@@ -77,15 +77,13 @@ codeToAtom(int chrcode)
|
||||
word
|
||||
globalString(size_t size, char *s)
|
||||
{
|
||||
// return YAP_MkBlobStringTerm(s, size);
|
||||
return 0L;
|
||||
return Yap_MkBlobStringTerm(s, size);
|
||||
}
|
||||
|
||||
word
|
||||
globalWString(size_t size, wchar_t *s)
|
||||
{
|
||||
// return YAP_MkBlobWideStringTerm(size, s);
|
||||
return 0L;
|
||||
return Yap_MkBlobWideStringTerm(s, size);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -282,6 +280,13 @@ _PL_unify_atomic(term_t t, PL_atomic_t a)
|
||||
return PL_unify_atom(t, a);
|
||||
}
|
||||
|
||||
int
|
||||
_PL_unify_string(term_t t, word w)
|
||||
{
|
||||
GET_LD
|
||||
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), w);
|
||||
}
|
||||
|
||||
word lookupAtom(const char *s, size_t len)
|
||||
{
|
||||
/* dirty trick to ensure s is null terminated */
|
||||
@@ -377,7 +382,21 @@ get_atom_text(atom_t atom, PL_chars_t *text)
|
||||
|
||||
int
|
||||
get_string_text(word w, PL_chars_t *text ARG_LD)
|
||||
{ fail;
|
||||
{
|
||||
CELL fl = RepAppl(w)[1];
|
||||
if (fl == BLOB_STRING) {
|
||||
fprintf(stderr,"%s\n", Yap_BlobStringOfTerm(w));
|
||||
text->text.t = Yap_BlobStringOfTerm(w);
|
||||
text->encoding = ENC_ISO_LATIN_1;
|
||||
text->length = strlen(text->text.t);
|
||||
} else {
|
||||
text->text.w = Yap_BlobWideStringOfTerm(w);
|
||||
text->encoding = ENC_WCHAR;
|
||||
text->length = wcslen(text->text.w);
|
||||
}
|
||||
text->storage = PL_CHARS_STACK;
|
||||
text->canonical = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1067,18 +1086,6 @@ recursiveMutexInit(recursiveMutex *m)
|
||||
|
||||
}
|
||||
|
||||
word
|
||||
pl_sleep(term_t time)
|
||||
{ double t;
|
||||
|
||||
if ( PL_get_float_ex(time, &t) )
|
||||
return Pause(t);
|
||||
|
||||
fail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
counting_mutex _PL_mutexes[] =
|
||||
{ COUNT_MUTEX_INITIALIZER("L_MISC"),
|
||||
COUNT_MUTEX_INITIALIZER("L_ALLOC"),
|
||||
|
@@ -115,7 +115,7 @@ void PL_license(const char *license, const char *module);
|
||||
|
||||
#define stringAtom(w) YAP_AtomName((YAP_Atom)(w))
|
||||
#define isInteger(A) (YAP_IsIntTerm((A)) || YAP_IsBigNumTerm((A)))
|
||||
#define isString(A) FALSE
|
||||
#define isString(A) Yap_IsStringTerm(A)
|
||||
#define isAtom(A) YAP_IsAtomTerm((A))
|
||||
#define isList(A) YAP_IsPairTerm((A))
|
||||
#define isNil(A) ((A) == YAP_TermNil())
|
||||
|
Reference in New Issue
Block a user