diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 6706fb227..e81a50e93 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,22 @@ +Mon Oct 28 06:28:28 1996 Gary Houston + + * configure.in: add tests for figuring out whether buffered data + is available in a FILE structure, which is needed by char-ready. + + * acconfig.h: define FILE_CNT_FIELD, FILE_CNT_GPTR and + FILE_CNT_READPTR. + + * simpos.c (scm_getenv): renamed from scm_sys_getenv. Throw + exceptions using misc_error instead of syserror. It seems a bit + odd to throw an exception if a string can't be found in the + environment, but it's consistent with open-file, stat etc. + (simpos.h): remove sys_ from getenv. + + * posix.c (scm_putenv): renamed from scm_sys_putenv. If an error + occurs, throw an error instead of returning errno. Return value + is now unspecified. + (numerous in posix.c and posix.h): removed superfluous sys_ from names. + Sun Oct 27 01:22:04 1996 Gary Houston * filesys.c (scm_stat2scm): derive file type and permissions from diff --git a/libguile/acconfig.h b/libguile/acconfig.h index d1337e086..c54e0c503 100644 --- a/libguile/acconfig.h +++ b/libguile/acconfig.h @@ -12,6 +12,26 @@ configure.in for more details. */ #undef HAVE_FD_SETTER +/* Define this if your system has a way to set a stdio stream's file + descriptor. You should also copy fd.h.in to fd.h, and give the + macro SET_FILE_FD_FIELD an appropriate definition. See + configure.in for more details. */ +#undef HAVE_FD_SETTER + +/* Set this to the name of a field in FILE which contains the number + of buffered characters waiting to be read. */ +#undef FILE_CNT_FIELD + +/* Define this if your stdio has _gptr and _egptr fields which can + be compared to give the number of buffered characters waiting to + be read. */ +#undef FILE_CNT_GPTR + +/* Define this if your stdio has _IO_read_ptr and _IO_read_end fields + which can be compared to give the number of buffered characters + waiting to be read. */ +#undef FILE_CNT_READPTR + /* Define this if your system defines struct linger, for use with the getsockopt and setsockopt system calls. */ #undef HAVE_STRUCT_LINGER diff --git a/libguile/configure b/libguile/configure index e97af9916..f0b4d69cd 100755 --- a/libguile/configure +++ b/libguile/configure @@ -1971,6 +1971,143 @@ test "x$FD_SETTER" != x && cat >> confdefs.h <<\EOF EOF +#-------------------------------------------------------------------- +# How to find out whether a FILE structure contains buffered data. +# From Tk we have the following list: +# _cnt: Most UNIX systems +# __cnt: HPUX +# _r: BSD +# readCount: Sprite +# Or, in GNU libc there are two fields, _gptr and _egptr, which +# have to be compared. +# These can also be known as _IO_read_ptr and _IO_read_end. +#-------------------------------------------------------------------- + +echo $ac_n "checking how to get buffer char count from FILE structure""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'scm_cv_struct_file_count'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int main() { return 0; } +int t() { +FILE *f = stdin; f->_cnt = 0 +; return 0; } +EOF +if { (eval echo configure:2000: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + scm_cv_struct_file_count="_cnt" +else + rm -rf conftest* + cat > conftest.$ac_ext < +int main() { return 0; } +int t() { +FILE *f = stdin; f->_r = 0 +; return 0; } +EOF +if { (eval echo configure:2014: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + scm_cv_struct_file_count="_r" +else + rm -rf conftest* + cat > conftest.$ac_ext < +int main() { return 0; } +int t() { +FILE *f = stdin; f->readCount = 0 +; return 0; } +EOF +if { (eval echo configure:2028: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + scm_cv_struct_file_count="readCount" +else + rm -rf conftest* + scm_cv_struct_file_count="" +fi +rm -f conftest* + +fi +rm -f conftest* + +fi +rm -f conftest* + +fi + +if test "$scm_cv_struct_file_count"; then + echo "$ac_t""$scm_cv_struct_file_count" 1>&6 + cat >> confdefs.h <&6 +else + cat > conftest.$ac_ext < +int main() { return 0; } +int t() { +FILE *f = stdin; f->_gptr = f->egptr; +; return 0; } +EOF +if { (eval echo configure:2064: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + scm_cv_struct_file_gptr=1 +else + rm -rf conftest* + scm_cv_struct_file_gptr="" +fi +rm -f conftest* + +fi + +if test "$scm_cv_struct_gptr"; then + echo "$ac_t""gptr" 1>&6 + cat >> confdefs.h <&6 +else + cat > conftest.$ac_ext < +int main() { return 0; } +int t() { +FILE *f = stdin; f->_IO_read_ptr = f->_IO_read_end; +; return 0; } +EOF +if { (eval echo configure:2094: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + scm_cv_struct_file_readptr=1 +fi +rm -f conftest* + +fi + +if test "$scm_cv_struct_file_readptr"; then + echo "$ac_t""read_ptr" 1>&6 + cat >> confdefs.h <], + [FILE *f = stdin; f->_cnt = 0], + scm_cv_struct_file_count="_cnt", + AC_TRY_COMPILE([#include ], + [FILE *f = stdin; f->_r = 0], + scm_cv_struct_file_count="_r", + AC_TRY_COMPILE([#include ], + [FILE *f = stdin; f->readCount = 0], + scm_cv_struct_file_count="readCount", + scm_cv_struct_file_count="")))) +if test "$scm_cv_struct_file_count"; then + AC_MSG_RESULT($scm_cv_struct_file_count) + AC_DEFINE_UNQUOTED(FILE_CNT_FIELD, $scm_cv_struct_file_count) +else +AC_CACHE_VAL(scm_cv_struct_file_gptr, + AC_TRY_COMPILE([#include ], + [FILE *f = stdin; f->_gptr = f->egptr;], + scm_cv_struct_file_gptr=1, + scm_cv_struct_file_gptr="")) +if test "$scm_cv_struct_gptr"; then + AC_MSG_RESULT(gptr) + AC_DEFINE_UNQUOTED(FILE_CNT_GPTR, $scm_cv_struct_file_gptr) +else +AC_CACHE_VAL(scm_cv_struct_file_readptr, + AC_TRY_COMPILE([#include ], + [FILE *f = stdin; f->_IO_read_ptr = f->_IO_read_end;], + scm_cv_struct_file_readptr=1)) +if test "$scm_cv_struct_file_readptr"; then + AC_MSG_RESULT(read_ptr) + AC_DEFINE_UNQUOTED(FILE_CNT_READPTR, $scm_cv_struct_file_readptr) +fi +fi +fi + #-------------------------------------------------------------------- # # Flags for thread support diff --git a/libguile/posix.c b/libguile/posix.c index f352d0796..48ca6b543 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -187,10 +187,10 @@ char *strptime (); -SCM_PROC (s_sys_pipe, "pipe", 0, 0, 0, scm_sys_pipe); +SCM_PROC (s_pipe, "pipe", 0, 0, 0, scm_pipe); SCM -scm_sys_pipe () +scm_pipe () { int fd[2], rv; FILE *f_rd, *f_wt; @@ -202,13 +202,13 @@ scm_sys_pipe () SCM_NEWCELL (p_wt); rv = pipe (fd); if (rv) - scm_syserror (s_sys_pipe); + scm_syserror (s_pipe); f_rd = fdopen (fd[0], "r"); if (!f_rd) { SCM_SYSCALL (close (fd[0])); SCM_SYSCALL (close (fd[1])); - scm_syserror (s_sys_pipe); + scm_syserror (s_pipe); } f_wt = fdopen (fd[1], "w"); if (!f_wt) @@ -218,7 +218,7 @@ scm_sys_pipe () fclose (f_rd); SCM_SYSCALL (close (fd[1])); errno = en; - scm_syserror (s_sys_pipe); + scm_syserror (s_pipe); } ptr = scm_add_to_port_table (p_rd); ptw = scm_add_to_port_table (p_wt); @@ -235,15 +235,15 @@ scm_sys_pipe () -SCM_PROC (s_sys_getgroups, "getgroups", 0, 0, 0, scm_sys_getgroups); +SCM_PROC (s_getgroups, "getgroups", 0, 0, 0, scm_getgroups); SCM -scm_sys_getgroups() +scm_getgroups() { SCM grps, ans; int ngroups = getgroups (0, NULL); if (!ngroups) - scm_syserror (s_sys_getgroups); + scm_syserror (s_getgroups); SCM_NEWCELL(grps); SCM_DEFER_INTS; { @@ -251,12 +251,12 @@ scm_sys_getgroups() int val; groups = (GETGROUPS_T *) scm_must_malloc(ngroups * sizeof(GETGROUPS_T), - s_sys_getgroups); + s_getgroups); val = getgroups(ngroups, groups); if (val < 0) { scm_must_free((char *)groups); - scm_syserror (s_sys_getgroups); + scm_syserror (s_getgroups); } SCM_SETCHARS(grps, groups); /* set up grps as a GC protect */ SCM_SETLENGTH(grps, 0L + ngroups * sizeof(GETGROUPS_T), scm_tc7_string); @@ -270,10 +270,10 @@ scm_sys_getgroups() -SCM_PROC (s_sys_getpwuid, "getpw", 0, 1, 0, scm_sys_getpwuid); +SCM_PROC (s_getpwuid, "getpw", 0, 1, 0, scm_getpwuid); SCM -scm_sys_getpwuid (user) +scm_getpwuid (user) SCM user; { SCM result; @@ -294,14 +294,14 @@ scm_sys_getpwuid (user) } else { - SCM_ASSERT (SCM_NIMP (user) && SCM_ROSTRINGP (user), user, SCM_ARG1, s_sys_getpwuid); + SCM_ASSERT (SCM_NIMP (user) && SCM_ROSTRINGP (user), user, SCM_ARG1, s_getpwuid); if (SCM_SUBSTRP (user)) user = scm_makfromstr (SCM_ROCHARS (user), SCM_ROLENGTH (user), 0); SCM_DEFER_INTS; entry = getpwnam (SCM_ROCHARS (user)); } if (!entry) - scm_syserror (s_sys_getpwuid); + scm_syserror (s_getpwuid); ve[0] = scm_makfrom0str (entry->pw_name); ve[1] = scm_makfrom0str (entry->pw_passwd); @@ -338,10 +338,10 @@ scm_setpwent (arg) /* Combines getgrgid and getgrnam. */ -SCM_PROC (s_sys_getgrgid, "getgr", 0, 1, 0, scm_sys_getgrgid); +SCM_PROC (s_getgrgid, "getgr", 0, 1, 0, scm_getgrgid); SCM -scm_sys_getgrgid (name) +scm_getgrgid (name) SCM name; { SCM result; @@ -356,13 +356,13 @@ scm_sys_getgrgid (name) SCM_SYSCALL (entry = getgrgid (SCM_INUM (name))); else { - SCM_ASSERT (SCM_NIMP (name) && SCM_STRINGP (name), name, SCM_ARG1, s_sys_getgrgid); + SCM_ASSERT (SCM_NIMP (name) && SCM_STRINGP (name), name, SCM_ARG1, s_getgrgid); if (SCM_SUBSTRP (name)) name = scm_makfromstr (SCM_ROCHARS (name), SCM_ROLENGTH (name), 0); SCM_SYSCALL (entry = getgrnam (SCM_CHARS (name))); } if (!entry) - scm_syserror (s_sys_getgrgid); + scm_syserror (s_getgrgid); ve[0] = scm_makfrom0str (entry->gr_name); ve[1] = scm_makfrom0str (entry->gr_passwd); @@ -389,27 +389,27 @@ scm_setgrent (arg) -SCM_PROC (s_sys_kill, "kill", 2, 0, 0, scm_sys_kill); +SCM_PROC (s_kill, "kill", 2, 0, 0, scm_kill); SCM -scm_sys_kill (pid, sig) +scm_kill (pid, sig) SCM pid; SCM sig; { - SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_sys_kill); - SCM_ASSERT (SCM_INUMP (sig), sig, SCM_ARG2, s_sys_kill); + SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_kill); + SCM_ASSERT (SCM_INUMP (sig), sig, SCM_ARG2, s_kill); /* Signal values are interned in scm_init_posix(). */ if (kill ((int) SCM_INUM (pid), (int) SCM_INUM (sig)) != 0) - scm_syserror (s_sys_kill); + scm_syserror (s_kill); return SCM_UNSPECIFIED; } -SCM_PROC (s_sys_waitpid, "waitpid", 1, 1, 0, scm_sys_waitpid); +SCM_PROC (s_waitpid, "waitpid", 1, 1, 0, scm_waitpid); SCM -scm_sys_waitpid (pid, options) +scm_waitpid (pid, options) SCM pid; SCM options; { @@ -417,21 +417,21 @@ scm_sys_waitpid (pid, options) int i; int status; int ioptions; - SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_sys_waitpid); + SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_waitpid); if (SCM_UNBNDP (options)) ioptions = 0; else { - SCM_ASSERT (SCM_INUMP (options), options, SCM_ARG2, s_sys_waitpid); + SCM_ASSERT (SCM_INUMP (options), options, SCM_ARG2, s_waitpid); /* Flags are interned in scm_init_posix. */ ioptions = SCM_INUM (options); } SCM_SYSCALL (i = waitpid (SCM_INUM (pid), &status, ioptions)); if (i == -1) - scm_syserror (s_sys_waitpid); + scm_syserror (s_waitpid); return scm_cons (SCM_MAKINUM (0L + i), SCM_MAKINUM (0L + status)); #else - scm_sysmissing (s_sys_waitpid); + scm_sysmissing (s_waitpid); /* not reached. */ return SCM_BOOL_F; #endif @@ -496,65 +496,65 @@ scm_getegid () } -SCM_PROC (s_sys_setuid, "setuid", 1, 0, 0, scm_sys_setuid); +SCM_PROC (s_setuid, "setuid", 1, 0, 0, scm_setuid); SCM -scm_sys_setuid (id) +scm_setuid (id) SCM id; { - SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_sys_setuid); + SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_setuid); if (setuid (SCM_INUM (id)) != 0) - scm_syserror (s_sys_setuid); + scm_syserror (s_setuid); return SCM_UNSPECIFIED; } -SCM_PROC (s_sys_setgid, "setgid", 1, 0, 0, scm_sys_setgid); +SCM_PROC (s_setgid, "setgid", 1, 0, 0, scm_setgid); SCM -scm_sys_setgid (id) +scm_setgid (id) SCM id; { - SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_sys_setgid); + SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_setgid); if (setgid (SCM_INUM (id)) != 0) - scm_syserror (s_sys_setgid); + scm_syserror (s_setgid); return SCM_UNSPECIFIED; } -SCM_PROC (s_sys_seteuid, "seteuid", 1, 0, 0, scm_sys_seteuid); +SCM_PROC (s_seteuid, "seteuid", 1, 0, 0, scm_seteuid); SCM -scm_sys_seteuid (id) +scm_seteuid (id) SCM id; { int rv; - SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_sys_seteuid); + SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_seteuid); #ifdef HAVE_SETEUID rv = seteuid (SCM_INUM (id)); #else rv = setuid (SCM_INUM (id)); #endif if (rv != 0) - scm_syserror (s_sys_seteuid); + scm_syserror (s_seteuid); return SCM_UNSPECIFIED; } -SCM_PROC (s_sys_setegid, "setegid", 1, 0, 0, scm_sys_setegid); +SCM_PROC (s_setegid, "setegid", 1, 0, 0, scm_setegid); SCM -scm_sys_setegid (id) +scm_setegid (id) SCM id; { int rv; - SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_sys_setegid); + SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_setegid); #ifdef HAVE_SETEUID rv = setegid (SCM_INUM (id)); #else rv = setgid (SCM_INUM (id)); #endif if (rv != 0) - scm_syserror (s_sys_setegid); + scm_syserror (s_setegid); return SCM_UNSPECIFIED; } @@ -568,36 +568,36 @@ scm_getpgrp () return SCM_MAKINUM (fn (0)); } -SCM_PROC (s_sys_setpgid, "setpgid", 2, 0, 0, scm_setpgid); +SCM_PROC (s_setpgid, "setpgid", 2, 0, 0, scm_setpgid); SCM scm_setpgid (pid, pgid) SCM pid, pgid; { #ifdef HAVE_SETPGID - SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_sys_setpgid); - SCM_ASSERT (SCM_INUMP (pgid), pgid, SCM_ARG2, s_sys_setpgid); + SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_setpgid); + SCM_ASSERT (SCM_INUMP (pgid), pgid, SCM_ARG2, s_setpgid); /* FIXME(?): may be known as setpgrp. */ if (setpgid (SCM_INUM (pid), SCM_INUM (pgid)) != 0) - scm_syserror (s_sys_setpgid); + scm_syserror (s_setpgid); return SCM_UNSPECIFIED; #else - scm_sysmissing (s_sys_setpgid); + scm_sysmissing (s_setpgid); /* not reached. */ return SCM_BOOL_F; #endif } -SCM_PROC (s_sys_setsid, "setsid", 0, 0, 0, scm_setsid); +SCM_PROC (s_setsid, "setsid", 0, 0, 0, scm_setsid); SCM scm_setsid () { #ifdef HAVE_SETSID pid_t sid = setsid (); if (sid == -1) - scm_syserror (s_sys_setsid); + scm_syserror (s_setsid); return SCM_UNSPECIFIED; #else - scm_sysmissing (s_sys_setsid); + scm_sysmissing (s_setsid); /* not reached. */ return SCM_BOOL_F; #endif @@ -625,23 +625,23 @@ scm_ttyname (port) } -SCM_PROC (s_sys_ctermid, "ctermid", 0, 0, 0, scm_ctermid); +SCM_PROC (s_ctermid, "ctermid", 0, 0, 0, scm_ctermid); SCM scm_ctermid () { #ifdef HAVE_CTERMID char *result = ctermid (NULL); if (*result == '\0') - scm_syserror (s_sys_ctermid); + scm_syserror (s_ctermid); return scm_makfrom0str (result); #else - scm_sysmissing (s_sys_ctermid); + scm_sysmissing (s_ctermid); /* not reached. */ return SCM_BOOL_F; #endif } -SCM_PROC (s_sys_tcgetpgrp, "tcgetpgrp", 1, 0, 0, scm_tcgetpgrp); +SCM_PROC (s_tcgetpgrp, "tcgetpgrp", 1, 0, 0, scm_tcgetpgrp); SCM scm_tcgetpgrp (port) SCM port; @@ -649,33 +649,33 @@ scm_tcgetpgrp (port) #ifdef HAVE_TCGETPGRP int fd; pid_t pgid; - SCM_ASSERT (SCM_NIMP (port) && SCM_OPFPORTP (port), port, SCM_ARG1, s_sys_tcgetpgrp); + SCM_ASSERT (SCM_NIMP (port) && SCM_OPFPORTP (port), port, SCM_ARG1, s_tcgetpgrp); fd = fileno ((FILE *)SCM_STREAM (port)); if (fd == -1 || (pgid = tcgetpgrp (fd)) == -1) - scm_syserror (s_sys_tcgetpgrp); + scm_syserror (s_tcgetpgrp); return SCM_MAKINUM (pgid); #else - scm_sysmissing (s_sys_tcgetpgrp); + scm_sysmissing (s_tcgetpgrp); /* not reached. */ return SCM_BOOL_F; #endif } -SCM_PROC (s_sys_tcsetpgrp, "tcsetpgrp", 2, 0, 0, scm_tcsetpgrp); +SCM_PROC (s_tcsetpgrp, "tcsetpgrp", 2, 0, 0, scm_tcsetpgrp); SCM scm_tcsetpgrp (port, pgid) SCM port, pgid; { #ifdef HAVE_TCSETPGRP int fd; - SCM_ASSERT (SCM_NIMP (port) && SCM_OPFPORTP (port), port, SCM_ARG1, s_sys_tcsetpgrp); - SCM_ASSERT (SCM_INUMP (pgid), pgid, SCM_ARG2, s_sys_tcsetpgrp); + SCM_ASSERT (SCM_NIMP (port) && SCM_OPFPORTP (port), port, SCM_ARG1, s_tcsetpgrp); + SCM_ASSERT (SCM_INUMP (pgid), pgid, SCM_ARG2, s_tcsetpgrp); fd = fileno ((FILE *)SCM_STREAM (port)); if (fd == -1 || tcsetpgrp (fd, SCM_INUM (pgid)) == -1) - scm_syserror (s_sys_tcsetpgrp); + scm_syserror (s_tcsetpgrp); return SCM_UNSPECIFIED; #else - scm_sysmissing (s_sys_tcsetpgrp); + scm_sysmissing (s_tcsetpgrp); /* not reached. */ return SCM_BOOL_F; #endif @@ -715,62 +715,62 @@ scm_convert_exec_args (args) return execargv; } -SCM_PROC (s_sys_execl, "execl", 0, 0, 1, scm_sys_execl); +SCM_PROC (s_execl, "execl", 0, 0, 1, scm_execl); SCM -scm_sys_execl (args) +scm_execl (args) SCM args; { char **execargv; SCM filename = SCM_CAR (args); - SCM_ASSERT (SCM_NIMP (filename) && SCM_ROSTRINGP (filename), filename, SCM_ARG1, s_sys_execl); + SCM_ASSERT (SCM_NIMP (filename) && SCM_ROSTRINGP (filename), filename, SCM_ARG1, s_execl); if (SCM_SUBSTRP (filename)) filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_ROLENGTH (filename), 0); args = SCM_CDR (args); execargv = scm_convert_exec_args (args); execv (SCM_ROCHARS (filename), execargv); - scm_syserror (s_sys_execl); + scm_syserror (s_execl); /* not reached. */ return SCM_BOOL_F; } -SCM_PROC (s_sys_execlp, "execlp", 0, 0, 1, scm_sys_execlp); +SCM_PROC (s_execlp, "execlp", 0, 0, 1, scm_execlp); SCM -scm_sys_execlp (args) +scm_execlp (args) SCM args; { char **execargv; SCM filename = SCM_CAR (args); - SCM_ASSERT (SCM_NIMP (filename) && SCM_ROSTRINGP (filename), filename, SCM_ARG1, s_sys_execlp); + SCM_ASSERT (SCM_NIMP (filename) && SCM_ROSTRINGP (filename), filename, SCM_ARG1, s_execlp); if (SCM_SUBSTRP (filename)) filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_ROLENGTH (filename), 0); args = SCM_CDR (args); execargv = scm_convert_exec_args (args); execvp (SCM_ROCHARS (filename), execargv); - scm_syserror (s_sys_execlp); + scm_syserror (s_execlp); /* not reached. */ return SCM_BOOL_F; } /* Flushing streams etc., is not done here. */ -SCM_PROC (s_sys_fork, "fork", 0, 0, 0, scm_sys_fork); +SCM_PROC (s_fork, "fork", 0, 0, 0, scm_fork); SCM -scm_sys_fork() +scm_fork() { int pid; pid = fork (); if (pid == -1) - scm_syserror (s_sys_fork); + scm_syserror (s_fork); return SCM_MAKINUM (0L+pid); } -SCM_PROC (s_sys_uname, "uname", 0, 0, 0, scm_sys_uname); +SCM_PROC (s_uname, "uname", 0, 0, 0, scm_uname); SCM -scm_sys_uname () +scm_uname () { #ifdef HAVE_UNAME struct utsname buf; @@ -789,7 +789,7 @@ scm_sys_uname () */ return ans; #else - scm_sysmissing (s_sys_uname); + scm_sysmissing (s_uname); /* not reached. */ return SCM_BOOL_F; #endif @@ -902,10 +902,10 @@ scm_open_output_pipe(pipestr) } -SCM_PROC (s_sys_utime, "utime", 1, 2, 0, scm_sys_utime); +SCM_PROC (s_utime, "utime", 1, 2, 0, scm_utime); SCM -scm_sys_utime (pathname, actime, modtime) +scm_utime (pathname, actime, modtime) SCM pathname; SCM actime; SCM modtime; @@ -913,37 +913,37 @@ scm_sys_utime (pathname, actime, modtime) int rv; struct utimbuf utm_tmp; - SCM_ASSERT (SCM_NIMP (pathname) && SCM_STRINGP (pathname), pathname, SCM_ARG1, s_sys_utime); + SCM_ASSERT (SCM_NIMP (pathname) && SCM_STRINGP (pathname), pathname, SCM_ARG1, s_utime); if (SCM_UNBNDP (actime)) SCM_SYSCALL (time (&utm_tmp.actime)); else - utm_tmp.actime = scm_num2ulong (actime, (char *) SCM_ARG2, s_sys_utime); + utm_tmp.actime = scm_num2ulong (actime, (char *) SCM_ARG2, s_utime); if (SCM_UNBNDP (modtime)) SCM_SYSCALL (time (&utm_tmp.modtime)); else - utm_tmp.modtime = scm_num2ulong (modtime, (char *) SCM_ARG3, s_sys_utime); + utm_tmp.modtime = scm_num2ulong (modtime, (char *) SCM_ARG3, s_utime); SCM_SYSCALL (rv = utime (SCM_CHARS (pathname), &utm_tmp)); if (rv != 0) - scm_syserror (s_sys_utime); + scm_syserror (s_utime); return SCM_UNSPECIFIED; } -SCM_PROC (s_sys_access, "access?", 2, 0, 0, scm_sys_access); +SCM_PROC (s_access, "access?", 2, 0, 0, scm_access); SCM -scm_sys_access (path, how) +scm_access (path, how) SCM path; SCM how; { int rv; - SCM_ASSERT (SCM_NIMP (path) && SCM_ROSTRINGP (path), path, SCM_ARG1, s_sys_access); + SCM_ASSERT (SCM_NIMP (path) && SCM_ROSTRINGP (path), path, SCM_ARG1, s_access); if (SCM_SUBSTRP (path)) path = scm_makfromstr (SCM_ROCHARS (path), SCM_ROLENGTH (path), 0); - SCM_ASSERT (SCM_INUMP (how), how, SCM_ARG2, s_sys_access); + SCM_ASSERT (SCM_INUMP (how), how, SCM_ARG2, s_access); rv = access (SCM_ROCHARS (path), SCM_INUM (how)); return rv ? SCM_BOOL_F : SCM_BOOL_T; } @@ -956,17 +956,22 @@ scm_getpid () return SCM_MAKINUM ((unsigned long) getpid ()); } -SCM_PROC (s_sys_putenv, "putenv", 1, 0, 0, scm_sys_putenv); +SCM_PROC (s_putenv, "putenv", 1, 0, 0, scm_putenv); SCM -scm_sys_putenv (str) +scm_putenv (str) SCM str; { #ifdef HAVE_PUTENV - SCM_ASSERT (SCM_NIMP (str) && SCM_STRINGP (str), str, SCM_ARG1, s_sys_putenv); - return putenv (SCM_CHARS (str)) ? SCM_MAKINUM (errno) : SCM_BOOL_T; + int rv; + + SCM_ASSERT (SCM_NIMP (str) && SCM_STRINGP (str), str, SCM_ARG1, s_putenv); + rv = putenv (SCM_CHARS (str)); + if (rv < 0) + scm_syserror (s_putenv); + return SCM_UNSPECIFIED; #else - scm_sysmissing (s_sys_putenv); + scm_sysmissing (s_putenv); /* not reached. */ return SCM_BOOL_F; #endif @@ -1163,10 +1168,10 @@ scm_strftime (format, stime) return scm_makfromstr (tbuf, len, 0); } -SCM_PROC (s_sys_strptime, "strptime", 2, 0, 0, scm_sys_strptime); +SCM_PROC (s_strptime, "strptime", 2, 0, 0, scm_strptime); SCM -scm_sys_strptime (format, string) +scm_strptime (format, string) SCM format; SCM string; { @@ -1177,10 +1182,10 @@ scm_sys_strptime (format, string) char *fmt, *str, *rest; int n; - SCM_ASSERT (SCM_NIMP (format) && SCM_ROSTRINGP (format), format, SCM_ARG1, s_sys_strptime); + SCM_ASSERT (SCM_NIMP (format) && SCM_ROSTRINGP (format), format, SCM_ARG1, s_strptime); if (SCM_SUBSTRP (format)) format = scm_makfromstr (SCM_ROCHARS (format), SCM_ROLENGTH (format), 0); - SCM_ASSERT (SCM_NIMP (string) && SCM_ROSTRINGP (string), string, SCM_ARG2, s_sys_strptime); + SCM_ASSERT (SCM_NIMP (string) && SCM_ROSTRINGP (string), string, SCM_ARG2, s_strptime); if (SCM_SUBSTRP (string)) string = scm_makfromstr (SCM_ROCHARS (string), SCM_ROLENGTH (string), 0); @@ -1205,7 +1210,7 @@ scm_sys_strptime (format, string) SCM_ALLOW_INTS; if (rest == NULL) - scm_syserror (s_sys_strptime); + scm_syserror (s_strptime); stime = scm_make_vector (SCM_MAKINUM (9), scm_long2num (0), SCM_UNDEFINED); @@ -1224,50 +1229,50 @@ scm_sys_strptime (format, string) return scm_cons (stime, scm_makfrom0str (rest)); #else - scm_sysmissing (s_sys_strptime); + scm_sysmissing (s_strptime); /* not reached. */ return SCM_BOOL_F; #endif } -SCM_PROC (s_sys_mknod, "mknod", 3, 0, 0, scm_sys_mknod); +SCM_PROC (s_mknod, "mknod", 3, 0, 0, scm_mknod); SCM -scm_sys_mknod(path, mode, dev) +scm_mknod(path, mode, dev) SCM path; SCM mode; SCM dev; { #ifdef HAVE_MKNOD int val; - SCM_ASSERT(SCM_NIMP(path) && SCM_STRINGP(path), path, SCM_ARG1, s_sys_mknod); - SCM_ASSERT(SCM_INUMP(mode), mode, SCM_ARG2, s_sys_mknod); - SCM_ASSERT(SCM_INUMP(dev), dev, SCM_ARG3, s_sys_mknod); + SCM_ASSERT(SCM_NIMP(path) && SCM_STRINGP(path), path, SCM_ARG1, s_mknod); + SCM_ASSERT(SCM_INUMP(mode), mode, SCM_ARG2, s_mknod); + SCM_ASSERT(SCM_INUMP(dev), dev, SCM_ARG3, s_mknod); SCM_SYSCALL(val = mknod(SCM_CHARS(path), SCM_INUM(mode), SCM_INUM(dev))); if (val != 0) - scm_syserror (s_sys_mknod); + scm_syserror (s_mknod); return SCM_UNSPECIFIED; #else - scm_sysmissing (s_sys_mknod); + scm_sysmissing (s_mknod); /* not reached. */ return SCM_BOOL_F; #endif } -SCM_PROC (s_sys_nice, "nice", 1, 0, 0, scm_sys_nice); +SCM_PROC (s_nice, "nice", 1, 0, 0, scm_nice); SCM -scm_sys_nice(incr) +scm_nice(incr) SCM incr; { #ifdef HAVE_NICE - SCM_ASSERT(SCM_INUMP(incr), incr, SCM_ARG1, s_sys_nice); + SCM_ASSERT(SCM_INUMP(incr), incr, SCM_ARG1, s_nice); if (nice(SCM_INUM(incr)) != 0) - scm_syserror (s_sys_nice); + scm_syserror (s_nice); return SCM_UNSPECIFIED; #else - scm_sysmissing (s_sys_nice); + scm_sysmissing (s_nice); /* not reached. */ return SCM_BOOL_F; #endif diff --git a/libguile/posix.h b/libguile/posix.h index 6797bb160..1dd9eb52d 100644 --- a/libguile/posix.h +++ b/libguile/posix.h @@ -56,45 +56,45 @@ extern SCM scm_tcgetpgrp SCM_P ((SCM port)); extern SCM scm_ctermid SCM_P ((void)); extern SCM scm_setsid SCM_P ((void)); extern SCM scm_setpgid SCM_P ((SCM pid, SCM pgid)); -extern SCM scm_sys_pipe SCM_P ((void)); -extern SCM scm_sys_getgroups SCM_P ((void)); +extern SCM scm_pipe SCM_P ((void)); +extern SCM scm_getgroups SCM_P ((void)); extern SCM scm_getpgrp SCM_P ((void)); -extern SCM scm_sys_getpwuid SCM_P ((SCM user)); +extern SCM scm_getpwuid SCM_P ((SCM user)); extern SCM scm_setpwent SCM_P ((SCM arg)); -extern SCM scm_sys_getgrgid SCM_P ((SCM name)); +extern SCM scm_getgrgid SCM_P ((SCM name)); extern SCM scm_setgrent SCM_P ((SCM arg)); -extern SCM scm_sys_kill SCM_P ((SCM pid, SCM sig)); -extern SCM scm_sys_waitpid SCM_P ((SCM pid, SCM options)); +extern SCM scm_kill SCM_P ((SCM pid, SCM sig)); +extern SCM scm_waitpid SCM_P ((SCM pid, SCM options)); extern SCM scm_getppid SCM_P ((void)); extern SCM scm_getuid SCM_P ((void)); extern SCM scm_getgid SCM_P ((void)); extern SCM scm_geteuid SCM_P ((void)); extern SCM scm_getegid SCM_P ((void)); -extern SCM scm_sys_setuid SCM_P ((SCM id)); -extern SCM scm_sys_setgid SCM_P ((SCM id)); -extern SCM scm_sys_seteuid SCM_P ((SCM id)); -extern SCM scm_sys_setegid SCM_P ((SCM id)); +extern SCM scm_setuid SCM_P ((SCM id)); +extern SCM scm_setgid SCM_P ((SCM id)); +extern SCM scm_seteuid SCM_P ((SCM id)); +extern SCM scm_setegid SCM_P ((SCM id)); extern SCM scm_ttyname SCM_P ((SCM port)); -extern SCM scm_sys_execl SCM_P ((SCM args)); -extern SCM scm_sys_execlp SCM_P ((SCM args)); -extern SCM scm_sys_fork SCM_P ((void)); -extern SCM scm_sys_uname SCM_P ((void)); +extern SCM scm_execl SCM_P ((SCM args)); +extern SCM scm_execlp SCM_P ((SCM args)); +extern SCM scm_fork SCM_P ((void)); +extern SCM scm_uname SCM_P ((void)); extern SCM scm_environ SCM_P ((SCM env)); extern SCM scm_open_pipe SCM_P ((SCM pipestr, SCM modes)); extern SCM scm_open_input_pipe SCM_P ((SCM pipestr)); extern SCM scm_open_output_pipe SCM_P ((SCM pipestr)); -extern SCM scm_sys_utime SCM_P ((SCM pathname, SCM actime, SCM modtime)); -extern SCM scm_sys_access SCM_P ((SCM path, SCM how)); +extern SCM scm_utime SCM_P ((SCM pathname, SCM actime, SCM modtime)); +extern SCM scm_access SCM_P ((SCM path, SCM how)); extern SCM scm_getpid SCM_P ((void)); -extern SCM scm_sys_putenv SCM_P ((SCM str)); +extern SCM scm_putenv SCM_P ((SCM str)); extern SCM scm_read_line SCM_P ((SCM port, SCM include_terminator)); extern SCM scm_read_line_x SCM_P ((SCM str, SCM port)); extern SCM scm_write_line SCM_P ((SCM obj, SCM port)); extern SCM scm_setlocale SCM_P ((SCM category, SCM locale)); extern SCM scm_strftime SCM_P ((SCM format, SCM stime)); -extern SCM scm_sys_strptime SCM_P ((SCM format, SCM string)); -extern SCM scm_sys_mknod SCM_P ((SCM path, SCM mode, SCM dev)); -extern SCM scm_sys_nice SCM_P ((SCM incr)); +extern SCM scm_strptime SCM_P ((SCM format, SCM string)); +extern SCM scm_mknod SCM_P ((SCM path, SCM mode, SCM dev)); +extern SCM scm_nice SCM_P ((SCM incr)); extern SCM scm_sync SCM_P ((void)); extern void scm_init_posix SCM_P ((void)); diff --git a/libguile/scmconfig.h.in b/libguile/scmconfig.h.in index b17472c40..fe9d14606 100644 --- a/libguile/scmconfig.h.in +++ b/libguile/scmconfig.h.in @@ -65,6 +65,26 @@ configure.in for more details. */ #undef HAVE_FD_SETTER +/* Define this if your system has a way to set a stdio stream's file + descriptor. You should also copy fd.h.in to fd.h, and give the + macro SET_FILE_FD_FIELD an appropriate definition. See + configure.in for more details. */ +#undef HAVE_FD_SETTER + +/* Set this to the name of a field in FILE which contains the number + of buffered characters waiting to be read. */ +#undef FILE_CNT_FIELD + +/* Define this if your stdio has _gptr and _egptr fields which can + be compared to give the number of buffered characters waiting to + be read. */ +#undef FILE_CNT_GPTR + +/* Define this if your stdio has _IO_read_ptr and _IO_read_end fields + which can be compared to give the number of buffered characters + waiting to be read. */ +#undef FILE_CNT_READPTR + /* Define this if your system defines struct linger, for use with the getsockopt and setsockopt system calls. */ #undef HAVE_STRUCT_LINGER diff --git a/libguile/simpos.c b/libguile/simpos.c index a726a73e9..57d5de19d 100644 --- a/libguile/simpos.c +++ b/libguile/simpos.c @@ -79,19 +79,27 @@ scm_system(cmd) #endif extern char *getenv(); -SCM_PROC (s_sys_getenv, "getenv", 1, 0, 0, scm_sys_getenv); +SCM_PROC (s_getenv, "getenv", 1, 0, 0, scm_getenv); SCM -scm_sys_getenv(nam) +scm_getenv(nam) SCM nam; { char *val; - SCM_ASSERT(SCM_NIMP(nam) && SCM_ROSTRINGP(nam), nam, SCM_ARG1, s_sys_getenv); + SCM_ASSERT(SCM_NIMP(nam) && SCM_ROSTRINGP(nam), nam, SCM_ARG1, s_getenv); if (SCM_ROSTRINGP (nam)) nam = scm_makfromstr (SCM_ROCHARS (nam), SCM_ROLENGTH (nam), 0); val = getenv(SCM_CHARS(nam)); if (!val) - scm_syserror (s_sys_getenv); + { + /* This isn't a system error (errno won't be set), but is still + treated as an exceptional condition, since getenv normally + returns a string. Can easily do (false-if-exception (getenv ...)) + to catch the exception. + */ + scm_misc_error (s_getenv, "%S not found in environment", + scm_listify (nam, SCM_UNDEFINED)); + } return scm_makfromstr(val, (scm_sizet)strlen(val), 0); } diff --git a/libguile/simpos.h b/libguile/simpos.h index 73ddb006d..023966ad1 100644 --- a/libguile/simpos.h +++ b/libguile/simpos.h @@ -48,7 +48,7 @@ extern SCM scm_system SCM_P ((SCM cmd)); -extern SCM scm_sys_getenv SCM_P ((SCM nam)); +extern SCM scm_getenv SCM_P ((SCM nam)); extern SCM scm_software_type SCM_P ((void)); extern void scm_init_simpos SCM_P ((void));