mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 15:40:19 +02:00
* README: using Automake 1.2d
* configure.in: AC_CHECK_FUNCS: add "system". * simpos.c (scm_system): always define: use sysmissing if not available. Check for HAVE_SYSTEM instead of _Windows (does Windows lack system or does it have an unusable one?). Check for error conditions -1 and 127. Use SCM_DEFER_INTS. Let the argument be optional: if not supplied, call system(NULL). * ports.c (scm_close_port): relax the type check from OPPORTP to PORTP; closing a closed port is allowed.
This commit is contained in:
parent
8122b543c1
commit
341eaef04b
16 changed files with 468 additions and 378 deletions
|
@ -57,24 +57,38 @@
|
|||
extern int system();
|
||||
|
||||
|
||||
#ifndef _Windows
|
||||
SCM_PROC(s_system, "system", 1, 0, 0, scm_system);
|
||||
SCM_PROC(s_system, "system", 0, 1, 0, scm_system);
|
||||
|
||||
SCM
|
||||
scm_system(cmd)
|
||||
SCM cmd;
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (SCM_UNBNDP (cmd))
|
||||
{
|
||||
#ifdef HAVE_SYSTEM
|
||||
rv = system (NULL);
|
||||
#else
|
||||
rv = 0;
|
||||
#endif
|
||||
return rv ? SCM_BOOL_T : SCM_BOOL_F;
|
||||
}
|
||||
SCM_ASSERT(SCM_NIMP(cmd) && SCM_ROSTRINGP(cmd), cmd, SCM_ARG1, s_system);
|
||||
#ifdef HAVE_SYSTEM
|
||||
SCM_DEFER_INTS;
|
||||
errno = 0;
|
||||
if (SCM_ROSTRINGP (cmd))
|
||||
cmd = scm_makfromstr (SCM_ROCHARS (cmd), SCM_ROLENGTH (cmd), 0);
|
||||
# ifdef AZTEC_C
|
||||
cmd = SCM_MAKINUM(Execute(SCM_ROCHARS(cmd), 0, 0));
|
||||
# else
|
||||
cmd = SCM_MAKINUM(0L+system(SCM_ROCHARS(cmd)));
|
||||
# endif
|
||||
return cmd;
|
||||
}
|
||||
rv = system(SCM_ROCHARS(cmd));
|
||||
if (rv == -1 || (rv == 127 && errno != 0))
|
||||
scm_syserror (s_system);
|
||||
SCM_ALLOW_INTS;
|
||||
return SCM_MAKINUM (rv);
|
||||
#else
|
||||
scm_sysmissing (s_system);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern char *getenv();
|
||||
SCM_PROC (s_getenv, "getenv", 1, 0, 0, scm_getenv);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue