fix fixes (lots of white space, somehow.
This commit is contained in:
parent
0ccee1aa55
commit
b9eb327d86
@ -1090,9 +1090,9 @@ execute_dealloc( USES_REGS1 )
|
|||||||
else
|
else
|
||||||
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CP));
|
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CP));
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
YENV = ENV_YREG;
|
YENV = ENVYREG;
|
||||||
P = NEXTOP(P,p);
|
P = NEXTOP(P,p);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't forget I cannot creep at deallocate (where to?) */
|
/* don't forget I cannot creep at deallocate (where to?) */
|
||||||
@ -1366,7 +1366,7 @@ undef_goal( USES_REGS1 )
|
|||||||
PredEntry *pe = PredFromDefCode(P);
|
PredEntry *pe = PredFromDefCode(P);
|
||||||
if (Yap_UnknownFlag(CurrentModule) == TermFail) {
|
if (Yap_UnknownFlag(CurrentModule) == TermFail) {
|
||||||
P = FAILCODE;
|
P = FAILCODE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
/* avoid trouble with undefined dynamic procedures */
|
/* avoid trouble with undefined dynamic procedures */
|
||||||
|
186
C/atomic.c
186
C/atomic.c
@ -25,7 +25,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
The following predicates are used to manipulate atoms:
|
The following predicates are used to manipulate atoms:
|
||||||
|
|
||||||
\toc
|
\toc
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ static Int unhide_atom( USES_REGS1 );
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
AlreadyHidden(unsigned char *name)
|
AlreadyHidden(unsigned char *name)
|
||||||
{
|
{
|
||||||
AtomEntry *chain;
|
AtomEntry *chain;
|
||||||
@ -93,7 +93,7 @@ AlreadyHidden(unsigned char *name)
|
|||||||
result in a different atom.xs
|
result in a different atom.xs
|
||||||
|
|
||||||
**/
|
**/
|
||||||
static Int
|
static Int
|
||||||
hide_atom( USES_REGS1 )
|
hide_atom( USES_REGS1 )
|
||||||
{ /* hide(+Atom) */
|
{ /* hide(+Atom) */
|
||||||
Atom atomToInclude;
|
Atom atomToInclude;
|
||||||
@ -119,7 +119,7 @@ hide_atom( USES_REGS1 )
|
|||||||
if (IsPredProperty(p->KindOfPE) ||
|
if (IsPredProperty(p->KindOfPE) ||
|
||||||
IsDBProperty(p->KindOfPE ) ) {
|
IsDBProperty(p->KindOfPE ) ) {
|
||||||
RepPredProp(p)->PredFlags |= HiddenPredFlag;
|
RepPredProp(p)->PredFlags |= HiddenPredFlag;
|
||||||
|
|
||||||
} else if (p->KindOfPE == FunctorProperty) {
|
} else if (p->KindOfPE == FunctorProperty) {
|
||||||
Prop q = RepFunctorProp(p)->PropsOfFE;
|
Prop q = RepFunctorProp(p)->PropsOfFE;
|
||||||
while (q) {
|
while (q) {
|
||||||
@ -142,11 +142,11 @@ hide_atom( USES_REGS1 )
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @pred hidden_atom( +Atom )
|
/** @pred hidden_atom( +Atom )
|
||||||
Is the atom _Ãtom_ visible to Prolog?
|
Is the atom _Ãtom_ visible to Prolog?
|
||||||
|
|
||||||
**/
|
**/
|
||||||
static Int
|
static Int
|
||||||
hidden_atom( USES_REGS1 )
|
hidden_atom( USES_REGS1 )
|
||||||
{ /* '$hidden_atom'(+F) */
|
{ /* '$hidden_atom'(+F) */
|
||||||
Atom at;
|
Atom at;
|
||||||
@ -172,13 +172,13 @@ hidden_atom( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @pred unhide_atom(+ _Atom_)
|
/** @pred unhide_atom(+ _Atom_)
|
||||||
Make hidden atom _Atom_ visible
|
Make hidden atom _Atom_ visible
|
||||||
|
|
||||||
Note that the operation fails if another atom with name _Atom_ was defined since.
|
Note that the operation fails if another atom with name _Atom_ was defined since.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
static Int
|
static Int
|
||||||
unhide_atom( USES_REGS1 )
|
unhide_atom( USES_REGS1 )
|
||||||
{ /* unhide_atom(+Atom) */
|
{ /* unhide_atom(+Atom) */
|
||||||
AtomEntry *atom, *old, *chain;
|
AtomEntry *atom, *old, *chain;
|
||||||
@ -217,7 +217,7 @@ unhide_atom( USES_REGS1 )
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
char_code( USES_REGS1 )
|
char_code( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Int t0 = Deref(ARG1);
|
Int t0 = Deref(ARG1);
|
||||||
@ -269,7 +269,7 @@ char_code( USES_REGS1 )
|
|||||||
|
|
||||||
if (IsWideAtom(at)) {
|
if (IsWideAtom(at)) {
|
||||||
wchar_t *c = RepAtom(at)->WStrOfAE;
|
wchar_t *c = RepAtom(at)->WStrOfAE;
|
||||||
|
|
||||||
if (c[1] != '\0') {
|
if (c[1] != '\0') {
|
||||||
Yap_Error(TYPE_ERROR_CHARACTER,t0,"char_code/2");
|
Yap_Error(TYPE_ERROR_CHARACTER,t0,"char_code/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -277,7 +277,7 @@ char_code( USES_REGS1 )
|
|||||||
tf = MkIntegerTerm(c[0]);
|
tf = MkIntegerTerm(c[0]);
|
||||||
} else {
|
} else {
|
||||||
unsigned char *c = RepAtom(at)->UStrOfAE;
|
unsigned char *c = RepAtom(at)->UStrOfAE;
|
||||||
|
|
||||||
if (c[1] != '\0') {
|
if (c[1] != '\0') {
|
||||||
Yap_Error(TYPE_ERROR_CHARACTER,t0,"char_code/2");
|
Yap_Error(TYPE_ERROR_CHARACTER,t0,"char_code/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -288,7 +288,7 @@ char_code( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
name( USES_REGS1 )
|
name( USES_REGS1 )
|
||||||
{ /* name(?Atomic,?String) */
|
{ /* name(?Atomic,?String) */
|
||||||
Term t = Deref(ARG2), NewT, AtomNameT = Deref(ARG1);
|
Term t = Deref(ARG2), NewT, AtomNameT = Deref(ARG1);
|
||||||
@ -322,7 +322,7 @@ name( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
string_to_atomic( USES_REGS1 )
|
string_to_atomic( USES_REGS1 )
|
||||||
{ /* string_to_atom(?String,?Atom) */
|
{ /* string_to_atom(?String,?Atom) */
|
||||||
Term t2 = Deref(ARG2), t1 = Deref(ARG1);
|
Term t2 = Deref(ARG2), t1 = Deref(ARG1);
|
||||||
@ -350,7 +350,7 @@ string_to_atomic( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
string_to_atom( USES_REGS1 )
|
string_to_atom( USES_REGS1 )
|
||||||
{ /* string_to_atom(?String,?Atom) */
|
{ /* string_to_atom(?String,?Atom) */
|
||||||
Term t2 = Deref(ARG2), t1 = Deref(ARG1);
|
Term t2 = Deref(ARG2), t1 = Deref(ARG1);
|
||||||
@ -378,9 +378,9 @@ string_to_atom( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
string_to_list( USES_REGS1 )
|
string_to_list( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term list = Deref(ARG2), string = Deref(ARG1);
|
Term list = Deref(ARG2), string = Deref(ARG1);
|
||||||
LOCAL_MAX_SIZE = 1024;
|
LOCAL_MAX_SIZE = 1024;
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ string_to_list( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atom_string( USES_REGS1 )
|
atom_string( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1), t2 = Deref(ARG2);
|
Term t1 = Deref(ARG1), t2 = Deref(ARG2);
|
||||||
@ -431,7 +431,7 @@ atom_string( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atom_chars( USES_REGS1 )
|
atom_chars( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -459,7 +459,7 @@ atom_chars( USES_REGS1 )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atom_codes( USES_REGS1 )
|
atom_codes( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -486,7 +486,7 @@ restart_aux:
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
string_codes( USES_REGS1 )
|
string_codes( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -513,7 +513,7 @@ restart_aux:
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
string_chars( USES_REGS1 )
|
string_chars( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -540,15 +540,15 @@ restart_aux:
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @pred number_chars(? _I_,? _L_) is iso
|
/** @pred number_chars(? _I_,? _L_) is iso
|
||||||
|
|
||||||
The predicate holds when at least one of the arguments is ground
|
The predicate holds when at least one of the arguments is ground
|
||||||
(otherwise, an error message will be displayed). The argument _I_ must
|
(otherwise, an error message will be displayed). The argument _I_ must
|
||||||
be unifiable with a number, and the argument _L_ with the list of the
|
be unifiable with a number, and the argument _L_ with the list of the
|
||||||
characters of the external representation of _I_.
|
characters of the external representation of _I_.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int
|
static Int
|
||||||
number_chars( USES_REGS1 )
|
number_chars( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -579,7 +579,7 @@ number_chars( USES_REGS1 )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
number_atom( USES_REGS1 )
|
number_atom( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -605,7 +605,7 @@ number_atom( USES_REGS1 )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
number_string( USES_REGS1 )
|
number_string( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -632,7 +632,7 @@ number_string( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
number_codes( USES_REGS1 )
|
number_codes( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -659,7 +659,7 @@ number_codes( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
cont_atom_concat3( USES_REGS1 )
|
cont_atom_concat3( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t3;
|
Term t3;
|
||||||
@ -691,7 +691,7 @@ cont_atom_concat3( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atom_concat3( USES_REGS1 )
|
atom_concat3( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -757,7 +757,7 @@ CastToNumeric__(Atom at USES_REGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
cont_atomic_concat3( USES_REGS1 )
|
cont_atomic_concat3( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t3;
|
Term t3;
|
||||||
@ -833,7 +833,7 @@ atomic_concat3( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
cont_string_concat3( USES_REGS1 )
|
cont_string_concat3( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t3;
|
Term t3;
|
||||||
@ -908,7 +908,7 @@ string_concat3( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
cont_string_code3( USES_REGS1 )
|
cont_string_code3( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t2;
|
Term t2;
|
||||||
@ -943,7 +943,7 @@ cont_string_code3( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
string_code3( USES_REGS1 )
|
string_code3( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -1001,7 +1001,7 @@ string_code3( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
get_string_code3( USES_REGS1 )
|
get_string_code3( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -1060,7 +1060,7 @@ get_string_code3( USES_REGS1 )
|
|||||||
cut_fail();
|
cut_fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atom_concat2( USES_REGS1 )
|
atom_concat2( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -1075,7 +1075,7 @@ atom_concat2( USES_REGS1 )
|
|||||||
seq_tv_t *inpv = (seq_tv_t *)malloc(n*sizeof(seq_tv_t)), out;
|
seq_tv_t *inpv = (seq_tv_t *)malloc(n*sizeof(seq_tv_t)), out;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Atom at;
|
Atom at;
|
||||||
|
|
||||||
if (!inpv) {
|
if (!inpv) {
|
||||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||||
free(inpv);
|
free(inpv);
|
||||||
@ -1109,7 +1109,7 @@ atom_concat2( USES_REGS1 )
|
|||||||
cut_fail();
|
cut_fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
string_concat2( USES_REGS1 )
|
string_concat2( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -1123,7 +1123,7 @@ string_concat2( USES_REGS1 )
|
|||||||
} else {
|
} else {
|
||||||
seq_tv_t *inpv = (seq_tv_t *)malloc(n*sizeof(seq_tv_t)), out;
|
seq_tv_t *inpv = (seq_tv_t *)malloc(n*sizeof(seq_tv_t)), out;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (!inpv) {
|
if (!inpv) {
|
||||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||||
free(inpv);
|
free(inpv);
|
||||||
@ -1157,7 +1157,7 @@ string_concat2( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atomic_concat2( USES_REGS1 )
|
atomic_concat2( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -1203,7 +1203,7 @@ atomic_concat2( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atomics_to_string2( USES_REGS1 )
|
atomics_to_string2( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -1218,7 +1218,7 @@ atomics_to_string2( USES_REGS1 )
|
|||||||
seq_tv_t *inpv = (seq_tv_t *)malloc(n*sizeof(seq_tv_t)), out;
|
seq_tv_t *inpv = (seq_tv_t *)malloc(n*sizeof(seq_tv_t)), out;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Atom at;
|
Atom at;
|
||||||
|
|
||||||
if (!inpv) {
|
if (!inpv) {
|
||||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||||
free(inpv);
|
free(inpv);
|
||||||
@ -1248,7 +1248,7 @@ atomics_to_string2( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atomics_to_string3( USES_REGS1 )
|
atomics_to_string3( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1, t2;
|
Term t1, t2;
|
||||||
@ -1264,7 +1264,7 @@ atomics_to_string3( USES_REGS1 )
|
|||||||
seq_tv_t *inpv = (seq_tv_t *)malloc((n*2-1)*sizeof(seq_tv_t)), out;
|
seq_tv_t *inpv = (seq_tv_t *)malloc((n*2-1)*sizeof(seq_tv_t)), out;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Atom at;
|
Atom at;
|
||||||
|
|
||||||
if (!inpv) {
|
if (!inpv) {
|
||||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||||
free(inpv);
|
free(inpv);
|
||||||
@ -1297,7 +1297,7 @@ atomics_to_string3( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atom_length( USES_REGS1 )
|
atom_length( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1);;
|
Term t1 = Deref(ARG1);;
|
||||||
@ -1317,7 +1317,7 @@ atom_length( USES_REGS1 )
|
|||||||
if (!IsIntegerTerm(t2)) {
|
if (!IsIntegerTerm(t2)) {
|
||||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "atom_length/2");
|
Yap_Error(TYPE_ERROR_INTEGER, t2, "atom_length/2");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else if ((len = IntegerOfTerm(t2)) < 0) {
|
} else if ((Int)(len = IntegerOfTerm(t2)) < 0) {
|
||||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "atom_length/2");
|
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "atom_length/2");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -1354,7 +1354,7 @@ atomic_length( USES_REGS1 )
|
|||||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "atomic_length/2");
|
Yap_Error(TYPE_ERROR_INTEGER, t2, "atomic_length/2");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if ((len = IntegerOfTerm(t2)) < 0) {
|
if ((Int)(len = IntegerOfTerm(t2)) < 0) {
|
||||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "atomic_length/2");
|
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "atomic_length/2");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -1383,7 +1383,7 @@ string_length( USES_REGS1 )
|
|||||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "string_length/2");
|
Yap_Error(TYPE_ERROR_INTEGER, t2, "string_length/2");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if (FALSE && (len = IntegerOfTerm(t2)) < 0) {
|
if (FALSE && (Int)(len = IntegerOfTerm(t2)) < 0) {
|
||||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "string_length/2");
|
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "string_length/2");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -1414,7 +1414,7 @@ is_wide(wchar_t *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* split an atom into two sub-atoms */
|
/* split an atom into two sub-atoms */
|
||||||
static Int
|
static Int
|
||||||
atom_split( USES_REGS1 )
|
atom_split( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -1426,7 +1426,7 @@ atom_split( USES_REGS1 )
|
|||||||
|
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t1, "$atom_split/4");
|
Yap_Error(INSTANTIATION_ERROR, t1, "$atom_split/4");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if (!IsAtomTerm(t1)) {
|
if (!IsAtomTerm(t1)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, t1, "$atom_split/4");
|
Yap_Error(TYPE_ERROR_ATOM, t1, "$atom_split/4");
|
||||||
@ -1434,7 +1434,7 @@ atom_split( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
if (IsVarTerm(t2)) {
|
if (IsVarTerm(t2)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t2, "$atom_split/4");
|
Yap_Error(INSTANTIATION_ERROR, t2, "$atom_split/4");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if (!IsIntTerm(t2)) {
|
if (!IsIntTerm(t2)) {
|
||||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "$atom_split/4");
|
Yap_Error(TYPE_ERROR_INTEGER, t2, "$atom_split/4");
|
||||||
@ -1473,7 +1473,7 @@ atom_split( USES_REGS1 )
|
|||||||
to1 = MkAtomTerm(Yap_LookupWideAtom(ws1));
|
to1 = MkAtomTerm(Yap_LookupWideAtom(ws1));
|
||||||
/* we don't know if the rest of the string is wide or not */
|
/* we don't know if the rest of the string is wide or not */
|
||||||
if (is_wide(ws+len)) {
|
if (is_wide(ws+len)) {
|
||||||
to2 = MkAtomTerm(Yap_LookupWideAtom(ws+len));
|
to2 = MkAtomTerm(Yap_LookupWideAtom(ws+len));
|
||||||
} else {
|
} else {
|
||||||
char *s2 = (char *)HR;
|
char *s2 = (char *)HR;
|
||||||
if (s2+(wlen-len) > (char *)ASP-1024)
|
if (s2+(wlen-len) > (char *)ASP-1024)
|
||||||
@ -1486,7 +1486,7 @@ atom_split( USES_REGS1 )
|
|||||||
s1[len] = '\0';
|
s1[len] = '\0';
|
||||||
to1 = MkAtomTerm(Yap_ULookupAtom(s1));
|
to1 = MkAtomTerm(Yap_ULookupAtom(s1));
|
||||||
/* second atom must be wide, if first wasn't */
|
/* second atom must be wide, if first wasn't */
|
||||||
to2 = MkAtomTerm(Yap_LookupWideAtom(ws+len));
|
to2 = MkAtomTerm(Yap_LookupWideAtom(ws+len));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned char *s, *s1 = (unsigned char *)HR;
|
unsigned char *s, *s1 = (unsigned char *)HR;
|
||||||
@ -1505,7 +1505,7 @@ atom_split( USES_REGS1 )
|
|||||||
return(Yap_unify_constant(ARG3,to1) && Yap_unify_constant(ARG4,to2));
|
return(Yap_unify_constant(ARG3,to1) && Yap_unify_constant(ARG4,to2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
atom_number( USES_REGS1 )
|
atom_number( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -1531,7 +1531,7 @@ atom_number( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
string_number( USES_REGS1 )
|
string_number( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t1;
|
Term t1;
|
||||||
@ -1584,7 +1584,7 @@ build_new_atomic(int mask, wchar_t *wp, const unsigned char *p, size_t min, size
|
|||||||
wchar_t *src = wp+min;
|
wchar_t *src = wp+min;
|
||||||
wchar_t *d = alloc_tmp_stack((len+1)*sizeof(wchar_t) PASS_REGS);
|
wchar_t *d = alloc_tmp_stack((len+1)*sizeof(wchar_t) PASS_REGS);
|
||||||
if (!d) return NIL;
|
if (!d) return NIL;
|
||||||
|
|
||||||
wcsncpy(d, src, len);
|
wcsncpy(d, src, len);
|
||||||
d[len] = '\0';
|
d[len] = '\0';
|
||||||
nat = Yap_LookupMaybeWideAtom(d);
|
nat = Yap_LookupMaybeWideAtom(d);
|
||||||
@ -1594,7 +1594,7 @@ build_new_atomic(int mask, wchar_t *wp, const unsigned char *p, size_t min, size
|
|||||||
const unsigned char *src = p+min;
|
const unsigned char *src = p+min;
|
||||||
unsigned char *d = alloc_tmp_stack((len+1)*sizeof(char) PASS_REGS);
|
unsigned char *d = alloc_tmp_stack((len+1)*sizeof(char) PASS_REGS);
|
||||||
if (!d) return NIL;
|
if (!d) return NIL;
|
||||||
|
|
||||||
strncpy((char *)d, (char *)src, len);
|
strncpy((char *)d, (char *)src, len);
|
||||||
d[len] = '\0';
|
d[len] = '\0';
|
||||||
nat = Yap_ULookupAtom(d);
|
nat = Yap_ULookupAtom(d);
|
||||||
@ -1616,7 +1616,7 @@ build_new_atomic(int mask, wchar_t *wp, const unsigned char *p, size_t min, size
|
|||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
*buf++ = '\0';
|
*buf++ = '\0';
|
||||||
|
|
||||||
close_tstring( buf PASS_REGS );
|
close_tstring( buf PASS_REGS );
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
@ -1797,8 +1797,8 @@ cont_sub_atomic( USES_REGS1 )
|
|||||||
after--;
|
after--;
|
||||||
min++;
|
min++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (sub_atom) {
|
} else if (sub_atom) {
|
||||||
p = RepAtom(at)->UStrOfAE;
|
p = RepAtom(at)->UStrOfAE;
|
||||||
while (!found) {
|
while (!found) {
|
||||||
@ -1866,7 +1866,7 @@ cont_sub_atomic( USES_REGS1 )
|
|||||||
Yap_unify(ARG4, MkIntegerTerm(after));
|
Yap_unify(ARG4, MkIntegerTerm(after));
|
||||||
Yap_unify(ARG5, nat);
|
Yap_unify(ARG5, nat);
|
||||||
len++;
|
len++;
|
||||||
if (after-- == 0) cut_succeed();
|
if (after-- == 0) cut_succeed();
|
||||||
} else if (mask & SUB_ATOM_HAS_AFTER) {
|
} else if (mask & SUB_ATOM_HAS_AFTER) {
|
||||||
len = sz-(min+after);
|
len = sz-(min+after);
|
||||||
nat = build_new_atomic(mask, wp, p, min, len PASS_REGS);
|
nat = build_new_atomic(mask, wp, p, min, len PASS_REGS);
|
||||||
@ -1874,7 +1874,7 @@ cont_sub_atomic( USES_REGS1 )
|
|||||||
Yap_unify(ARG3, MkIntegerTerm(len));
|
Yap_unify(ARG3, MkIntegerTerm(len));
|
||||||
Yap_unify(ARG5, nat);
|
Yap_unify(ARG5, nat);
|
||||||
min++;
|
min++;
|
||||||
if (len-- == 0) cut_succeed();
|
if (len-- == 0) cut_succeed();
|
||||||
} else {
|
} else {
|
||||||
nat = build_new_atomic(mask, wp, p, min, len PASS_REGS);
|
nat = build_new_atomic(mask, wp, p, min, len PASS_REGS);
|
||||||
Yap_unify(ARG2, MkIntegerTerm(min));
|
Yap_unify(ARG2, MkIntegerTerm(min));
|
||||||
@ -1892,8 +1892,8 @@ cont_sub_atomic( USES_REGS1 )
|
|||||||
EXTRA_CBACK_ARG(5,1) = MkIntegerTerm(mask);
|
EXTRA_CBACK_ARG(5,1) = MkIntegerTerm(mask);
|
||||||
EXTRA_CBACK_ARG(5,2) = MkIntegerTerm(min);
|
EXTRA_CBACK_ARG(5,2) = MkIntegerTerm(min);
|
||||||
EXTRA_CBACK_ARG(5,3) = MkIntegerTerm(len);
|
EXTRA_CBACK_ARG(5,3) = MkIntegerTerm(len);
|
||||||
EXTRA_CBACK_ARG(5,4) = MkIntegerTerm(after);
|
EXTRA_CBACK_ARG(5,4) = MkIntegerTerm(after);
|
||||||
EXTRA_CBACK_ARG(5,5) = MkIntegerTerm(sz);
|
EXTRA_CBACK_ARG(5,5) = MkIntegerTerm(sz);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1909,7 +1909,7 @@ sub_atomic( int sub_atom USES_REGS )
|
|||||||
Term nat = 0L;
|
Term nat = 0L;
|
||||||
Atom at = NULL;
|
Atom at = NULL;
|
||||||
|
|
||||||
tat1 = Deref(ARG1);
|
tat1 = Deref(ARG1);
|
||||||
EXTRA_CBACK_ARG(5,3) = MkIntegerTerm(0);
|
EXTRA_CBACK_ARG(5,3) = MkIntegerTerm(0);
|
||||||
if (IsVarTerm(tat1)) {
|
if (IsVarTerm(tat1)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, tat1, "sub_atom/5: first argument");
|
Yap_Error(INSTANTIATION_ERROR, tat1, "sub_atom/5: first argument");
|
||||||
@ -1921,7 +1921,7 @@ sub_atomic( int sub_atom USES_REGS )
|
|||||||
Yap_Error(TYPE_ERROR_STRING, tat1, "sub_string/5");
|
Yap_Error(TYPE_ERROR_STRING, tat1, "sub_string/5");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
tbef = Deref(ARG2);
|
tbef = Deref(ARG2);
|
||||||
if (IsVarTerm(tbef)) {
|
if (IsVarTerm(tbef)) {
|
||||||
min = 0;
|
min = 0;
|
||||||
} else if (!IsIntegerTerm(tbef)) {
|
} else if (!IsIntegerTerm(tbef)) {
|
||||||
@ -1973,7 +1973,7 @@ sub_atomic( int sub_atom USES_REGS )
|
|||||||
Atom oat;
|
Atom oat;
|
||||||
mask |= SUB_ATOM_HAS_VAL|SUB_ATOM_HAS_SIZE;
|
mask |= SUB_ATOM_HAS_VAL|SUB_ATOM_HAS_SIZE;
|
||||||
oat = AtomOfTerm(tout);
|
oat = AtomOfTerm(tout);
|
||||||
if (IsWideAtom(oat))
|
if (IsWideAtom(oat))
|
||||||
len = wcslen(RepAtom(oat)->WStrOfAE);
|
len = wcslen(RepAtom(oat)->WStrOfAE);
|
||||||
else
|
else
|
||||||
len = strlen((const char *)RepAtom(oat)->StrOfAE);
|
len = strlen((const char *)RepAtom(oat)->StrOfAE);
|
||||||
@ -2062,7 +2062,7 @@ sub_atomic( int sub_atom USES_REGS )
|
|||||||
if (!out) cut_fail();
|
if (!out) cut_fail();
|
||||||
}
|
}
|
||||||
if (len == sz) {
|
if (len == sz) {
|
||||||
out = out &&
|
out = out &&
|
||||||
Yap_unify(ARG1, ARG5) &&
|
Yap_unify(ARG1, ARG5) &&
|
||||||
Yap_unify(ARG2, MkIntegerTerm(0)) &&
|
Yap_unify(ARG2, MkIntegerTerm(0)) &&
|
||||||
Yap_unify(ARG4, MkIntegerTerm(0));
|
Yap_unify(ARG4, MkIntegerTerm(0));
|
||||||
@ -2086,12 +2086,12 @@ sub_atomic( int sub_atom USES_REGS )
|
|||||||
EXTRA_CBACK_ARG(5,1) = MkIntegerTerm(mask);
|
EXTRA_CBACK_ARG(5,1) = MkIntegerTerm(mask);
|
||||||
EXTRA_CBACK_ARG(5,2) = MkIntegerTerm(min);
|
EXTRA_CBACK_ARG(5,2) = MkIntegerTerm(min);
|
||||||
EXTRA_CBACK_ARG(5,3) = MkIntegerTerm(len);
|
EXTRA_CBACK_ARG(5,3) = MkIntegerTerm(len);
|
||||||
EXTRA_CBACK_ARG(5,4) = MkIntegerTerm(after);
|
EXTRA_CBACK_ARG(5,4) = MkIntegerTerm(after);
|
||||||
EXTRA_CBACK_ARG(5,5) = MkIntegerTerm(sz);
|
EXTRA_CBACK_ARG(5,5) = MkIntegerTerm(sz);
|
||||||
return cont_sub_atomic( PASS_REGS1 );
|
return cont_sub_atomic( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @pred sub_atom(+ _A_,? _Bef_, ? _Size_, ? _After_, ? _At_out_) is iso
|
/** @pred sub_atom(+ _A_,? _Bef_, ? _Size_, ? _After_, ? _At_out_) is iso
|
||||||
|
|
||||||
|
|
||||||
True when _A_ and _At_out_ are atoms such that the name of
|
True when _A_ and _At_out_ are atoms such that the name of
|
||||||
@ -2103,7 +2103,7 @@ Note that _A_ must always be known, but _At_out_ can be unbound when
|
|||||||
calling this built-in. If all the arguments for sub_atom/5 but _A_
|
calling this built-in. If all the arguments for sub_atom/5 but _A_
|
||||||
are unbound, the built-in will backtrack through all possible
|
are unbound, the built-in will backtrack through all possible
|
||||||
sub-strings of _A_.
|
sub-strings of _A_.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int
|
static Int
|
||||||
sub_atom( USES_REGS1 )
|
sub_atom( USES_REGS1 )
|
||||||
@ -2111,10 +2111,10 @@ sub_atom( USES_REGS1 )
|
|||||||
return sub_atomic( TRUE PASS_REGS );
|
return sub_atomic( TRUE PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @pred sub_string(+ _S_,? _Bef_, ? _Size_, ? _After_, ? _S_out_) is iso
|
/** @pred sub_string(+ _S_,? _Bef_, ? _Size_, ? _After_, ? _S_out_) is iso
|
||||||
|
|
||||||
|
|
||||||
True when _S_ and _S_out_ are strings such that the
|
True when _S_ and _S_out_ are strings such that the
|
||||||
_S_out_ has size _Size_ and is a sub-string of
|
_S_out_ has size _Size_ and is a sub-string of
|
||||||
_S_, _Bef_ is the number of characters before, and
|
_S_, _Bef_ is the number of characters before, and
|
||||||
_After_ the number of characters afterwards.
|
_After_ the number of characters afterwards.
|
||||||
@ -2123,7 +2123,7 @@ Note that _S_ must always be known, but _S_out_ can be unbound when
|
|||||||
calling this built-in. If all the arguments for sub_string/5 but _S_
|
calling this built-in. If all the arguments for sub_string/5 but _S_
|
||||||
are unbound, the built-in will generate all possible
|
are unbound, the built-in will generate all possible
|
||||||
sub-strings of _S_.
|
sub-strings of _S_.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static Int
|
static Int
|
||||||
sub_string( USES_REGS1 )
|
sub_string( USES_REGS1 )
|
||||||
@ -2131,7 +2131,7 @@ sub_string( USES_REGS1 )
|
|||||||
return sub_atomic( FALSE PASS_REGS );
|
return sub_atomic( FALSE PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
cont_current_atom( USES_REGS1 )
|
cont_current_atom( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Atom catom;
|
Atom catom;
|
||||||
@ -2190,7 +2190,7 @@ cont_current_atom( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
current_atom( USES_REGS1 )
|
current_atom( USES_REGS1 )
|
||||||
{ /* current_atom(?Atom) */
|
{ /* current_atom(?Atom) */
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -2212,7 +2212,7 @@ current_atom( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
cont_current_wide_atom( USES_REGS1 )
|
cont_current_wide_atom( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Atom catom;
|
Atom catom;
|
||||||
@ -2271,7 +2271,7 @@ cont_current_wide_atom( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
current_wide_atom( USES_REGS1 )
|
current_wide_atom( USES_REGS1 )
|
||||||
{ /* current_atom(?Atom) */
|
{ /* current_atom(?Atom) */
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
@ -2310,7 +2310,7 @@ void
|
|||||||
Yap_InitAtomPreds(void)
|
Yap_InitAtomPreds(void)
|
||||||
{
|
{
|
||||||
Yap_InitCPred("name", 2, name, 0);
|
Yap_InitCPred("name", 2, name, 0);
|
||||||
/** @pred name( _A_, _L_)
|
/** @pred name( _A_, _L_)
|
||||||
|
|
||||||
|
|
||||||
The predicate holds when at least one of the arguments is ground
|
The predicate holds when at least one of the arguments is ground
|
||||||
@ -2337,14 +2337,14 @@ will return:
|
|||||||
L = [51].
|
L = [51].
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
Yap_InitCPred("string_to_atom", 2, string_to_atom, 0);
|
Yap_InitCPred("string_to_atom", 2, string_to_atom, 0);
|
||||||
Yap_InitCPred("atom_string", 2, atom_string, 0);
|
Yap_InitCPred("atom_string", 2, atom_string, 0);
|
||||||
Yap_InitCPred("string_to_atomic", 2, string_to_atomic, 0);
|
Yap_InitCPred("string_to_atomic", 2, string_to_atomic, 0);
|
||||||
Yap_InitCPred("string_to_list", 2, string_to_list, 0);
|
Yap_InitCPred("string_to_list", 2, string_to_list, 0);
|
||||||
Yap_InitCPred("char_code", 2, char_code, SafePredFlag);
|
Yap_InitCPred("char_code", 2, char_code, SafePredFlag);
|
||||||
/** @pred char_code(? _A_,? _I_) is iso
|
/** @pred char_code(? _A_,? _I_) is iso
|
||||||
|
|
||||||
|
|
||||||
The built-in succeeds with _A_ bound to character represented as an
|
The built-in succeeds with _A_ bound to character represented as an
|
||||||
@ -2352,10 +2352,10 @@ atom, and _I_ bound to the character code represented as an
|
|||||||
integer. At least, one of either _A_ or _I_ must be bound before
|
integer. At least, one of either _A_ or _I_ must be bound before
|
||||||
the call.
|
the call.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
Yap_InitCPred("atom_chars", 2, atom_chars, 0);
|
Yap_InitCPred("atom_chars", 2, atom_chars, 0);
|
||||||
/** @pred atom_chars(? _A_,? _L_) is iso
|
/** @pred atom_chars(? _A_,? _L_) is iso
|
||||||
|
|
||||||
|
|
||||||
The predicate holds when at least one of the arguments is ground
|
The predicate holds when at least one of the arguments is ground
|
||||||
@ -2363,26 +2363,26 @@ The predicate holds when at least one of the arguments is ground
|
|||||||
be unifiable with an atom, and the argument _L_ with the list of the
|
be unifiable with an atom, and the argument _L_ with the list of the
|
||||||
characters of _A_.
|
characters of _A_.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
Yap_InitCPred("atom_codes", 2, atom_codes, 0);
|
Yap_InitCPred("atom_codes", 2, atom_codes, 0);
|
||||||
Yap_InitCPred("string_codes", 2, string_codes, 0);
|
Yap_InitCPred("string_codes", 2, string_codes, 0);
|
||||||
Yap_InitCPred("string_chars", 2, string_chars, 0);
|
Yap_InitCPred("string_chars", 2, string_chars, 0);
|
||||||
Yap_InitCPred("atom_length", 2, atom_length, SafePredFlag);
|
Yap_InitCPred("atom_length", 2, atom_length, SafePredFlag);
|
||||||
/** @pred atom_length(+ _A_,? _I_) is iso
|
/** @pred atom_length(+ _A_,? _I_) is iso
|
||||||
|
|
||||||
|
|
||||||
The predicate holds when the first argument is an atom, and the second
|
The predicate holds when the first argument is an atom, and the second
|
||||||
unifies with the number of characters forming that atom.
|
unifies with the number of characters forming that atom.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
Yap_InitCPred("atomic_length", 2, atomic_length, SafePredFlag);
|
Yap_InitCPred("atomic_length", 2, atomic_length, SafePredFlag);
|
||||||
Yap_InitCPred("string_length", 2, string_length, SafePredFlag);
|
Yap_InitCPred("string_length", 2, string_length, SafePredFlag);
|
||||||
Yap_InitCPred("$atom_split", 4, atom_split, SafePredFlag);
|
Yap_InitCPred("$atom_split", 4, atom_split, SafePredFlag);
|
||||||
Yap_InitCPred("number_chars", 2, number_chars, 0);
|
Yap_InitCPred("number_chars", 2, number_chars, 0);
|
||||||
Yap_InitCPred("number_atom", 2, number_atom, 0);
|
Yap_InitCPred("number_atom", 2, number_atom, 0);
|
||||||
/** @pred number_atom(? _I_,? _L_)
|
/** @pred number_atom(? _I_,? _L_)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2391,12 +2391,12 @@ The predicate holds when at least one of the arguments is ground
|
|||||||
be unifiable with a number, and the argument _L_ must be unifiable
|
be unifiable with a number, and the argument _L_ must be unifiable
|
||||||
with an atom representing the number.
|
with an atom representing the number.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
Yap_InitCPred("number_string", 2, number_string, 0);
|
Yap_InitCPred("number_string", 2, number_string, 0);
|
||||||
Yap_InitCPred("number_codes", 2, number_codes, 0);
|
Yap_InitCPred("number_codes", 2, number_codes, 0);
|
||||||
Yap_InitCPred("atom_number", 2, atom_number, 0);
|
Yap_InitCPred("atom_number", 2, atom_number, 0);
|
||||||
/** @pred atom_number(? _Atom_,? _Number_)
|
/** @pred atom_number(? _Atom_,? _Number_)
|
||||||
|
|
||||||
|
|
||||||
The predicate holds when at least one of the arguments is ground
|
The predicate holds when at least one of the arguments is ground
|
||||||
@ -2405,13 +2405,13 @@ The predicate holds when at least one of the arguments is ground
|
|||||||
to the characters in _Atom_, otherwise the characters in
|
to the characters in _Atom_, otherwise the characters in
|
||||||
_Atom_ must encode a number _Number_.
|
_Atom_ must encode a number _Number_.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
Yap_InitCPred("string_number", 2, string_number, 0);
|
Yap_InitCPred("string_number", 2, string_number, 0);
|
||||||
Yap_InitCPred("$atom_concat", 2, atom_concat2, 0);
|
Yap_InitCPred("$atom_concat", 2, atom_concat2, 0);
|
||||||
Yap_InitCPred("$string_concat", 2, string_concat2, 0);
|
Yap_InitCPred("$string_concat", 2, string_concat2, 0);
|
||||||
Yap_InitCPred("atomic_concat", 2, atomic_concat2, 0);
|
Yap_InitCPred("atomic_concat", 2, atomic_concat2, 0);
|
||||||
/** @pred atomic_concat(+ _As_,? _A_)
|
/** @pred atomic_concat(+ _As_,? _A_)
|
||||||
|
|
||||||
|
|
||||||
The predicate holds when the first argument is a list of atomic terms, and
|
The predicate holds when the first argument is a list of atomic terms, and
|
||||||
@ -2419,7 +2419,7 @@ the second unifies with the atom obtained by concatenating all the
|
|||||||
atomic terms in the first list. The first argument thus may contain
|
atomic terms in the first list. The first argument thus may contain
|
||||||
atoms or numbers.
|
atoms or numbers.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
Yap_InitCPred("atomics_to_string", 2, atomics_to_string2, 0);
|
Yap_InitCPred("atomics_to_string", 2, atomics_to_string2, 0);
|
||||||
Yap_InitCPred("atomics_to_string", 3, atomics_to_string3, 0);
|
Yap_InitCPred("atomics_to_string", 3, atomics_to_string3, 0);
|
||||||
|
@ -1019,7 +1019,7 @@ Term Yap_UnknownFlag(Term mod) {
|
|||||||
|
|
||||||
ModEntry *fv = Yap_GetModuleEntry(mod);
|
ModEntry *fv = Yap_GetModuleEntry(mod);
|
||||||
if (fv == NULL)
|
if (fv == NULL)
|
||||||
fv = Yap_GetModuleEntry(AtomUser);
|
fv = Yap_GetModuleEntry(TermUser);
|
||||||
if (fv->flags & UNKNOWN_ERROR)
|
if (fv->flags & UNKNOWN_ERROR)
|
||||||
return TermError;
|
return TermError;
|
||||||
if (fv->flags & UNKNOWN_WARNING)
|
if (fv->flags & UNKNOWN_WARNING)
|
||||||
|
2
C/save.c
2
C/save.c
@ -206,7 +206,7 @@ mywrite(FILE *fd, char *buff, Int len) {
|
|||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
nwritten = fwrite(buff, 1, (size_t)len, fd);
|
nwritten = fwrite(buff, 1, (size_t)len, fd);
|
||||||
if (nwritten < 0) {
|
if ((long int)nwritten < 0) {
|
||||||
return do_SYSTEM_ERROR_INTERNAL(SYSTEM_ERROR_INTERNAL,"bad write on saved state");
|
return do_SYSTEM_ERROR_INTERNAL(SYSTEM_ERROR_INTERNAL,"bad write on saved state");
|
||||||
}
|
}
|
||||||
buff += nwritten;
|
buff += nwritten;
|
||||||
|
66
C/stdpreds.c
66
C/stdpreds.c
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* *
|
* *
|
||||||
* YAP Prolog *
|
* YAP Prolog *
|
||||||
@ -35,11 +34,11 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#if YAP_JIT
|
#if YAP_JIT
|
||||||
#include "amijit.h"
|
#include "amijit.h"
|
||||||
#endif
|
#endif
|
||||||
#include "Yatom.h"
|
#include "Foreign.h"
|
||||||
#include "YapHeap.h"
|
#include "YapHeap.h"
|
||||||
|
#include "Yatom.h"
|
||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
#include "yapio.h"
|
#include "yapio.h"
|
||||||
#include "Foreign.h"
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
#include "tab.macros.h"
|
#include "tab.macros.h"
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
@ -56,8 +55,8 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#if YAP_JIT
|
#if YAP_JIT
|
||||||
#include <JIT_Compiler.hpp>
|
#include <JIT_Compiler.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <wchar.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
static Int p_setval(USES_REGS1);
|
static Int p_setval(USES_REGS1);
|
||||||
static Int p_value(USES_REGS1);
|
static Int p_value(USES_REGS1);
|
||||||
@ -386,8 +385,11 @@ static Int p_systime(USES_REGS1) {
|
|||||||
|
|
||||||
static Int p_walltime(USES_REGS1) {
|
static Int p_walltime(USES_REGS1) {
|
||||||
uint64_t now, interval;
|
uint64_t now, interval;
|
||||||
return (Yap_unify_constant(ARG1, MkIntegerTerm(now)) &&
|
uint64_t t = Yap_walltime();
|
||||||
Yap_unify_constant(ARG2, MkIntegerTerm(interval)));
|
now = t - Yap_StartOfWTimes;
|
||||||
|
interval = t - LOCAL_LastWTime;
|
||||||
|
return (Yap_unify_constant(ARG1, MkIntegerTerm(now / 1000)) &&
|
||||||
|
Yap_unify_constant(ARG2, MkIntegerTerm(interval / 1000)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int p_univ(USES_REGS1) { /* A =.. L */
|
static Int p_univ(USES_REGS1) { /* A =.. L */
|
||||||
@ -630,13 +632,13 @@ static Int
|
|||||||
|
|
||||||
static bool valid_prop(Prop p, Term task) {
|
static bool valid_prop(Prop p, Term task) {
|
||||||
if ((RepPredProp(p)->PredFlags & HiddenPredFlag) ||
|
if ((RepPredProp(p)->PredFlags & HiddenPredFlag) ||
|
||||||
(RepPredProp(p)->OpcodeOfPred == UNDEF_OPCODE) ){
|
(RepPredProp(p)->OpcodeOfPred == UNDEF_OPCODE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(task == TermSystem || task == TermProlog) {
|
if (task == TermSystem || task == TermProlog) {
|
||||||
return RepPredProp(p)->PredFlags & StandardPredFlag;
|
return RepPredProp(p)->PredFlags & StandardPredFlag;
|
||||||
}
|
}
|
||||||
if(task == TermUser) {
|
if (task == TermUser) {
|
||||||
return !(RepPredProp(p)->PredFlags & StandardPredFlag);
|
return !(RepPredProp(p)->PredFlags & StandardPredFlag);
|
||||||
}
|
}
|
||||||
if (IsVarTerm(task)) {
|
if (IsVarTerm(task)) {
|
||||||
@ -682,8 +684,8 @@ static PropEntry *nextPredForAtom(PropEntry *p, Term task) {
|
|||||||
return NIL;
|
return NIL;
|
||||||
pe = RepPredProp(p);
|
pe = RepPredProp(p);
|
||||||
if (pe->ArityOfPE == 0 ||
|
if (pe->ArityOfPE == 0 ||
|
||||||
(pe->PredFlags & (NumberDBPredFlag |AtomDBPredFlag) ) ) {
|
(pe->PredFlags & (NumberDBPredFlag | AtomDBPredFlag))) {
|
||||||
// if atom prop, search atom list
|
// if atom prop, search atom list
|
||||||
return followLinkedListOfProps(p->NextOfPE, task);
|
return followLinkedListOfProps(p->NextOfPE, task);
|
||||||
} else {
|
} else {
|
||||||
FunctorEntry *f = pe->FunctorOfPred;
|
FunctorEntry *f = pe->FunctorOfPred;
|
||||||
@ -860,28 +862,27 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||||||
ModEntry *m = Yap_GetModuleEntry(t2);
|
ModEntry *m = Yap_GetModuleEntry(t2);
|
||||||
pp = firstModulePred(m->PredForME, task);
|
pp = firstModulePred(m->PredForME, task);
|
||||||
if (!pp) {
|
if (!pp) {
|
||||||
/* try Prolog Module */
|
/* try Prolog Module */
|
||||||
if (task != TermUser) {
|
if (task != TermUser) {
|
||||||
ModEntry *m = Yap_GetModuleEntry(TermProlog);
|
ModEntry *m = Yap_GetModuleEntry(TermProlog);
|
||||||
pp = firstModulePred(m->PredForME, task);
|
pp = firstModulePred(m->PredForME, task);
|
||||||
if (!pp) {
|
if (!pp) {
|
||||||
cut_fail();
|
cut_fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
npp = firstModulePred(pp, task);
|
npp = firstModulePred(pp, task);
|
||||||
|
|
||||||
if (!npp) {
|
if (!npp) {
|
||||||
if (pp->ModuleOfPred != PROLOG_MODULE &&
|
if (pp->ModuleOfPred != PROLOG_MODULE && task != TermUser) {
|
||||||
task != TermUser) {
|
ModEntry *m = Yap_GetModuleEntry(TermProlog);
|
||||||
ModEntry *m = Yap_GetModuleEntry(TermProlog);
|
npp = firstModulePred(m->PredForME, task);
|
||||||
npp = firstModulePred(m->PredForME, task);
|
if (!npp)
|
||||||
if (!npp)
|
will_cut = true;
|
||||||
will_cut = true;
|
} else {
|
||||||
} else {
|
will_cut = true;
|
||||||
will_cut = true;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// just try next one
|
// just try next one
|
||||||
else {
|
else {
|
||||||
@ -892,7 +893,7 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||||||
// operating across all modules.
|
// operating across all modules.
|
||||||
PredEntry *npp = pp;
|
PredEntry *npp = pp;
|
||||||
ModEntry *me;
|
ModEntry *me;
|
||||||
|
|
||||||
if (!pp) {
|
if (!pp) {
|
||||||
pp = firstModulesPred(CurrentModules->PredForME, CurrentModules, task);
|
pp = firstModulesPred(CurrentModules->PredForME, CurrentModules, task);
|
||||||
}
|
}
|
||||||
@ -938,9 +939,8 @@ static Int cont_current_predicate(USES_REGS1) {
|
|||||||
} else {
|
} else {
|
||||||
rc = Yap_unify(ARG3, name);
|
rc = Yap_unify(ARG3, name);
|
||||||
}
|
}
|
||||||
rc = rc && (IsAtomTerm(t2) ||
|
rc = rc && (IsAtomTerm(t2) || Yap_unify(ARG2, ModToTerm(pp->ModuleOfPred))) &&
|
||||||
Yap_unify(ARG2, ModToTerm(pp->ModuleOfPred)))
|
Yap_unify(ARG1, name);
|
||||||
&& Yap_unify(ARG1, name);
|
|
||||||
if (will_cut) {
|
if (will_cut) {
|
||||||
if (rc)
|
if (rc)
|
||||||
cut_succeed();
|
cut_succeed();
|
||||||
@ -1105,7 +1105,7 @@ void Yap_show_statistics(void) {
|
|||||||
(Unsigned(TR) - Unsigned(LOCAL_TrailBase))));
|
(Unsigned(TR) - Unsigned(LOCAL_TrailBase))));
|
||||||
fprintf(stderr, "Runtime: %lds.\n", (unsigned long int)(runtime(PASS_REGS1)));
|
fprintf(stderr, "Runtime: %lds.\n", (unsigned long int)(runtime(PASS_REGS1)));
|
||||||
fprintf(stderr, "Cputime: %lds.\n", (unsigned long int)(Yap_cputime()));
|
fprintf(stderr, "Cputime: %lds.\n", (unsigned long int)(Yap_cputime()));
|
||||||
fprintf(stderr, "Walltime: %lds.\n", (unsigned long int)(Yap_walltime()));
|
fprintf(stderr, "Walltime: %llu.\n", Yap_walltime() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int p_statistics_heap_max(USES_REGS1) {
|
static Int p_statistics_heap_max(USES_REGS1) {
|
||||||
|
@ -15,8 +15,11 @@
|
|||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define X_API __declspec(dllexport)
|
#define X_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define X_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* prototype file for Yap */
|
/* prototype file for Yap */
|
||||||
|
|
||||||
/* absmi.c */
|
/* absmi.c */
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
#define GLOBAL_ThreadsTotalTime Yap_global->ThreadsTotalTime_
|
#define GLOBAL_ThreadsTotalTime Yap_global->ThreadsTotalTime_
|
||||||
|
|
||||||
#define GLOBAL_ThreadHandlesLock Yap_global->ThreadHandlesLock_
|
#define GLOBAL_ThreadHandlesLock Yap_global->ThreadHandlesLock_
|
||||||
#endif
|
#endif
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
|
||||||
#define GLOBAL_BGL Yap_global->BGL_
|
#define GLOBAL_BGL Yap_global->BGL_
|
||||||
@ -140,7 +140,5 @@
|
|||||||
#define GLOBAL_CharConversionTable Yap_global->CharConversionTable_
|
#define GLOBAL_CharConversionTable Yap_global->CharConversionTable_
|
||||||
#define GLOBAL_CharConversionTable2 Yap_global->CharConversionTable2_
|
#define GLOBAL_CharConversionTable2 Yap_global->CharConversionTable2_
|
||||||
|
|
||||||
#define GLOBAL_LastWTimePtr Yap_global->LastWTimePtr_
|
|
||||||
|
|
||||||
#define GLOBAL_MaxPriority Yap_global->MaxPriority_
|
#define GLOBAL_MaxPriority Yap_global->MaxPriority_
|
||||||
|
|
||||||
|
@ -491,3 +491,6 @@
|
|||||||
#define LOCAL_MAX_SIZE LOCAL->MAX_SIZE_
|
#define LOCAL_MAX_SIZE LOCAL->MAX_SIZE_
|
||||||
#define REMOTE_MAX_SIZE(wid) REMOTE(wid)->MAX_SIZE_
|
#define REMOTE_MAX_SIZE(wid) REMOTE(wid)->MAX_SIZE_
|
||||||
|
|
||||||
|
#define LOCAL_LastWTime LOCAL->LastWTime_
|
||||||
|
#define REMOTE_LastWTime(wid) REMOTE(wid)->LastWTime_
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
//
|
//
|
||||||
// The defs include 3+ components:
|
// The defs include 3+ components:
|
||||||
// Type
|
// Type
|
||||||
// name in structured / global name
|
// name in structured / global name
|
||||||
// init code (optional)
|
// init code (optional)
|
||||||
// restore code (optional)
|
// restore code (optional)
|
||||||
//
|
//
|
||||||
@ -51,7 +51,7 @@ EXTERNAL UInt GLOBAL_NOfThreadsCreated;
|
|||||||
EXTERNAL UInt GLOBAL_ThreadsTotalTime;
|
EXTERNAL UInt GLOBAL_ThreadsTotalTime;
|
||||||
// Threads Array
|
// Threads Array
|
||||||
EXTERNAL lockvar GLOBAL_ThreadHandlesLock;
|
EXTERNAL lockvar GLOBAL_ThreadHandlesLock;
|
||||||
#endif
|
#endif
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
// protect long critical regions
|
// protect long critical regions
|
||||||
EXTERNAL lockvar GLOBAL_BGL;
|
EXTERNAL lockvar GLOBAL_BGL;
|
||||||
@ -69,12 +69,12 @@ EXTERNAL lockvar GLOBAL_mboxq_lock;
|
|||||||
EXTERNAL UInt GLOBAL_mbox_count;
|
EXTERNAL UInt GLOBAL_mbox_count;
|
||||||
EXTERNAL struct swi_mutex* GLOBAL_WithMutex;
|
EXTERNAL struct swi_mutex* GLOBAL_WithMutex;
|
||||||
#endif /* THREADS */
|
#endif /* THREADS */
|
||||||
// streams
|
// streams
|
||||||
EXTERNAL struct stream_desc* GLOBAL_Stream;
|
EXTERNAL struct stream_desc* GLOBAL_Stream;
|
||||||
#if defined(THREADS)||defined(YAPOR)
|
#if defined(THREADS)||defined(YAPOR)
|
||||||
EXTERNAL lockvar GLOBAL_StreamDescLock;
|
EXTERNAL lockvar GLOBAL_StreamDescLock;
|
||||||
#endif
|
#endif
|
||||||
// access to yap initial arguments
|
// access to yap initial arguments
|
||||||
EXTERNAL char** GLOBAL_argv;
|
EXTERNAL char** GLOBAL_argv;
|
||||||
EXTERNAL int GLOBAL_argc;
|
EXTERNAL int GLOBAL_argc;
|
||||||
// extensions to Terms
|
// extensions to Terms
|
||||||
@ -110,8 +110,8 @@ EXTERNAL struct opaque_handler_struct* GLOBAL_OpaqueHandlers;
|
|||||||
EXTERNAL char GLOBAL_pwd[YAP_FILENAME_MAX];
|
EXTERNAL char GLOBAL_pwd[YAP_FILENAME_MAX];
|
||||||
#endif
|
#endif
|
||||||
//udi.c
|
//udi.c
|
||||||
//struct udi_control_block RtreeCmd void
|
//struct udi_control_block RtreeCmd void
|
||||||
EXTERNAL char* GLOBAL_RestoreFile;
|
EXTERNAL const char* GLOBAL_RestoreFile;
|
||||||
//gprof.c
|
//gprof.c
|
||||||
EXTERNAL Int GLOBAL_ProfCalls;
|
EXTERNAL Int GLOBAL_ProfCalls;
|
||||||
EXTERNAL Int GLOBAL_ProfGCs;
|
EXTERNAL Int GLOBAL_ProfGCs;
|
||||||
@ -139,8 +139,6 @@ EXTERNAL char* GLOBAL_Home;
|
|||||||
/* ISO char conversion: I will make no comments */
|
/* ISO char conversion: I will make no comments */
|
||||||
EXTERNAL char* GLOBAL_CharConversionTable;
|
EXTERNAL char* GLOBAL_CharConversionTable;
|
||||||
EXTERNAL char* GLOBAL_CharConversionTable2;
|
EXTERNAL char* GLOBAL_CharConversionTable2;
|
||||||
/* time */
|
|
||||||
EXTERNAL void* GLOBAL_LastWTimePtr;
|
|
||||||
/* max priority */
|
/* max priority */
|
||||||
EXTERNAL int GLOBAL_MaxPriority;
|
EXTERNAL int GLOBAL_MaxPriority;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
//
|
//
|
||||||
// The defs include 3+ components:
|
// The defs include 3+ components:
|
||||||
// Type
|
// Type
|
||||||
// name in structured / global name
|
// name in structured / global name
|
||||||
// init code (optional)
|
// init code (optional)
|
||||||
// restore code (optional)
|
// restore code (optional)
|
||||||
//
|
//
|
||||||
@ -51,7 +51,7 @@ typedef struct global_data {
|
|||||||
UInt ThreadsTotalTime_;
|
UInt ThreadsTotalTime_;
|
||||||
// Threads Array
|
// Threads Array
|
||||||
lockvar ThreadHandlesLock_;
|
lockvar ThreadHandlesLock_;
|
||||||
#endif
|
#endif
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
// protect long critical regions
|
// protect long critical regions
|
||||||
lockvar BGL_;
|
lockvar BGL_;
|
||||||
@ -69,12 +69,12 @@ typedef struct global_data {
|
|||||||
UInt mbox_count_;
|
UInt mbox_count_;
|
||||||
struct swi_mutex* WithMutex_;
|
struct swi_mutex* WithMutex_;
|
||||||
#endif /* THREADS */
|
#endif /* THREADS */
|
||||||
// streams
|
// streams
|
||||||
struct stream_desc* Stream_;
|
struct stream_desc* Stream_;
|
||||||
#if defined(THREADS)||defined(YAPOR)
|
#if defined(THREADS)||defined(YAPOR)
|
||||||
lockvar StreamDescLock_;
|
lockvar StreamDescLock_;
|
||||||
#endif
|
#endif
|
||||||
// access to yap initial arguments
|
// access to yap initial arguments
|
||||||
char** argv_;
|
char** argv_;
|
||||||
int argc_;
|
int argc_;
|
||||||
// extensions to Terms
|
// extensions to Terms
|
||||||
@ -110,8 +110,8 @@ typedef struct global_data {
|
|||||||
char pwd_[YAP_FILENAME_MAX];
|
char pwd_[YAP_FILENAME_MAX];
|
||||||
#endif
|
#endif
|
||||||
//udi.c
|
//udi.c
|
||||||
//struct udi_control_block RtreeCmd void
|
//struct udi_control_block RtreeCmd void
|
||||||
char* RestoreFile_;
|
const char* RestoreFile_;
|
||||||
//gprof.c
|
//gprof.c
|
||||||
Int ProfCalls_;
|
Int ProfCalls_;
|
||||||
Int ProfGCs_;
|
Int ProfGCs_;
|
||||||
@ -139,8 +139,6 @@ typedef struct global_data {
|
|||||||
/* ISO char conversion: I will make no comments */
|
/* ISO char conversion: I will make no comments */
|
||||||
char* CharConversionTable_;
|
char* CharConversionTable_;
|
||||||
char* CharConversionTable2_;
|
char* CharConversionTable2_;
|
||||||
/* time */
|
|
||||||
void* LastWTimePtr_;
|
|
||||||
/* max priority */
|
/* max priority */
|
||||||
int MaxPriority_;
|
int MaxPriority_;
|
||||||
} w_shared;
|
} w_shared;
|
||||||
|
@ -274,4 +274,6 @@ const char* Error_Function_;
|
|||||||
Term SourceModule_;
|
Term SourceModule_;
|
||||||
Term Including_;
|
Term Including_;
|
||||||
size_t MAX_SIZE_;
|
size_t MAX_SIZE_;
|
||||||
|
/* last call to walltime. */
|
||||||
|
uint64_t LastWTime_;
|
||||||
} w_local;
|
} w_local;
|
||||||
|
@ -51,7 +51,7 @@ static void InitGlobal(void) {
|
|||||||
GLOBAL_ThreadsTotalTime = 0L;
|
GLOBAL_ThreadsTotalTime = 0L;
|
||||||
|
|
||||||
INIT_LOCK(GLOBAL_ThreadHandlesLock);
|
INIT_LOCK(GLOBAL_ThreadHandlesLock);
|
||||||
#endif
|
#endif
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
|
||||||
INIT_LOCK(GLOBAL_BGL);
|
INIT_LOCK(GLOBAL_BGL);
|
||||||
@ -140,7 +140,5 @@ static void InitGlobal(void) {
|
|||||||
GLOBAL_CharConversionTable = NULL;
|
GLOBAL_CharConversionTable = NULL;
|
||||||
GLOBAL_CharConversionTable2 = NULL;
|
GLOBAL_CharConversionTable2 = NULL;
|
||||||
|
|
||||||
GLOBAL_LastWTimePtr = NULL;
|
|
||||||
|
|
||||||
GLOBAL_MaxPriority = 1200;
|
GLOBAL_MaxPriority = 1200;
|
||||||
}
|
}
|
||||||
|
@ -274,4 +274,6 @@ static void InitWorker(int wid) {
|
|||||||
REMOTE_SourceModule(wid) = 0;
|
REMOTE_SourceModule(wid) = 0;
|
||||||
REMOTE_Including(wid) = TermNil;
|
REMOTE_Including(wid) = TermNil;
|
||||||
REMOTE_MAX_SIZE(wid) = 1024L;
|
REMOTE_MAX_SIZE(wid) = 1024L;
|
||||||
|
|
||||||
|
REMOTE_LastWTime(wid) = NULL;
|
||||||
}
|
}
|
||||||
|
@ -274,4 +274,6 @@ static void RestoreWorker(int wid USES_REGS) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,17 +16,17 @@
|
|||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
/* static char SccsId[] = "X 4.3.3"; */
|
/* static char SccsId[] = "X 4.3.3"; */
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "YapInterface.h"
|
#include "YapInterface.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "cut_c.h"
|
#include "cut_c.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
|
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
|
||||||
#undef HAVE_UNISTD_H
|
#undef HAVE_UNISTD_H
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32 /* Microsoft's Visual C++ Compiler */
|
#ifdef _WIN32 /* Microsoft's Visual C++ Compiler */
|
||||||
#include <windows.h>
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if HAVE_SYS_TYPES_H
|
#if HAVE_SYS_TYPES_H
|
||||||
@ -58,7 +58,6 @@
|
|||||||
#include <ieeefp.h>
|
#include <ieeefp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void do_top_goal(YAP_Term Goal);
|
static void do_top_goal(YAP_Term Goal);
|
||||||
static void exec_top_level(int BootMode, YAP_init_args *iap);
|
static void exec_top_level(int BootMode, YAP_init_args *iap);
|
||||||
|
|
||||||
@ -70,98 +69,84 @@ static void exec_top_level(int BootMode, YAP_init_args *iap);
|
|||||||
long _stksize = 32000;
|
long _stksize = 32000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void do_top_goal(YAP_Term Goal) { YAP_RunGoalOnce(Goal); }
|
||||||
|
|
||||||
|
static int init_standard_system(int argc, char *argv[], YAP_init_args *iap) {
|
||||||
static void
|
|
||||||
do_top_goal (YAP_Term Goal)
|
|
||||||
{
|
|
||||||
YAP_RunGoalOnce(Goal);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
init_standard_system(int argc, char *argv[], YAP_init_args *iap)
|
|
||||||
{
|
|
||||||
int BootMode;
|
int BootMode;
|
||||||
|
|
||||||
// BootMode = YAP_parse_yap_arguments(argc,argv,iap);
|
BootMode = YAP_parse_yap_arguments(argc, argv, iap);
|
||||||
|
|
||||||
/* init memory */
|
/* init memory */
|
||||||
if (BootMode == YAP_BOOT_FROM_PROLOG ||
|
if (BootMode == YAP_BOOT_FROM_PROLOG ||
|
||||||
BootMode == YAP_FULL_BOOT_FROM_PROLOG) {
|
BootMode == YAP_FULL_BOOT_FROM_PROLOG) {
|
||||||
int NewBootMode = YAP_Init(iap);
|
int NewBootMode = YAP_Init(iap);
|
||||||
if (NewBootMode != YAP_BOOT_FROM_PROLOG && BootMode != YAP_FULL_BOOT_FROM_PROLOG)
|
if (NewBootMode != YAP_BOOT_FROM_PROLOG &&
|
||||||
|
BootMode != YAP_FULL_BOOT_FROM_PROLOG)
|
||||||
BootMode = NewBootMode;
|
BootMode = NewBootMode;
|
||||||
} else {
|
} else {
|
||||||
BootMode = YAP_Init(iap);
|
BootMode = YAP_Init(iap);
|
||||||
}
|
}
|
||||||
if (iap->ErrorNo) {
|
if (iap->ErrorNo) {
|
||||||
/* boot failed */
|
/* boot failed */
|
||||||
YAP_Error(iap->ErrorNo,0L,iap->ErrorCause);
|
YAP_Error(iap->ErrorNo, 0L, iap->ErrorCause);
|
||||||
}
|
}
|
||||||
return BootMode;
|
return BootMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void exec_top_level(int BootMode, YAP_init_args *iap) {
|
||||||
static void
|
|
||||||
exec_top_level(int BootMode, YAP_init_args *iap)
|
|
||||||
{
|
|
||||||
YAP_Term atomfalse;
|
YAP_Term atomfalse;
|
||||||
YAP_Atom livegoal;
|
YAP_Atom livegoal;
|
||||||
|
|
||||||
if (BootMode == YAP_BOOT_FROM_SAVED_STACKS)
|
if (BootMode == YAP_BOOT_FROM_SAVED_STACKS) {
|
||||||
{
|
/* continue executing from the frozen stacks */
|
||||||
/* continue executing from the frozen stacks */
|
YAP_ContinueGoal();
|
||||||
YAP_ContinueGoal();
|
}
|
||||||
}
|
|
||||||
/* the top-level is now ready */
|
/* the top-level is now ready */
|
||||||
|
|
||||||
/* read it before case someone, that is, Ashwin, hides
|
/* read it before case someone, that is, Ashwin, hides
|
||||||
the atom false away ;-).
|
the atom false away ;-).
|
||||||
*/
|
*/
|
||||||
livegoal = YAP_FullLookupAtom("$live");
|
livegoal = YAP_FullLookupAtom("$live");
|
||||||
atomfalse = YAP_MkAtomTerm (YAP_FullLookupAtom("$false"));
|
atomfalse = YAP_MkAtomTerm(YAP_FullLookupAtom("$false"));
|
||||||
while (YAP_GetValue (livegoal) != atomfalse) {
|
while (YAP_GetValue(livegoal) != atomfalse) {
|
||||||
YAP_Reset( YAP_FULL_RESET );
|
YAP_Reset(YAP_FULL_RESET);
|
||||||
do_top_goal (YAP_MkAtomTerm (livegoal));
|
do_top_goal(YAP_MkAtomTerm(livegoal));
|
||||||
}
|
}
|
||||||
YAP_Exit(EXIT_SUCCESS);
|
YAP_Exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
//FILE *debugf;
|
// FILE *debugf;
|
||||||
|
|
||||||
#ifdef LIGHT
|
#ifdef LIGHT
|
||||||
int
|
int _main(int argc, char **argv)
|
||||||
_main (int argc, char **argv)
|
|
||||||
#else
|
#else
|
||||||
int
|
int main(int argc, char **argv)
|
||||||
main (int argc, char **argv)
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int BootMode;
|
int BootMode;
|
||||||
int i;
|
int i;
|
||||||
|
YAP_init_args init_args;
|
||||||
BootMode = init_standard_system(argc, argv, &init_args);
|
BootMode = init_standard_system(argc, argv, &init_args);
|
||||||
if (BootMode == YAP_BOOT_ERROR) {
|
if (BootMode == YAP_BOOT_ERROR) {
|
||||||
fprintf(stderr,"[ FATAL ERROR: could not find saved state ]\n");
|
fprintf(stderr, "[ FATAL ERROR: could not find saved state ]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
/* Begin preprocessor code */
|
/* Begin preprocessor code */
|
||||||
if (BootMode != YAP_BOOT_FROM_SAVED_STACKS) {
|
if (BootMode != YAP_BOOT_FROM_SAVED_STACKS) {
|
||||||
// process the definitions
|
// process the definitions
|
||||||
for(i=0;i<init_args.def_c;++i) {
|
for (i = 0; i < init_args.def_c; ++i) {
|
||||||
YAP_Term t_args[2],t_goal;
|
YAP_Term t_args[2], t_goal;
|
||||||
t_args[0] = YAP_MkAtomTerm(YAP_LookupAtom(init_args.def_var[i]));
|
t_args[0] = YAP_MkAtomTerm(YAP_LookupAtom(init_args.def_var[i]));
|
||||||
t_args[1] = YAP_MkAtomTerm(YAP_LookupAtom(init_args.def_value[i]));
|
t_args[1] = YAP_MkAtomTerm(YAP_LookupAtom(init_args.def_value[i]));
|
||||||
t_goal = YAP_MkApplTerm(YAP_MkFunctor(YAP_LookupAtom("ypp_define"),2), 2, t_args);
|
t_goal = YAP_MkApplTerm(YAP_MkFunctor(YAP_LookupAtom("ypp_define"), 2), 2,
|
||||||
|
t_args);
|
||||||
YAP_RunGoalOnce(t_goal);
|
YAP_RunGoalOnce(t_goal);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
YAP_Reset( YAP_FULL_RESET );
|
YAP_Reset(YAP_FULL_RESET);
|
||||||
/* End preprocessor code */
|
/* End preprocessor code */
|
||||||
|
|
||||||
exec_top_level(BootMode, &init_args);
|
exec_top_level(BootMode, &init_args);
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
misc/GLOBALS
22
misc/GLOBALS
@ -9,7 +9,7 @@
|
|||||||
//
|
//
|
||||||
// The defs include 3+ components:
|
// The defs include 3+ components:
|
||||||
// Type
|
// Type
|
||||||
// name in structured / global name
|
// name in structured / global name
|
||||||
// init code (optional)
|
// init code (optional)
|
||||||
// restore code (optional)
|
// restore code (optional)
|
||||||
//
|
//
|
||||||
@ -54,7 +54,7 @@ UInt NOfThreadsCreated =1
|
|||||||
UInt ThreadsTotalTime =0L
|
UInt ThreadsTotalTime =0L
|
||||||
// Threads Array
|
// Threads Array
|
||||||
lockvar ThreadHandlesLock MkLock
|
lockvar ThreadHandlesLock MkLock
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
// protect long critical regions
|
// protect long critical regions
|
||||||
@ -62,7 +62,7 @@ lockvar BGL MkLock
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(YAPOR) || defined(TABLING)
|
#if defined(YAPOR) || defined(TABLING)
|
||||||
struct global_optyap_data optyap_data void
|
struct global_optyap_data optyap_data void
|
||||||
#endif /* YAPOR || TABLING */
|
#endif /* YAPOR || TABLING */
|
||||||
|
|
||||||
// whether Yap is responsible for signal handling
|
// whether Yap is responsible for signal handling
|
||||||
@ -78,13 +78,13 @@ UInt mbox_count =0
|
|||||||
struct swi_mutex* WithMutex void
|
struct swi_mutex* WithMutex void
|
||||||
#endif /* THREADS */
|
#endif /* THREADS */
|
||||||
|
|
||||||
// streams
|
// streams
|
||||||
struct stream_desc* Stream void
|
struct stream_desc* Stream void
|
||||||
#if defined(THREADS)||defined(YAPOR)
|
#if defined(THREADS)||defined(YAPOR)
|
||||||
lockvar StreamDescLock MkLock
|
lockvar StreamDescLock MkLock
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// access to yap initial arguments
|
// access to yap initial arguments
|
||||||
char** argv void
|
char** argv void
|
||||||
int argc void
|
int argc void
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ YAP_ULONG_LONG agc_collected void
|
|||||||
/* total time spent in GC */
|
/* total time spent in GC */
|
||||||
Int tot_agc_time =0
|
Int tot_agc_time =0
|
||||||
/* number of heap objects in all garbage collections */
|
/* number of heap objects in all garbage collections */
|
||||||
Int tot_agc_recovered =0
|
Int tot_agc_recovered =0
|
||||||
|
|
||||||
//arrays.c
|
//arrays.c
|
||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
@ -129,12 +129,12 @@ char pwd[YAP_FILENAME_MAX] void
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//udi.c
|
//udi.c
|
||||||
//struct udi_control_block RtreeCmd void
|
//struct udi_control_block RtreeCmd void
|
||||||
|
|
||||||
char* RestoreFile void
|
const char* RestoreFile void
|
||||||
|
|
||||||
//gprof.c
|
//gprof.c
|
||||||
Int ProfCalls void
|
Int ProfCalls void
|
||||||
Int ProfGCs void
|
Int ProfGCs void
|
||||||
Int ProfHGrows void
|
Int ProfHGrows void
|
||||||
Int ProfSGrows void
|
Int ProfSGrows void
|
||||||
@ -165,13 +165,9 @@ char* CharConversionTable =NULL
|
|||||||
char* CharConversionTable2 =NULL
|
char* CharConversionTable2 =NULL
|
||||||
|
|
||||||
|
|
||||||
/* time */
|
|
||||||
void* LastWTimePtr =NULL
|
|
||||||
|
|
||||||
/* max priority */
|
/* max priority */
|
||||||
int MaxPriority =1200
|
int MaxPriority =1200
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
END_GLOBAL_DATA
|
END_GLOBAL_DATA
|
||||||
|
|
||||||
|
@ -103,6 +103,8 @@ Term WokenGoals =0L TermToGlobalAdjust
|
|||||||
Term AttsMutableList =0L TermToGlobalAdjust
|
Term AttsMutableList =0L TermToGlobalAdjust
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// gc_stuff
|
// gc_stuff
|
||||||
Term GcGeneration =0L TermToGlobalAdjust
|
Term GcGeneration =0L TermToGlobalAdjust
|
||||||
Term GcPhase =0L TermToGlobalAdjust
|
Term GcPhase =0L TermToGlobalAdjust
|
||||||
@ -319,4 +321,8 @@ Term Including =TermNil
|
|||||||
|
|
||||||
size_t MAX_SIZE =1024L
|
size_t MAX_SIZE =1024L
|
||||||
|
|
||||||
|
/* last call to walltime. */
|
||||||
|
uint64_t LastWTime =0
|
||||||
|
|
||||||
|
|
||||||
END_WORKER_LOCAL
|
END_WORKER_LOCAL
|
||||||
|
513
os/files.c
513
os/files.c
@ -20,48 +20,43 @@ static char SccsId[] = "%W% %G%";
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* This file includes the definition of a miscellania of standard predicates
|
* This file includes the definition of a miscellania of standard predicates
|
||||||
* for yap refering to: Files and GLOBAL_Streams, Simple Input/Output,
|
* for yap refering to: Files and GLOBAL_Streams, Simple Input/Output,
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sysbits.h"
|
#include "sysbits.h"
|
||||||
|
|
||||||
|
#if _MSC_VER || defined(__MINGW32__)
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
|
||||||
#define SYSTEM_STAT _stat
|
#define SYSTEM_STAT _stat
|
||||||
#else
|
#else
|
||||||
#define SYSTEM_STAT stat
|
#define SYSTEM_STAT stat
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static Int file_name_extension(USES_REGS1) {
|
||||||
|
|
||||||
static Int
|
|
||||||
file_name_extension(USES_REGS1)
|
|
||||||
{
|
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
Term t2 = Deref(ARG2);
|
Term t2 = Deref(ARG2);
|
||||||
Term t3 = Deref(ARG3);
|
Term t3 = Deref(ARG3);
|
||||||
bool use_string = false;
|
bool use_string = false;
|
||||||
loop:
|
loop:
|
||||||
if (!IsVarTerm((t3))) {
|
if (!IsVarTerm((t3))) {
|
||||||
const char *f;
|
const char *f;
|
||||||
if (IsAtomTerm(t3)) {
|
if (IsAtomTerm(t3)) {
|
||||||
f = AtomName( AtomOfTerm( t3 ) );
|
f = AtomName(AtomOfTerm(t3));
|
||||||
} else if (IsStringTerm( t3 )) {
|
} else if (IsStringTerm(t3)) {
|
||||||
f = StringOfTerm( t3 );
|
f = StringOfTerm(t3);
|
||||||
use_string = true;
|
use_string = true;
|
||||||
} else if (IsApplTerm(t3) && FunctorOfTerm(t3) == FunctorSlash) {
|
} else if (IsApplTerm(t3) && FunctorOfTerm(t3) == FunctorSlash) {
|
||||||
// descend a compound term of the form a/b.
|
// descend a compound term of the form a/b.
|
||||||
Term tn1 = MkVarTerm(), tf1;
|
Term tn1 = MkVarTerm(), tf1;
|
||||||
Term ts[2];
|
Term ts[2];
|
||||||
ts[0] = ArgOfTerm(1,t3);
|
ts[0] = ArgOfTerm(1, t3);
|
||||||
ts[1] = tn1;
|
ts[1] = tn1;
|
||||||
tf1 = Yap_MkApplTerm( FunctorSlash, 2, ts );
|
tf1 = Yap_MkApplTerm(FunctorSlash, 2, ts);
|
||||||
if (!Yap_unify(ARG1, tf1)) {
|
if (!Yap_unify(ARG1, tf1)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
t3 = ArgOfTerm(2, t3);
|
t3 = ArgOfTerm(2, t3);
|
||||||
goto loop;
|
goto loop;
|
||||||
} else {
|
} else {
|
||||||
Yap_Error(TYPE_ERROR_ATOMIC, t3, "file_name_extension/3");
|
Yap_Error(TYPE_ERROR_ATOMIC, t3, "file_name_extension/3");
|
||||||
return false;
|
return false;
|
||||||
@ -69,120 +64,119 @@ file_name_extension(USES_REGS1)
|
|||||||
char *pts = strrchr(f, '/');
|
char *pts = strrchr(f, '/');
|
||||||
#if WIN32_ssss
|
#if WIN32_ssss
|
||||||
char *pts1 = strrchr(f, '\\');
|
char *pts1 = strrchr(f, '\\');
|
||||||
if (pts11 > pts) pts = pts1;
|
if (pts11 > pts)
|
||||||
|
pts = pts1;
|
||||||
#endif
|
#endif
|
||||||
char *ss = strrchr(f, '.');
|
char *ss = strrchr(f, '.');
|
||||||
if (pts > ss) ss = NULL;
|
if (pts > ss)
|
||||||
|
ss = NULL;
|
||||||
if (use_string) {
|
if (use_string) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
if (!ss) {
|
if (!ss) {
|
||||||
return Yap_unify(ARG1, ARG3) &&
|
return Yap_unify(ARG1, ARG3) && Yap_unify(ARG2, MkStringTerm(""));
|
||||||
Yap_unify(ARG2, MkStringTerm( "" ) );
|
|
||||||
}
|
}
|
||||||
tmp = malloc((ss - f)+1);
|
tmp = malloc((ss - f) + 1);
|
||||||
strncpy(tmp, f, (ss)-f);
|
strncpy(tmp, f, (ss)-f);
|
||||||
if (!Yap_unify(ARG1, MkStringTerm( tmp )) ) {
|
if (!Yap_unify(ARG1, MkStringTerm(tmp))) {
|
||||||
if (tmp != f)
|
if (tmp != f)
|
||||||
free( tmp );
|
free(tmp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (tmp != f)
|
if (tmp != f)
|
||||||
free(tmp);
|
free(tmp);
|
||||||
// without and with dot
|
// without and with dot
|
||||||
if (!Yap_unify(ARG2, MkStringTerm(ss+1)))
|
if (!Yap_unify(ARG2, MkStringTerm(ss + 1)))
|
||||||
return Yap_unify(ARG2, MkStringTerm(ss));
|
return Yap_unify(ARG2, MkStringTerm(ss));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
if (!ss) {
|
if (!ss) {
|
||||||
return Yap_unify(ARG1, ARG3) &&
|
return Yap_unify(ARG1, ARG3) &&
|
||||||
Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom( "" ) ));
|
Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom("")));
|
||||||
}
|
}
|
||||||
tmp = malloc((ss - f)+1);
|
tmp = malloc((ss - f) + 1);
|
||||||
strncpy(tmp, f, (ss)-f);
|
strncpy(tmp, f, (ss)-f);
|
||||||
if (!Yap_unify(ARG1, MkAtomTerm(Yap_LookupAtom( tmp ))) ) {
|
if (!Yap_unify(ARG1, MkAtomTerm(Yap_LookupAtom(tmp)))) {
|
||||||
if (tmp != f)
|
if (tmp != f)
|
||||||
free( tmp );
|
free(tmp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (tmp != f)
|
if (tmp != f)
|
||||||
free(tmp);
|
free(tmp);
|
||||||
// without and with dot
|
// without and with dot
|
||||||
if (!Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(ss+1))))
|
if (!Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(ss + 1))))
|
||||||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(ss)));
|
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(ss)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char s[MAXPATHLEN+1];
|
char s[MAXPATHLEN + 1];
|
||||||
const char *f1, *f2;
|
const char *f1, *f2;
|
||||||
loop1:
|
loop1:
|
||||||
if (IsVarTerm(t1)) {
|
if (IsVarTerm(t1)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t1, "access");
|
Yap_Error(INSTANTIATION_ERROR, t1, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (IsAtomTerm(t1)) {
|
} else if (IsAtomTerm(t1)) {
|
||||||
f1 = AtomName( AtomOfTerm( t1 ) );
|
f1 = AtomName(AtomOfTerm(t1));
|
||||||
} else if (IsStringTerm( t1 )) {
|
} else if (IsStringTerm(t1)) {
|
||||||
f1 = StringOfTerm( t1 );
|
f1 = StringOfTerm(t1);
|
||||||
use_string = true;
|
use_string = true;
|
||||||
} else if (IsApplTerm(t1) && FunctorOfTerm(t1) == FunctorSlash) {
|
} else if (IsApplTerm(t1) && FunctorOfTerm(t1) == FunctorSlash) {
|
||||||
// descend a compound term of the form a/b.
|
// descend a compound term of the form a/b.
|
||||||
Term tn1 = MkVarTerm(), tf1;
|
Term tn1 = MkVarTerm(), tf1;
|
||||||
Term ts[2];
|
Term ts[2];
|
||||||
|
|
||||||
ts[0] = ArgOfTerm(1,t1);
|
ts[0] = ArgOfTerm(1, t1);
|
||||||
ts[1] = tn1;
|
ts[1] = tn1;
|
||||||
tf1 = Yap_MkApplTerm( FunctorSlash, 2, ts );
|
tf1 = Yap_MkApplTerm(FunctorSlash, 2, ts);
|
||||||
if (!Yap_unify(ARG3, tf1)) {
|
if (!Yap_unify(ARG3, tf1)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
t1 = ArgOfTerm(2, t1);
|
t1 = ArgOfTerm(2, t1);
|
||||||
goto loop1;
|
goto loop1;
|
||||||
} else {
|
} else {
|
||||||
Yap_Error(TYPE_ERROR_ATOMIC, t1, "file_name_extension/3");
|
Yap_Error(TYPE_ERROR_ATOMIC, t1, "file_name_extension/3");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsVarTerm(t2)) {
|
if (IsVarTerm(t2)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t2, "access");
|
Yap_Error(INSTANTIATION_ERROR, t2, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (IsAtomTerm(t2)) {
|
} else if (IsAtomTerm(t2)) {
|
||||||
f2 = AtomName( AtomOfTerm( t2 ) );
|
f2 = AtomName(AtomOfTerm(t2));
|
||||||
} else if (IsStringTerm( t1 )) {
|
} else if (IsStringTerm(t1)) {
|
||||||
f2 = StringOfTerm( t2 );
|
f2 = StringOfTerm(t2);
|
||||||
use_string = true;
|
use_string = true;
|
||||||
} else {
|
} else {
|
||||||
Yap_Error(TYPE_ERROR_ATOMIC, t2, "file_name_extension/3");
|
Yap_Error(TYPE_ERROR_ATOMIC, t2, "file_name_extension/3");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (f2[0] == '.') {
|
if (f2[0] == '.') {
|
||||||
strncpy(s,f1,MAXPATHLEN);
|
strncpy(s, f1, MAXPATHLEN);
|
||||||
strncat(s,f2,MAXPATHLEN);
|
strncat(s, f2, MAXPATHLEN);
|
||||||
if (use_string)
|
if (use_string)
|
||||||
return Yap_unify_constant(ARG3,MkStringTerm(s));
|
return Yap_unify_constant(ARG3, MkStringTerm(s));
|
||||||
else
|
else
|
||||||
return Yap_unify_constant(ARG3,MkAtomTerm(Yap_LookupAtom(s)));
|
return Yap_unify_constant(ARG3, MkAtomTerm(Yap_LookupAtom(s)));
|
||||||
} else {
|
} else {
|
||||||
strncpy(s,f1,MAXPATHLEN);
|
strncpy(s, f1, MAXPATHLEN);
|
||||||
strncat(s,".",MAXPATHLEN);
|
strncat(s, ".", MAXPATHLEN);
|
||||||
strncat(s,f2,MAXPATHLEN);
|
strncat(s, f2, MAXPATHLEN);
|
||||||
if (use_string)
|
if (use_string)
|
||||||
return Yap_unify_constant(ARG3,MkStringTerm(s));
|
return Yap_unify_constant(ARG3, MkStringTerm(s));
|
||||||
else
|
else
|
||||||
return Yap_unify_constant(ARG3,MkAtomTerm(Yap_LookupAtom(s)));
|
return Yap_unify_constant(ARG3, MkAtomTerm(Yap_LookupAtom(s)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int access_path(USES_REGS1) {
|
||||||
access_path(USES_REGS1)
|
|
||||||
{
|
|
||||||
Term tname = Deref(ARG1);
|
Term tname = Deref(ARG1);
|
||||||
char *file_name;
|
char *file_name;
|
||||||
|
|
||||||
if (IsVarTerm(tname)) {
|
if (IsVarTerm(tname)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!IsAtomTerm (tname)) {
|
} else if (!IsAtomTerm(tname)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -191,7 +185,7 @@ access_path(USES_REGS1)
|
|||||||
|
|
||||||
file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
|
file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
|
||||||
if (SYSTEM_STAT(file_name, &ss) != 0) {
|
if (SYSTEM_STAT(file_name, &ss) != 0) {
|
||||||
/* ignore errors while checking a file */
|
/* ignore errors while checking a file */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -201,16 +195,14 @@ access_path(USES_REGS1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int exists_file(USES_REGS1) {
|
||||||
exists_file(USES_REGS1)
|
|
||||||
{
|
|
||||||
Term tname = Deref(ARG1);
|
Term tname = Deref(ARG1);
|
||||||
char *file_name;
|
char *file_name;
|
||||||
|
|
||||||
if (IsVarTerm(tname)) {
|
if (IsVarTerm(tname)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!IsAtomTerm (tname)) {
|
} else if (!IsAtomTerm(tname)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -219,13 +211,13 @@ exists_file(USES_REGS1)
|
|||||||
|
|
||||||
file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
|
file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
|
||||||
if (SYSTEM_STAT(file_name, &ss) != 0) {
|
if (SYSTEM_STAT(file_name, &ss) != 0) {
|
||||||
/* ignore errors while checking a file */
|
/* ignore errors while checking a file */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#if _MSC_VER
|
#if _MSC_VER
|
||||||
return ss.st_mode & S_IFREG;
|
return ss.st_mode & S_IFREG;
|
||||||
#else
|
#else
|
||||||
return (_stat(ss.st_mode));
|
return S_ISREG(ss.st_mode);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -233,16 +225,14 @@ exists_file(USES_REGS1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int file_exists(USES_REGS1) {
|
||||||
file_exists(USES_REGS1)
|
|
||||||
{
|
|
||||||
Term tname = Deref(ARG1);
|
Term tname = Deref(ARG1);
|
||||||
char *file_name;
|
char *file_name;
|
||||||
|
|
||||||
if (IsVarTerm(tname)) {
|
if (IsVarTerm(tname)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!IsAtomTerm (tname)) {
|
} else if (!IsAtomTerm(tname)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -252,8 +242,9 @@ file_exists(USES_REGS1)
|
|||||||
file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
|
file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
|
||||||
if (SYSTEM_STAT(file_name, &ss) != 0) {
|
if (SYSTEM_STAT(file_name, &ss) != 0) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return false;
|
return false;
|
||||||
PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, tname, "error %s", strerror(errno) );
|
PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, tname, "error %s",
|
||||||
|
strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -263,16 +254,13 @@ file_exists(USES_REGS1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Int time_file(USES_REGS1) {
|
||||||
static Int
|
|
||||||
time_file(USES_REGS1)
|
|
||||||
{
|
|
||||||
Term tname = Deref(ARG1);
|
Term tname = Deref(ARG1);
|
||||||
|
|
||||||
if (IsVarTerm(tname)) {
|
if (IsVarTerm(tname)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!IsAtomTerm (tname)) {
|
} else if (!IsAtomTerm(tname)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -281,37 +269,37 @@ time_file(USES_REGS1)
|
|||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
HANDLE hdl;
|
HANDLE hdl;
|
||||||
Term rc;
|
Term rc;
|
||||||
|
|
||||||
if ((hdl = CreateFile( n, 0, 0, NULL, OPEN_EXISTING, 0, 0)) == 0)
|
if ((hdl = CreateFile(n, 0, 0, NULL, OPEN_EXISTING, 0, 0)) == 0)
|
||||||
return false;
|
return false;
|
||||||
if (GetFileTime(hdl, NULL,NULL,&ft))
|
if (GetFileTime(hdl, NULL, NULL, &ft))
|
||||||
return false;
|
return false;
|
||||||
// Convert the last-write time to local time.
|
// Convert the last-write time to local time.
|
||||||
// FileTimeToSystemTime(&ftWrite, &stUTC);
|
// FileTimeToSystemTime(&ftWrite, &stUTC);
|
||||||
// SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
|
// SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
|
||||||
CloseHandle( hdl );
|
CloseHandle(hdl);
|
||||||
ULONGLONG qwResult;
|
ULONGLONG qwResult;
|
||||||
|
|
||||||
// Copy the time into a quadword.
|
// Copy the time into a quadword.
|
||||||
qwResult = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
qwResult = (((ULONGLONG)ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||||
#if SIZEOF_INT_P==8
|
#if SIZEOF_INT_P == 8
|
||||||
rc = MkIntegerTerm(qwResult);
|
rc = MkIntegerTerm(qwResult);
|
||||||
#elif USE_GMP
|
#elif USE_GMP
|
||||||
char s[64];
|
char s[64];
|
||||||
MP_INT rop;
|
MP_INT rop;
|
||||||
|
|
||||||
snprintf(s, 64, "%I64d", (long long int)n);
|
snprintf(s, 64, "%I64d", (long long int)n);
|
||||||
mpz_init_set_str (&rop, s, 10);
|
mpz_init_set_str(&rop, s, 10);
|
||||||
rc = Yap_MkBigNumTerm((void *)&rop) PASS_REGS);
|
rc = Yap_MkBigNumTerm((void *)&rop) PASS_REGS);
|
||||||
#else
|
#else
|
||||||
rc = MkIntegerTerm(ft.dwHighDateTime);
|
rc = MkIntegerTerm(ft.dwHighDateTime);
|
||||||
#endif
|
#endif
|
||||||
return Yap_unify(ARG2, rc);
|
return Yap_unify(ARG2, rc);
|
||||||
#elif HAVE_STAT
|
#elif HAVE_STAT
|
||||||
struct SYSTEM_STAT ss;
|
struct SYSTEM_STAT ss;
|
||||||
|
|
||||||
if (SYSTEM_STAT(n, &ss) != 0) {
|
if (SYSTEM_STAT(n, &ss) != 0) {
|
||||||
/* ignore errors while checking a file */
|
/* ignore errors while checking a file */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return Yap_unify(ARG2, MkIntegerTerm(ss.st_mtime));
|
return Yap_unify(ARG2, MkIntegerTerm(ss.st_mtime));
|
||||||
@ -321,36 +309,37 @@ time_file(USES_REGS1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int file_size(USES_REGS1) {
|
||||||
file_size(USES_REGS1)
|
|
||||||
{
|
|
||||||
int rc;
|
int rc;
|
||||||
Int sno = Yap_CheckStream (ARG1, (Input_Stream_f | Output_Stream_f | Socket_Stream_f), "file_size/2");
|
Int sno = Yap_CheckStream(
|
||||||
|
ARG1, (Input_Stream_f | Output_Stream_f | Socket_Stream_f),
|
||||||
|
"file_size/2");
|
||||||
if (sno < 0)
|
if (sno < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
if (GLOBAL_Stream[sno]. status & Seekable_Stream_f &&
|
if (GLOBAL_Stream[sno].status & Seekable_Stream_f &&
|
||||||
!(GLOBAL_Stream[sno]. status & (InMemory_Stream_f|Socket_Stream_f|Pipe_Stream_f))) {
|
!(GLOBAL_Stream[sno].status &
|
||||||
// there
|
(InMemory_Stream_f | Socket_Stream_f | Pipe_Stream_f))) {
|
||||||
struct stat file_stat;
|
// there
|
||||||
if ((rc = fstat(fileno(GLOBAL_Stream[sno].file), &file_stat) )< 0) {
|
struct stat file_stat;
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
if ((rc = fstat(fileno(GLOBAL_Stream[sno].file), &file_stat)) < 0) {
|
||||||
if (rc == ENOENT)
|
|
||||||
PlIOError( EXISTENCE_ERROR_SOURCE_SINK, ARG1, "%s in file_size", strerror(errno));
|
|
||||||
else
|
|
||||||
PlIOError( PERMISSION_ERROR_INPUT_STREAM, ARG1, "%s in file_size", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// and back again
|
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
return Yap_unify_constant( ARG2, MkIntegerTerm( file_stat.st_size) );
|
if (rc == ENOENT)
|
||||||
}
|
PlIOError(EXISTENCE_ERROR_SOURCE_SINK, ARG1, "%s in file_size",
|
||||||
|
strerror(errno));
|
||||||
|
else
|
||||||
|
PlIOError(PERMISSION_ERROR_INPUT_STREAM, ARG1, "%s in file_size",
|
||||||
|
strerror(errno));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// and back again
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
|
return Yap_unify_constant(ARG2, MkIntegerTerm(file_stat.st_size));
|
||||||
|
}
|
||||||
|
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int access_file(USES_REGS1) {
|
||||||
access_file(USES_REGS1)
|
|
||||||
{
|
|
||||||
Term tname = Deref(ARG1);
|
Term tname = Deref(ARG1);
|
||||||
Term tmode = Deref(ARG2);
|
Term tmode = Deref(ARG2);
|
||||||
char *ares;
|
char *ares;
|
||||||
@ -359,7 +348,7 @@ access_file(USES_REGS1)
|
|||||||
if (IsVarTerm(tmode)) {
|
if (IsVarTerm(tmode)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, tmode, "access_file/2");
|
Yap_Error(INSTANTIATION_ERROR, tmode, "access_file/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!IsAtomTerm (tmode)) {
|
} else if (!IsAtomTerm(tmode)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access_file/2");
|
Yap_Error(TYPE_ERROR_ATOM, tname, "access_file/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -367,42 +356,42 @@ access_file(USES_REGS1)
|
|||||||
if (IsVarTerm(tname)) {
|
if (IsVarTerm(tname)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, tname, "access_file/2");
|
Yap_Error(INSTANTIATION_ERROR, tname, "access_file/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!IsAtomTerm (tname)) {
|
} else if (!IsAtomTerm(tname)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access_file/2");
|
Yap_Error(TYPE_ERROR_ATOM, tname, "access_file/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
if (atmode == AtomNone)
|
if (atmode == AtomNone)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
if (! (ares = RepAtom(AtomOfTerm(tname))->StrOfAE))
|
if (!(ares = RepAtom(AtomOfTerm(tname))->StrOfAE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#if HAVE_ACCESS
|
#if HAVE_ACCESS
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
if (atmode == AtomExist)
|
if (atmode == AtomExist)
|
||||||
mode = 00;
|
mode = 00;
|
||||||
else if (atmode == AtomWrite)
|
else if (atmode == AtomWrite)
|
||||||
mode = 02;
|
mode = 02;
|
||||||
else if (atmode == AtomRead)
|
else if (atmode == AtomRead)
|
||||||
mode = 04;
|
mode = 04;
|
||||||
else if (atmode == AtomAppend)
|
else if (atmode == AtomAppend)
|
||||||
mode = 03;
|
mode = 03;
|
||||||
else if (atmode == AtomCsult)
|
else if (atmode == AtomCsult)
|
||||||
mode = 04;
|
mode = 04;
|
||||||
else if (atmode == AtomExecute)
|
else if (atmode == AtomExecute)
|
||||||
mode = 00; // can always execute?
|
mode = 00; // can always execute?
|
||||||
else {
|
else {
|
||||||
Yap_Error(DOMAIN_ERROR_IO_MODE, tmode, "access_file/2");
|
Yap_Error(DOMAIN_ERROR_IO_MODE, tmode, "access_file/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (access(ares, mode) < 0) {
|
if (access(ares, mode) < 0) {
|
||||||
/* ignore errors while checking a file */
|
/* ignore errors while checking a file */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
@ -421,7 +410,7 @@ access_file(USES_REGS1)
|
|||||||
mode = X_OK;
|
mode = X_OK;
|
||||||
else {
|
else {
|
||||||
Yap_Error(DOMAIN_ERROR_IO_MODE, tmode, "access_file/2");
|
Yap_Error(DOMAIN_ERROR_IO_MODE, tmode, "access_file/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (access(ares, mode) < 0) {
|
if (access(ares, mode) < 0) {
|
||||||
/* ignore errors while checking a file */
|
/* ignore errors while checking a file */
|
||||||
@ -435,7 +424,7 @@ access_file(USES_REGS1)
|
|||||||
struct SYSTEM_STAT ss;
|
struct SYSTEM_STAT ss;
|
||||||
|
|
||||||
if (SYSTEM_STAT(ares, &ss) != 0) {
|
if (SYSTEM_STAT(ares, &ss) != 0) {
|
||||||
/* ignore errors while checking a file */
|
/* ignore errors while checking a file */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -445,16 +434,14 @@ access_file(USES_REGS1)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int exists_directory(USES_REGS1) {
|
||||||
exists_directory(USES_REGS1)
|
|
||||||
{
|
|
||||||
Term tname = Deref(ARG1);
|
Term tname = Deref(ARG1);
|
||||||
char *file_name;
|
char *file_name;
|
||||||
|
|
||||||
if (IsVarTerm(tname)) {
|
if (IsVarTerm(tname)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, tname, "exists_directory/1");
|
Yap_Error(INSTANTIATION_ERROR, tname, "exists_directory/1");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!IsAtomTerm (tname)) {
|
} else if (!IsAtomTerm(tname)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM, tname, "exists_directory/1");
|
Yap_Error(TYPE_ERROR_ATOM, tname, "exists_directory/1");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -463,7 +450,7 @@ exists_directory(USES_REGS1)
|
|||||||
|
|
||||||
file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
|
file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
|
||||||
if (SYSTEM_STAT(file_name, &ss) != 0) {
|
if (SYSTEM_STAT(file_name, &ss) != 0) {
|
||||||
/* ignore errors while checking a file */
|
/* ignore errors while checking a file */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (S_ISDIR(ss.st_mode));
|
return (S_ISDIR(ss.st_mode));
|
||||||
@ -473,157 +460,154 @@ exists_directory(USES_REGS1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Int is_absolute_file_name(USES_REGS1) { /* file_base_name(Stream,N) */
|
||||||
static Int
|
|
||||||
is_absolute_file_name ( USES_REGS1 )
|
|
||||||
{ /* file_base_name(Stream,N) */
|
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Atom at;
|
Atom at;
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t, "file_base_name/2");
|
Yap_Error(INSTANTIATION_ERROR, t, "file_base_name/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
const char *buf = Yap_TextTermToText( t, NULL, 0);
|
const char *buf = Yap_TextTermToText(t, NULL, 0);
|
||||||
if (buf) {
|
if (buf) {
|
||||||
return Yap_IsAbsolutePath( buf );
|
return Yap_IsAbsolutePath(buf);
|
||||||
} else {
|
} else {
|
||||||
at = AtomOfTerm(t);
|
at = AtomOfTerm(t);
|
||||||
if (IsWideAtom(at)) {
|
if (IsWideAtom(at)) {
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
return PathIsRelativeW(RepAtom(at)->WStrOfAE);
|
return PathIsRelativeW(RepAtom(at)->WStrOfAE);
|
||||||
#else
|
#else
|
||||||
return RepAtom(at)->WStrOfAE[0] == '/';
|
return RepAtom(at)->WStrOfAE[0] == '/';
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int file_base_name(USES_REGS1) { /* file_base_name(Stream,N) */
|
||||||
file_base_name ( USES_REGS1 )
|
|
||||||
{ /* file_base_name(Stream,N) */
|
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Atom at;
|
Atom at;
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t, "file_base_name/2");
|
Yap_Error(INSTANTIATION_ERROR, t, "file_base_name/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
at = AtomOfTerm(t);
|
at = AtomOfTerm(t);
|
||||||
if (IsWideAtom(at)) {
|
if (IsWideAtom(at)) {
|
||||||
wchar_t *c = RepAtom(at)->WStrOfAE;
|
wchar_t *c = RepAtom(at)->WStrOfAE;
|
||||||
Int i = wcslen(c);
|
Int i = wcslen(c);
|
||||||
while (i && !Yap_dir_separator((int)c[--i]));
|
while (i && !Yap_dir_separator((int)c[--i]))
|
||||||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupWideAtom(c+i)));
|
;
|
||||||
|
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupWideAtom(c + i)));
|
||||||
} else {
|
} else {
|
||||||
const char *c = RepAtom(at)->StrOfAE;
|
const char *c = RepAtom(at)->StrOfAE;
|
||||||
const char *s;
|
const char *s;
|
||||||
#if HAVE_BASENAME && 0 // DISABLED: Linux basename is not compatible with file_base_name in SWI and GNU
|
#if HAVE_BASENAME && 0 // DISABLED: Linux basename is not compatible with
|
||||||
char c1[YAP_FILENAME_MAX+1];
|
// file_base_name in SWI and GNU
|
||||||
strncpy( c1, c, YAP_FILENAME_MAX);
|
char c1[YAP_FILENAME_MAX + 1];
|
||||||
s = basename( c1 );
|
strncpy(c1, c, YAP_FILENAME_MAX);
|
||||||
|
s = basename(c1);
|
||||||
#else
|
#else
|
||||||
Int i = strlen(c);
|
Int i = strlen(c);
|
||||||
while (i && !Yap_dir_separator((int)c[--i]));
|
while (i && !Yap_dir_separator((int)c[--i]))
|
||||||
if (Yap_dir_separator((int)c[i])) {
|
;
|
||||||
i++;
|
if (Yap_dir_separator((int)c[i])) {
|
||||||
}
|
i++;
|
||||||
s = c+i;
|
}
|
||||||
|
s = c + i;
|
||||||
#endif
|
#endif
|
||||||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(s)));
|
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(s)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int file_directory_name(USES_REGS1) { /* file_directory_name(Stream,N) */
|
||||||
file_directory_name ( USES_REGS1 )
|
|
||||||
{ /* file_directory_name(Stream,N) */
|
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Atom at;
|
Atom at;
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t, "file_directory_name/2");
|
Yap_Error(INSTANTIATION_ERROR, t, "file_directory_name/2");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
at = AtomOfTerm(t);
|
at = AtomOfTerm(t);
|
||||||
if (IsWideAtom(at)) {
|
if (IsWideAtom(at)) {
|
||||||
wchar_t s[YAP_FILENAME_MAX+1];
|
wchar_t s[YAP_FILENAME_MAX + 1];
|
||||||
wchar_t *c = RepAtom(at)->WStrOfAE;
|
wchar_t *c = RepAtom(at)->WStrOfAE;
|
||||||
Int i = wcslen(c);
|
Int i = wcslen(c);
|
||||||
while (i && !Yap_dir_separator((int)c[--i]));
|
while (i && !Yap_dir_separator((int)c[--i]))
|
||||||
if (Yap_dir_separator((int)c[i])) {
|
;
|
||||||
i++;
|
if (Yap_dir_separator((int)c[i])) {
|
||||||
}
|
i++;
|
||||||
wcsncpy(s, c, i);
|
}
|
||||||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupWideAtom(s)));
|
wcsncpy(s, c, i);
|
||||||
|
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupWideAtom(s)));
|
||||||
} else {
|
} else {
|
||||||
const char *c = RepAtom(at)->StrOfAE;
|
const char *c = RepAtom(at)->StrOfAE;
|
||||||
#if HAVE_BASENAME && 0 // DISABLED: Linux basename is not compatible with file_base_name in SWI and GNU
|
#if HAVE_BASENAME && 0 // DISABLED: Linux basename is not compatible with
|
||||||
const char *s;
|
// file_base_name in SWI and GNU
|
||||||
char c1[YAP_FILENAME_MAX+1];
|
const char *s;
|
||||||
strncpy( c1, c, YAP_FILENAME_MAX);
|
char c1[YAP_FILENAME_MAX + 1];
|
||||||
s = dirname( c1 );
|
strncpy(c1, c, YAP_FILENAME_MAX);
|
||||||
|
s = dirname(c1);
|
||||||
#else
|
#else
|
||||||
char s[YAP_FILENAME_MAX+1];
|
char s[YAP_FILENAME_MAX + 1];
|
||||||
Int i = strlen(c);
|
Int i = strlen(c);
|
||||||
while (i && !Yap_dir_separator((int)c[--i]));
|
while (i && !Yap_dir_separator((int)c[--i]))
|
||||||
strncpy(s, c, i);
|
;
|
||||||
s[i] = '\0';
|
strncpy(s, c, i);
|
||||||
|
s[i] = '\0';
|
||||||
#endif
|
#endif
|
||||||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(s)));
|
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(s)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Int same_file(USES_REGS1) {
|
||||||
static Int
|
|
||||||
same_file( USES_REGS1 ) {
|
|
||||||
char *f1 = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
|
char *f1 = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
|
||||||
char *f2 = RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE;
|
char *f2 = RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE;
|
||||||
|
|
||||||
if (strcmp(f1,f2) == 0)
|
if (strcmp(f1, f2) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#if HAVE_LSTAT
|
#if HAVE_LSTAT
|
||||||
{
|
{
|
||||||
int out;
|
int out;
|
||||||
struct stat *b1, *b2;
|
struct stat *b1, *b2;
|
||||||
while ((char *)HR+sizeof(struct stat)*2 > (char *)(ASP-1024)) {
|
while ((char *)HR + sizeof(struct stat) * 2 > (char *)(ASP - 1024)) {
|
||||||
if (!Yap_gcl(2*sizeof(struct stat), 2, ENV,Yap_gcP() ) ) {
|
if (!Yap_gcl(2 * sizeof(struct stat), 2, ENV, Yap_gcP())) {
|
||||||
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b1 = (struct stat *)HR;
|
b1 = (struct stat *)HR;
|
||||||
b2 = b1+1;
|
b2 = b1 + 1;
|
||||||
if (strcmp(f1,"user_input") == 0) {
|
if (strcmp(f1, "user_input") == 0) {
|
||||||
if (fstat(fileno(GLOBAL_Stream[0].file), b1) == -1) {
|
if (fstat(fileno(GLOBAL_Stream[0].file), b1) == -1) {
|
||||||
/* file does not exist, but was opened? Return -1 */
|
/* file does not exist, but was opened? Return -1 */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (strcmp(f1,"user_output") == 0) {
|
} else if (strcmp(f1, "user_output") == 0) {
|
||||||
if (fstat(fileno(GLOBAL_Stream[1].file), b1) == -1) {
|
if (fstat(fileno(GLOBAL_Stream[1].file), b1) == -1) {
|
||||||
/* file does not exist, but was opened? Return -1 */
|
/* file does not exist, but was opened? Return -1 */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (strcmp(f1,"user_error") == 0) {
|
} else if (strcmp(f1, "user_error") == 0) {
|
||||||
if (fstat(fileno(GLOBAL_Stream[2].file), b1) == -1) {
|
if (fstat(fileno(GLOBAL_Stream[2].file), b1) == -1) {
|
||||||
/* file does not exist, but was opened? Return -1 */
|
/* file does not exist, but was opened? Return -1 */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (stat(f1, b1) == -1) {
|
} else if (stat(f1, b1) == -1) {
|
||||||
/* file does not exist, but was opened? Return -1 */
|
/* file does not exist, but was opened? Return -1 */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (strcmp(f2,"user_input") == 0) {
|
if (strcmp(f2, "user_input") == 0) {
|
||||||
if (fstat(fileno(GLOBAL_Stream[0].file), b2) == -1) {
|
if (fstat(fileno(GLOBAL_Stream[0].file), b2) == -1) {
|
||||||
/* file does not exist, but was opened? Return -1 */
|
/* file does not exist, but was opened? Return -1 */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (strcmp(f2,"user_output") == 0) {
|
} else if (strcmp(f2, "user_output") == 0) {
|
||||||
if (fstat(fileno(GLOBAL_Stream[1].file), b2) == -1) {
|
if (fstat(fileno(GLOBAL_Stream[1].file), b2) == -1) {
|
||||||
/* file does not exist, but was opened? Return -1 */
|
/* file does not exist, but was opened? Return -1 */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (strcmp(f2,"user_error") == 0) {
|
} else if (strcmp(f2, "user_error") == 0) {
|
||||||
if (fstat(fileno(GLOBAL_Stream[2].file), b2) == -1) {
|
if (fstat(fileno(GLOBAL_Stream[2].file), b2) == -1) {
|
||||||
/* file does not exist, but was opened? Return -1 */
|
/* file does not exist, but was opened? Return -1 */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (stat(f2, b2) == -1) {
|
} else if (stat(f2, b2) == -1) {
|
||||||
/* file does not exist, but was opened? Return -1 */
|
/* file does not exist, but was opened? Return -1 */
|
||||||
@ -631,34 +615,35 @@ same_file( USES_REGS1 ) {
|
|||||||
}
|
}
|
||||||
out = (b1->st_ino == b2->st_ino
|
out = (b1->st_ino == b2->st_ino
|
||||||
#ifdef __LCC__
|
#ifdef __LCC__
|
||||||
&& memcmp((const void *)&(b1->st_dev),(const void *)&(b2->st_dev),sizeof(buf1.st_dev)) == 0
|
&&
|
||||||
|
memcmp((const void *)&(b1->st_dev), (const void *)&(b2->st_dev),
|
||||||
|
sizeof(buf1.st_dev)) == 0
|
||||||
#else
|
#else
|
||||||
&& b1->st_dev == b2->st_dev
|
&& b1->st_dev == b2->st_dev
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Yap_InitFiles(void) {
|
||||||
void
|
Yap_InitCPred("file_base_name", 2, file_base_name, SafePredFlag);
|
||||||
Yap_InitFiles( void )
|
Yap_InitCPred("file_directory_name", 2, file_directory_name, SafePredFlag);
|
||||||
{
|
Yap_InitCPred("is_absolute_file_name", 1, is_absolute_file_name,
|
||||||
Yap_InitCPred ("file_base_name", 2, file_base_name, SafePredFlag);
|
SafePredFlag);
|
||||||
Yap_InitCPred ("file_directory_name", 2, file_directory_name, SafePredFlag);
|
Yap_InitCPred("same_file", 2, same_file, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("is_absolute_file_name", 1, is_absolute_file_name, SafePredFlag);
|
Yap_InitCPred("$access_file", 2, access_file, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("same_file", 2, same_file, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("access", 1, access_path, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("$access_file", 2, access_file, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("exists_directory", 1, exists_directory,
|
||||||
Yap_InitCPred ("access", 1, access_path, SafePredFlag|SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("exists_directory", 1, exists_directory, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("exists_file", 1, exists_file, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("exists_file", 1, exists_file, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$file_exists", 1, file_exists, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("$file_exists", 1, file_exists, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("time_file64", 2, time_file, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("time_file64", 2, time_file, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("time_file", 2, time_file, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("time_file", 2, time_file, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("file_size", 2, file_size, SafePredFlag | SyncPredFlag);
|
||||||
Yap_InitCPred ("file_size", 2,file_size, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("file_name_extension", 3, file_name_extension,
|
||||||
Yap_InitCPred ("file_name_extension", 3, file_name_extension, SafePredFlag|SyncPredFlag);
|
SafePredFlag | SyncPredFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3282
os/sysbits.c
3282
os/sysbits.c
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "sysbits.h"
|
#include "sysbits.h"
|
||||||
|
|
||||||
#ifdef SIMICS
|
#ifdef SIMICS
|
||||||
#ifdef HAVE_GETRUSAGE
|
#ifdef HAVE_GETRUSAGE
|
||||||
@ -569,7 +569,7 @@ Yap_InitWTime (void)
|
|||||||
Yap_StartOfWTimes = (uint64_t)tp.tv_sec * 1000000000 + (uint64_t)tp.tv_usec * 1000;
|
Yap_StartOfWTimes = (uint64_t)tp.tv_sec * 1000000000 + (uint64_t)tp.tv_usec * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// returns time in nano-secs since the epoch
|
/// returns time in nano-secs since the epoch
|
||||||
uint64_t
|
uint64_t
|
||||||
Yap_walltime(void)
|
Yap_walltime(void)
|
||||||
@ -628,7 +628,9 @@ Yap_walltime (void)
|
|||||||
void
|
void
|
||||||
Yap_InitWTime (void)
|
Yap_InitWTime (void)
|
||||||
{
|
{
|
||||||
Yap_StartOfWTimes = ((uint64_t)times(NULL))*10000000/TicksPerSec;
|
// start thread 0
|
||||||
|
REMOTE_LastWTime(0) =
|
||||||
|
Yap_StartOfWTimes = ((uint64_t)times(NULL))*10000000/TicksPerSec;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include <Yatom.h>
|
|
||||||
#include "os/YapIOConfig.h"
|
#include "os/YapIOConfig.h"
|
||||||
|
#include <Yatom.h>
|
||||||
|
|
||||||
#ifndef _PL_WRITE_
|
#ifndef _PL_WRITE_
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ extern int errno;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint64_t HashFunction(const unsigned char *);
|
uint64_t HashFunction(const unsigned char *);
|
||||||
uint64_t WideHashFunction(wchar_t *);
|
uint64_t WideHashFunction(wchar_t *);
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c);
|
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c);
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c);
|
|||||||
* @return the term.
|
* @return the term.
|
||||||
*/
|
*/
|
||||||
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
|
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
|
||||||
int cs[2];
|
wchar_t cs[2];
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
return MkAtomTerm(AtomEof);
|
return MkAtomTerm(AtomEof);
|
||||||
cs[0] = c;
|
cs[0] = c;
|
||||||
@ -169,4 +169,7 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
|
|||||||
return MkAtomTerm(Yap_LookupMaybeWideAtom(cs));
|
return MkAtomTerm(Yap_LookupMaybeWideAtom(cs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// UT when yap started
|
||||||
|
uint64_t Yap_StartOfWTimes;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -974,7 +974,107 @@ int AddNamedVar(namedvars varmap, const char *varname) {
|
|||||||
|
|
||||||
void SetNamedVarValuesAt(namedvars varmap, int index, double dvalue, int ivalue,
|
void SetNamedVarValuesAt(namedvars varmap, int index, double dvalue, int ivalue,
|
||||||
void *dynvalue) {
|
void *dynvalue) {
|
||||||
varmap.dvalue[index] = dvalue;
|
varmap.dvalue[index] = dvalue;all_names -o packages/myddas/odbc/libYapodbc.1.0.0.dylib -install_name @rpath/libYapodbc.1.dylib packages/myddas/odbc/CMakeFiles/Yapodbc.dir/myddas_odbc.c.o libYap.6.3.4.dylib /usr/lib/libiodbc.dylib -ldl -lm /usr/local/lib/libgmp.dylib utf8proc/libutf8proc.1.3.0.dylib /usr/local/opt/readline/lib/libreadline.dylib /usr/lib/libncurses.dylib -Wl,-rpath,/Users/vsc/git/yap-6.3/Debug && :
|
||||||
|
[7/87] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -dynamiclib -Wl,-headerpad_max_install_names -o packages/myddas/postgres/libYappostgres.1.0.0.dylib -install_name @rpath/libYappostgres.1.dylib packages/myddas/postgres/CMakeFiles/Yappostgres.dir/myddas_postgres.c.o libYap.6.3.4.dylib -lpq -ldl -lm /usr/local/lib/libgmp.dylib utf8proc/libutf8proc.1.3.0.dylib /usr/local/opt/readline/lib/libreadline.dylib /usr/lib/libncurses.dylib -Wl,-rpath,/Users/vsc/git/yap-6.3/Debug && :
|
||||||
|
[8/87] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -dynamiclib -Wl,-headerpad_max_install_names -o packages/myddas/sqlite3/libYapsqlite3.1.0.0.dylib -install_name @rpath/libYapsqlite3.1.dylib packages/myddas/sqlite3/CMakeFiles/Yapsqlite3.dir/myddas_sqlite3.c.o /usr/local/opt/sqlite/lib/libsqlite3.dylib libYap.6.3.4.dylib -ldl -lm /usr/local/lib/libgmp.dylib utf8proc/libutf8proc.1.3.0.dylib /usr/local/opt/readline/lib/libreadline.dylib /usr/lib/libncurses.dylib -Wl,-rpath,/Users/vsc/git/yap-6.3/Debug && :
|
||||||
|
[9/87] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DCOROUTINING=1 -DDEBUG=1 -DDEPTH_LIMIT=1 -DHAVE_CONFIG_H=1 -DLOW_LEVEL_TRACER=1 -DRATIONAL_TREES=1 -DTABLING=1 -DTHREADED_CODE=1 -DUSE_MYDDAS=1 -DUSE_SYSTEM_MALLOC=1 -DUTF8PROC=1 -DYap___EXPORTS -D_YAP_NOT_INSTALLED_=1 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fPIC -I. -I../H -I../H/generated -I../include -I../os -I../OPTYap -I../utf8proc -I../JIT/HPP -I/usr/local/include -I../CXX/H -I../CXX/include -Wall -fexceptions -MMD -MT CXX/CMakeFiles/Yap++.dir/yapi.cpp.o -MF CXX/CMakeFiles/Yap++.dir/yapi.cpp.o.d -o CXX/CMakeFiles/Yap++.dir/yapi.cpp.o -c ../CXX/yapi.cpp
|
||||||
|
[10/87] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -dynamiclib -Wl,-headerpad_max_install_names -o library/matrix/matrix.dylib -install_name @rpath/matrix.dylib library/matrix/CMakeFiles/matrix.dir/matrix.c.o libYap.6.3.4.dylib -ldl -lm /usr/local/lib/libgmp.dylib utf8proc/libutf8proc.1.3.0.dylib /usr/local/opt/readline/lib/libreadline.dylib /usr/lib/libncurses.dylib -Wl,-rpath,/Users/vsc/git/yap-6.3/Debug && :
|
||||||
|
[11/87] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -dynamiclib -Wl,-headerpad_max_install_names -o library/random/yap_random.dylib -install_name @rpath/yap_random.dylib library/random/CMakeFiles/yap_random.dir/yap_random.c.o libYap.6.3.4.dylib -ldl -lm /usr/local/lib/libgmp.dylib utf8proc/libutf8proc.1.3.0.dylib /usr/local/opt/readline/lib/libreadline.dylib /usr/lib/libncurses.dylib -Wl,-rpath,/Users/vsc/git/yap-6.3/Debug && :
|
||||||
|
[12/87] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -dynamiclib -Wl,-headerpad_max_install_names -o library/regex/regexp.dylib -install_name @rpath/regexp.dylib library/regex/CMakeFiles/regexp.dir/regexp.c.o libYap.6.3.4.dylib -ldl -lm /usr/local/lib/libgmp.dylib utf8proc/libutf8proc.1.3.0.dylib /usr/local/opt/readline/lib/libreadline.dylib /usr/lib/libncurses.dylib -Wl,-rpath,/Users/vsc/git/yap-6.3/Debug && :
|
||||||
|
[13/87] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -dynamiclib -Wl,-headerpad_max_install_names -o library/rltree/yap_rl.dylib -install_name @rpath/yap_rl.dylib library/rltree/CMakeFiles/yap_rl.dir/yap_rl.c.o library/rltree/CMakeFiles/yap_rl.dir/range_list.c.o libYap.6.3.4.dylib -ldl -lm /usr/local/lib/libgmp.dylib utf8proc/libutf8proc.1.3.0.dylib /usr/local/opt/readline/lib/libreadline.dylib /usr/lib/libncurses.dylib -Wl,-rpath,/Users/vsc/git/yap-6.3/Debug && :
|
||||||
|
[14/87] cd /Users/vsc/git/yap-6.3/Debug && /Users/vsc/git/yap-6.3/Debug/yap -b /Users/vsc/git/yap-6.3/pl/boot.yap -L /Users/vsc/git/yap-6.3/pl/init.yap -z qend_program
|
||||||
|
% consulting /Users/vsc/git/yap-6.3/pl/init.yap...
|
||||||
|
% consulting arith.yap...
|
||||||
|
% arith.yap consulted 0 bytes in 4 msecs
|
||||||
|
% consulting bootlists.yap...
|
||||||
|
% bootlists.yap consulted 0 bytes in 1 msecs
|
||||||
|
% consulting consult.yap...
|
||||||
|
% consult.yap consulted 0 bytes in 11 msecs
|
||||||
|
% consulting preddecls.yap...
|
||||||
|
% preddecls.yap consulted 0 bytes in 3 msecs
|
||||||
|
% consulting preddyns.yap...
|
||||||
|
% preddyns.yap consulted 0 bytes in 3 msecs
|
||||||
|
% consulting meta.yap...
|
||||||
|
% meta.yap consulted 0 bytes in 6 msecs
|
||||||
|
% consulting newmod.yap...
|
||||||
|
% newmod.yap consulted 0 bytes in 3 msecs
|
||||||
|
% consulting atoms.yap...
|
||||||
|
% atoms.yap consulted 0 bytes in 3 msecs
|
||||||
|
% consulting os.yap...
|
||||||
|
% os.yap consulted 0 bytes in 3 msecs
|
||||||
|
% consulting grammar.yap...
|
||||||
|
:- prolog:use_module(library(expand_macros)) failed.
|
||||||
|
:- prolog:dynamic prolog:$goal_expansion_allowed/0 failed.
|
||||||
|
% grammar.yap consulted 0 bytes in 5 msecs
|
||||||
|
% consulting absf.yap...
|
||||||
|
% absf.yap consulted 0 bytes in 7 msecs
|
||||||
|
loading(consulting,directives.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/directives.yap,prolog,5,0)
|
||||||
|
loading(consulting,preds.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/preds.yap,prolog,9,0)
|
||||||
|
loading(consulting,modules.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/modules.yap,prolog,9,0)
|
||||||
|
loading(reconsulting,error.yap)
|
||||||
|
loaded(reconsulted,/Users/vsc/git/yap-6.3/pl/error.yap,error,3,0)
|
||||||
|
loading(consulting,errors.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/errors.yap,prolog,1,0)
|
||||||
|
loading(consulting,utils.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/utils.yap,prolog,4,0)
|
||||||
|
loading(consulting,control.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/control.yap,prolog,4,0)
|
||||||
|
loading(consulting,flags.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/flags.yap,prolog,1,0)
|
||||||
|
loading(consulting,yio.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/yio.yap,prolog,2,0)
|
||||||
|
loading(consulting,debug.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/debug.yap,prolog,9,0)
|
||||||
|
loading(consulting,checker.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/checker.yap,prolog,1,0)
|
||||||
|
loading(consulting,depth_bound.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/depth_bound.yap,prolog,0,0)
|
||||||
|
loading(consulting,ground.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/ground.yap,prolog,1,0)
|
||||||
|
loading(consulting,listing.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/listing.yap,prolog,3,0)
|
||||||
|
loading(consulting,arithpreds.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/arithpreds.yap,prolog,1,0)
|
||||||
|
loading(consulting,eval.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/eval.yap,prolog,1,0)
|
||||||
|
loading(consulting,signals.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/signals.yap,prolog,3,0)
|
||||||
|
loading(consulting,profile.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/profile.yap,prolog,2,0)
|
||||||
|
loading(consulting,callcount.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/callcount.yap,prolog,0,0)
|
||||||
|
loading(consulting,load_foreign.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/load_foreign.yap,prolog,1,0)
|
||||||
|
loading(consulting,setof.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/setof.yap,prolog,1,0)
|
||||||
|
loading(consulting,sort.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/sort.yap,prolog,1,0)
|
||||||
|
loading(consulting,statistics.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/statistics.yap,prolog,3,0)
|
||||||
|
loading(consulting,strict_iso.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/strict_iso.yap,prolog,3,0)
|
||||||
|
loading(consulting,tabling.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/tabling.yap,prolog,4,0)
|
||||||
|
loading(consulting,threads.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/threads.yap,prolog,10,0)
|
||||||
|
loading(consulting,eam.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/eam.yap,prolog,1,0)
|
||||||
|
loading(consulting,yapor.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/yapor.yap,prolog,2,0)
|
||||||
|
loading(consulting,qly.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/qly.yap,prolog,7,0)
|
||||||
|
loading(consulting,spy.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/spy.yap,prolog,3,0)
|
||||||
|
loading(consulting,udi.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/udi.yap,prolog,0,0)
|
||||||
|
loading(consulting,protect.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/protect.yap,prolog,1,0)
|
||||||
|
loading(consulting,arrays.yap)
|
||||||
|
loaded(consulted,/Users/vsc/git/yap-6.3/pl/arrays.yap,prolog,1,0)
|
||||||
|
loading(consulting,undefined.yap)
|
||||||
varmap.ivalue[index] = ivalue;
|
varmap.ivalue[index] = ivalue;
|
||||||
varmap.dynvalue[index] = dynvalue;
|
varmap.dynvalue[index] = dynvalue;
|
||||||
}
|
}
|
||||||
@ -987,7 +1087,7 @@ int SetNamedVarValues(namedvars varmap, const char *varname, double dvalue,
|
|||||||
} else if ((index < 0) || (index == 0 && varmap.vars[0] == NULL)) {
|
} else if ((index < 0) || (index == 0 && varmap.vars[0] == NULL)) {
|
||||||
index *= -1;
|
index *= -1;
|
||||||
varmap.vars[index] = (char *)malloc(sizeof(char) * (strlen(varname) + 1));
|
varmap.vars[index] = (char *)malloc(sizeof(char) * (strlen(varname) + 1));
|
||||||
strcpy(varmap.vars[index], varname);
|
strcpy((cinst char *)varmap.vars[index], varname);
|
||||||
varmap.dvalue[index] = dvalue;
|
varmap.dvalue[index] = dvalue;
|
||||||
varmap.ivalue[index] = ivalue;
|
varmap.ivalue[index] = ivalue;
|
||||||
varmap.dynvalue[index] = dynvalue;
|
varmap.dynvalue[index] = dynvalue;
|
||||||
|
@ -48,7 +48,7 @@ refactoring (trivial):
|
|||||||
#define JPL_C_LIB_VERSION_PATCH 4
|
#define JPL_C_LIB_VERSION_PATCH 4
|
||||||
#define JPL_C_LIB_VERSION_STATUS "alpha"
|
#define JPL_C_LIB_VERSION_STATUS "alpha"
|
||||||
|
|
||||||
#if JPL_DEBUG
|
#ifndef JPL_DEBUG
|
||||||
/*#define DEBUG(n, g) ((void)0) */
|
/*#define DEBUG(n, g) ((void)0) */
|
||||||
#define DEBUG_LEVEL 4
|
#define DEBUG_LEVEL 4
|
||||||
#define JPL_DEBUG(n, g) ( n >= DEBUG_LEVEL ? g : (void)0 )
|
#define JPL_DEBUG(n, g) ( n >= DEBUG_LEVEL ? g : (void)0 )
|
||||||
|
@ -3,6 +3,7 @@ macro_optional_find_package (SWIG ON)
|
|||||||
macro_log_feature (SWIG_FOUND "Swig"
|
macro_log_feature (SWIG_FOUND "Swig"
|
||||||
"Use SWIG Documentation System "
|
"Use SWIG Documentation System "
|
||||||
"http://www.swig.org" FALSE)
|
"http://www.swig.org" FALSE)
|
||||||
|
|
||||||
if (SWIG_FOUND)
|
if (SWIG_FOUND)
|
||||||
#
|
#
|
||||||
# SWIG_FOUND - set to true if SWIG is found
|
# SWIG_FOUND - set to true if SWIG is found
|
||||||
@ -15,10 +16,10 @@ if (SWIG_FOUND)
|
|||||||
|
|
||||||
INCLUDE(${SWIG_USE_FILE})
|
INCLUDE(${SWIG_USE_FILE})
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(python)
|
add_subdirectory(python)
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(java)
|
add_subdirectory(java)
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ set(PL_SOURCES
|
|||||||
hacks.yap
|
hacks.yap
|
||||||
init.yap
|
init.yap
|
||||||
listing.yap
|
listing.yap
|
||||||
lists.yap
|
bootlists.yap
|
||||||
load_foreign.yap
|
load_foreign.yap
|
||||||
messages.yap
|
messages.yap
|
||||||
meta.yap
|
meta.yap
|
||||||
@ -48,7 +48,6 @@ set(PL_SOURCES
|
|||||||
udi.yap
|
udi.yap
|
||||||
undefined.yap
|
undefined.yap
|
||||||
utils.yap
|
utils.yap
|
||||||
history.pl
|
|
||||||
swi.yap
|
swi.yap
|
||||||
yapor.yap
|
yapor.yap
|
||||||
yio.yap
|
yio.yap
|
||||||
|
46
pl/absf.yap
46
pl/absf.yap
@ -8,7 +8,7 @@
|
|||||||
* *
|
* *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ absolute_file_name(File0,File) :-
|
|||||||
file_errors(fail),
|
file_errors(fail),
|
||||||
solutions(first),
|
solutions(first),
|
||||||
expand(true)],F,G).
|
expand(true)],F,G).
|
||||||
|
|
||||||
'$absolute_file_name'(File,LOpts,TrueFileName, G) :-
|
'$absolute_file_name'(File,LOpts,TrueFileName, G) :-
|
||||||
% must_be_of_type( atom, File ),
|
% must_be_of_type( atom, File ),
|
||||||
abs_file_parameters(LOpts,Opts),
|
abs_file_parameters(LOpts,Opts),
|
||||||
@ -215,7 +215,7 @@ absolute_file_name(File0,File) :-
|
|||||||
FileErrors = error,
|
FileErrors = error,
|
||||||
'$do_error'(existence_error(file,File),G)
|
'$do_error'(existence_error(file,File),G)
|
||||||
).
|
).
|
||||||
|
|
||||||
% This sequence must be followed:
|
% This sequence must be followed:
|
||||||
% user and user_input are special;
|
% user and user_input are special;
|
||||||
% library(F) must check library_directories
|
% library(F) must check library_directories
|
||||||
@ -229,7 +229,7 @@ absolute_file_name(File0,File) :-
|
|||||||
% ( atom(Name) -> true ; start_low_level_trace ),
|
% ( atom(Name) -> true ; start_low_level_trace ),
|
||||||
get_abs_file_parameter( file_type, Opts, Type ),
|
get_abs_file_parameter( file_type, Opts, Type ),
|
||||||
get_abs_file_parameter( access, Opts, Access ),
|
get_abs_file_parameter( access, Opts, Access ),
|
||||||
get_abs_file_parameter( expand, Opts, Expand ),
|
get_abs_file_parameter( expand, Opts, Expand ),
|
||||||
'$absf_trace'('start with ~w', [Name]),
|
'$absf_trace'('start with ~w', [Name]),
|
||||||
'$core_file_name'(Name, Opts, CorePath, []),
|
'$core_file_name'(Name, Opts, CorePath, []),
|
||||||
'$absf_trace'(' after name/library unfolding: ~w', [Name]),
|
'$absf_trace'(' after name/library unfolding: ~w', [Name]),
|
||||||
@ -239,29 +239,29 @@ absolute_file_name(File0,File) :-
|
|||||||
'$absf_trace'(' after prefix expansion: ~s', [Path]),
|
'$absf_trace'(' after prefix expansion: ~s', [Path]),
|
||||||
atom_codes( APath, Path ),
|
atom_codes( APath, Path ),
|
||||||
(
|
(
|
||||||
Expand = true
|
Expand = true
|
||||||
->
|
->
|
||||||
expand_file_name( APath, EPaths),
|
expand_file_name( APath, EPaths),
|
||||||
'$absf_trace'(' after shell globbing: ~w', [EPaths]),
|
'$absf_trace'(' after shell globbing: ~w', [EPaths]),
|
||||||
lists:member(EPath, EPaths)
|
lists:member(EPath, EPaths)
|
||||||
;
|
;
|
||||||
EPath = APath
|
EPath = APath
|
||||||
),
|
),
|
||||||
real_path( EPath, File),
|
real_path( EPath, File),
|
||||||
'$absf_trace'(' after canonical path name: ~a', [File]),
|
'$absf_trace'(' after canonical path name: ~a', [File]),
|
||||||
'$check_file'( File, Type, Access ),
|
'$check_file'( File, Type, Access ),
|
||||||
'$absf_trace'(' after testing ~a for ~a and ~a', [File,Type,Access]).
|
'$absf_trace'(' after testing ~a for ~a and ~a', [File,Type,Access]).
|
||||||
|
|
||||||
% allow paths in File Name
|
% allow paths in File Name
|
||||||
'$core_file_name'(Name, Opts) -->
|
'$core_file_name'(Name, Opts) -->
|
||||||
'$file_name'(Name, Opts, E),
|
'$file_name'(Name, Opts, E),
|
||||||
'$suffix'(E, Opts),
|
'$suffix'(E, Opts),
|
||||||
'$glob'(Opts).
|
'$glob'(Opts).
|
||||||
|
|
||||||
%
|
%
|
||||||
% handle library(lists) or foreign(jpl)
|
% handle library(lists) or foreign(jpl)
|
||||||
%
|
%
|
||||||
'$file_name'(Name, Opts, E) -->
|
'$file_name'(Name, Opts, E) -->
|
||||||
{ Name =.. [Lib, P0] },
|
{ Name =.. [Lib, P0] },
|
||||||
!,
|
!,
|
||||||
{ user:file_search_path(Lib, IDirs) },
|
{ user:file_search_path(Lib, IDirs) },
|
||||||
@ -269,9 +269,9 @@ absolute_file_name(File0,File) :-
|
|||||||
'$absf_trace'(' ~w first', [Dir]),
|
'$absf_trace'(' ~w first', [Dir]),
|
||||||
'$file_name'(Dir, Opts, _),
|
'$file_name'(Dir, Opts, _),
|
||||||
'$dir',
|
'$dir',
|
||||||
{ '$absf_trace'(' ~w next', [P0]) },
|
{ '$absf_trace'(' ~w next', [P0]) },
|
||||||
'$cat_file_name'(P0, E).
|
'$cat_file_name'(P0, E).
|
||||||
'$file_name'(Name, _Opts, E) -->
|
'$file_name'(Name, _Opts, E) -->
|
||||||
'$cat_file_name'(Name, E).
|
'$cat_file_name'(Name, E).
|
||||||
|
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ absolute_file_name(File0,File) :-
|
|||||||
'$cat_file_name'(File, S) -->
|
'$cat_file_name'(File, S) -->
|
||||||
{string(File), string_to_codes(File, S) },
|
{string(File), string_to_codes(File, S) },
|
||||||
!,
|
!,
|
||||||
S.
|
S.
|
||||||
|
|
||||||
|
|
||||||
'$variable_expansion'( Path, Opts, APath ) :-
|
'$variable_expansion'( Path, Opts, APath ) :-
|
||||||
@ -326,7 +326,7 @@ absolute_file_name(File0,File) :-
|
|||||||
|
|
||||||
'$suffix'(Last, _Opts) -->
|
'$suffix'(Last, _Opts) -->
|
||||||
{ lists:append(_, [0'.|Alphas], Last), '$id'(Alphas, _, [] ) },
|
{ lists:append(_, [0'.|Alphas], Last), '$id'(Alphas, _, [] ) },
|
||||||
'$absf_trace'(' suffix in ~s', [Last]),
|
'$absf_trace'(' suffix in ~s', [Last]),
|
||||||
!.
|
!.
|
||||||
'$suffix'(_, Opts) -->
|
'$suffix'(_, Opts) -->
|
||||||
{
|
{
|
||||||
@ -358,7 +358,7 @@ absolute_file_name(File0,File) :-
|
|||||||
'$glob'(Opts) -->
|
'$glob'(Opts) -->
|
||||||
{
|
{
|
||||||
get_abs_file_parameter( glob, Opts, G ),
|
get_abs_file_parameter( glob, Opts, G ),
|
||||||
G \= '',
|
G \= '',
|
||||||
atom_codes( G, Gs )
|
atom_codes( G, Gs )
|
||||||
},
|
},
|
||||||
!,
|
!,
|
||||||
@ -415,7 +415,7 @@ absolute_file_name(File0,File) :-
|
|||||||
'$dir'(_) --> '$dir'.
|
'$dir'(_) --> '$dir'.
|
||||||
|
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
'$system_library_directories'(library, Dir) :-
|
'$system_library_directories'(library, Dir) :-
|
||||||
user:library_directory( Dir ).
|
user:library_directory( Dir ).
|
||||||
@ -441,7 +441,7 @@ absolute_file_name(File0,File) :-
|
|||||||
'$paths'(RC, C)
|
'$paths'(RC, C)
|
||||||
).
|
).
|
||||||
'$paths'(S, S).
|
'$paths'(S, S).
|
||||||
|
|
||||||
'$absf_trace'(Msg, Args ) -->
|
'$absf_trace'(Msg, Args ) -->
|
||||||
{ current_prolog_flag( verbose_file_search, true ) },
|
{ current_prolog_flag( verbose_file_search, true ) },
|
||||||
!,
|
!,
|
||||||
|
@ -115,7 +115,7 @@ otherwise.
|
|||||||
|
|
||||||
:- compile_expressions.
|
:- compile_expressions.
|
||||||
|
|
||||||
:- bootstrap('lists.yap').
|
:- bootstrap('bootlists.yap').
|
||||||
:- bootstrap('consult.yap').
|
:- bootstrap('consult.yap').
|
||||||
:- bootstrap('preddecls.yap').
|
:- bootstrap('preddecls.yap').
|
||||||
:- bootstrap('preddyns.yap').
|
:- bootstrap('preddyns.yap').
|
||||||
|
Reference in New Issue
Block a user