fix ! in debugger (execute_clause)
improve system/1 and execute/1 git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1610 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
1265946374
commit
b9e5416355
8
C/exec.c
8
C/exec.c
@ -42,7 +42,7 @@ cp_as_integer(choiceptr cp)
|
||||
static choiceptr
|
||||
cp_from_integer(Term cpt)
|
||||
{
|
||||
return (choiceptr)(LCL0-(CELL *)IntegerOfTerm(cpt));
|
||||
return (choiceptr)(LCL0-IntegerOfTerm(cpt));
|
||||
}
|
||||
|
||||
Term
|
||||
@ -82,7 +82,7 @@ CallPredicate(PredEntry *pen, choiceptr cut_pt, yamop *code) {
|
||||
ENV = YENV;
|
||||
YENV = ASP;
|
||||
YENV[E_CB] = (CELL) cut_pt;
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline static Int
|
||||
@ -422,7 +422,7 @@ p_execute_clause(void)
|
||||
{ /* '$execute_clause'(Goal) */
|
||||
Term t = Deref(ARG1);
|
||||
Term mod = Deref(ARG2);
|
||||
choiceptr cp = cp_from_integer(Deref(ARG4));
|
||||
choiceptr cut_cp = cp_from_integer(Deref(ARG4));
|
||||
unsigned int arity;
|
||||
Prop pe;
|
||||
yamop *code;
|
||||
@ -478,7 +478,7 @@ p_execute_clause(void)
|
||||
} else {
|
||||
code = Yap_ClauseFromTerm(clt)->ClCode;
|
||||
}
|
||||
return CallPredicate(RepPredProp(pe), cp, code);
|
||||
return CallPredicate(RepPredProp(pe), cut_cp, code);
|
||||
}
|
||||
|
||||
static Int
|
||||
|
10
C/sysbits.c
10
C/sysbits.c
@ -1783,12 +1783,12 @@ p_shell (void)
|
||||
bourne = TRUE;
|
||||
/* Yap_CloseStreams(TRUE); */
|
||||
if (bourne)
|
||||
return (system (RepAtom(AtomOfTerm(t1))->StrOfAE) == 0);
|
||||
return system(RepAtom(AtomOfTerm(t1))->StrOfAE) == 0;
|
||||
else {
|
||||
int status = -1;
|
||||
int child = fork ();
|
||||
if (child == 0)
|
||||
{ /* let the children go */
|
||||
|
||||
if (child == 0) { /* let the children go */
|
||||
if (!execl (shell, shell, "-c", RepAtom(AtomOfTerm(t1))->StrOfAE , NULL)) {
|
||||
exit(-1);
|
||||
}
|
||||
@ -1815,10 +1815,10 @@ p_shell (void)
|
||||
shell = "msh -i";
|
||||
/* Yap_CloseStreams(); */
|
||||
system (shell);
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
#else
|
||||
Yap_Error (SYSTEM_ERROR,TermNil,"shell not available in this configuration");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
#endif
|
||||
#endif /* HAVE_SYSTEM */
|
||||
#endif /* _MSC_VER */
|
||||
|
@ -16,6 +16,10 @@
|
||||
|
||||
<h2>Yap-5.1.2:</h2>
|
||||
<ul>
|
||||
<li> FIXED: ! was not pruning right in p_execute_clause (obs Nicos
|
||||
Angelopoulos).</li>
|
||||
<li> FIXED: system/1 and shell/1 should check return code (obs Nicos
|
||||
Angelopoulos).</li>
|
||||
<li> FIXED: thread_peek_message should use aliases (obs Paulo Moura).</li>
|
||||
<li> FIXED: garbage collector should no rewrite cp_tr fields until
|
||||
after marking (obs Paulo Moura).</li>
|
||||
|
@ -374,7 +374,8 @@ shell(Command) :-
|
||||
G = shell(Command),
|
||||
check_command(Command, G),
|
||||
get_shell(Shell,Opt),
|
||||
do_shell(Shell, Opt, Command, _, Error),
|
||||
do_shell(Shell, Opt, Command, Status, Error),
|
||||
Status = 0,
|
||||
handle_system_error(Error, off, G).
|
||||
|
||||
shell(Command, Status) :-
|
||||
@ -416,6 +417,7 @@ system(Command, Status) :-
|
||||
G = system(Command, Status),
|
||||
check_command(Command, G),
|
||||
do_system(Command, Status, Error),
|
||||
Status = 0,
|
||||
handle_system_error(Error, off, G).
|
||||
|
||||
sleep(Interval) :- var(Interval), !,
|
||||
|
@ -8,8 +8,13 @@
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* $Id: sys.c,v 1.25 2006-01-17 14:10:42 vsc Exp $ *
|
||||
* $Id: sys.c,v 1.26 2006-04-25 03:23:40 vsc Exp $ *
|
||||
* mods: $Log: not supported by cvs2svn $
|
||||
* mods: Revision 1.25 2006/01/17 14:10:42 vsc
|
||||
* mods: YENV may be an HW register (breaks some tabling code)
|
||||
* mods: All YAAM instructions are now brackedted, so Op introduced an { and EndOp introduces an }. This is because Ricardo assumes that.
|
||||
* mods: Fix attvars when COROUTING is undefined.
|
||||
* mods:
|
||||
* mods: Revision 1.24 2006/01/08 23:01:48 vsc
|
||||
* mods: *** empty log message ***
|
||||
* mods:
|
||||
@ -52,9 +57,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "YapInterface.h"
|
||||
#if STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -687,12 +690,12 @@ do_system(void)
|
||||
#if HAVE_SYSTEM
|
||||
int sys = system(command);
|
||||
if (sys < 0) {
|
||||
return(YAP_Unify(YAP_ARG3,YAP_MkIntTerm(errno)));
|
||||
return YAP_Unify(YAP_ARG3,YAP_MkIntTerm(errno));
|
||||
}
|
||||
return(YAP_Unify(YAP_ARG2, YAP_MkIntTerm(sys)));
|
||||
return YAP_Unify(YAP_ARG2, YAP_MkIntTerm(sys));
|
||||
#else
|
||||
YAP_Error(0,0L,"system not available in this configuration");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -703,6 +706,9 @@ static int
|
||||
do_shell(void)
|
||||
{
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
YAP_Error(0,0L,"system not available in this configuration");
|
||||
return(FALSE);
|
||||
#elif HAVE_SYSTEM
|
||||
char *buf = YAP_AllocSpaceFromYap(BUF_SIZE);
|
||||
int sys;
|
||||
|
||||
@ -711,29 +717,23 @@ do_shell(void)
|
||||
return(FALSE);
|
||||
}
|
||||
#if HAVE_STRNCPY
|
||||
strncpy(YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)), buf, BUF_SIZE);
|
||||
strncpy(" ", buf, BUF_SIZE);
|
||||
strncpy(YAP_AtomName(YAP_AtomOfTerm(YAP_ARG2)), buf, BUF_SIZE);
|
||||
strncpy(" ", buf, BUF_SIZE);
|
||||
strncpy(YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3)), buf, BUF_SIZE);
|
||||
strncpy(buf, YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)), BUF_SIZE);
|
||||
strncpy(buf, " ", BUF_SIZE);
|
||||
strncpy(buf, YAP_AtomName(YAP_AtomOfTerm(YAP_ARG2)), BUF_SIZE);
|
||||
strncpy(buf, " ", BUF_SIZE);
|
||||
strncpy(buf, YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3)), BUF_SIZE);
|
||||
#else
|
||||
strcpy(YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)), buf);
|
||||
strcpy(" ", buf);
|
||||
strcpy(YAP_AtomName(YAP_AtomOfTerm(YAP_ARG2)), buf);
|
||||
strcpy(" ", buf);
|
||||
strcpy(YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3)), buf);
|
||||
strcpy(buf, YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)));
|
||||
strcpy(buf, YAP_AtomName(YAP_AtomOfTerm(YAP_ARG2)));
|
||||
strcpy(buf, " ");
|
||||
strcpy(bug, YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3)));
|
||||
#endif
|
||||
#if HAVE_SYSTEM
|
||||
sys = system(buf);
|
||||
YAP_FreeSpaceFromYap(buf);
|
||||
if (sys < 0) {
|
||||
return(YAP_Unify(YAP_ARG5,YAP_MkIntTerm(errno)));
|
||||
return YAP_Unify(YAP_ARG5,YAP_MkIntTerm(errno));
|
||||
}
|
||||
return(YAP_Unify(YAP_ARG4, YAP_MkIntTerm(sys)));
|
||||
#else
|
||||
YAP_Error(0,0L,"system not available in this configuration");
|
||||
return(FALSE);
|
||||
#endif
|
||||
return YAP_Unify(YAP_ARG4, YAP_MkIntTerm(sys));
|
||||
#else
|
||||
char *cptr[4];
|
||||
int t;
|
||||
@ -745,17 +745,19 @@ do_shell(void)
|
||||
cptr[3]= NULL;
|
||||
t = fork();
|
||||
if (t < 0) {
|
||||
return(YAP_Unify(YAP_ARG5,YAP_MkIntTerm(errno)));
|
||||
return YAP_Unify(YAP_ARG5,YAP_MkIntTerm(errno));
|
||||
} else if (t == 0) {
|
||||
t = execvp(YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)),cptr);
|
||||
return(t);
|
||||
t = execvp(cptr[0],cptr);
|
||||
return t;
|
||||
} else {
|
||||
t = wait(&sys);
|
||||
fprintf(stderr,"after wait %x:%x\n",t,sys);
|
||||
if (t < 0) {
|
||||
return(YAP_Unify(YAP_ARG5,YAP_MkIntTerm(errno)));
|
||||
return YAP_Unify(YAP_ARG5,YAP_MkIntTerm(errno));
|
||||
}
|
||||
}
|
||||
return(YAP_Unify(YAP_ARG4, YAP_MkIntTerm(sys)));
|
||||
fprintf(stderr,"after wait %x\n", sys);
|
||||
return YAP_Unify(YAP_ARG4, YAP_MkIntTerm(sys));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user