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

492 commits

Author SHA1 Message Date
Greg J. Badros
b450f07086 * arbiters.c, eq.c, gc.c, guardians.c, list.c, ports.c, print.c,
regex-posix.c, scmsigs.c, stime.c, strings.c, variable.c, stime.c,
strings.c, variable.c:  Added lots of documentation, cleaned up
some existing documentation.  Occasionally changed formal params
to match docs.  Also folded an #ifdef into the inners of a
primitive instead of having two copies of the primitive
(`get-internal-real-time', from stime.c)
2000-02-14 03:13:19 +00:00
Greg J. Badros
bfc46627ce * ports.c: Doc patches from Richard Kim. Pasted from MIT Scheme.
Thanks Richard!
2000-02-08 21:59:19 +00:00
Gary Houston
bd9e24b301 * strings.h: don't use SCM_P. don't include <string.h>.
* error.c, gh_data.c, ports.c, script.c, strop.c: include <string.h>.

	* strings.c (scm_string_ref): make the 2nd argument compulsory.
	previously it defaulted to zero for no good reason that I can see.
	use a local variable for SCM_INUM (k).  replace
	SCM_VALIDATE_INUM_DEF with SCM_VALIDATE_INUM_COPY.

	(scm_makfromstr): cosmetic changes.

	(scm_string): Accept only chars in the list, not strings, for
	conformance to R5RS (particularly for list->string, which is
	supposed to be the inverse of string->list.)  remove
	SCM_DEFER_INTS/SCM_ALLOW_INTS, which is unnecessary since
	scm_makstr handles the cell allocation.  when reporting wrong-type
	arg, don't report the position as 1.

	* posix.c (scm_init_posix): intern PIPE_BUF if it's defined.

	* boot-9.scm (find-and-link-dynamic-module): pass strings, not symbols,
	to string-append.
2000-01-31 18:29:56 +00:00
Mikael Djurfeldt
a3c8b9fce9 * strports.c (st_end_input): Inserted parenthesis to get operator
grouping correct.

* fports.c, list.c, numbers.c, ports.c, stime.c, symbols.c,
filesys.c, posix.c: Converted docstrings to ANSI C format and
escaped " occurring inside string literals.
2000-01-18 14:13:31 +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
c1bfcf602b * scm_validate.h: Added SCM_NUM2LONG_DEF macro. Make
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.
2000-01-12 01:51:18 +00:00
Greg J. Badros
8aa011a12c * fports.c, ports.c, ports.h, strports.c, vports.c: Make write
port function take const void*, not void*.
2000-01-11 19:32:10 +00:00
Greg J. Badros
9a8351bc15 * scm_validate.h, chars.c, ports.c, print.c, read.c, strings.c,
strop.c: Use SCM_VALIDATE_ICHR, SCM_VALIDATE_ICHR_COPY instead of
SCM_VALIDATE_CHAR, SCM_VALIDATE_CHAR_COPY.  Change made for
consistency with the other macros dealing with immediate
characters.  (Similar to INT -> INUM change a week or so ago).
2000-01-11 19:19:59 +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
cdc9576725 * ports.c (s_scm_close_all_ports_except): Use SCM_ARG1 in a
SCM_VALIDATE instead of 1 to avoid a check on the argument (since
it's not the actual name of the formal).
2000-01-05 18:51:17 +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
cfaba30ebd * tags.h (SCM_ECONSP, SCM_NECONSP): Fix these macros to have the
SCM_NIMP test integrated into an || clause that I'd missed before
and was causing a segfault in the regression tests.

* symbols.h (SCM_ROUCHARS): Make cast be to (unsigned char *), not
(char *);  fixes a problem reported by the regression test
ports.test.

* ports.c: Fixed a couple of arg/number mismatches in
SCM_VALIDATE_ macros.

Now passes the (not-comprehensive) guile-modules test-suite again!
1999-12-17 20:11:34 +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
Mikael Djurfeldt
5623a9b459 * guile-doc-snarf.awk: Removed.
* guile-doc-snarf.awk.in: Added.

* ports.c (s_scm_pt_member): Fixed validation.

* guile-doc-snarf.in (filename): Use basename in order to strip
away path.

* debug.c (scm_make_iloc, s_scm_proc_to_mem): Added missing
semicolon.
(scm_memcons, scm_memcons, mem_to_proc): Renamed function name
strings to new form.

* backtrace.c (set_print_params_x): Fixed GUILE_PROC macro.

* tags.h (SCM_UNBOUND): New iflag which is needed for some time to
mark the unboundness of a GOOPS slot.  (Added now in order to
correct a oversight.  Should probably be removed again and
replaced with SCM_UNDEFINED when the corresponding code in GOOPS
is rewritten.)

* print.c (scm_isymnames): Added printed representation for
SCM_UNBOUND.

* eval.c (SCM_CEVAL): Bugfix: Added check for unbound slot in
SCM_IM_SLOT_REF.
1999-12-14 17:08:25 +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
60d0643dbf * ports.c (scm_port_closed_p): new procedure, implements
"port-closed?" suggested by Bernard Urban.
	ports.h: added prototype, removed the SCM_P macros.
1999-12-04 22:59:10 +00:00
Gary Houston
7dcb364d3b * Move the responsibility for resetting port buffers from the
caller of the ptob seek procedure to the implementation.  This
	gives more control in general to the ptob seek: in particular the
	change of 1999-10-20 can be made to work without breaking seek on
	string ports.  There's a comment in NEWS about upgrading port
	types.

	* ports.c (scm_seek): don't reset the port buffers here.

	* fports.c (fport_seek): reset the buffers, except for the
	0 SEEK_CUR case.

	* strports.c (st_end_input): (bug fix): decrement pt->read_pos by
	offset.  check that it's not less than read_buf.
	(st_seek): reset the buffers first, unless it's the 0 SEEK_CUR
	case and currently reading.
1999-10-24 11:25:31 +00:00
Gary Houston
e9c66ab079 * ports.c (scm_seek): Add a special case for SEEK_CUR, offset 0,
so that unread chars are not needlessly discarded.  (thanks to
	Roland Orre).
1999-10-20 21:03:09 +00:00
Gary Houston
0de97b83c0 * fports.c (scm_fdes_to_port): always set rw_random if the fdes is
random access.  rw_active needs to be maintained even for single
	directional ports, otherwise scm_seek and probably other things are
	broken.  (thanks to Roland Orre).

	* strports.c (scm_mkstrport): set rw_random to 1 unconditionally.

	* ports.c (scm_add_to_port_table): initialise rw_random to 0.

	* ports.h (scm_port): change the comments on rw_random and rw_active.
1999-10-18 20:49:29 +00:00
Jim Blandy
4cc81ec6ca * read.c (scm_read): Don't assume that scm_cur_inp is always open.
* ports.c (scm_read_char): Same.
* ioext.c (scm_read_line): Same.
(Thanks to Bernard Urban.)
1999-09-20 23:34:57 +00:00
Jim Blandy
aa97ff6036 * gh_data.c (gh_set_substr): Revert change of 1999-08-29; bcopy is
not a correct substitute for memmove, because it doesn't handle
overlapping source and destination areas on many platforms.
Overlaps are the primary reason to use memmove in the first place.
* ports.c (scm_ungetc): Same.
* strop.c (scm_substring_move_x): Same.
1999-08-30 07:02:25 +00:00
Mikael Djurfeldt
a284e29725 * gh_data.c, ports.c, strop.c: Alternatively use bcopy if memmove
isn't present.  (Thanks to suzukis@file.phys.tohoku.ac.jp.)

* ports.c: Use ANSI C prototypes in definitions.  (Thanks to
Bernard Urban.)
1999-08-29 18:04:28 +00:00
Gary Houston
6e2e75db52 1999-08-29 Gary Houston <ghouston@easynet.co.uk>
* ports.c (scm_ungetc): bugfix: if putback_buf is NULL
	don't allocate zero bytes.
1999-08-29 16:50:40 +00:00
Mikael Djurfeldt
4a94d8ca0b * ports.c (scm_output_port_p): Bugfix: Coerce output port before
testing (otherwise the port-print-state trick won't be transparent
to the user; one example where this caused problems was in the
(ice-9 format) module).
1999-08-24 02:11:17 +00:00
Jim Blandy
61e452baa7 * ports.h (enum scm_port_rw_active): New enum, containing
SCM_PORT_READ, SCM_PORT_WRITE, and SCM_PORT_NEITHER (instead of
zero).  The debugger knows about enums, but doesn't know about
#defines.
(typedef scm_port): Declare rw_active member to be an enum
scm_port_rw_active.
* fports.c (fport_flush, fport_end_input): Use SCM_PORT_NEITHER
instead of zero.
* ports.c (scm_add_to_port_table): Same.
* strports.c (st_flush, st_end_input): Same.
1999-08-20 02:44:14 +00:00
Gary Houston
c94577b445 1999-08-12 Gary Houston <ghouston@easynet.co.uk>
* ports.c (scm_seek): one more: was scm_lseek.  Also changed the
	Scheme name from lseek to seek, but lseek was added recently so
	it shouldn't be a big problem.
	* ports.c, gdbint.c, ioext.c: changed callers.
1999-08-12 18:58:55 +00:00
Gary Houston
affc96b533 1999-08-11 Gary Houston <ghouston@easynet.co.uk>
* 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.
1999-08-11 18:35:42 +00:00
Gary Houston
265e6a4d28 1999-08-04 Gary Houston <ghouston@easynet.co.uk>
* ports.c (scm_putc, scm_puts),
	* unif.c (scm_uniform_array_write): use scm_lfwrite.
	* ports.c (scm_putc): change type of first argument from int to	char.
1999-08-04 18:15:31 +00:00
Gary Houston
31703ab8c6 * ports.h (scm_ptob_descriptor): include a write procedure again.
it's more efficient for unbuffered fports (e.g., sockets.)

	* ports.c (scm_puts): use ptob->write.
	* vports.c (scm_make_sfptob): set write proc in ptob.
	* strports.c (scm_make_stptob): set write proc in ptob.
	* ports.c (write_void_port): new procedure.
	* vports.c (sf_write): new procedure.
	* ports.c (scm_lfwrite): use ptob->write.
	* strports.c (st_write): new procedure.
	* fports.c (fport_write): new procedure.
	(scm_make_fptob): set write in ptob to fport_write.
	* ports.h: prototype for scm_set_port_write.
	* ports.c (scm_make_port_type): initialise ptob write procedure.
	(scm_set_port_write): new proc.
1999-08-03 21:09:49 +00:00
Jim Blandy
ae4c401660 * ports.c (scm_char_ready_p): Don't try to find PORT's ptab entry
until we've verified that it is actually a port.  (Thanks to
Lorentey Karoly.)
1999-08-01 08:07:40 +00:00
Gary Houston
1b9c3daec9 1999-07-25 Gary Houston <ghouston@easynet.co.uk>
* ports.c (scm_putc): fix line-buffering.

(init.c: remove an obsolete comment).
1999-07-25 17:45:01 +00:00
Mikael Djurfeldt
6c747373c5 * ports.c, ports.h, fports.c, strports.c, vports.c: Renamed
scm_set_ptob_XXX --> scm_set_port_XXX.
1999-07-25 12:21:03 +00:00
Mikael Djurfeldt
f12733c9d4 * ports.c, ports.h (scm_make_port_type): New interface for
creation of port types (replaces scm_newptob).  Just as for the
smobs, we need to separate the internal representation of smob
types from the interface, so that we easily can add new fields and
rearrange things without caring about backward compatibility.
This change was forced by the need in GOOPS to create classes
representing port types.
(scm_set_ptob_mark, scm_set_ptob_free, scm_set_ptob_print,
scm_set_ptob_equalp, scm_set_ptob_flush_input, scm_set_ptob_close,
scm_set_ptob_seek, scm_set_ptob_truncate,
scm_set_ptob_input_waiting_p): New setters.
(scm_newptob): Rewritten to use scm_make_port_type.  For backward
compatibility.
(scm_ptobs): Changed type scm_ptobfuns --> scm_ptob_descriptor.
(scm_prinport): Removed.
(scm_port_print): Added.
(scm_print_port_mode): Added.
(void_port_ptob, print_void_port, close_void_port, noop0):
Removed.  Removed #include "genio.h" Added #include "objects.h",
#include "smobs.h"
1999-07-24 23:10:13 +00:00
Gary Houston
69bc9ff335 1999-07-24 Gary Houston <ghouston@easynet.co.uk>
* 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.
1999-07-24 19:52:13 +00:00
Gary Houston
5c070ca7fd 1999-07-14 Gary Houston <ghouston@easynet.co.uk>
* unif.c (scm_uniform_array_read_x), ports.c (scm_getc): increment
	read_pos after scm_fill_buffer.
	* ioext.c (scm_do_read_line): simplify by ignoring the fill_buffer
	return char.
	* vports.c (sf_fill_buffer), strports.c (stfill_buffer),
	fports.c (fport_fill_buffer): implement the interface change.
	* ports.c (scm_fill_buffer): interface change: no longer increments
	read_pos past the character that's returned.  it seems clearer to
	leave it to the caller to decide what to do (thanks Jim).
	* vports.c (sf_fill_buffer): put the read char into the buffer
	as well as returning it.
	* ports.c (scm_grow_port_cbuf): residue of this deleted procedure
	deleted.
1999-07-14 13:55:01 +00:00
Gary Houston
3fe6190f46 1999-07-13 Gary Houston <ghouston@easynet.co.uk>
* strports.c (scm_strprint_obj): simplify.  start with initial
	buffer size of 0.
	(st_seek): don't allow string to be extended if seeking past
	the end of a read-only port.
1999-07-12  Gary Houston  <ghouston@easynet.co.uk>
	* strports.c (st_seek): change the resize checks.
	* ports.c (scm_ftruncate): throw error if offset works out negative.
	* strports.c (st_flush): increase string size in blocks of
	SCM_WRITE_BLOCK instead of 1. set read_end to read_pos if
	it's greater and reset read_buf_size.
	(scm_mkstrport): set rw_randow if only writing, since read_buf needs
	to be maintained for output ports too (it holds the written
	part of the string, while write_buf may have unwritten buffer
	chars.)
	(st_truncate): rewritten.
	(top of file): added a few notes.
1999-07-06  Gary Houston  <ghouston@easynet.co.uk>
	* strports.c (st_grow_port): set pt->read_pos.  set
	pt->read_buf_size one less than pt->write_buf_size if there's
	an unwritten char at the end of the string.  similarly for
	pt->read_end.
	(st_resize_port): renamed from st_grow_port.
	(st_seek): simplify by assuming that pt->write_pos == pt->read_pos.
	seek from read_end instead of write_end for SEEK_END.
	(st_ftruncate): calculate current length using readbuf, not write
	buf.
	(scm_strport_to_string): use read_buf_size for length.
	(stfill_buffer): don't re-initialise the readbuf.
1999-07-05  Gary Houston  <ghouston@easynet.co.uk>
	* strports.c (scm_strport_to_string): new procedure.
	(scm_call_with_output_string, scm_strprint_obj): use
	scm_strport_to_string.
	used SCM_INUM0 instead of SCM_MAKINUM (0) in a few places.
1999-07-13 11:06:18 +00:00
Gary Houston
283a1a0e77 1999-07-04 Gary Houston <ghouston@easynet.co.uk>
* unif.c (scm_uniform_array_write): likewise.
	* ioext.c (scm_redirect_port): likewise.
	* ports.c (scm_putc): call scm_read_flush.
	(scm_puts): likewise.
	(scm_lfwrite): likewise.
	(scm_lseek): likewise.
	(scm_ftruncate): likewise.
	* ports.c (scm_fill_buffer): don't take pt argument.  change callers.
	(read_flush_void_port): new proc, for void port ptob.
	* vports.c (sf_read_flush): likewise.
	* strports.c (st_read_flush): take offset arg.
	* fports.c (local_read_flush): use offset, don't reset putback
	buffer here.
	* ports.h (scm_ptobfuns): let read_flush take an offset argument,
	which is the number of chars from the putback buffer.
	* ports.c (scm_read_flush): new procedure, resets the putback
	buffer before calling the ptob routine.
1999-07-04 11:50:54 +00:00
Gary Houston
6c9514275b 1999-07-04 Gary Houston <ghouston@easynet.co.uk>
* strports.c (scm_strprint_obj): bug fix: get pt from the port,
	not from the parameter obj.  (Thanks to Eric Moore.)
	* ports.h: SCM_CRDY, SCM_CUC, SCM_CRDYP, SCM_SETRDY, SCM_CUNGET,
	SCM_CGETUN, SCM_CLRDY, SCM_TRY_CLRDY, SCM_N_READY_CHARS: deleted.
	* strings.c (scm_make_string): throw error if 2nd arg isn't
	a char.
	* unif.c (scm_uniform_array_read_x): fix reading from a port.
	allow non-fports.
	(scm_uniform_array_write): likewise.
1999-06-29  Gary Houston  <ghouston@easynet.co.uk>
	* ports.c (scm_drain_input): rewritten.
	* fports.c (local_fclose): check putback_buf.
	(local_read_flush): likewise.
	* ports.c (scm_remove_from_port_table): maybe free putback_buf.
	* ports.h (scm_port): replace cbuf/cbufend/cp with putback_buf/
	putback_buf_size.
	(SCM_INITIAL_PUTBACK_BUF_SIZE): renamed from SCM_INITIAL_CBUF_SIZE.
	* ports.c (scm_grow_port_cbuf): deleted.
	(scm_add_to_port_table): initialise putback_buf to 0.  remove cbuf
	stuff.
	(scm_char_ready_p): check putback_buf
	(scm_fill_buffer): likewise.
	(scm_ungetc): rewritten.
1999-06-27  Gary Houston  <ghouston@easynet.co.uk>
	* fports.c (local_fclose): account for push-back buffer.
	* ports.c (scm_char_ready_p): check the push-back buffer in
	a new way.
	* ioext.c (scm_do_read_line): remove the extra code to handle
	the push-back buffer.
	* ports.c (scm_getc): don't use SCM_CRDYP etc.
	* ioext.c (scm_do_read_line): call scm_fill_buffer.
	* ports.c (scm_ungetc): don't call SCM_CUNGET.  reset the
	read buffer pointers.
	scm_fill_buffer: new procedure.
	(scm_getc): call scm_fill_buffer.
	* ports.h (struct scm_port): saved_read_buf, saved_read_pos,
	saved_read_end: new fields.
1999-07-04  Gary Houston  <ghouston@easynet.co.uk>
	* configure.in: don't check for ways to violate stdio abstraction.
1999-07-04 11:02:21 +00:00
Jim Blandy
cb8dfa3f67 * fports.c (local_seek): Signal an error if the seek fails.
* ports.c (scm_lseek): Don't check return value of port's seek
function; it's its job to signal an error if there's a problem.
1999-06-14 16:29:48 +00:00
Jim Blandy
840ae05d91 * fports.c, fports.h, gc.c, gdbint.c, ioext.c, ports.c, ports.h,
scmsigs.c, strports.c, vports.c: Install the sources which
actually correspond to the changes described below.  I got the
ChangeLog entries and the patch from two different places...
1999-06-12 17:26:22 +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
Mikael Djurfeldt
944f4c7067 * eval.c, fports.c, libguile.h, ports.c: Removed #include
"markers.h".
1999-05-23 10:02:31 +00:00
Mikael Djurfeldt
547e65b5df #include "keywords.h" 1999-03-14 18:51:45 +00:00
Mikael Djurfeldt
d1c90db5d6 * ports.c (scm_unread_string): Bugfixes: Check for SCM_STRINGP,
not SCM_ROSTRINGP; use SCM_ROUCHARS instead of SCM_UCHARS.
1998-11-06 18:15:12 +00:00
Mikael Djurfeldt
ee1e7e13b3 * ports.h, ports.c (scm_unread_string): New procedure.
(scm_grow_port_cbuf): New function.
* ports.c (scm_add_to_port_table, scm_remove_from_port_table):
Handle new fields.
(scm_generic_fgets), fports.c (local_fgets): Use a loop
to read unread characters.  Use SCM_TRY_CLRDY instead of
SCM_CLRDY.
1998-10-30 08:23:13 +00:00