From 712300027e2d87da1e9802c8c7bd4be151e4ecf2 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 12 Feb 2011 00:26:28 +0000 Subject: [PATCH] include support for working_directory/2 as a system predicate. --- docs/yap.tex | 14 +++++++------- library/system.yap | 6 +----- packages/PLStream/pl-incl.h | 6 ++++++ packages/PLStream/pl-yap.h | 2 +- pl/utils.yap | 3 +++ 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/docs/yap.tex b/docs/yap.tex index a7dffd36e..fe8976f65 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -6895,6 +6895,13 @@ atoms. Execute a new shell. @end table +@item working_directory(-@var{CurDir},?@var{NextDir}) +@findex working_directory/2 +@syindex working_directory/2 +@cnindex working_directory/2 @c +Fetch the current directory at @var{CurDir}. If @var{NextDir} is bound +to an atom, make its value the current working directory. + @item alarm(+@var{Seconds},+@var{Callable},+@var{OldAlarm}) @findex alarm/3 @snindex alarm/3 @@ -11594,13 +11601,6 @@ The streams may be one of standard stream, @code{std}, null stream, @code{null}, or @code{pipe(S)}, where @var{S} is a pipe stream. Note that it is up to the user to close the pipe. -@item working_directory(-@var{CurDir},?@var{NextDir}) -@findex working_directory/2 -@syindex working_directory/2 -@cnindex working_directory/2 @c -Fetch the current directory at @var{CurDir}. If @var{NextDir} is bound -to an atom, make its value the current working directory. - @item popen(+@var{Command}, +@var{TYPE}, -@var{Stream}) @findex popen/3 @syindex popen/3 diff --git a/library/system.yap b/library/system.yap index 8270ab653..61e4461a0 100644 --- a/library/system.yap +++ b/library/system.yap @@ -43,7 +43,7 @@ mktime/2, tmpnam/1, tmp_file/2, - tmpdir/1, + tmpdir/1, wait/2, working_directory/2 ]). @@ -269,10 +269,6 @@ environ_split([61|SVal], [], SVal) :- !. environ_split([C|S],[C|SNa],SVal) :- environ_split(S,SNa,SVal). -working_directory(OLD, NEW) :- - getcwd(OLD), - cd(NEW). - % % process execution % diff --git a/packages/PLStream/pl-incl.h b/packages/PLStream/pl-incl.h index edac799e1..57ef4d8d8 100755 --- a/packages/PLStream/pl-incl.h +++ b/packages/PLStream/pl-incl.h @@ -862,7 +862,13 @@ typedef double real; #define false(s, a) (!true((s), (a))) #define set(s, a) ((s)->flags |= (a)) #define clear(s, a) ((s)->flags &= ~(a)) +#ifdef DEBUG +/* should have messages here */ +#undef DEBUG #define DEBUG(LEVEL, COMMAND) +#else +#define DEBUG(LEVEL, COMMAND) +#endif #define forwards static /* forwards function declarations */ diff --git a/packages/PLStream/pl-yap.h b/packages/PLStream/pl-yap.h index 3e2892744..5d12751b8 100644 --- a/packages/PLStream/pl-yap.h +++ b/packages/PLStream/pl-yap.h @@ -27,7 +27,7 @@ typedef YAP_Term Module; typedef YAP_Term *Word; /* Anonymous 4 byte object */ typedef YAP_Atom Atom; -typedef YAP_Term (*Func)(); /* foreign functions */ +typedef YAP_Term (*Func)(term_t); /* foreign functions */ const char *Yap_GetCurrentPredName(void); YAP_Int Yap_GetCurrentPredArity(void); diff --git a/pl/utils.yap b/pl/utils.yap index 80829018f..59a777825 100644 --- a/pl/utils.yap +++ b/pl/utils.yap @@ -247,6 +247,9 @@ pwd :- getcwd(X), write(X), nl. +working_directory(OLD, NEW) :- + swi_working_directory(OLD, NEW). + unix(V) :- var(V), !, '$do_error'(instantiation_error,unix(V)). unix(argv(L)) :- '$is_list_of_atoms'(L,L), !, '$argv'(L).