=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/builtin/miscf.c,v retrieving revision 1.25 retrieving revision 1.30 diff -u -p -r1.25 -r1.30 --- OpenXM_contrib2/asir2000/builtin/miscf.c 2004/11/16 01:47:31 1.25 +++ OpenXM_contrib2/asir2000/builtin/miscf.c 2013/06/13 08:11:55 1.30 @@ -45,20 +45,26 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/builtin/miscf.c,v 1.24 2004/10/27 08:21:47 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/builtin/miscf.c,v 1.29 2013/06/13 07:45:28 ohara Exp $ */ #include "ca.h" #include "parse.h" +#include #if !defined(VISUAL) && defined(DO_PLOT) #include #include #endif #if defined(VISUAL) +#include #include #include +#else +#include +#include #endif +void Pgetcwd(), Pchdir(); void Pset_secure_mode(); void Pset_secure_flag(); void Pquit(), Pdebug(), Pnmono(), Pnez(), Popt(), Pshell(), Pheap(); @@ -79,6 +85,8 @@ void Ptest(); void delete_history(int,int); struct ftab misc_tab[] = { + {"pwd",Pgetcwd,0}, + {"chdir",Pchdir,1}, {"set_secure_mode",Pset_secure_mode,-1}, {"set_secure_flag",Pset_secure_flag,-2}, {"module_list",Pmodule_list,0}, @@ -118,6 +126,32 @@ struct ftab misc_tab[] = { {0,0,0}, }; +void Pgetcwd(STRING *rp) +{ + char *r; +#if defined(VISUAL) + char buf[_MAX_PATH]; + _getcwd(buf, _MAX_PATH); +#else + char buf[MAXPATHLEN]; + getcwd(buf, MAXPATHLEN); +#endif + r = (char *)MALLOC_ATOMIC(strlen(buf)+1); + strcpy(r,buf); + MKSTR(*rp,r); +} + +void Pchdir(NODE arg, Q *rp) +{ + char *dir = BDY((STRING)ARG0(arg)); +#if defined(VISUAL) + int status = _chdir(dir); +#else + int status = chdir(dir); +#endif + STOQ(status,*rp); +} + void Pset_secure_mode(NODE arg,Q *rp) { int s; @@ -264,12 +298,11 @@ Q *rp; void Pquit(rp) pointer *rp; { - if ( !NEXT(asir_infile) ) - asir_terminate(2); + if ( asir_infile && NEXT(asir_infile) && asir_infile->ready_for_longjmp ) + LONGJMP(asir_infile->jmpbuf,1); else { closecurrentinput(); - if ( !asir_infile->fp && strcmp(asir_infile->name,"string") ) - asir_terminate(2); + asir_terminate(2); } *rp = 0; } @@ -322,7 +355,9 @@ void Pheap(arg,rp) NODE arg; Q *rp; { - int h0,h; + size_t h0,h; + unsigned int u,l; + N n; void GC_expand_hp(int); h0 = get_heapsize(); @@ -332,7 +367,16 @@ Q *rp; GC_expand_hp(h-h0); } h = get_heapsize(); - STOQ(h,*rp); + if(sizeof(size_t)>sizeof(int)) { + u = h>>(sizeof(int)*CHAR_BIT); l = h&(~0); + if ( !u ) UTOQ(l,*rp); + else { + n = NALLOC(2); PL(n)=2; BD(n)[0] = l; BD(n)[1] = u; + NTOQ(n,1,*rp); + } + }else { + UTOQ(h,*rp); + } } unsigned int get_asir_version();