fix fixes (lots of white space, somehow.
This commit is contained in:
parent
0ccee1aa55
commit
b9eb327d86
@ -1090,7 +1090,7 @@ execute_dealloc( USES_REGS1 )
|
||||
else
|
||||
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CP));
|
||||
#endif /* FROZEN_STACKS */
|
||||
YENV = ENV_YREG;
|
||||
YENV = ENVYREG;
|
||||
P = NEXTOP(P,p);
|
||||
|
||||
}
|
||||
|
@ -1317,7 +1317,7 @@ atom_length( USES_REGS1 )
|
||||
if (!IsIntegerTerm(t2)) {
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "atom_length/2");
|
||||
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");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -1354,7 +1354,7 @@ atomic_length( USES_REGS1 )
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "atomic_length/2");
|
||||
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");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -1383,7 +1383,7 @@ string_length( USES_REGS1 )
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t2, "string_length/2");
|
||||
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");
|
||||
return(FALSE);
|
||||
}
|
||||
|
@ -1019,7 +1019,7 @@ Term Yap_UnknownFlag(Term mod) {
|
||||
|
||||
ModEntry *fv = Yap_GetModuleEntry(mod);
|
||||
if (fv == NULL)
|
||||
fv = Yap_GetModuleEntry(AtomUser);
|
||||
fv = Yap_GetModuleEntry(TermUser);
|
||||
if (fv->flags & UNKNOWN_ERROR)
|
||||
return TermError;
|
||||
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) {
|
||||
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");
|
||||
}
|
||||
buff += nwritten;
|
||||
|
32
C/stdpreds.c
32
C/stdpreds.c
@ -1,4 +1,3 @@
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
@ -35,11 +34,11 @@ static char SccsId[] = "%W% %G%";
|
||||
#if YAP_JIT
|
||||
#include "amijit.h"
|
||||
#endif
|
||||
#include "Yatom.h"
|
||||
#include "Foreign.h"
|
||||
#include "YapHeap.h"
|
||||
#include "Yatom.h"
|
||||
#include "eval.h"
|
||||
#include "yapio.h"
|
||||
#include "Foreign.h"
|
||||
#ifdef TABLING
|
||||
#include "tab.macros.h"
|
||||
#endif /* TABLING */
|
||||
@ -56,8 +55,8 @@ static char SccsId[] = "%W% %G%";
|
||||
#if YAP_JIT
|
||||
#include <JIT_Compiler.hpp>
|
||||
#endif
|
||||
#include <wchar.h>
|
||||
#include <fcntl.h>
|
||||
#include <wchar.h>
|
||||
|
||||
static Int p_setval(USES_REGS1);
|
||||
static Int p_value(USES_REGS1);
|
||||
@ -386,8 +385,11 @@ static Int p_systime(USES_REGS1) {
|
||||
|
||||
static Int p_walltime(USES_REGS1) {
|
||||
uint64_t now, interval;
|
||||
return (Yap_unify_constant(ARG1, MkIntegerTerm(now)) &&
|
||||
Yap_unify_constant(ARG2, MkIntegerTerm(interval)));
|
||||
uint64_t t = Yap_walltime();
|
||||
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 */
|
||||
@ -630,13 +632,13 @@ static Int
|
||||
|
||||
static bool valid_prop(Prop p, Term task) {
|
||||
if ((RepPredProp(p)->PredFlags & HiddenPredFlag) ||
|
||||
(RepPredProp(p)->OpcodeOfPred == UNDEF_OPCODE) ){
|
||||
(RepPredProp(p)->OpcodeOfPred == UNDEF_OPCODE)) {
|
||||
return false;
|
||||
}
|
||||
if(task == TermSystem || task == TermProlog) {
|
||||
if (task == TermSystem || task == TermProlog) {
|
||||
return RepPredProp(p)->PredFlags & StandardPredFlag;
|
||||
}
|
||||
if(task == TermUser) {
|
||||
if (task == TermUser) {
|
||||
return !(RepPredProp(p)->PredFlags & StandardPredFlag);
|
||||
}
|
||||
if (IsVarTerm(task)) {
|
||||
@ -682,7 +684,7 @@ static PropEntry *nextPredForAtom(PropEntry *p, Term task) {
|
||||
return NIL;
|
||||
pe = RepPredProp(p);
|
||||
if (pe->ArityOfPE == 0 ||
|
||||
(pe->PredFlags & (NumberDBPredFlag |AtomDBPredFlag) ) ) {
|
||||
(pe->PredFlags & (NumberDBPredFlag | AtomDBPredFlag))) {
|
||||
// if atom prop, search atom list
|
||||
return followLinkedListOfProps(p->NextOfPE, task);
|
||||
} else {
|
||||
@ -873,8 +875,7 @@ static Int cont_current_predicate(USES_REGS1) {
|
||||
npp = firstModulePred(pp, task);
|
||||
|
||||
if (!npp) {
|
||||
if (pp->ModuleOfPred != PROLOG_MODULE &&
|
||||
task != TermUser) {
|
||||
if (pp->ModuleOfPred != PROLOG_MODULE && task != TermUser) {
|
||||
ModEntry *m = Yap_GetModuleEntry(TermProlog);
|
||||
npp = firstModulePred(m->PredForME, task);
|
||||
if (!npp)
|
||||
@ -938,9 +939,8 @@ static Int cont_current_predicate(USES_REGS1) {
|
||||
} else {
|
||||
rc = Yap_unify(ARG3, name);
|
||||
}
|
||||
rc = rc && (IsAtomTerm(t2) ||
|
||||
Yap_unify(ARG2, ModToTerm(pp->ModuleOfPred)))
|
||||
&& Yap_unify(ARG1, name);
|
||||
rc = rc && (IsAtomTerm(t2) || Yap_unify(ARG2, ModToTerm(pp->ModuleOfPred))) &&
|
||||
Yap_unify(ARG1, name);
|
||||
if (will_cut) {
|
||||
if (rc)
|
||||
cut_succeed();
|
||||
@ -1105,7 +1105,7 @@ void Yap_show_statistics(void) {
|
||||
(Unsigned(TR) - Unsigned(LOCAL_TrailBase))));
|
||||
fprintf(stderr, "Runtime: %lds.\n", (unsigned long int)(runtime(PASS_REGS1)));
|
||||
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) {
|
||||
|
@ -15,8 +15,11 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define X_API __declspec(dllexport)
|
||||
#else
|
||||
#define X_API
|
||||
#endif
|
||||
|
||||
|
||||
/* prototype file for Yap */
|
||||
|
||||
/* absmi.c */
|
||||
|
@ -140,7 +140,5 @@
|
||||
#define GLOBAL_CharConversionTable Yap_global->CharConversionTable_
|
||||
#define GLOBAL_CharConversionTable2 Yap_global->CharConversionTable2_
|
||||
|
||||
#define GLOBAL_LastWTimePtr Yap_global->LastWTimePtr_
|
||||
|
||||
#define GLOBAL_MaxPriority Yap_global->MaxPriority_
|
||||
|
||||
|
@ -491,3 +491,6 @@
|
||||
#define LOCAL_MAX_SIZE LOCAL->MAX_SIZE_
|
||||
#define REMOTE_MAX_SIZE(wid) REMOTE(wid)->MAX_SIZE_
|
||||
|
||||
#define LOCAL_LastWTime LOCAL->LastWTime_
|
||||
#define REMOTE_LastWTime(wid) REMOTE(wid)->LastWTime_
|
||||
|
||||
|
@ -111,7 +111,7 @@ EXTERNAL char GLOBAL_pwd[YAP_FILENAME_MAX];
|
||||
#endif
|
||||
//udi.c
|
||||
//struct udi_control_block RtreeCmd void
|
||||
EXTERNAL char* GLOBAL_RestoreFile;
|
||||
EXTERNAL const char* GLOBAL_RestoreFile;
|
||||
//gprof.c
|
||||
EXTERNAL Int GLOBAL_ProfCalls;
|
||||
EXTERNAL Int GLOBAL_ProfGCs;
|
||||
@ -139,8 +139,6 @@ EXTERNAL char* GLOBAL_Home;
|
||||
/* ISO char conversion: I will make no comments */
|
||||
EXTERNAL char* GLOBAL_CharConversionTable;
|
||||
EXTERNAL char* GLOBAL_CharConversionTable2;
|
||||
/* time */
|
||||
EXTERNAL void* GLOBAL_LastWTimePtr;
|
||||
/* max priority */
|
||||
EXTERNAL int GLOBAL_MaxPriority;
|
||||
|
||||
|
@ -111,7 +111,7 @@ typedef struct global_data {
|
||||
#endif
|
||||
//udi.c
|
||||
//struct udi_control_block RtreeCmd void
|
||||
char* RestoreFile_;
|
||||
const char* RestoreFile_;
|
||||
//gprof.c
|
||||
Int ProfCalls_;
|
||||
Int ProfGCs_;
|
||||
@ -139,8 +139,6 @@ typedef struct global_data {
|
||||
/* ISO char conversion: I will make no comments */
|
||||
char* CharConversionTable_;
|
||||
char* CharConversionTable2_;
|
||||
/* time */
|
||||
void* LastWTimePtr_;
|
||||
/* max priority */
|
||||
int MaxPriority_;
|
||||
} w_shared;
|
||||
|
@ -274,4 +274,6 @@ const char* Error_Function_;
|
||||
Term SourceModule_;
|
||||
Term Including_;
|
||||
size_t MAX_SIZE_;
|
||||
/* last call to walltime. */
|
||||
uint64_t LastWTime_;
|
||||
} w_local;
|
||||
|
@ -140,7 +140,5 @@ static void InitGlobal(void) {
|
||||
GLOBAL_CharConversionTable = NULL;
|
||||
GLOBAL_CharConversionTable2 = NULL;
|
||||
|
||||
GLOBAL_LastWTimePtr = NULL;
|
||||
|
||||
GLOBAL_MaxPriority = 1200;
|
||||
}
|
||||
|
@ -274,4 +274,6 @@ static void InitWorker(int wid) {
|
||||
REMOTE_SourceModule(wid) = 0;
|
||||
REMOTE_Including(wid) = TermNil;
|
||||
REMOTE_MAX_SIZE(wid) = 1024L;
|
||||
|
||||
REMOTE_LastWTime(wid) = NULL;
|
||||
}
|
||||
|
@ -274,4 +274,6 @@ static void RestoreWorker(int wid USES_REGS) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
*************************************************************************/
|
||||
/* static char SccsId[] = "X 4.3.3"; */
|
||||
|
||||
#include "config.h"
|
||||
#include "YapInterface.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "cut_c.h"
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
#undef HAVE_UNISTD_H
|
||||
#endif
|
||||
#ifdef _WIN32 /* Microsoft's Visual C++ Compiler */
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#if HAVE_SYS_TYPES_H
|
||||
@ -58,7 +58,6 @@
|
||||
#include <ieeefp.h>
|
||||
#endif
|
||||
|
||||
|
||||
static void do_top_goal(YAP_Term Goal);
|
||||
static void exec_top_level(int BootMode, YAP_init_args *iap);
|
||||
|
||||
@ -70,46 +69,35 @@ static void exec_top_level(int BootMode, YAP_init_args *iap);
|
||||
long _stksize = 32000;
|
||||
#endif
|
||||
|
||||
static void do_top_goal(YAP_Term Goal) { YAP_RunGoalOnce(Goal); }
|
||||
|
||||
|
||||
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 int init_standard_system(int argc, char *argv[], YAP_init_args *iap) {
|
||||
int BootMode;
|
||||
|
||||
// BootMode = YAP_parse_yap_arguments(argc,argv,iap);
|
||||
BootMode = YAP_parse_yap_arguments(argc, argv, iap);
|
||||
|
||||
/* init memory */
|
||||
if (BootMode == YAP_BOOT_FROM_PROLOG ||
|
||||
BootMode == YAP_FULL_BOOT_FROM_PROLOG) {
|
||||
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;
|
||||
} else {
|
||||
BootMode = YAP_Init(iap);
|
||||
}
|
||||
if (iap->ErrorNo) {
|
||||
/* boot failed */
|
||||
YAP_Error(iap->ErrorNo,0L,iap->ErrorCause);
|
||||
YAP_Error(iap->ErrorNo, 0L, iap->ErrorCause);
|
||||
}
|
||||
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_Atom livegoal;
|
||||
|
||||
if (BootMode == YAP_BOOT_FROM_SAVED_STACKS)
|
||||
{
|
||||
if (BootMode == YAP_BOOT_FROM_SAVED_STACKS) {
|
||||
/* continue executing from the frozen stacks */
|
||||
YAP_ContinueGoal();
|
||||
}
|
||||
@ -119,49 +107,46 @@ exec_top_level(int BootMode, YAP_init_args *iap)
|
||||
the atom false away ;-).
|
||||
*/
|
||||
livegoal = YAP_FullLookupAtom("$live");
|
||||
atomfalse = YAP_MkAtomTerm (YAP_FullLookupAtom("$false"));
|
||||
while (YAP_GetValue (livegoal) != atomfalse) {
|
||||
YAP_Reset( YAP_FULL_RESET );
|
||||
do_top_goal (YAP_MkAtomTerm (livegoal));
|
||||
atomfalse = YAP_MkAtomTerm(YAP_FullLookupAtom("$false"));
|
||||
while (YAP_GetValue(livegoal) != atomfalse) {
|
||||
YAP_Reset(YAP_FULL_RESET);
|
||||
do_top_goal(YAP_MkAtomTerm(livegoal));
|
||||
}
|
||||
YAP_Exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
//FILE *debugf;
|
||||
// FILE *debugf;
|
||||
|
||||
#ifdef LIGHT
|
||||
int
|
||||
_main (int argc, char **argv)
|
||||
int _main(int argc, char **argv)
|
||||
#else
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
int BootMode;
|
||||
int i;
|
||||
|
||||
YAP_init_args init_args;
|
||||
BootMode = init_standard_system(argc, argv, &init_args);
|
||||
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);
|
||||
}
|
||||
/* Begin preprocessor code */
|
||||
if (BootMode != YAP_BOOT_FROM_SAVED_STACKS) {
|
||||
// process the definitions
|
||||
for(i=0;i<init_args.def_c;++i) {
|
||||
YAP_Term t_args[2],t_goal;
|
||||
for (i = 0; i < init_args.def_c; ++i) {
|
||||
YAP_Term t_args[2], t_goal;
|
||||
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_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_Reset( YAP_FULL_RESET );
|
||||
YAP_Reset(YAP_FULL_RESET);
|
||||
/* End preprocessor code */
|
||||
|
||||
exec_top_level(BootMode, &init_args);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ char pwd[YAP_FILENAME_MAX] void
|
||||
//udi.c
|
||||
//struct udi_control_block RtreeCmd void
|
||||
|
||||
char* RestoreFile void
|
||||
const char* RestoreFile void
|
||||
|
||||
//gprof.c
|
||||
Int ProfCalls void
|
||||
@ -165,13 +165,9 @@ char* CharConversionTable =NULL
|
||||
char* CharConversionTable2 =NULL
|
||||
|
||||
|
||||
/* time */
|
||||
void* LastWTimePtr =NULL
|
||||
|
||||
/* max priority */
|
||||
int MaxPriority =1200
|
||||
|
||||
|
||||
|
||||
END_GLOBAL_DATA
|
||||
|
||||
|
@ -103,6 +103,8 @@ Term WokenGoals =0L TermToGlobalAdjust
|
||||
Term AttsMutableList =0L TermToGlobalAdjust
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// gc_stuff
|
||||
Term GcGeneration =0L TermToGlobalAdjust
|
||||
Term GcPhase =0L TermToGlobalAdjust
|
||||
@ -319,4 +321,8 @@ Term Including =TermNil
|
||||
|
||||
size_t MAX_SIZE =1024L
|
||||
|
||||
/* last call to walltime. */
|
||||
uint64_t LastWTime =0
|
||||
|
||||
|
||||
END_WORKER_LOCAL
|
||||
|
289
os/files.c
289
os/files.c
@ -26,37 +26,32 @@ static char SccsId[] = "%W% %G%";
|
||||
|
||||
#include "sysbits.h"
|
||||
|
||||
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
#define SYSTEM_STAT _stat
|
||||
#else
|
||||
#define SYSTEM_STAT stat
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static Int
|
||||
file_name_extension(USES_REGS1)
|
||||
{
|
||||
static Int file_name_extension(USES_REGS1) {
|
||||
Term t1 = Deref(ARG1);
|
||||
Term t2 = Deref(ARG2);
|
||||
Term t3 = Deref(ARG3);
|
||||
bool use_string = false;
|
||||
loop:
|
||||
loop:
|
||||
if (!IsVarTerm((t3))) {
|
||||
const char *f;
|
||||
if (IsAtomTerm(t3)) {
|
||||
f = AtomName( AtomOfTerm( t3 ) );
|
||||
} else if (IsStringTerm( t3 )) {
|
||||
f = StringOfTerm( t3 );
|
||||
f = AtomName(AtomOfTerm(t3));
|
||||
} else if (IsStringTerm(t3)) {
|
||||
f = StringOfTerm(t3);
|
||||
use_string = true;
|
||||
} else if (IsApplTerm(t3) && FunctorOfTerm(t3) == FunctorSlash) {
|
||||
// descend a compound term of the form a/b.
|
||||
Term tn1 = MkVarTerm(), tf1;
|
||||
Term ts[2];
|
||||
ts[0] = ArgOfTerm(1,t3);
|
||||
ts[0] = ArgOfTerm(1, t3);
|
||||
ts[1] = tn1;
|
||||
tf1 = Yap_MkApplTerm( FunctorSlash, 2, ts );
|
||||
tf1 = Yap_MkApplTerm(FunctorSlash, 2, ts);
|
||||
if (!Yap_unify(ARG1, tf1)) {
|
||||
return false;
|
||||
}
|
||||
@ -69,69 +64,70 @@ file_name_extension(USES_REGS1)
|
||||
char *pts = strrchr(f, '/');
|
||||
#if WIN32_ssss
|
||||
char *pts1 = strrchr(f, '\\');
|
||||
if (pts11 > pts) pts = pts1;
|
||||
if (pts11 > pts)
|
||||
pts = pts1;
|
||||
#endif
|
||||
char *ss = strrchr(f, '.');
|
||||
if (pts > ss) ss = NULL;
|
||||
if (pts > ss)
|
||||
ss = NULL;
|
||||
if (use_string) {
|
||||
char *tmp;
|
||||
if (!ss) {
|
||||
return Yap_unify(ARG1, ARG3) &&
|
||||
Yap_unify(ARG2, MkStringTerm( "" ) );
|
||||
return Yap_unify(ARG1, ARG3) && Yap_unify(ARG2, MkStringTerm(""));
|
||||
}
|
||||
tmp = malloc((ss - f)+1);
|
||||
tmp = malloc((ss - f) + 1);
|
||||
strncpy(tmp, f, (ss)-f);
|
||||
if (!Yap_unify(ARG1, MkStringTerm( tmp )) ) {
|
||||
if (!Yap_unify(ARG1, MkStringTerm(tmp))) {
|
||||
if (tmp != f)
|
||||
free( tmp );
|
||||
free(tmp);
|
||||
return false;
|
||||
}
|
||||
if (tmp != f)
|
||||
free(tmp);
|
||||
// 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 true;
|
||||
} else {
|
||||
char *tmp;
|
||||
if (!ss) {
|
||||
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);
|
||||
if (!Yap_unify(ARG1, MkAtomTerm(Yap_LookupAtom( tmp ))) ) {
|
||||
if (!Yap_unify(ARG1, MkAtomTerm(Yap_LookupAtom(tmp)))) {
|
||||
if (tmp != f)
|
||||
free( tmp );
|
||||
free(tmp);
|
||||
return false;
|
||||
}
|
||||
if (tmp != f)
|
||||
free(tmp);
|
||||
// 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 true;
|
||||
}
|
||||
} else {
|
||||
char s[MAXPATHLEN+1];
|
||||
char s[MAXPATHLEN + 1];
|
||||
const char *f1, *f2;
|
||||
loop1:
|
||||
if (IsVarTerm(t1)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t1, "access");
|
||||
return FALSE;
|
||||
} else if (IsAtomTerm(t1)) {
|
||||
f1 = AtomName( AtomOfTerm( t1 ) );
|
||||
} else if (IsStringTerm( t1 )) {
|
||||
f1 = StringOfTerm( t1 );
|
||||
f1 = AtomName(AtomOfTerm(t1));
|
||||
} else if (IsStringTerm(t1)) {
|
||||
f1 = StringOfTerm(t1);
|
||||
use_string = true;
|
||||
} else if (IsApplTerm(t1) && FunctorOfTerm(t1) == FunctorSlash) {
|
||||
// descend a compound term of the form a/b.
|
||||
Term tn1 = MkVarTerm(), tf1;
|
||||
Term ts[2];
|
||||
|
||||
ts[0] = ArgOfTerm(1,t1);
|
||||
ts[0] = ArgOfTerm(1, t1);
|
||||
ts[1] = tn1;
|
||||
tf1 = Yap_MkApplTerm( FunctorSlash, 2, ts );
|
||||
tf1 = Yap_MkApplTerm(FunctorSlash, 2, ts);
|
||||
if (!Yap_unify(ARG3, tf1)) {
|
||||
return false;
|
||||
}
|
||||
@ -146,43 +142,41 @@ file_name_extension(USES_REGS1)
|
||||
Yap_Error(INSTANTIATION_ERROR, t2, "access");
|
||||
return FALSE;
|
||||
} else if (IsAtomTerm(t2)) {
|
||||
f2 = AtomName( AtomOfTerm( t2 ) );
|
||||
} else if (IsStringTerm( t1 )) {
|
||||
f2 = StringOfTerm( t2 );
|
||||
f2 = AtomName(AtomOfTerm(t2));
|
||||
} else if (IsStringTerm(t1)) {
|
||||
f2 = StringOfTerm(t2);
|
||||
use_string = true;
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_ATOMIC, t2, "file_name_extension/3");
|
||||
return false;
|
||||
}
|
||||
if (f2[0] == '.') {
|
||||
strncpy(s,f1,MAXPATHLEN);
|
||||
strncat(s,f2,MAXPATHLEN);
|
||||
strncpy(s, f1, MAXPATHLEN);
|
||||
strncat(s, f2, MAXPATHLEN);
|
||||
if (use_string)
|
||||
return Yap_unify_constant(ARG3,MkStringTerm(s));
|
||||
return Yap_unify_constant(ARG3, MkStringTerm(s));
|
||||
else
|
||||
return Yap_unify_constant(ARG3,MkAtomTerm(Yap_LookupAtom(s)));
|
||||
return Yap_unify_constant(ARG3, MkAtomTerm(Yap_LookupAtom(s)));
|
||||
} else {
|
||||
strncpy(s,f1,MAXPATHLEN);
|
||||
strncat(s,".",MAXPATHLEN);
|
||||
strncat(s,f2,MAXPATHLEN);
|
||||
strncpy(s, f1, MAXPATHLEN);
|
||||
strncat(s, ".", MAXPATHLEN);
|
||||
strncat(s, f2, MAXPATHLEN);
|
||||
if (use_string)
|
||||
return Yap_unify_constant(ARG3,MkStringTerm(s));
|
||||
return Yap_unify_constant(ARG3, MkStringTerm(s));
|
||||
else
|
||||
return Yap_unify_constant(ARG3,MkAtomTerm(Yap_LookupAtom(s)));
|
||||
return Yap_unify_constant(ARG3, MkAtomTerm(Yap_LookupAtom(s)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Int
|
||||
access_path(USES_REGS1)
|
||||
{
|
||||
static Int access_path(USES_REGS1) {
|
||||
Term tname = Deref(ARG1);
|
||||
char *file_name;
|
||||
|
||||
if (IsVarTerm(tname)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
||||
return FALSE;
|
||||
} else if (!IsAtomTerm (tname)) {
|
||||
} else if (!IsAtomTerm(tname)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
||||
return FALSE;
|
||||
} else {
|
||||
@ -201,16 +195,14 @@ access_path(USES_REGS1)
|
||||
}
|
||||
}
|
||||
|
||||
static Int
|
||||
exists_file(USES_REGS1)
|
||||
{
|
||||
static Int exists_file(USES_REGS1) {
|
||||
Term tname = Deref(ARG1);
|
||||
char *file_name;
|
||||
|
||||
if (IsVarTerm(tname)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
||||
return FALSE;
|
||||
} else if (!IsAtomTerm (tname)) {
|
||||
} else if (!IsAtomTerm(tname)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
||||
return FALSE;
|
||||
} else {
|
||||
@ -225,7 +217,7 @@ exists_file(USES_REGS1)
|
||||
#if _MSC_VER
|
||||
return ss.st_mode & S_IFREG;
|
||||
#else
|
||||
return (_stat(ss.st_mode));
|
||||
return S_ISREG(ss.st_mode);
|
||||
#endif
|
||||
#else
|
||||
return FALSE;
|
||||
@ -233,16 +225,14 @@ exists_file(USES_REGS1)
|
||||
}
|
||||
}
|
||||
|
||||
static Int
|
||||
file_exists(USES_REGS1)
|
||||
{
|
||||
static Int file_exists(USES_REGS1) {
|
||||
Term tname = Deref(ARG1);
|
||||
char *file_name;
|
||||
|
||||
if (IsVarTerm(tname)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
||||
return FALSE;
|
||||
} else if (!IsAtomTerm (tname)) {
|
||||
} else if (!IsAtomTerm(tname)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
||||
return FALSE;
|
||||
} else {
|
||||
@ -253,7 +243,8 @@ file_exists(USES_REGS1)
|
||||
if (SYSTEM_STAT(file_name, &ss) != 0) {
|
||||
if (errno == ENOENT)
|
||||
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 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);
|
||||
|
||||
if (IsVarTerm(tname)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, tname, "access");
|
||||
return FALSE;
|
||||
} else if (!IsAtomTerm (tname)) {
|
||||
} else if (!IsAtomTerm(tname)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access");
|
||||
return FALSE;
|
||||
} else {
|
||||
@ -282,28 +270,28 @@ time_file(USES_REGS1)
|
||||
HANDLE hdl;
|
||||
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;
|
||||
if (GetFileTime(hdl, NULL,NULL,&ft))
|
||||
if (GetFileTime(hdl, NULL, NULL, &ft))
|
||||
return false;
|
||||
// Convert the last-write time to local time.
|
||||
// FileTimeToSystemTime(&ftWrite, &stUTC);
|
||||
// SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
|
||||
CloseHandle( hdl );
|
||||
CloseHandle(hdl);
|
||||
ULONGLONG qwResult;
|
||||
|
||||
// Copy the time into a quadword.
|
||||
qwResult = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||
#if SIZEOF_INT_P==8
|
||||
qwResult = (((ULONGLONG)ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||
#if SIZEOF_INT_P == 8
|
||||
rc = MkIntegerTerm(qwResult);
|
||||
#elif USE_GMP
|
||||
#elif USE_GMP
|
||||
char s[64];
|
||||
MP_INT rop;
|
||||
|
||||
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);
|
||||
#else
|
||||
#else
|
||||
rc = MkIntegerTerm(ft.dwHighDateTime);
|
||||
#endif
|
||||
return Yap_unify(ARG2, rc);
|
||||
@ -321,36 +309,37 @@ time_file(USES_REGS1)
|
||||
}
|
||||
}
|
||||
|
||||
static Int
|
||||
file_size(USES_REGS1)
|
||||
{
|
||||
static Int file_size(USES_REGS1) {
|
||||
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)
|
||||
return (FALSE);
|
||||
if (GLOBAL_Stream[sno]. status & Seekable_Stream_f &&
|
||||
!(GLOBAL_Stream[sno]. status & (InMemory_Stream_f|Socket_Stream_f|Pipe_Stream_f))) {
|
||||
if (GLOBAL_Stream[sno].status & Seekable_Stream_f &&
|
||||
!(GLOBAL_Stream[sno].status &
|
||||
(InMemory_Stream_f | Socket_Stream_f | Pipe_Stream_f))) {
|
||||
// there
|
||||
struct stat file_stat;
|
||||
if ((rc = fstat(fileno(GLOBAL_Stream[sno].file), &file_stat) )< 0) {
|
||||
if ((rc = fstat(fileno(GLOBAL_Stream[sno].file), &file_stat)) < 0) {
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
if (rc == ENOENT)
|
||||
PlIOError( EXISTENCE_ERROR_SOURCE_SINK, ARG1, "%s in file_size", strerror(errno));
|
||||
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));
|
||||
PlIOError(PERMISSION_ERROR_INPUT_STREAM, ARG1, "%s in file_size",
|
||||
strerror(errno));
|
||||
return false;
|
||||
}
|
||||
// and back again
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
return Yap_unify_constant( ARG2, MkIntegerTerm( file_stat.st_size) );
|
||||
return Yap_unify_constant(ARG2, MkIntegerTerm(file_stat.st_size));
|
||||
}
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
return false;
|
||||
}
|
||||
|
||||
static Int
|
||||
access_file(USES_REGS1)
|
||||
{
|
||||
static Int access_file(USES_REGS1) {
|
||||
Term tname = Deref(ARG1);
|
||||
Term tmode = Deref(ARG2);
|
||||
char *ares;
|
||||
@ -359,7 +348,7 @@ access_file(USES_REGS1)
|
||||
if (IsVarTerm(tmode)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, tmode, "access_file/2");
|
||||
return FALSE;
|
||||
} else if (!IsAtomTerm (tmode)) {
|
||||
} else if (!IsAtomTerm(tmode)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access_file/2");
|
||||
return FALSE;
|
||||
}
|
||||
@ -367,13 +356,13 @@ access_file(USES_REGS1)
|
||||
if (IsVarTerm(tname)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, tname, "access_file/2");
|
||||
return FALSE;
|
||||
} else if (!IsAtomTerm (tname)) {
|
||||
} else if (!IsAtomTerm(tname)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, tname, "access_file/2");
|
||||
return FALSE;
|
||||
} else {
|
||||
if (atmode == AtomNone)
|
||||
return TRUE;
|
||||
if (! (ares = RepAtom(AtomOfTerm(tname))->StrOfAE))
|
||||
if (!(ares = RepAtom(AtomOfTerm(tname))->StrOfAE))
|
||||
return FALSE;
|
||||
}
|
||||
#if HAVE_ACCESS
|
||||
@ -402,7 +391,7 @@ access_file(USES_REGS1)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
int mode;
|
||||
@ -445,16 +434,14 @@ access_file(USES_REGS1)
|
||||
#endif
|
||||
}
|
||||
|
||||
static Int
|
||||
exists_directory(USES_REGS1)
|
||||
{
|
||||
static Int exists_directory(USES_REGS1) {
|
||||
Term tname = Deref(ARG1);
|
||||
char *file_name;
|
||||
|
||||
if (IsVarTerm(tname)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, tname, "exists_directory/1");
|
||||
return FALSE;
|
||||
} else if (!IsAtomTerm (tname)) {
|
||||
} else if (!IsAtomTerm(tname)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, tname, "exists_directory/1");
|
||||
return FALSE;
|
||||
} else {
|
||||
@ -473,19 +460,16 @@ 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);
|
||||
Atom at;
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "file_base_name/2");
|
||||
return FALSE;
|
||||
}
|
||||
const char *buf = Yap_TextTermToText( t, NULL, 0);
|
||||
const char *buf = Yap_TextTermToText(t, NULL, 0);
|
||||
if (buf) {
|
||||
return Yap_IsAbsolutePath( buf );
|
||||
return Yap_IsAbsolutePath(buf);
|
||||
} else {
|
||||
at = AtomOfTerm(t);
|
||||
if (IsWideAtom(at)) {
|
||||
@ -499,9 +483,7 @@ is_absolute_file_name ( USES_REGS1 )
|
||||
return false;
|
||||
}
|
||||
|
||||
static Int
|
||||
file_base_name ( USES_REGS1 )
|
||||
{ /* file_base_name(Stream,N) */
|
||||
static Int file_base_name(USES_REGS1) { /* file_base_name(Stream,N) */
|
||||
Term t = Deref(ARG1);
|
||||
Atom at;
|
||||
if (IsVarTerm(t)) {
|
||||
@ -512,30 +494,31 @@ file_base_name ( USES_REGS1 )
|
||||
if (IsWideAtom(at)) {
|
||||
wchar_t *c = RepAtom(at)->WStrOfAE;
|
||||
Int i = wcslen(c);
|
||||
while (i && !Yap_dir_separator((int)c[--i]));
|
||||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupWideAtom(c+i)));
|
||||
while (i && !Yap_dir_separator((int)c[--i]))
|
||||
;
|
||||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupWideAtom(c + i)));
|
||||
} else {
|
||||
const char *c = RepAtom(at)->StrOfAE;
|
||||
const char *s;
|
||||
#if HAVE_BASENAME && 0 // DISABLED: Linux basename is not compatible with file_base_name in SWI and GNU
|
||||
char c1[YAP_FILENAME_MAX+1];
|
||||
strncpy( c1, c, YAP_FILENAME_MAX);
|
||||
s = basename( c1 );
|
||||
#if HAVE_BASENAME && 0 // DISABLED: Linux basename is not compatible with
|
||||
// file_base_name in SWI and GNU
|
||||
char c1[YAP_FILENAME_MAX + 1];
|
||||
strncpy(c1, c, YAP_FILENAME_MAX);
|
||||
s = basename(c1);
|
||||
#else
|
||||
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++;
|
||||
}
|
||||
s = c+i;
|
||||
s = c + i;
|
||||
#endif
|
||||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(s)));
|
||||
}
|
||||
}
|
||||
|
||||
static Int
|
||||
file_directory_name ( USES_REGS1 )
|
||||
{ /* file_directory_name(Stream,N) */
|
||||
static Int file_directory_name(USES_REGS1) { /* file_directory_name(Stream,N) */
|
||||
Term t = Deref(ARG1);
|
||||
Atom at;
|
||||
if (IsVarTerm(t)) {
|
||||
@ -544,10 +527,11 @@ file_directory_name ( USES_REGS1 )
|
||||
}
|
||||
at = AtomOfTerm(t);
|
||||
if (IsWideAtom(at)) {
|
||||
wchar_t s[YAP_FILENAME_MAX+1];
|
||||
wchar_t s[YAP_FILENAME_MAX + 1];
|
||||
wchar_t *c = RepAtom(at)->WStrOfAE;
|
||||
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++;
|
||||
}
|
||||
@ -555,15 +539,17 @@ file_directory_name ( USES_REGS1 )
|
||||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupWideAtom(s)));
|
||||
} else {
|
||||
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
|
||||
// file_base_name in SWI and GNU
|
||||
const char *s;
|
||||
char c1[YAP_FILENAME_MAX+1];
|
||||
strncpy( c1, c, YAP_FILENAME_MAX);
|
||||
s = dirname( c1 );
|
||||
char c1[YAP_FILENAME_MAX + 1];
|
||||
strncpy(c1, c, YAP_FILENAME_MAX);
|
||||
s = dirname(c1);
|
||||
#else
|
||||
char s[YAP_FILENAME_MAX+1];
|
||||
char s[YAP_FILENAME_MAX + 1];
|
||||
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';
|
||||
#endif
|
||||
@ -571,37 +557,35 @@ file_directory_name ( USES_REGS1 )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Int
|
||||
same_file( USES_REGS1 ) {
|
||||
static Int same_file(USES_REGS1) {
|
||||
char *f1 = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
|
||||
char *f2 = RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE;
|
||||
|
||||
if (strcmp(f1,f2) == 0)
|
||||
if (strcmp(f1, f2) == 0)
|
||||
return TRUE;
|
||||
#if HAVE_LSTAT
|
||||
{
|
||||
int out;
|
||||
struct stat *b1, *b2;
|
||||
while ((char *)HR+sizeof(struct stat)*2 > (char *)(ASP-1024)) {
|
||||
if (!Yap_gcl(2*sizeof(struct stat), 2, ENV,Yap_gcP() ) ) {
|
||||
while ((char *)HR + sizeof(struct stat) * 2 > (char *)(ASP - 1024)) {
|
||||
if (!Yap_gcl(2 * sizeof(struct stat), 2, ENV, Yap_gcP())) {
|
||||
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
b1 = (struct stat *)HR;
|
||||
b2 = b1+1;
|
||||
if (strcmp(f1,"user_input") == 0) {
|
||||
b2 = b1 + 1;
|
||||
if (strcmp(f1, "user_input") == 0) {
|
||||
if (fstat(fileno(GLOBAL_Stream[0].file), b1) == -1) {
|
||||
/* file does not exist, but was opened? Return -1 */
|
||||
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) {
|
||||
/* file does not exist, but was opened? Return -1 */
|
||||
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) {
|
||||
/* file does not exist, but was opened? Return -1 */
|
||||
return FALSE;
|
||||
@ -610,17 +594,17 @@ same_file( USES_REGS1 ) {
|
||||
/* file does not exist, but was opened? Return -1 */
|
||||
return FALSE;
|
||||
}
|
||||
if (strcmp(f2,"user_input") == 0) {
|
||||
if (strcmp(f2, "user_input") == 0) {
|
||||
if (fstat(fileno(GLOBAL_Stream[0].file), b2) == -1) {
|
||||
/* file does not exist, but was opened? Return -1 */
|
||||
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) {
|
||||
/* file does not exist, but was opened? Return -1 */
|
||||
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) {
|
||||
/* file does not exist, but was opened? Return -1 */
|
||||
return FALSE;
|
||||
@ -631,7 +615,9 @@ same_file( USES_REGS1 ) {
|
||||
}
|
||||
out = (b1->st_ino == b2->st_ino
|
||||
#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
|
||||
&& b1->st_dev == b2->st_dev
|
||||
#endif
|
||||
@ -639,26 +625,25 @@ same_file( USES_REGS1 ) {
|
||||
return out;
|
||||
}
|
||||
#else
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Yap_InitFiles( void )
|
||||
{
|
||||
Yap_InitCPred ("file_base_name", 2, file_base_name, SafePredFlag);
|
||||
Yap_InitCPred ("file_directory_name", 2, file_directory_name, SafePredFlag);
|
||||
Yap_InitCPred ("is_absolute_file_name", 1, is_absolute_file_name, SafePredFlag);
|
||||
Yap_InitCPred ("same_file", 2, same_file, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$access_file", 2, access_file, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("access", 1, access_path, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("exists_directory", 1, exists_directory, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("exists_file", 1, exists_file, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$file_exists", 1, file_exists, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("time_file64", 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_name_extension", 3, file_name_extension, SafePredFlag|SyncPredFlag);
|
||||
void Yap_InitFiles(void) {
|
||||
Yap_InitCPred("file_base_name", 2, file_base_name, SafePredFlag);
|
||||
Yap_InitCPred("file_directory_name", 2, file_directory_name, SafePredFlag);
|
||||
Yap_InitCPred("is_absolute_file_name", 1, is_absolute_file_name,
|
||||
SafePredFlag);
|
||||
Yap_InitCPred("same_file", 2, same_file, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$access_file", 2, access_file, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("access", 1, access_path, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("exists_directory", 1, exists_directory,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("exists_file", 1, exists_file, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$file_exists", 1, file_exists, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("time_file64", 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_name_extension", 3, file_name_extension,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
}
|
||||
|
||||
|
1308
os/sysbits.c
1308
os/sysbits.c
File diff suppressed because it is too large
Load Diff
@ -628,6 +628,8 @@ Yap_walltime (void)
|
||||
void
|
||||
Yap_InitWTime (void)
|
||||
{
|
||||
// start thread 0
|
||||
REMOTE_LastWTime(0) =
|
||||
Yap_StartOfWTimes = ((uint64_t)times(NULL))*10000000/TicksPerSec;
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <Yatom.h>
|
||||
#include "os/YapIOConfig.h"
|
||||
#include <Yatom.h>
|
||||
|
||||
#ifndef _PL_WRITE_
|
||||
|
||||
@ -161,7 +161,7 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c);
|
||||
* @return the term.
|
||||
*/
|
||||
INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
|
||||
int cs[2];
|
||||
wchar_t cs[2];
|
||||
if (c < 0)
|
||||
return MkAtomTerm(AtomEof);
|
||||
cs[0] = c;
|
||||
@ -169,4 +169,7 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
|
||||
return MkAtomTerm(Yap_LookupMaybeWideAtom(cs));
|
||||
}
|
||||
|
||||
/// UT when yap started
|
||||
uint64_t Yap_StartOfWTimes;
|
||||
|
||||
#endif
|
||||
|
@ -974,7 +974,107 @@ int AddNamedVar(namedvars varmap, const char *varname) {
|
||||
|
||||
void SetNamedVarValuesAt(namedvars varmap, int index, double dvalue, int ivalue,
|
||||
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.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)) {
|
||||
index *= -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.ivalue[index] = ivalue;
|
||||
varmap.dynvalue[index] = dynvalue;
|
||||
|
@ -48,7 +48,7 @@ refactoring (trivial):
|
||||
#define JPL_C_LIB_VERSION_PATCH 4
|
||||
#define JPL_C_LIB_VERSION_STATUS "alpha"
|
||||
|
||||
#if JPL_DEBUG
|
||||
#ifndef JPL_DEBUG
|
||||
/*#define DEBUG(n, g) ((void)0) */
|
||||
#define DEBUG_LEVEL 4
|
||||
#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"
|
||||
"Use SWIG Documentation System "
|
||||
"http://www.swig.org" FALSE)
|
||||
|
||||
if (SWIG_FOUND)
|
||||
#
|
||||
# SWIG_FOUND - set to true if SWIG is found
|
||||
|
@ -25,7 +25,7 @@ set(PL_SOURCES
|
||||
hacks.yap
|
||||
init.yap
|
||||
listing.yap
|
||||
lists.yap
|
||||
bootlists.yap
|
||||
load_foreign.yap
|
||||
messages.yap
|
||||
meta.yap
|
||||
@ -48,7 +48,6 @@ set(PL_SOURCES
|
||||
udi.yap
|
||||
undefined.yap
|
||||
utils.yap
|
||||
history.pl
|
||||
swi.yap
|
||||
yapor.yap
|
||||
yio.yap
|
||||
|
@ -115,7 +115,7 @@ otherwise.
|
||||
|
||||
:- compile_expressions.
|
||||
|
||||
:- bootstrap('lists.yap').
|
||||
:- bootstrap('bootlists.yap').
|
||||
:- bootstrap('consult.yap').
|
||||
:- bootstrap('preddecls.yap').
|
||||
:- bootstrap('preddyns.yap').
|
||||
|
Reference in New Issue
Block a user