fix absolute_file_name

put intermediate data structures for system in TR


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@249 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-01-02 05:35:20 +00:00
parent 2b72b6f71b
commit 441ad190ff
5 changed files with 36 additions and 8 deletions

View File

@ -1658,6 +1658,22 @@ p_open (void)
}
static Int
p_file_expansion (void)
{ /* '$file_expansion'(+File,-Name) */
Term file_name = Deref(ARG1);
/* we know file_name is bound */
if (!IsAtomTerm (file_name)) {
PlIOError(TYPE_ERROR_ATOM, file_name, "absolute_file_name/3");
return(FALSE);
}
if (!TrueFileName (RepAtom (AtomOfTerm (file_name))->StrOfAE, FileNameBuf, FALSE))
return (PlIOError (EXISTENCE_ERROR_SOURCE_SINK,file_name,"absolute_file_name/3"));
return(unify(ARG2,MkAtomTerm(LookupAtom(FileNameBuf))));
}
static Int p_add_alias_to_stream (void)
{
Term tname = Deref(ARG1);
@ -4782,6 +4798,7 @@ InitIOPreds(void)
InitCPred ("$get0_line_codes", 2, p_get0_line_codes, SafePredFlag|SyncPredFlag);
InitCPred ("$get_byte", 2, p_get_byte, SafePredFlag|SyncPredFlag);
InitCPred ("$open", 4, p_open, SafePredFlag|SyncPredFlag);
InitCPred ("$file_expansion", 2, p_file_expansion, SafePredFlag|SyncPredFlag);
InitCPred ("$open_null_stream", 1, p_open_null_stream, SafePredFlag|SyncPredFlag);
InitCPred ("$open_pipe_stream", 2, p_open_pipe_stream, SafePredFlag|SyncPredFlag);
InitCPred ("open_mem_read_stream", 2, p_open_mem_read_stream, SyncPredFlag);

View File

@ -1611,7 +1611,7 @@ p_shell (void)
#else
#if HAVE_SYSTEM
char *shell;
char *command = AllocTmpSpaceFromGlobal();
#define command ((char *)TR)
register int bourne = FALSE;
Term t1 = Deref (ARG1);
@ -1651,6 +1651,7 @@ p_shell (void)
return (result);
}
}
#undef command
#else /* HAVE_SYSTEM */
#ifdef MSH
register char *shell;
@ -1670,7 +1671,7 @@ static Int
p_system (void)
{ /* '$system'(+SystCommand) */
#ifdef HAVE_SYSTEM
char *command = AllocTmpSpaceFromGlobal();
#define command ((char *)TR)
Term t1 = Deref (ARG1);
if (!GetName (command, t1)) {
Error(SYSTEM_ERROR,t1,"argument to system/1 is not valid");
@ -1688,6 +1689,7 @@ p_system (void)
/* CloseStreams(); */
system (shell);
return (TRUE);
#undef command
#else
Error(SYSTEM_ERROR,TermNil,"sh not available in this machine");
return(FALSE);

View File

@ -10,7 +10,7 @@
* File: Regs.h *
* mods: *
* comments: YAP abstract machine registers *
* version: $Id: Regs.h,v 1.8 2001-12-07 20:27:03 vsc Exp $ *
* version: $Id: Regs.h,v 1.9 2002-01-02 05:35:20 vsc Exp $ *
*************************************************************************/
@ -678,9 +678,6 @@ EXTERN inline void restore_B(void) {
#define BBREG BB
#endif
/* use global stack for intermediate data-structures */
#define AllocTmpSpaceFromGlobal() ((char *)H)
#if !THREADS
/* use actual addresses for regs */
#define PRECOMPUTE_REGADDRESS 1

View File

@ -3329,6 +3329,14 @@ Closes the stream @var{S}, following options @var{O}.
The only valid options are @code{force(true)} and @code{force(false)}.
YAP currently ignores these options.
@item absolute_file_name(+@var{Name},-@var{FullPath})
@findex absolute_file_name/2
@syindex absolute_file_name/2
@cnindex absolute_file_name/2
Give the path a full path @var{FullPath} Yap would use to consule a file
named @var{Name}. Unify @var{FullPath} with @code{user} if the file
name is @code{user}.
@item current_stream(@var{F},@var{M},@var{S})
@findex current_stream/3
@syindex current_stream/3

View File

@ -871,10 +871,14 @@ at_end_of_stream(S) :-
consult_depth(LV) :- '$show_consult_level'(LV).
absolute_file_name(V,Out) :-
throw(error(instantiation_error, absolute_file_name(V, Out))).
absolute_file_name(user,user) :- !.
absolute_file_name(RelFile,AbsFile) :-
'$find_in_path'(RelFile,PathFile),
'$exists'(PathFile,'$csult', AbsFile).
'$exists'(PathFile,'$csult', AbsFile), !.
absolute_file_name(RelFile, AbsFile) :-
'$file_expansion'(RelFile, AbsFile).
'$exists'(F,Mode,AbsFile) :-
'$get_value'(fileerrors,V),