1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

177 commits

Author SHA1 Message Date
Michael Livshin
dd85ce4758 * strop.c (s_scm_string_capitalize_x): fix docstring quoting.
* socket.c (s_scm_inet_pton): fix docstring quoting.
(s_scm_inet_ntop): ditto.

* num2integral.i.c (INTEGRAL2NUM): cast to fix a warning.

* hashtab.c (scm_internal_hash_fold): fix argument position in
SCM_ASSERT.

* environments.c (s_scm_import_environment_set_imports_x): fix
argument position in SCM_ASSERT.

* debug.c (s_scm_make_gloc): fix SCM packing/unpacking.
(s_scm_make_iloc): ditto.
2001-05-28 12:36:41 +00:00
Michael Livshin
1be6b49ccb * validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.

* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.

* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.

* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.

* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.

* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.

* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.

* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.

* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.

* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t

* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.

* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.

* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.

* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x

* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.

* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.

* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.

* gsubr.c: various int -> scm_bits_t changes.

* gh_data.c (gh_scm2double): no loss of precision any more.

* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.

* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.

* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t

* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.

* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t

* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t

* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.

* extensions.c: extension -> extension_t (and made a typedef).

* eval.h (SCM_IFRAME): cast to scm_bits_t, not int.  just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.

* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t

* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t

* dynwind.c (scm_dowinds): delta: long -> scm_bits_t

* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t

* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.

* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t

* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.

* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.

* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.

* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
Marius Vollmer
86d31dfe7d Merge from mvo-vcell-cleanup-1-branch. 2001-05-15 14:57:22 +00:00
Gary Houston
a57a0b1e6a * socket.c: use HAVE_IPV6 instead of AF_INET6 to enable IPv6
support.
2001-05-05 08:31:00 +00:00
Gary Houston
0012013017 * socket.c: define uint32_t if netdb.h doesn't. thanks to
Dale P. Smith.
2001-05-03 23:42:31 +00:00
Gary Houston
eefae53898 * socket.c: attempted to improve the docstrings slightly. 2001-04-22 19:52:41 +00:00
Gary Houston
66c73b7654 * net_db.c: remove bogus "close" declaration.
(inet_aton declaration, scm_inet_aton, scm_inet_ntoa,
	scm_inet_netof, scm_lnaof, scm_inet_makeaddr, INADDR_ANY etc.):
	moved to socket.c.
	* net_db.h: declarations moved too.

	* socket.c (scm_htonl, scm_ntohl): use uint32_t instead of unsigned
	long.
	(ipv6_net_to_num, ipv6_num_to_net): new static procedures.
	(VALIDATE_INET6): new macro.
	(scm_inet_pton, scm_inet_ntop): new procedures, implementing
	inet-pton and inet-ntop.
	(scm_fill_sockaddr): use VALIDATE_INET6 and ipv6_num_to_net.
	(scm_addr_vector): use ipv6_net_to_num.
2001-04-22 16:05:21 +00:00
Gary Houston
e1368a8d44 * socket.c (FLIP_NET_HOST_128): new macro.
(scm_fill_sockaddr): use new macro.
	(scm_addr_vector): completed IPv6 address support.  added const
	to the address parameter.
2001-04-21 19:10:15 +00:00
Gary Houston
5a525b8441 * socket.c (scm_fill_sockaddr): call htons for sin6_port.
Don't assign sin6_scope_id in structure unless HAVE_SIN6_SCOPE_ID
	is defined.
	(scm_addr_vector): use a switch instead of multiple if statements.
	Add support for IPv6 (incomplete) .
	MAX_ADDR_SIZE: increase to size of struct sockaddr_in if needed.
2001-04-20 19:22:47 +00:00
Gary Houston
3453619bd3 * some initial support for IPv6:
* socket.c (scm_fill_sockaddr): improve the argument validation.
	don't allocate memory until all args are checked.  instead of
	unconditional memset of soka, try setting sin_len to 0 if
	SIN_LEN is defined.  add support for AF_INET6.  define FUNC_NAME.
	(scm_socket, scm_connect): extend docstrings for IPv6.
	(scm_init_socket): intern AF_INET6 and PF_INET6.
2001-04-17 23:03:07 +00:00
Dirk Herrmann
e4b265d817 * Avoid redundant casting of argument numbers to char* and vice versa. 2001-04-10 07:57:05 +00:00
Martin Grabmüller
1e6808ea20 Correct, update, improve and clean up a lot of docstrings in order to make
the documentation much more consistent.
2001-04-03 13:19:05 +00:00
Keisuke Nishida
e0c08f17b1 Use SCM_LISTn instead of scm_listify. 2001-03-11 09:44:08 +00:00
Mikael Djurfeldt
e6e2e95aa5 * _scm.h: Removed #include <errno.h>.
* error.c, net_db.c, putenv.c, stime.c: Removed declaration of
errno variable (can be a macro on some systems, for example when
using linux libc with threads).

* error.c, filesys.c, gc.c, ioext.c, iselect.c, net_db.c, ports.c,
posix.c, print.c, putenv.c, scmsigs.c, script.c, simpos.c, smob.c,
socket.c, srcprop.c, stime.c, strop.c, unif.c, vports.c: Added
#include <errno.h> in these 20 out of 100 files.
2001-03-10 16:56:09 +00:00
Gary Houston
97d0e20b2e * socket.c: add a definition of SUN_LEN (from glibc) for when it's
not already defined.
2001-03-10 10:30:16 +00:00
Keisuke Nishida
783e777478 Remove #include <stdio.h>. Add #include <string.h>. 2001-03-09 23:33:41 +00:00
Gary Houston
439006bf6e * socket.c (scm_fill_sockaddr): don't allow buffer overflows when
taking an unexpectedly large filename for an AF_UNIX socket from
	bind/connect/sendto (thanks to Martin Grabmueller).

	* socket.c (scm_sock_fd_to_port, SCM_SOCK_FD_TO_PORT): removed the
	former and adjusted the latter.
	(scm_socket, scm_socketpair): cosmetic changes.
	(scm_getsockopt, scm_setsockopt): declare optlen as int, not
	size_t as socklen_t substitute.  don't restrict args/return values
	to INUM: allow full range of int or size_t.
	(scm_fill_sockaddr): check arguments before allocating memory, to
	avoid leakage.  use malloc, not scm_must_malloc.
	(scm_connect, scm_bind, scm_sendto): use int, not size_t as socklen_t
	substitute.  free the sockaddr structure before throwing an error.
	(scm_init_add_buffer): procedure removed, together with its static
	buffer scm_addr_buffer, which wouldn't be thread safe.  instead,
	define a macro MAX_ADDR_SIZE and declare the buffer where needed.
	(scm_accept, scm_getpeername, scm_getsockname, scm_recvfrom,
	scm_sendto): use a local buffer instead of scm_addr_buffer.
	adjust for new SCM_SOCK_FD_TO_PORT.  use int for address size,
	not size_t.
	(scm_recvfrom): set addr->sa_family to AF_UNSPEC before the recvfrom
	call to detect whether recvfrom could be bothered to set the address.
	(scm_init_socket): don't call scm_init_addr_buffer.
2001-03-04 23:34:16 +00:00
Keisuke Nishida
00ffa0e7d6 New functions: scm_c_make_vector, scm_c_make_hash_table. 2001-02-02 04:56:25 +00:00
Gary Houston
60d02d0914 * validate.h (SCM_VALIDATE_SUBSTRING_SPEC_COPY): new macro.
* ioext.c (scm_read_string_x_partial, scm_read_delimited_x),
	socket.c (scm_recvfrom): use the new macro, plus minor docstring
	changes.
	* ioext.c (scm_read_string_x_partial): don't crash if -1 is supplied
	for fdes.  if current input port is used, check that it's a file
	port.
2001-01-08 23:10:06 +00:00
Dirk Herrmann
34f0f2b8af * Deprecated macros SCM_ROCHARS and SCM_ROUCHARS. 2000-11-22 11:20:03 +00:00
Marius Vollmer
8dc9439fc6 * alist.c, arbiters.c, async.c, backtrace.c, boolean.c, chars.c,
continuations.c, debug-malloc.c, debug.c, dynl.c, dynwind.c,
environments.c, eq.c, error.c, eval.c, evalext.c, feature.c,
filesys.c, fluids.c, fports.c, gc.c, goops.c, guardians.c, hash.c,
hashtab.c, hooks.c, ioext.c, iselect.c, keywords.c, lang.c,
list.c, load.c, macros.c, modules.c, net_db.c, numbers.c,
objects.c, objprop.c, options.c, pairs.c, ports.c, posix.c,
print.c, procprop.c, procs.c, properties.c, ramap.c, random.c,
read.c, regex-posix.c, root.c, scmsigs.c, script.c, simpos.c,
socket.c, sort.c, srcprop.c, stackchk.c, stacks.c, stime.c,
strings.c, strop.c, strorder.c, strports.c, struct.c, symbols.c,
tag.c, threads.c, throw.c, unif.c, variable.c, vectors.c,
version.c, vports.c, weaks.c: Makes sure the snarfer output
inclusion is disabled when the snarfer is run on the file.  Thanks
to Lars J. Aas!

* Makefile.am: Install guile-procedures.txt in version-specific
directory to enable multiple installed guile versions.  Suggested
by Karl M. Hegbloom <karlheg@debian.org, patch by Matthias Koeppe.
2000-11-17 16:25:05 +00:00
Dirk Herrmann
a6d9e5abe5 * Change a couple of functions to accept either symbols or strings only.
* Get rid of remainig uses of SCM_LENGTH etc.
2000-10-30 11:42:26 +00:00
Dirk Herrmann
bfa974f0a4 * Replace a bunch of calls to SCM_LENGTH. 2000-10-09 14:37:36 +00:00
Dirk Herrmann
86c991c2a2 * Replaced SCM_CHARS with SCM_STRING_CHARS or SCM_SYMBOL_CHARS. 2000-09-22 17:17:55 +00:00
Neil Jerram
09831f943c * Docstring fixes. 2000-09-02 23:20:40 +00:00
Mikael Djurfeldt
2cf6d0146c * socket.c (scm_getsockopt): Changed type for `optlen' from int to
size_t.
(scm_accept, scm_getsockname, scm_getpeername, scm_recvfrom):
Ditto for `tmp_size'.
(scm_addr_buffer_size): Changed type from int to size_t.
2000-06-14 01:33:10 +00:00
Mikael Djurfeldt
f2c9fcb07e Updated copyrights 2000-06-12 12:28:24 +00:00
Mikael Djurfeldt
a059974535 * Makefile.am (DEFS): Added. automake adds -I options to DEFS,
and we don't want that.
(INCLUDES): Removed all -I options except for the root source
directory and the root build directory.

* *.*: Change includes so that they always use the "prefixes"
libguile/, qt/, guile-readline/, or libltdl/.
(Thanks to Tim Mooney.)
2000-04-21 14:16:44 +00:00
Michael Livshin
89e00824a0 * *.[hc]: add Emacs magic at the end of file, to ensure GNU
indentation style.
2000-03-19 19:01:16 +00:00
Dirk Herrmann
7ab3fdd51f Only include strings.h where it is actually needed. 2000-03-17 18:11:58 +00:00
Dirk Herrmann
003d1fd046 Only include vectors.h in those files, where it is actually needed. 2000-03-17 15:23:03 +00:00
Greg J. Badros
b6791b2e94 * error.h, error.c: Added `scm_wrong_type_arg_msg' to support
displaying the expected type.  Use SCM_LISTn in a couple places
instead of scm_cons-ing by hand.

* __scm.h: Added SCM_ASSERT_TYPE macro.

* validate.h, scm_validate.h: Added the former, as a renamed
version of the latter with SCM_ASSERT_TYPE used in
SCM_MAKE_VALIDATE (instead of just SCM_ASSERT)

* Makefile.am: Rename scm_validate.h to validate.h.

* *.c, *.h: Include validate.h, not scm_validate.h (old name's
prefix was superfluous).
2000-03-03 00:09:54 +00:00
Mikael Djurfeldt
b380b88547 * alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
   keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
   objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
   ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
   stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
   symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
   weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
Greg J. Badros
70d6375376 * dynl.c, error.c, eval.c, feature.c, filesys.c, fports.c, list.c, load.c,
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
2000-01-11 18:48:57 +00:00
Greg J. Badros
3b3b36ddb7 * *.[ch]: Whitespace changes -- added space after SCM_VALIDATE_*
macros and SCM_DEFINE macros to match GNU coding standards.
2000-01-05 19:25:37 +00:00
Greg J. Badros
a1ec69163d *.[ch]: Replace GUILE_PROC w/ SCM_DEFINE. 2000-01-05 19:05:23 +00:00
Greg J. Badros
47c6b75ea9 * *.[ch]: Replace SCM_VALIDATE_INT w/ SCM_VALIDATE_INUM for
better consistency with the names of other SCM_VALIDATE_ macros
and better conformance to guile naming policy.
2000-01-05 19:00:03 +00:00
Greg J. Badros
3093947745 * tags.h (SCM_CONSP, SCM_NCONSP): Define these in terms of
SCM_SLOPPY_CONSP and SCM_SLOPPY_NCONSP.  (SCM_CONSP) Define this
in terms of SCM_SLOPPY_NCONSP instead of repeating the
expression.

* symbols.h (SCM_SLOPPY_SUBSTRP, SCM_SUBSTRP): Added former, and
define latter in terms of sloppy variant.

* strings.h (SCM_SLOPPY_STRINGP, SCM_STRINGP): Added former, and
define latter in terms of sloppy variant.

* scm_validate.h (SCM_MAKE_VALIDATE): Added this macro to factor
out the commonality of the various basic SCM_VALIDATE_foop
macros. Use SCM_MAKE_VALIDATE macro where possible.  Fix
SCM_VALIDATE_INT_COPY to not use scm_num2ulong -- that does
coercion to an integer which is more advanced than desired and
SCM_NUM2ULONG provides that functionality.  Use SCM_ASSERT_RANGE
appropriately for the various _MIN, _MAX, _RANGE macros.  Drop
some superfluous "SCM_NIMP &&" where possible. Eliminate obsoleted
SCM_VALIDATE_NIMCONS (SCM_VALIDATE_CONS now does the NIMP test as
part of its SCM_CONSP test).

* socket.c, ports.c, pairs.c, list.c, lang.c, async.c: Use
SCM_VALIDATE_CONS, not obsoleted SCM_VALIDATE_NIMCONS.
1999-12-19 01:04:37 +00:00
Greg J. Badros
0c95b57d77 * coop-threads.c: Remove K&R function headers.
* 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.
1999-12-16 20:48:05 +00:00
Greg J. Badros
4079f87ed2 * Makefile.am: Fix ETAGS_ARGS to recognize GUILE_PROC,
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.
1999-12-13 03:40:23 +00:00
Greg J. Badros
717050c8d5 Remove leading whitespace before empty docstrings. 1999-12-13 00:44:10 +00:00
Greg J. Badros
1bbd0b849f * *.c: Pervasive software-engineering-motivated rewrite of
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.
1999-12-12 02:36:16 +00:00
Gary Houston
5c11cc9deb * configure.in: check for hstrerror.
* socket.c (scm_htons, scm_ntohs, scm_htonl, scm_ntohl): new
	functions for network data conversion.

	* numbers.c (scm_num2long, scm_num2longlong):
	throw out-of-range instead of wrong-type-arg if appropriate.
	(scm_iint2str): handle -2^31 correctly.
	(scm_num2long): handle -2^31 bignum correctly.
	(scm_num2long_long): rewrite the bigdig case: basically copied
	from scm_num2long.
	numbers.h: (SCM_BITSPERLONGLONG): deleted.

	* unif.c (rapr1): use sprintf instead of intprint for unsigned
	longs: intprint can't cope with large values.

	* numbers.c (scm_num2ulong): check more consistently that the
	input is not negative.  if it is, throw out-of-range instead of
	wrong-type-arg.

	* ramap.c (scm_array_fill_int): don't limit fill to INUM for
	uvect, ivect or llvect.
	Check that fill doesn't overflow short uniform array.

	* __scm.h: add another long to the definition of long_long and
	ulong_long.

	* unif.c (scm_raprin1): use 'l' instead of "long_long" in the
	print representation of llvect.  read can't handle more than
	one character.
	(scm_dimensions_to_uniform_array): make "fill" an optional argument
	instead of a rest argument.

	* tags.h (scm_tc7_llvect): wasn't defined anywhere, so use the free
	tag 29 for now.

	* __scm.h: don't mention LONGLONGS.

	* unif.c, numbers.c, eq.c, gc.c, print.c, eval.c, ramap.c:
	replace LONGLONGS with HAVE_LONG_LONGS as set by configure.

	* net_db.c (scm_inet_aton): throw errors using the misc-error key
	instead of system-error.  inet_aton doesn't set errno.
	system-error isn't right in gethost either, since it's throwing
	the value of h_errno instead of errno. so:
	(scm_host_not_found_key, scm_try_again_key,
	scm_no_recovery_key, scm_no_data_key): new error keys.
	(scm_resolv_error): new procedure, use the new keys.
	(scm_gethost): call scm_resolv_error not scm_syserror_msg.

	* error.c: (various): use scm_cons instead of scm_listify
	to build short lists.

	* boot-9.scm (read-hash-extend to set up arrays): add 'l' for
	long_long uniform vectors.

	* networking.scm (sethostent, setnetent, setprotoent, setservent):
	take an optional argument STAYOPEN.  default is #f.

	* readline.c (scm_init_readline): set rl_readline_name to Guile,
	to allow conditionals in  .inputrc.
1999-11-18 22:36:28 +00:00
Gary Houston
93a6b6f5a7 * socket.c (scm_fill_sockaddr): zero the address structure before
use, in case it has a sin_len field and the OS doesn't like random
	values (thanks to Bertrand Petit).
1999-11-04 20:04:18 +00:00
Jim Blandy
ee149d0368 * ioext.c (scm_do_read_line): Rewritten to use memchr to find the
newline.  A bit faster, and definitely hairier.
	(scm_read_line): Count newlines here instead.
	* strings.c (scm_take_str): New function.
	(scm_take0str): Reimplement in terms of scm_take_str.  * strings.h
	(scm_take_str): New declaration.  * ioext.c (scm_read_line): Use
	scm_take_str, to avoid copying the string.
	Add some simple-minded support for line buffered ports.
	* ports.h (SCM_BUFLINE): New flag for ports.
	* init.c (scm_init_standard_ports): Request line-buffering on
	the standard output port.
*	* ports.c (scm_mode_bits): Recognize 'l' as a request for line
	buffering.
	(scm_putc, scm_puts, scm_lfwrite): If the port is line-buffered,
	and there's a newline to be written, flush the port.
	* ports.c: (scm_lseek): clear buffers even if just reading current
	position.
	* fports.c (local_fclose): call local_fflush unconditionally.
	(various): don't use the scm_must... memory procs.
	* ports.h (scm_port): make read_pos a pointer to const.
	strports.c: take care of rw_active and rw_randow.
	fports.c: scm_fport_drain_input: removed.  do it all in ports.c.
	strports.c (scm_mkstrport): check that pos is reasonable.
	ioext.c (scm_ftell, scm_fseek): use lseek.
	(SCM_CLEAR_BUFFERS): macro deleted.
	ioext.c (redirect_port: use ptob fflush, read_flush.
	ports.h (scm_ptobfuns): add ftruncate.
	ports.c (scm_newptob): set ftruncate.
	adjust ptob tables.
*	ports.c (scm_ftruncate): new procedure.
	fports.c (local_ftrunate), strports.c (str_ftruncate): new procs.
	strports.c (st_seek, st_grow_port): new procs.
	fports.h (scm_port): change size types from int to off_t.
	ports.c (scm_init_ports): initialise the seek symbols here
	instead of in ioext.c.
	strports.c (scm_call_with_output_string): start with an empty
	string, so seek and ftruncate can be used.
	* ports.h (scm_ptobfuns): add a read_flush procedure which is the
	equivalent to fflush for the read buffer.
	* ports.c (scm_newptob): set read_flush.
	ports.c (void_port_ptob): set read_flush.
	fports.c (local_read_flush): new proc.  add to ptob.
	strport.c (st_read_flush): likewise.
	vport.c (sf_read_flush): likewise.
	fports.h (struct scm_fport): remove random member.  there's nothing
	left but fdes.  leaving it as a struct to allow for future changes.
	fports.c: replace usage of scm_fport::random with scm_port::rw_random.
	ports.c: (scm_putc, scm_puts, scm_lfwrite): call the read_flush
	ptob proc if the read buffer is filled.
	* ports.h (scm_port): add a rw_random member and replace
	reading and writing members with rw_active member.
	SCM_PORT_READ/SCM_PORT_WRITE: new values.
	* ports.h (struct scm_port_table): add writing and reading members
	to replace write_needs_seek: it isn't good enough for non-fports.
	ports.c, ioext.c, fports.c: corresponding changes.
	(struct scm_port_table): give it a typedef and rename to scm_port.
	ports.c, fports.c, strports.c, vports.c, ioext.c, ports.h:
	corresponding changes.
	* ports.c (scm_newptob): bugfix: set seek member.
*	* (scm_lseek): new procedure, using code from ioext.c:scm_fseek
	and generalised to all port types.
	* scmsigs.c (scm_init_scmsigs): set the SA_RESTART flag for all
	signals (it was only being done for handlers installed from Scheme).
	Otherwise (for example) SIGSTOP followed by SIGCONT on an interpreter
	waiting for input caused an EINTR error from read.
	* ports.h (struct scm_port_table): make all the char members
	unsigned, so they convert to int without becoming negative if large.
	* fports.c (scm_fdes_wait_for_input): forgot to check compilation
	with threads enabled.  rename this procedure to
	fport_wait_for_input and take a port instead of a fdes.
	use scm_fport_input_waiting_p instead of scm_fdes_waiting_p.
	* readline.c (scm_readline): Applied a patch from Greg Harvey to
	get readline support working again: use fdopen to get FILE objects.
	* gc.c (scm_init_storage): install an atexit proc to flush the
	ports.
	(cleanup): the new proc.  it sets a global variable which can be
	checked by the ptob flush procs to avoid trying to throw
	exceptions during exit.  not very pleasant but it seems more reliable.
	* fports.c (local_fflush): check terminating variable and if set
	don't throw exception.
	* CHECKME: that the atexit proc is installed if unexec used.
	* throw.c (scm_handle_by_message): don't flush all ports here.
	it still causes bus errors.
	* fports.h (SCM_FPORT_CLEAR_BUFFERS): rename to SCM_CLEAR_BUFFERS
	and move to ioext.c.
	* fports.c (scm_fdes_waiting_p): merged into fport_input_waiting_p.
	* ports.c (scm_char_ready_p): check the port buffer and call the
	ptob entry if needed.
	* ports.h (scm_ptobfuns): input_waiting_p added.  change all the
	ptob initialisers.  use it in char-ready
	* ioext.c (scm_do_read_line): moved from ports.c.  make it static.
	* vports.c (sfflush): modified to write a char (since softports
	currently use shortbuf.)
	* fports.c (scm_standard_stream_to_port): moved to init.c and
	made static.
	* init.c (scm_init_standard_ports): make stdout and stderr
	unbuffered if connected to a terminal.  with stdio they
	were line-buffered by default.
	* ports.h (scm_ptobfuns): change fflush return to void.
	change flush proc definitions.
	* strports.c (scm_call_with_output_string): get size from
	buffer instead of port stream.
	(scm_strprint_obj): likewise.
	(st_flush): new proc.
	* ports.h (struct scm_port_table): added write_end member,
	as an optimisation.  set it where write_buf_size is set.
	* ports.h (struct scm_port_table): change stream from void *
	back to SCM.  SCM presumably must be large enough to hold a
	pointer (and probably vice versa but who knows.)
	(SCM_SSTREAM): deleted.  change users back to SCM_STREAM.
	(scm_puts): rewritten
	* fports.c (local_ffwrite, local_fputs): removed.
	* strports.c (stputc, stputs, stwrite): dyked out (FIXME)
	* vports.c (sfputc, sfputs, sfwrite) likewise.
	* ports.c (write_void_port, puts_void_port): removed.
	(putc_void_port, getc_void_port, fgets_void_port): likewise.
	* ports.c (scm_lfwrite): rewritten using fport.c version.
	* fports.c (local_fputc): deleted.
	* ports.c (scm_add_to_port_table): initialise write_needs_seek.
	* ports.h (scm_ptobfuns): add seek function pointer.
	* fports.c: set it to local_seek, new procedure.
	* fports.h (SCM_MAYBE_DRAIN_INPUT): moved to ports.c.
	use ptob for seek. take ptob instead of fport arg.
	* ports.h (struct scm_port_table): new member write_needs_seek,
	replaces reading member in fport struct.
	* vports.c (sfgetc): store the getted char into the buffer.
	rename to sf_fill_buffer and install it for fill-buffer in ptob.
	the Scheme interface is still a	procedure that gets a char.
	(scm_make_soft_port): set up the port buffer (shortbuf).
	* fports.c (local_fgetc, local_fgets): deleted.
	* strports.c (stgetc): likewise.
	* ports.c: scm_generic_fgets: likewise.
	* ports.h (scm_ptobfuns): add fill_buffer.
	* ports.c (scm_newptob): assign it.
	* strports.c (scm_mkstrport): set up the buffer.
	put just the string into the stream, not cons (pos stream).
	(stfill_buffer): new proc.
	* ports.h: fport buffer moved into port table: to be
	used for all port types.
	* throw.c (scm_handle_by_message): flush ports at exit.
	* socket.c (scm_sock_fd_to_port): use scm_fdes_to_port.
	(scm_getsockopt, scm_setsockopt, scm_shutdown, scm_connect,
	scm_bind, scm_listen, scm_accept, scm_getsockname,
	scm_getpeername, scm_recv, scm_send, scm_recvfrom,
	scm_sendto,
	use SCM_FPORT_FDES.  use SCM_OPFPORTP not SCM_FPORTP.
	* posix.c (scm_getgroups): use SCM_ALLOW/DEFER_INTS.
	(scm_ttyname): use SCM_FPORT_FDES.
	(scm_tcgetpgrp, scm_tcsetpgrp): likewise.
	* ioext.c (scm_isatty_p): use SCM_FPORT_FDES.
	(scm_fdes_to_ports): modified.
	(scm_fdopen): use scm_fdes_to_port.
	* ports.c (scm_init_ports): don't try to flush ports using
	atexit().  it's too late, errors will cause SEGV.
	* fports.c (scm_fport_buffer_add): new procedure.
	* fports.h (SCM_FDES_RANDOM_P): new macro.  use it in
	scm_fdes_to_port and scm_redirect_port.
	* ioext.c (scm_redirect_port): use setvbuf to set buffers in the
	new port.  reset fp->random.
	* 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.
	vports.c (various places): use SCM_SSTREAM.
	strports.c: likewise.
	* gdbint.c: likewise.
	* ports.h (SCM_SSTREAM): new macro.
	* fports.c (scm_input_waiting_p): use scm_return_first, since port
	may be removed from the stack by the tail call to scm_fdes_waiting_p.
	* fports.h (SCM_CLEAR_BUFFERS): new macro.
	* ports.c (scm_force_output): call scm_fflush.
	* print.c (scm_newline): don't check errno for EPIPE (it wouldn't
*	reach this point.)  don't flush port (if scm_cur_outp).
	* fports.h (SCM_FPORT_FDES): new macro.
	* vports.c (sfflush): don't need to set errno.
	* ports.c: install scm_flush_all_ports to be run on exit.
	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.
	* scmsigs.c (take_signal): save and restore errno while this
	proc runs.
	*fports.c (print_pipe_port, local_pclose, scm_pipob): deleted.
*	open-pipe, close-pipe are emulated in (ice-9 popen)
	ports.c (scm_ports_prehistory): don't init scm_pipob.
	ports.h (scm_tc16_pipe): deleted.
	posix.c (scm_open_pipe, scm_close_pipe): deleted.
	* ioext.c (scm_primitive_move_to_fdes): use fport.
	* fport.c (scm_fport_fill_buffer): flush write buffer if needed.
	change arg type from scm_fport to SCM port.
	fport.h (SCM_SETFDES): removed.
	(SCM_MAYBE_DRAIN_INPUT): new macro.
	* ioext.c (scm_dup_to_fdes): use SCM_FSTREAM.
	(scm_ftell): always use lseek and account for the buffer.
	(scm_fileno): use fport buffer.
	(scm_fseek): clear fport buffers.  always use lseek.
	* posix.c (scm_pipe): use fport buffer.
	* unif.c: include fports.h instead of genio.h.
	* fports.c (scm_fdes_wait_for_input, scm_fport_fill_buffer): new
	procedures.
	(local_fgetc): use them.
	(local_ffwrite): use buffer.
	(local_fgets): use buffer.
	(scm_setbuf0): deleted.
	(scm_setvbuf): set the buffer.
	(scm_setfileno): deleted.
	(scm_evict_ports): set fdes directly.
*	(scm_freopen): deleted.  doesn't seem useful in Guile.
	(scm_stdio_to_port): deleted.
	fports.h (struct scm_fport): add shortbuf member to avoid separate
	code for unbuffered ports.
	(SCM_FPORTP, SCM_OPFPORTP, SCM_OPINFPORTP, SCM_OPOUTFPORTP): moved
	from ports.h.
	* genio.c, genio.h: move contents into ports.c, ports.h.  The
	division wasn't useful.
	* fports.c, fports.h (scm_fport_drain_input): new procedure.
	* ports.c (scm_drain_input): call scm_fport_drain_input.
	* scm_fdes_waiting_p: new procedure.
	* fports.c (scm_fdes_to_port): allocate read and/or write buffers.
	(scm_input_waiting_p): check the buffer.
	(local_fgetc, local_fflush, local_fputc): likewise.
	* fports.h (scm_fport): read/write_buf,_pos,_buf_end,,_buf_size:
	new members.
	* init.c (scm_init_standard_ports): pass fdes instead of FILE *.
*	* 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.
1999-06-09 12:19:58 +00:00
Jim Blandy
3eeba8d4f5 * chars.c (scm_lowers, scm_uppers, scm_charnames, scm_charnums),
eval.c (s_expression, s_test, s_body, s_bindings, s_variable,
s_clauses, s_formals): Variables now const.
* eval.c (promsmob): Now const.
* macros.c (macrosmob): Now const.
* smob.c (scm_newsmob): Smobfuns argument now points to const.
(freecell, flob, bigob): Now const.
* dynl.c (scm_make_argv_from_stringlist, scm_coerce_rostring),
error.c (scm_error, scm_syserror, scm_syserror_msg,
scm_num_overflow, scm_out_of_range, scm_wrong_type_arg,
scm_memory_error, scm_misc_error, scm_wta), macros.c
(scm_make_synt), feature.c (scm_add_feature), filesys.c
(scm_input_waiting_p), gc.c (scm_gc_start, scm_igc,
scm_must_malloc, scm_must_realloc), gsubr.c (scm_make_gsubr),
numbers.c (scm_num2dbl, scm_two_doubles, scm_num2long,
scm_num2long_long, scm_num2ulong),
options.c (scm_options), posix.c (scm_convert_exec_args,
environ_list_to_c), procs.c (scm_make_subr_opt, scm_make_subr),
ramap.c (scm_ramapc), read.c (scm_flush_ws), socket.c
(scm_sock_fd_to_port, scm_fill_sockaddr, scm_addr_vector), stime.c
(setzone, restorezone, bdtime2c), strop.c (scm_i_index),
strports.c (scm_mkstrport), symbols.c (scm_intern_obarray_soft,
scm_intern_obarray, scm_intern, scm_intern0,
scm_sysintern0_no_module_lookup, scm_sysintern, scm_sysintern0,
scm_symbol_value0), unif.c (scm_aind, scm_shap2ra): Argument
indicating calling subr, error message text, reason for error,
symbol name or feature name are now pointer to const.
* snarf.h (SCM_PROC, SCM_PROC1): String variables are now const.
* procs.c (scm_init_iprocs): iproc argument now points to const.
* pairs.c (cxrs): Now const.
* chars.h, error.h, feature.h, filesys.h, gc.h, gsubr.h, macros.h,
numbers.h, options.h, procs.h, ramap.h, read.h, smob.h,
strports.h, symbols.h, unif.h: Update variable declarations and
function prototypes for above changes.
* dynl.c, dynl-dld.c, dynl-dl.c, dynl-shl.c (sysdep_dynl_link,
sysdep_dynl_unlink, sysdep_dynl_func): Arguments FNAME, SUBR, and
SYMB now point to const.
1999-02-06 12:31:04 +00:00
Jim Blandy
7dc6e7547a * __scm.h, alist.c, async.c, async.h, backtrace.h, chars.c,
continuations.c, debug.c, debug.h, dynl-dl.c, dynl.c, dynl.h,
dynwind.c, dynwind.h, eq.c, error.c, error.h, eval.c, eval.h,
feature.c, filesys.c, filesys.h, fports.c, fports.h, gc.c, gc.h,
genio.c, genio.h, gh.h, gh_data.c, gsubr.c, gsubr.h, hash.c,
hashtab.c, init.c, init.h, ioext.c, ioext.h, kw.c, libguile.h,
list.c, list.h, load.c, load.h, mallocs.c, markers.c,
mit-pthreads.c, net_db.c, numbers.c, numbers.h, options.c,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, regex-posix.c,
regex-posix.h, root.c, root.h, scmsigs.c, scmsigs.h, script.c,
script.h, simpos.c, simpos.h, smob.c, smob.h, snarf.h, socket.c,
srcprop.c, stackchk.c, stackchk.h, stacks.c, stime.c, stime.h,
strings.c, strings.h, strports.c, struct.c, struct.h, symbols.c,
symbols.h, tags.h, threads.c, throw.h, unif.c, variable.c,
vectors.c, vectors.h, version.h, vports.c, weaks.c: Update
copyright years.
1998-10-19 21:36:50 +00:00
Jim Blandy
d9803e92ba Don't use local_fgets on sockets; ftell doesn't work on sockets.
(Thanks to Jorgen "forcer" Schaefer.)
* ports.h (SCM_NOFTELL): New flag.
* fports.c (local_fgets): If it's set, use the generic fgets.
* socket.c (scm_socket): Set SCM_NOFTELL on the ports we produce.
1998-10-17 18:10:30 +00:00
Jim Blandy
bc45012d8f Centralize the creation of port objects based on stdio FILE * in
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.
1998-10-09 12:46:31 +00:00
Mikael Djurfeldt
a8741caa54 * eval.c, filesys.c, fluids.c, gc.c, gh_data.c, init.c, kw.c,
net_db.c, posix.c, print.c, regex-posix.c, scmsigs.c, socket.c,
stime.c, symbols.c, unif.c, vectors.c, weaks.c: Removed third
argument in call to scm_make_vector.
1998-07-12 00:10:02 +00:00