check for available space in GetName
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@253 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
3962e559aa
commit
7064c42fc1
@ -574,7 +574,7 @@ ArrayToList(register Term *tp, int nof)
|
||||
}
|
||||
|
||||
int
|
||||
GetName(char *s, Term t)
|
||||
GetName(char *s, UInt max, Term t)
|
||||
{
|
||||
register Term Head;
|
||||
register Int i;
|
||||
@ -590,6 +590,9 @@ GetName(char *s, Term t)
|
||||
return (FALSE);
|
||||
*s++ = i;
|
||||
t = TailOfTerm(t);
|
||||
if (--max == 0) {
|
||||
Error(FATAL_ERROR,t,"not enough space for GetName");
|
||||
}
|
||||
}
|
||||
*s = '\0';
|
||||
return (TRUE);
|
||||
|
4
C/save.c
4
C/save.c
@ -529,7 +529,7 @@ do_save(int mode) {
|
||||
NewFileInfo('YAPS', 'MYap');
|
||||
#endif
|
||||
Term t1 = Deref(ARG1);
|
||||
if (!GetName(FileNameBuf, t1)) {
|
||||
if (!GetName(FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
Error(TYPE_ERROR_LIST,t1,"save/1");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -2988,7 +2988,7 @@ p_restore(void)
|
||||
int mode;
|
||||
|
||||
Term t1 = Deref(ARG1);
|
||||
if (!GetName(FileNameBuf, t1)) {
|
||||
if (!GetName(FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
Error(TYPE_ERROR_LIST,t1,"restore/1");
|
||||
return(FALSE);
|
||||
}
|
||||
|
20
C/sysbits.c
20
C/sysbits.c
@ -1611,11 +1611,10 @@ p_shell (void)
|
||||
#else
|
||||
#if HAVE_SYSTEM
|
||||
char *shell;
|
||||
#define command ((char *)TR)
|
||||
register int bourne = FALSE;
|
||||
Term t1 = Deref (ARG1);
|
||||
|
||||
if (!GetName (command, t1)) {
|
||||
if (!GetName (FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
Error(SYSTEM_ERROR,t1,"invalid argument to shell/1");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -1626,14 +1625,14 @@ p_shell (void)
|
||||
bourne = TRUE;
|
||||
/* CloseStreams(TRUE); */
|
||||
if (bourne)
|
||||
return (system (command) == 0);
|
||||
return (system (FileNameBuf) == 0);
|
||||
else
|
||||
{
|
||||
int status = -1;
|
||||
int child = fork ();
|
||||
if (child == 0)
|
||||
{ /* let the children go */
|
||||
execl (shell, shell, "-c", command, NIL);
|
||||
execl (shell, shell, "-c", FileNameBuf, NIL);
|
||||
exit (TRUE);
|
||||
}
|
||||
{ /* put the father on wait */
|
||||
@ -1671,9 +1670,8 @@ static Int
|
||||
p_system (void)
|
||||
{ /* '$system'(+SystCommand) */
|
||||
#ifdef HAVE_SYSTEM
|
||||
#define command ((char *)TR)
|
||||
Term t1 = Deref (ARG1);
|
||||
if (!GetName (command, t1)) {
|
||||
if (!GetName (FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
Error(SYSTEM_ERROR,t1,"argument to system/1 is not valid");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -1681,7 +1679,7 @@ p_system (void)
|
||||
#if _MSC_VER
|
||||
_flushall();
|
||||
#endif
|
||||
return (system (command) == 0);
|
||||
return (system (FileNameBuf) == 0);
|
||||
#else
|
||||
#ifdef MSH
|
||||
register char *shell;
|
||||
@ -1708,12 +1706,12 @@ p_mv (void)
|
||||
char oldname[YAP_FILENAME_MAX], newname[YAP_FILENAME_MAX];
|
||||
Term t1 = Deref (ARG1);
|
||||
Term t2 = Deref (ARG2);
|
||||
if (!GetName (FileNameBuf, t1)) {
|
||||
if (!GetName (FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
Error(SYSTEM_ERROR,t1,"first argument to rename/2 is not valid");
|
||||
return(FALSE);
|
||||
}
|
||||
TrueFileName (FileNameBuf, oldname, FALSE);
|
||||
if (!GetName (FileNameBuf, t2)) {
|
||||
if (!GetName (FileNameBuf, YAP_FILENAME_MAX, t2)) {
|
||||
Error(SYSTEM_ERROR,t2,"second argument to rename/2 is not valid");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -1740,7 +1738,7 @@ p_cd (void)
|
||||
Term t1 = Deref (ARG1);
|
||||
if (t1 == TermNil)
|
||||
return(TRUE);
|
||||
if (!GetName (FileNameBuf, t1)) {
|
||||
if (!GetName (FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
Error(SYSTEM_ERROR,t1,"argument to cd/1 is not valid");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -1754,7 +1752,7 @@ p_cd (void)
|
||||
#else
|
||||
#ifdef MACYAP
|
||||
Term t1 = Deref (ARG1);
|
||||
if (!GetName (FileNameBuf, t1)) {
|
||||
if (!GetName (FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
||||
Error(SYSTEM_ERROR,t1,"argument to cd/1 is not valid");
|
||||
return(FALSE);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ CHR_PROGRAMS= $(srcdir)/chr/chrcmp.pl \
|
||||
$(srcdir)/chr/matching.pl \
|
||||
$(srcdir)/chr/operator.pl \
|
||||
$(srcdir)/chr/ordering.pl \
|
||||
$(srcdir)/chr/sbag.pl \
|
||||
$(srcdir)/chr/sbag.yap \
|
||||
$(srcdir)/chr/sbag_a.pl \
|
||||
$(srcdir)/chr/sbag_l.pl \
|
||||
$(srcdir)/chr/trace.yap
|
||||
|
@ -311,6 +311,9 @@ notify_constrained( [M|Ms], X) :-
|
||||
%
|
||||
% Approximation because debug state might change between calls ...
|
||||
%
|
||||
|
||||
:- start_low_level_trace.
|
||||
|
||||
run_suspensions( Slots) :-
|
||||
getval( debug, State),
|
||||
( State == off ->
|
||||
@ -320,6 +323,8 @@ run_suspensions( Slots) :-
|
||||
),
|
||||
true.
|
||||
|
||||
:- stop_low_level_trace.
|
||||
|
||||
run_suspensions_loop( []).
|
||||
run_suspensions_loop( [A|As]) :-
|
||||
arg( 1, A, Stack),
|
||||
|
@ -10,7 +10,7 @@
|
||||
* File: Yap.proto *
|
||||
* mods: *
|
||||
* comments: Function declarations for YAP *
|
||||
* version: $Id: Yapproto.h,v 1.5 2001-11-15 00:01:43 vsc Exp $ *
|
||||
* version: $Id: Yapproto.h,v 1.6 2002-01-02 20:56:22 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* prototype file for Yap */
|
||||
@ -30,7 +30,7 @@ Int STD_PROTO(absmi,(int));
|
||||
|
||||
/* adtdefs.c */
|
||||
Term STD_PROTO(ArrayToList,(Term *,int));
|
||||
int STD_PROTO(GetName,(char *,Term));
|
||||
int STD_PROTO(GetName,(char *,UInt,Term));
|
||||
Term STD_PROTO(GetValue,(Atom));
|
||||
Atom STD_PROTO(LookupAtom,(char *));
|
||||
Atom STD_PROTO(FullLookupAtom,(char *));
|
||||
|
Reference in New Issue
Block a user