SCM_OUT_OF_RANGE use SCM_MAKINUM, not scm_long2num. Added
SCM_COERCE_ROSTRING macro. Added SCM_VALIDATE_NONEMPTYLIST
macro. Fix SCM_VALIDATE_STRINGORSUBSTR macro to not use SLOPPY
variants.
* ports.c (scm_port_closed_p): Validate that the arg is a PORT,
then return whether it's an open port (was validating that it was
an open port -- this was a bug I introduced back in December, but
my careful reading of diffs caught it).
* numbers.c: Recombine the two conditional-compilation paths for
all the log* primitives -- they were split based on #ifndef
scm_long2num; factored out a SCM_LOGOP_RETURN macro, and fixed
some bugs and inconsistencies in the two sets of implementations.
(scm_lognot) Fixed *atrocious* re-use of a SCM as an integer!
* ioext.c: Use SCM_ASSERT_RANGE in a couple places, and
SCM_VALIDATE_INUM_COPY once where it should've been used.
* fluids.c (scm_internal_with_fluids): Use
SCM_VALIDATE_LIST_COPYLEN.
* filesys.c: Use SCM_NUM2LONG instead of SCM_VALIDATE_INUM_COPY;
this is questionable as it relaxes type safety, but other changes
were useful and all SCM_NUM2LONG's should probably be
revisited. Use SCM_OUT_OF_RANGE, SCM_WRONG_TYPE_ARG.
* evalext.c: line-break change on 1 line.
* eval.c (nconc2last): Takes a non-empty list as its first
argument, not just a list.
* dynl.c: Use new SCM_COERCE_ROSTRING macro.
net_db.c, sort.c, stacks.c, unif.c: Use SCM_WTA, SCM_MISC_ERROR
where possible.
* symbols.c (scm_sysintern0): Fixed the function name in a
scm_misc_error invocation.
* print.c (scm_simple_format): Do not need SCM_COERCE_SUBSTR, and
use scm_return_first to ward off latent GC bug that Mikael caught.
* async.c: Use SCM_VALIDATE_ASYNC_COPY one place where it wasn't
used before but should've been.
net_db.c, read.c, socket.c: Update error messages to use ~A for
%s, ~S for %S to work with new `simple-format' format and be
standardized better.
* print.h, print.c (scm_simple_format): Added `simple-format'
primitive. It's the old scm_display_error, with ARGS now a rest
parameter, and the destination first instead of last (and a couple
new capabilities inspired by `format' -- #t as destination means
current-output-port, #f means return the formatted text as a
string.
* gh.h, gh_data.c, ports.h, ports.c: Added some missing const specifications.
* backtrace.c (scm_display_error_message): Rewrote to use
scm_simple_format() procedure.
* __scm.h: Added commented-out #define of GUILE_DEBUG_FREELIST
scm_lookupcar1: throw an error with key 'unbound-variable instead
of 'misc-error when an unbound variable is encountered.
* filesys.c (scm_mkdir, scm_rmdir, scm_getcwd, scm_select,
scm_symlink, scm_readlink, scm_lstat),
posix.c (scm_setpgid, scm_setsid, scm_ctermid, scm_tcgetpgrp,
scm_tcsetpgrp, scm_uname, scm_setlocale, scm_mknod, scm_nice,
scm_sync),
simpos.c (scm_system),
stime.c (scm_times, scm_strptime):
move the HAVE_XXX feature tests out of the procedure bodies.
don't use SCM_SYSMISSING.
scm_validate.h (SCM_SYSMISSING): removed.
error.h, error.c (scm_sysmissing): comment that this is deprecated.
see ChangeLog entry for 1999-12-28.
* scm_validate.h: Added SCM_VALIDATE_THREAD.
* *.c: Remove SCM_NIMP(X) when it is an extraneous pre-test given
that SCM_FOOP macros all now include SCM_NIMP in their expansion.
This simplifies lots of code, making it far more readable.
GUILE_PROC1. Build guile-procedures.txt, and add that file to
pkgdata_DATA.
* load.c: Added `pkgdata-dir', `site-dir', `library-dir'
primitives.
* guile-doc-snarf.awk: Drop trailing space when no arguments:
e.g., "(foo )" is now "(foo)".
* *.c: moved all the documentation for primitives from
guile-doc/ref/{appendices,posix,scheme}.texi into the source code.
This leaves about half of the primitives undocumented. Also, all
the markup is currently still texinfo. I don't have a problem
with texinfo per se, but the markup is not very descriptive or
accurate.
function headers and argument checking. Switched SCM_PROC,
SCM_PROC1 macros to be GUILE_PROC, GUILE_PROC1 (may change names
later, but was useful to keep old versions around while migrate)
that has docstrings and argument lists embedded in the GUILE_PROC
macro invocations that expand into a function header. Use lots of
new SCM_VALIDATE_* macros to simplify error checking and reduce
tons of redundancy. This is very similar to what I did for Scwm.
Note that none of the extraction of the docstrings, nor software
engineering checks of Scwm is yet added to Guile. I'll work on
that tomorrow, I expect.
* Makefile.am: Added scm_validate.h to modinclude_HEADERS.
* chars.c: Added docstrings for the primitives defined in here.
* snarf.h: Added GUILE_PROC, GUILE_PROC1. Added
SCM_REGISTER_PROC to be like old SCM_PROC, though old SCM_PROC
still remains for now. Changed naming convention for the s_foo
string name of the primitive to be s_scm_foo for ease of use with
the macro.
* scm_validate.h: Lots of new SCM_VALIDATE macros to simplify
argument checking through guile. Maybe some of these should be
folded into the header file for the types they check, but for now
it was easiest to just stick them all in one place.
"directory" to "directory stream". A predicate named "directory?"
would be confusing.
* filesys.c (scm_directory_stream_p): Renamed from scm_directory_p.
At the Scheme level, "directory?" -> "directory-stream?".
(scm_dir_print): Use the phrase "directory stream" in printed form.
* filesys.h (scm_directory_stream_p): Prototype renamed
accordingly.
* filesys.c (scm_directory_p): new procedure "directory?" Returns
a boolean indicating whether its argument is a directory
port as returned by opendir (thanks to Dirk Herrmann for the
suggestion.)
* fports.c (fport_input_waiting): if select is used, return 1
instead of whatever FD_ISSET expands to. maybe it will be useful
to interpret the value from the input_waiting ptob procedure as a
lower bound on the number of bytes available.
* Mikael asked for a few names to be changed...
* ports.c (scm_make_port_type): take the write procedure as the
second argument instead of the flush procedure.
* ports.h (scm_ptob_descriptor): rename the ptob procedures:
fflush -> flush, read_flush -> end_input, fclose -> close,
fill_buffer -> fill_input, ftruncate -> truncate,
input_waiting_p -> input_waiting.
* ports.c (end_input_void_port): was read_flush_void_port.
(scm_set_port_end_input): was scm_set_port_flush_input.
(scm_set_port_flush): was scm_set_port_write.
(scm_set_port_input_waiting): was scm_set_port_input_waiting_p
(scm_end_input): was scm_read_flush.
(scm_fill_input): was scm_fill_buffer.
(scm_flush): was scm_fflush.
* fports.c (fport_input_waiting): renamed from fport_input_waiting_p.
(fport_end_input): was local_read_flush.
(fport_flush): was local_fflush.
(fport_close): was local_fclose.
(fport_truncate): was local_ftruncate.
(fport_seek): was local_seek.
(fport_free): was local_free.
(fport_fill_input): was fport_fill_buffer.
* strports.c (st_end_input): was st_read_flush.
(st_truncate): was st_ftruncate.
* vports.c: (sf_flush): was sfflush.
(sf_close): was sfclose.
(sf_fill_input): was sf_fill_buffer.
* ports.c, fports.c, strports, vports.c, ioext.c, unif.c, filesys.c:
change callers.
* gdbint.c (gdb_print, gdb_read): call scm_truncate_file.
* ports.c (scm_truncate_file): renamed from scm_ftruncate.
allow the 1st argument to be a fdes or filename as well as a
port (as in the filesys.c version).
* filesys.c (scm_truncate_file): removed.
(scm_chmod, scm_stat, scm_truncate_file: likewise.
* fports.c (scm_fdes_to_port), ports.c (scm_void_port),
filesys.c (scm_opendir):
restore defer interrupts while the port is constructed.
* (scm_setvbuf): if mode is _IOFBF and size is not supplied,
derive buffer size from fdes or use a default.
(scm_fdes_to_port): use setvbuf instead of creating the buffers
directly.
* filesys.c (scm_fsync): use SCM_FDES.
* filesys.c (scm_fcntl): get fdes from fport.
(set_element, get_element): likewise.
* filesys.c (scm_open): adjust port_mode for O_APPEND and O_CREAT.
ports.c fports.c ioext.c posix.c socket.c net_db.c filesys.c:
removed all uses of SCM_DEFER/ALLOW ints for now. they were mainly
just protecting errno. some may need to be put back.
* * ports.c (scm_drain_input): new procedure.
ports.h: prototype.
* fports.c (FPORT_READ_SAFE, FPORT_WRITE_SAFE, FPORT_ALL_OKAY,
pre_read, pre_write): removed.
(local_fputc, local_fputs, local_ffwrite): use write, not stdio.
(scm_standard_stream_to_port): change first arg from FILE * to
int fdes.
(local_fflush): flush fdes, not FILE *.
* fports.h (SCM_NOFTELL): removed.
* genio.c, ports.c: don't include filesys.h.
* genio.c (scm_getc): don't use scm_internal_select if FPORT.
do it in fports.c:local_fgetc.
* genio.c: don't use SCM_SYSCALL when calling ptob procedures.
do it where it's needed in the port smobs.
* filesys.c (scm_input_waiting_p): moved to fports.c, stdio
buffer support removed. take SCM arg, not FILE *.
* filesys.h: prototype moved too.
* fports.c (scm_fdes_to_port): new procedure.
(local_fgetc): use read not fgetc.
(local_fclose): use close, not fclose.
(local_fgets): use read, not fgets
* fports.h: prototype for scm_fdes_to_port.
* fports.h (scm_fport): new struct.
* fports.c (scm_open_file): use open, not fopen.
#include fcntl.h
* ports.h (struct scm_port_table): change stream from SCM to void *.
* ports.c (scm_add_to_port_table): check for memory allocation error.
(scm_prinport): remove MSDOS hair.
(scm_void_port): set stream to 0 instead of SCM_BOOL_F.
(scm_close_port): don't throw errors: do it in fports.c.
fports.c; don't just throw them together anywhere.
* fports.c (scm_stdio_to_port): Make NAME a SCM value, which is
what the rest of Guile wants. Don't set the revealed count;
that's only appropriate for stdin, stdout, stderr.
(scm_standard_stream_to_port): This function does set the revealed
count.
* init.c (scm_init_standard_ports): Use scm_standard_stream_to_port,
not scm_stdio_to_port.
* filesys.c (scm_open): Call scm_stdio_to_port; don't write it out.
* fports.c (scm_open_file): Same.
* posix.c (scm_pipe): Same.
* socket.c (scm_sock_fd_to_port): Same.
* ioext.c (scm_fdopen): Same.
(scm_freopen): Moved from here to...
* fports.c (scm_freopen): ... here. This is really something that
munges the internals of an fport, so it should go here.
* fports.h (scm_stdio_to_port): Adjust prototype.
(scm_standard_stream_to_port, scm_freopen): New protoypes.
* ioext.h (scm_freopen): Prototype removed.
* filesys.c (set_element, get_element): This can work on both pipe
and file ports, so use SCM_FPORTP to typecheck, instead of testing
for scm_tc16_fport.
avoid signed/unsigned comparison warnings, and because the return
value of readlink may be -1. Don't bother casting the third
argument to readlink.
* filesys.c (scm_dirname, scm_basename): Move these to their own
page, at the end of the file.
* filesys.h (scm_dirname, scm_basename): Add prototypes for these.
marking code, and make marker routines only responsible for
turning up outgoing pointers.
* gc.c (scm_gc_mark): Set the mark bit on ports and smobs here,
before calling the marking function. Don't call the marking
function if it's zero.
* markers.c (scm_mark0): Just return #f. This function isn't
necessary at all now, but it's harmless to call it. We'll leave
it in so other folks' code doesn't croak at link time.
(scm_markcdr): Don't call SCM_SETGC8MARK.
* async.c (mark_async): Don't call SCM_SETGC8MARK.
* dynl.c (mark_dynl_obj): Same.
* root.c (mark_root): Same.
* srcprop.c (marksrcprops): Same.
* unif.c (markra): Same.
* variable.c (scm_markvar): Same.
* ports.c (scm_markstream): Same.
(void_port_ptob): Specify zero for our marking function.
* debug.c (debugobjsmob): Same.
* dynwind.c (guardsmob): Same.
* filesys.c (dir_smob): Same.
* fluids.c (fluid_smob): Same.
* fports.c (scm_fptob, scm_pipob): Same.
* mallocs.c (mallocsmob): Same.
* regex-posix.c (regex_t_smob): Same.
* smob.c (freecell, flob, bigob): Same.
* threads.c (thread_smob, mutex_smob, condvar_smob): Same.
* throw.c (jbsmob, lazy_catch_funs): Same.
(fill_select_type): Return the highest file descriptor.
(scm_select): Tell select about the highest file descriptor. On
some systems the SELECT_SET_SIZE can be as much as 128 bytes.
Therefore the extra overhead for calculating the maximum fd seems
to be more than compensated. Is this correct? In any case,
scm_internal_select will be much faster with this info.
(scm_select, fill_select_type, set_element): Don't accept any kind
of object in the file descriptor list or vector.
* coop.c (coop_qinit): Initialize fields used by
scm_internal_select.
(coop_qget, coop_qget, coop_tmp_queue): Made global.
(coop_next_runnable_thread): If GUILE_ISELECT enabled, use
replacement in iselect.c.
(coop_mutex_lock, coop_condition_variable_wait, coop_abort,
coop_join): If GUILE_ISELECT enabled, use
coop_wait_for_runnable_thread instead of
coop_next_runnable_thread.
(usleep, sleep): New replacements for system functions if
GUILE_ISELECT is enabled.
* coop-threads.h: Declare coop_wait_for_runnable_thread.
* coop-defs.h (coop_t): Added fields used by scm_internal_select.
* filesys.c: Added #include "iselect.h". Moved FD-macros to
iselect.h. Implement Scheme level `select' using
scm_internal_select. (See NEWS.)
* genio.c (scm_getc): Block with scm_internal_select. (See NEWS.)
* init.c: Call scm_init_iselect.
* stime.c (scm_times): new procedure.
* ioext.c (scm_fseek): if the first argument is a file descriptor
call lseek.
(scm_ftell): if the first argument is a file descriptor call lseek
(sic).
* filesys.h: prototypes for scm_open_fdes, scm_fsync.
* filesys.c (scm_chmod): if the first argument is a file descriptor,
call fchmod.
(scm_chown): if the first argument is a port or file descriptor,
call fchown.
(scm_truncate_file): new procedure.
Add DEFER/ALLOW INTS to a few other procedures.
(scm_fsync): new procedure.
(scm_open_fdes): new procedure.
(scm_open): use scm_open_fdes. If mode isn't specified, 666 will
now be used.
(scm_fcntl): the first argument can now be a file descriptor. The
third argument is now optional.
* posix.c (scm_execl, scm_execlp): make the filename argument
compulsory, since omitting it causes SEGV.
(scm_sync): return unspecified instead of #f.
(scm_execle): new procedure.
(environ_list_to_c): new procedure.
(scm_environ): use environ_list_to_c. disable interrupts.
(scm_convert_exec_args): take pos and subr arguments and
improve error checking.
* boot-9.scm: define tms accessors: clock, utime, stime, cutime,
cstime.
SCM_THREAD_CRITICAL_SECTION_START/END unless USE_THREADS is defined.
* ports.h: prototypes too.
* ports.c (scm_mode_bits, scm_port_mode): moved from fports.c.
* fports.h: prototype too.
* fports.c (scm_evict_ports): moved from ioext.c.
* ports.c (scm_close_port): return a boolean instead of unspecified.
throw an error if an error other than EBADF occurs.
* filesys.h: scm_close prototype.
* filesys.c (scm_close): new procedure, can close file descriptors
and ports (scsh compatible).
* ports.c (scm_flush_all_ports): SCM_PROC incorrectly allowed an
optional argument.
select, since they were not used in this file.
* * filesys.c (scm_select): make the fifth parameter microseconds,
not milliseconds. let the fourth parameter be either a real value
or an integer or #f. The first, second and third arguments can
now be vectors: the type of the corresponding return set will be
the same.
(set_element, get_element): new static procedures.
scm_misc_error.
* stime.c (scm_localtime): copy the result of localtime before
calling gmtime in case they share a buffer.
(scm_localtime, scm_mktime): throw an error if neither HAVE_TM_ZONE
nor HAVE_TZNAME.
wan't defined. Don't include fd.h.
* Previously fd.h was regenerated whenever configure was run,
forcing a couple of files to be recompiled.
* fd.h.in: deleted, SET_FILE_FD_FIELD moved to ioext.c.
* configure.in: AC_DEFINE FD_SETTER instead of HAVE_FD_SETTER.
Check for _fileno as well as _file.
Don't output fd.h.
* ioext.c: don't fd.h.
* acconfig.h: remove duplicate HAVE_FD_SETTER and change the
other to FD_SETTER.
* Change the stratigy for getting information about errno
(and now signal number) values, e.g., ENOSYS, SIGKILL. Instead of
generating lists of symbols during the build process, which will
not always work, include comprehensive lists in the distribution.
To help keep the lists up to date, the "check_signals" and
"check_errnos" make targets can be used.
* configure.in: don't check for a command to extract errno codes.
* Makefile.am: update file lists, remove errnos.list and errnos.c
targets, add cpp_err_symbols.c, cpp_sig_symbols.c, check_signals,
check_errnos targets.
(CLEANFILES): remove errnos.c and errnos.list, add
cpp_err_symbols_here cpp_err_symbols_diff cpp_err_symbols_new
cpp_sig_symbols_here cpp_sig_symbols_diff cpp_sig_symbols_new
* errnos.default: deleted.
* cpp_signal.c: new file.
* cpp_errno.c: renamed from errnos_get.c.
* cpp_err_symbols, cpp_sig_symbols: new files.
* cpp_cnvt.awk: renamed from errnos_cnvt_awk.
* error.c (scm_init_error): #include cpp_err_symbols instead of
errnos.c.
* posix.c (scm_init_posix): don't intern signal symbols. #include
cpp_sig_symbols.c.
* strop.c (scm_i_index): allow the lower bound to be equal to the
length of the string, so a null string doesn't always give an error.
* posix.h: new prototypes.
* posix.c (scm_status_exit_val, scm_status_term_sig,
scm_status_stop_sig): new functions, as in scsh. They break down
process status values as returned by waitpid.
primitives.
load errno.scm.
* netconst.scm: undefine maybe-define and maybe-define-so after use.
* errno.scm: new file.
* fports.c (scm_open_file): pass errno to scm_syserror_msg.
* filesys.h: update prototypes. Remove macros: SCM_FD_P, SCM_FD_FLAGS,
SCM_FD.
* filesys.c (scm_sys_stat, scm_sys_lstat): pass errno to
scm_syserror_msg.
* (scm_sys_read_fd, scm_sys_write_fd, scm_sys_close, scm_sys_lseek,
scm_sys_dup): deleted: FD capability will be added to other
procedures.
* Remove support for the FD object type: scm_tc16_fd, scm_fd_print,
scm_fd_free, fd_smob, scm_intern_fd.
* (scm_open): renamed from scm_sys_open. Return a port instead of
an FD object. Make the mode argument optional.
* (scm_sys_create): deleted, it's just a special case of open.
(scm_init_filesys): move interning of constants O_CREAT etc.,
here (were previously using SCM_CONST_LONG macro).
Add missing constants: O_RDONLY, O_WRONLY, O_RDWR, O_CREAT.
don't newsmob fd.
(numerous _sys_ procedures): remove gratuitous _sys_ from names.
include "fports.h" and <stdio.h>
(scm_stat, scm_select): don't support FD objects.
* error.h: adjust scm_syserror_msg prototype.
* error.c (scm_syserror_msg): take an extra argument for errno.
Using the global value didn't always work, since it could be
reset by procedure calls in the message or args arguments.
* fports.c (scm_setbuf0): call setbuf even if FIONREAD is not defined.
I don't understand why the check was there (and what about the
ultrix check?)
* strop.c (scm_string_copy): allow shared substrings to be copied.
* unif.h: corresponding change to prototypes.
* unif.c (scm_uniform_array_read_x, scm_uniform_array_write_x):
recognize two new optional arguments: offset and length. Allow
the port argument to be an integer (file descriptor, for scsh).
Include <unistd.h> for "read" prototype.
FIONREAD, since the latter doesn't detect EOF.
Throw error if neither select nor FIONREAD available.
* socket.c (scm_connect): take a port, not a fd object.
(scm_fill_sockaddr): throw an error if fam is not recognised.
(scm_bind): use scm_fill_sockaddr.
(scm_listen): take a port, not a fd object.
(scm_accept): take and return a port. return CDR in the car if
address can't be got
(scm_sock_fd_to_port): new procedure.
(scm_socket): use scm_sock_fd_to_port.
(scm_addr_vector): throw error if unrecognised address type.
take an extra argument with the calling procedure name.
(scm_getsockname): take a port. return #f if address can't be got.
(scm_getpeername): take a port. return #f if address can't be got.
(scm_recvfrom): take a port. return #f for address component if can't
be got.
(scm_sendto, scm_socketpair, scm_getsockopt scm_shutdown,
scm_setsockopt, scm_recv, scm_send): take a port not a fd object.
* socket.h (SCM_P): update bind prototype.
* socket.c (scm_init_socket): intern PF_UNSPEC, PF_UNIX, PF_INET.
include "feature.h".
(scm_socket): return a port, not a file descriptor object.
include "fports.h" and <unistd.h>
(scm_bind): take a port, not a file descriptor object.
take an extra argument for address args.
* net_db.c (scm_init_net_db): intern INADDR_ANY, INADDR_BROADCAST,
INADDR_NONE, INADDR_LOOPBACK.
* init.c: include net_db.h and not fdsocket.h.
(scm_boot_guile_1): call scm_init_net_db and not scm_init_fdsocket.
* Makefile.am: corresponding changes.
* socket.h: renamed from fdsocket.h, fix names.
* net_db.h: renamed from socket.h, fix names.
* socket.c: renamed from fdsocket.c.
remove _sys from procedure names.
(scm_init_socket): rename from scm_init_fdsocket. include socket.x.
add "socket" to features list.
* net_db.c: renamed from socket.c.
remove _sys from procedure names.
(scm_init_net_db): rename from scm_init_socket. include net_db.x.
add "net-db" to features list.
include "net_db.h". don't include <sys/socket.h> or
<sys/un.h>.