SWI compatible module only operators
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1412 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
|
||||
:- use_module(library(lists),[nth/3]).
|
||||
|
||||
:- use_module(library(system),[datime/1,
|
||||
mktime/2]).
|
||||
|
||||
:- use_module(library(terms),[term_variables/2,
|
||||
term_variables/3]).
|
||||
|
||||
@@ -161,6 +164,10 @@ prolog:append([],L,L).
|
||||
prolog:append([X|L0],L,[X|Lf]) :-
|
||||
prolog:append(L0,L,Lf).
|
||||
|
||||
prolog:member(X[X|_]).
|
||||
prolog:member(X,[_|L0]) :-
|
||||
prolog:member(X,L0).
|
||||
|
||||
tv(Term,List) :- term_variables(Term,List).
|
||||
|
||||
prolog:term_variables(Term,List) :- tv(Term,List).
|
||||
@@ -175,3 +182,13 @@ prolog:working_directory(OCWD,NCWD) :-
|
||||
|
||||
prolog:chdir(X) :- cd(X).
|
||||
|
||||
% Time is given as int, not as float.
|
||||
prolog:get_time(Secs) :- datime(Datime), mktime(Datime, Secs).
|
||||
|
||||
% Time is received as int, and converted to "..."
|
||||
prolog:convert_time(X,Y) :- swi:ctime(X,Y).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -8,8 +8,12 @@
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* $Id: sys.c,v 1.22 2005-03-10 18:04:01 rslopes Exp $ *
|
||||
* $Id: sys.c,v 1.23 2005-10-21 16:09:03 vsc Exp $ *
|
||||
* mods: $Log: not supported by cvs2svn $
|
||||
* mods: Revision 1.22 2005/03/10 18:04:01 rslopes
|
||||
* mods: update YAP_Error arguments
|
||||
* mods: to be able to compile on Windows...
|
||||
* mods:
|
||||
* mods: Revision 1.21 2004/08/11 16:14:54 vsc
|
||||
* mods: whole lot of fixes:
|
||||
* mods: - memory leak in indexing
|
||||
@@ -144,7 +148,7 @@ sysmktime(void)
|
||||
return YAP_Unify(YAP_ARG8,YAP_MkIntTerm((long int)((f1-f0)/10000000)));
|
||||
}
|
||||
#else
|
||||
return FALSE
|
||||
return FALSE;
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_MKTIME
|
||||
@@ -208,7 +212,7 @@ datime(void)
|
||||
oops
|
||||
#endif /* HAVE_TIME */
|
||||
tf = YAP_MkApplTerm(YAP_MkFunctor(YAP_LookupAtom("datime"),6), 6, out);
|
||||
return(YAP_Unify(YAP_ARG1, tf));
|
||||
return YAP_Unify(YAP_ARG1, tf);
|
||||
}
|
||||
|
||||
#define BUF_SIZE 1024
|
||||
|
@@ -1320,10 +1320,28 @@ X_API int Sdprintf(char *format,...)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
SWI_ctime(void)
|
||||
{
|
||||
YAP_Term t1 = YAP_ARG1;
|
||||
|
||||
if (YAP_IsVarTerm(t1)) {
|
||||
YAP_Error(0,t1,"bad argumento to ctime");
|
||||
return FALSE;
|
||||
}
|
||||
#if HAVE_CTIME
|
||||
time_t tim = (time_t)YAP_IntOfTerm(t1);
|
||||
return YAP_Unify(YAP_BufferToString(ctime(&tim)), YAP_ARG2);
|
||||
#else
|
||||
YAP_Error(0,0L,"convert_time requires ctime");
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
swi_install(void)
|
||||
{
|
||||
return TRUE;
|
||||
YAP_UserCPredicate("ctime", SWI_ctime, 2);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@@ -12,8 +12,12 @@
|
||||
|
||||
|
||||
//=== includes ===============================================================
|
||||
#include "config.h"
|
||||
#include <YapInterface.h>
|
||||
#include <stdarg.h>
|
||||
#if HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(YAP_EXPORTS)
|
||||
#define X_API __declspec(dllexport)
|
||||
@@ -231,5 +235,5 @@ extern X_API int PL_action(int,...);
|
||||
extern X_API int Sprintf(char *,...);
|
||||
extern X_API int Sdprintf(char *,...);
|
||||
|
||||
int swi_install(void);
|
||||
void swi_install(void);
|
||||
|
||||
|
Reference in New Issue
Block a user