| Commit message (Expand) | Author | Age | Files | Lines |
* | Register R6RS port and bytevector internals early...* libguile/bytevectors.c (sym_big, sym_little): Rename from scm_sym_big
and scm_sym_little, and don't use the snarf mechanism as we need to
initialize this value eagerly in case the C API is used before the
Scheme module is loaded.
(scm_bootstrap_bytevectors): Initialize the endianness symbols here.
* libguile/r6rs-ports.c (scm_register_r6rs_ports): Register the R6RS
port kinds here, for the same reason.
| Andy Wingo | 2017-02-28 | 1 | -6/+6 |
* | Prevent TOCTTOU bugs in C ports...* libguile/ports-internal.h (scm_port_buffer_can_take):
(scm_port_buffer_can_put): Add cur/end output arguments so that when a
caller asks the buffer room, it can be relative to a fixed point in
the buffer and not whatever point it's at when we go to fill it.
(scm_port_buffer_did_take, scm_port_buffer_did_put): Similarly,
require that the caller knows where they took/put data in the buffer.
Prevents overflow.
(scm_port_buffer_take_pointer, scm_port_buffer_put_pointer): Likewise,
require that the caller has already checked and knows a position in
the buffer and therefore how much data is available.
(scm_port_buffer_take, scm_port_buffer_put, scm_port_buffer_putback):
Adapt.
* libguile/ports.h (scm_fill_input): Add cur/avail output arguments.
* libguile/filesys.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/r6rs-ports.c:
* libguile/read.c:
* libguile/rw.c: Adapt all callers. Gnarly work!
| Andy Wingo | 2017-02-08 | 1 | -7/+6 |
* | Set rw_random correctly for all custom binary port types...* libguile/r6rs-ports.c (custom_binary_port_random_access_p): Rename
from custom_binary_input_output_port_type, and use for all custom
binary port types.
| Andy Wingo | 2016-08-31 | 1 | -10/+13 |
* | Implement R6RS custom binary input/output ports...* NEWS: Add new feature.
* doc/ref/r6rs.texi (rnrs io ports):
* doc/ref/api-io.texi (Custom Ports): Document new procedure.
* libguile/r6rs-ports.h:
* libguile/r6rs-ports.c (make_custom_binary_input_output_port)
(scm_make_custom_binary_input_output_port)
(custom_binary_input_output_port_random_access_p)
(initialize_custom_binary_input_output_ports)
(scm_init_r6rs_ports): Implement custom binary input/output ports.
* module/rnrs/io/ports.scm (rnrs):
* module/ice-9/binary-ports.scm (ice-9): Export
make-custom-binary-input/output-port.
| Andy Wingo | 2016-08-04 | 1 | -0/+86 |
* | Add SCM_OPN to mode bits when making ports...* libguile/ports.c (scm_c_make_port_with_encoding): Add SCM_OPN to mode
bits, so that users don't have to.
(scm_i_mode_bits_n):
* libguile/print.c (scm_simple_format)
* libguile/r6rs-ports.c (make_bytevector_input_port)
(make_custom_binary_input_port, make_bytevector_output_port)
(make_custom_binary_output_port, make_transcoded_port)
* libguile/strports.c (scm_object_to_string, scm_open_input_string)
(scm_open_output_string, scm_c_read_string): Remove now-unneeded
SCM_OPN mentions.
| Andy Wingo | 2016-05-14 | 1 | -10/+5 |
* | Use heap-allocated port types instead of ptobnums...This removes a limitation on the number of port types, simplifies the
API, and removes a central point of coordination.
* libguile/ports-internal.h (struct scm_t_port_type): Rename from
scm_t_ptob_descriptor, now that it's private. Add GOOPS class
fields.
(struct scm_t_port): Rename from struct scm_port, especially
considering that deprecated.h redefines scm_port using the
preprocessor :(.
* libguile/ports.h: Add definitions of SCM_PORT and SCM_PORT_TYPE,
though the scm_t_port and scm_t_port_type types are incomplete.
(SCM_TC2PTOBNUM, SCM_PTOBNUM, SCM_PTOBNAME): Remove, as there are no
more typecodes for port types.
(scm_c_num_port_types, scm_c_port_type_ref, scm_c_port_type_add_x):
Remove.
(scm_make_port_type): Return a scm_t_port_type*. All methods adapted
to take a scm_t_port_type* instead of a ptobnum.
(scm_c_make_port_with_encoding, scm_c_make_port): Take a port type
pointer instead of a tag.
(scm_new_port_table_entry): Remove; not useful.
* libguile/ports.c: Remove things related to the port kind table. Adapt
uses of SCM_PORT_DESCRIPTOR / scm_t_ptob_descriptor to use
SCM_PORT_TYPE and scm_t_port_type.
* libguile/deprecated.c:
* libguile/deprecated.h:
* libguile/filesys.c:
* libguile/fports.c:
* libguile/fports.h:
* libguile/print.c:
* libguile/r6rs-ports.c:
* libguile/strports.c:
* libguile/strports.h:
* libguile/tags.h:
* libguile/vports.c:
* test-suite/standalone/test-scm-c-read.c: Adapt to change.
* libguile/goops.c (scm_class_of, make_port_classes)
(scm_make_port_classes, create_port_classes): Adapt to store the
classes in the ptob.
| Andy Wingo | 2016-05-13 | 1 | -5/+5 |
* | Port conversion strategies internally are symbols...* libguile/ports.h (scm_t_port): Represent the conversion strategy as a
symbol, to make things easier for Scheme. Rename to
"conversion_strategy".
(scm_c_make_port_with_encoding): Change to take encoding and
conversion_strategy arguments as symbols.
(scm_i_string_failed_conversion_handler): New internal helper, to turn
a symbol to a scm_t_string_failed_conversion_handler.
(scm_i_default_port_encoding): Return the default port encoding as a
symbol.
(scm_i_default_port_conversion_strategy)
(scm_i_set_default_port_conversion_strategy): Rename from
scm_i_default_port_conversion_handler et al. Take and return Scheme
symbols.
* libguile/foreign.c (scm_string_to_pointer, scm_pointer_to_string): Use
scm_i_default_string_failed_conversion_handler instead of
scm_i_default_port_conversion_handler.
* libguile/print.c (PORT_CONVERSION_HANDLER): Update definition.
(print_normal_symbol): Use PORT_CONVERSION_HANDLER.
* libguile/r6rs-ports.c (make_bytevector_input_port):
(make_custom_binary_input_port, make_bytevector_output_port): Adapt to
changes in scm_c_make_port_with_encoding.
* libguile/strings.h:
* libguile/strings.c (scm_i_default_string_failed_conversion_handler):
New helper.
(scm_from_locale_stringn, scm_from_port_stringn):
(scm_to_locale_stringn, scm_to_port_stringn): Adapt to interface
changes.
* libguile/strports.c (scm_mkstrport): Adapt to
scm_c_make_port_with_encoding change.
* libguile/ports.c (scm_c_make_port): Adapt to
scm_c_make_port_with_encoding change.
(ascii_toupper, encoding_matches, canonicalize_encoding): Move down in
the file.
(peek_codepoint, get_codepoint, scm_ungetc): Adapt to port conversion
strategy change. Remove duplicate case in get_codepoint.
(scm_init_ports): Move symbol initializations to the same place.
| Andy Wingo | 2016-05-04 | 1 | -10/+11 |
* | scm_fill_input can guarantee a minimum fill amount...* libguile/ports.h (scm_fill_input): Add "minimum_size" argument. Adapt
all callers to pass 0 as this argument.
* libguile/ports.c (scm_i_read): Inline into scm_fill_input.
(scm_fill_input): "minimum_size" argument ensures that there are a
certain number of bytes available, or EOF. Instead of shrinking the
read buffer, only fill by the read_buffering amount, or the
minimum_size, whichever is larger.
* libguile/r6rs-ports.c:
* libguile/read.c: Adapt scm_fill_input callers.
| Andy Wingo | 2016-05-01 | 1 | -1/+1 |
* | Remove scm_putc_unlocked....* libguile/ports.h (scm_putc_unlocked): Remove.
* libguile/ports.c (scm_putc): Replace implementation with
scm_putc_unlocked's implementation.
(scm_port_print): Use scm_putc.
* libguile/arbiters.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/smob.c:
* libguile/srcprop.c:
* libguile/struct.c:
* libguile/variable.c:
* libguile/weak-set.c:
* libguile/weak-table.c: Use scm_putc instead of scm_putc_unlocked.
| Andy Wingo | 2016-04-26 | 1 | -1/+1 |
* | Remove scm_fill_input_unlocked...* libguile/ports.h (scm_fill_input_unlocked): Remove.
* libguile/ports.c (scm_fill_input): Rename from
scm_fill_input_unlocked. Adapt callers.
* libguile/r6rs-ports.c (scm_get_bytevector_some): Adapt.
* libguile/read.c (scm_i_scan_for_encoding): Adapt.
| Andy Wingo | 2016-04-26 | 1 | -1/+1 |
* | Replace scm_getc with scm_getc_unlocked...* libguile/ports.h (scm_getc_unlocked): Remove, or rather rename to
scm_getc. This probably introduces some thread-related bugs but we'll
fix them in a different way.
* libguile/ports.c (scm_getc): Rename from scm_getc_unlocked, replacing
the locky implementation.
(scm_read_char): Use scm_getc.
* libguile/r6rs-ports.c (scm_get_string_n_x): Use scm_getc.
* libguile/rdelim.c (scm_read_delimited_x, scm_read_line): Use
scm_getc.
* libguile/read.c: Use scm_getc.
| Andy Wingo | 2016-04-23 | 1 | -1/+1 |
* | Port buffers are Scheme values...* libguile/ports-internal.h (scm_port_buffer_bytevector)
(scm_port_buffer_cur, scm_port_buffer_set_cur)
(scm_port_buffer_end, scm_port_buffer_set_end)
(scm_port_buffer_has_eof_p, scm_port_buffer_set_has_eof_p): New
helpers.
* libguile/ports-internal.h (scm_port_buffer_size)
(scm_port_buffer_reset, scm_port_buffer_reset_end)
(scm_port_buffer_can_take, scm_port_buffer_can_put)
(scm_port_buffer_can_putback, scm_port_buffer_did_take)
(scm_port_buffer_did_put, scm_port_buffer_take_pointer)
(scm_port_buffer_put_pointer, scm_port_buffer_take)
(scm_port_buffer_put, scm_port_buffer_putback): Adapt to treat port
buffers as SCM values and use helpers to access them.
* libguile/ports.c (scm_i_clear_pending_eof, scm_i_set_pending_eof)
(scm_c_make_port_buffer, scm_i_read_unlocked)
(scm_c_read_bytes_unlocked, scm_i_unget_bytes_unlocked)
(scm_setvbuf, scm_fill_input, scm_take_from_input_buffers)
(scm_drain_input, scm_end_input_unlocked, scm_flush_unlocked)
(scm_fill_input_unlocked, scm_i_write_unlocked)
(scm_c_write_bytes_unlocked, scm_c_write_unlocked)
(scm_char_ready_p): Adapt to treat port buffers as SCM values and use
helpers to access them.
(scm_port_read_buffer, scm_port_write_buffer): New functions,
allowing (ice-9 ports) to access port buffers.
* libguile/ports.h: Update comments on port buffers. Replace
scm_t_port_buffer structure with a Scheme vector whose fields are
enumerated by "enum scm_port_buffer_field".
(scm_get_byte_or_eof_unlocked, scm_peek_byte_or_eof_unlocked): Adapt
these implementations to port buffer representation change.
* libguile/r6rs-ports.c (scm_get_bytevector_some):
* libguile/read.c (scm_i_scan_for_encoding):
* libguile/rw.c (scm_write_string_partial): Port buffers are Scheme
objects.
| Andy Wingo | 2016-04-20 | 1 | -2/+2 |
* | Remove size field from port buffers...* libguile/ports.h (scm_t_port_buffer): Remove size field. Instead use
bytevector size.
* libguile/ports-internal.h (scm_port_buffer_size)
(scm_port_buffer_reset)
(scm_port_buffer_can_take, scm_port_buffer_can_put)
(scm_port_buffer_did_take, scm_port_buffer_did_put)
(scm_port_buffer_take_pointer, scm_port_buffer_put_pointer)
(scm_port_buffer_take, scm_port_buffer_put): New helpers.
* libguile/filesys.c (set_element): Use new helpers.
* libguile/poll.c (scm_primitive_poll): Use new helpers.
* libguile/ports.c (scm_c_make_port_buffer): No more "size" field.
(scm_i_read_unlocked, scm_c_read_bytes_unlocked)
(scm_c_read_unlocked, scm_i_unget_bytes_unlocked)
(scm_unget_bytes, scm_setvbuf, scm_take_from_input_buffers)
(scm_drain_input, scm_end_input_unlocked, scm_flush_unlocked)
(scm_fill_input_unlocked, scm_i_write_unlocked)
(scm_c_write_bytes_unlocked, scm_c_write_unlocked)
(scm_char_ready_p): Use new helpers.
* libguile/r6rs-ports.c (scm_get_bytevector_some): Use new helpers.
* libguile/rw.c (scm_write_string_partial): Use new helpers.
| Andy Wingo | 2016-04-17 | 1 | -2/+2 |
* | Port buffer has-eof? field is SCM value...* libguile/ports.h (scm_t_port_buffer): Rename has_eof member to
has_eof_p, and be a Scheme value, in anticipation of moving the port
buffers to be Scheme objects.
| Andy Wingo | 2016-04-17 | 1 | -1/+1 |
* | Allow port "write" functions to only write a chunk...* libguile/ports.c (scm_i_write_bytes_unlocked): Allow incomplete
writes from the implementation.
(scm_c_write_bytes_unlocked): Use scm_i_write_bytes_unlocked helper to
call the write function.
* libguile/r6rs-ports.c (custom_binary_output_port_write): Don't loop;
core Guile will do that.
| Andy Wingo | 2016-04-12 | 1 | -21/+10 |
* | Port read/write functions take bytevectors...This will allow better Scheme integration for ports.
* libguile/ports.h (scm_t_port_buffer): Change "holder" member to be a
bytevector defined to have "buf" as its starting point.
(scm_t_ptob_descriptor): Change read and write functions to take
bytevectors as arguments and to return the number of octets read or
written.
(scm_make_port_type): Adapt accordingly.
(scm_c_read_bytes, scm_c_write_bytes): New functions that take
bytevectors.
* libguile/ports.c (scm_make_port_type): Adapt to read/write function
prototype change.
(scm_c_make_port_buffer): Arrange to populate the "bytevector" field.
(scm_i_read_bytes_unlocked): New function.
(scm_i_read_unlocked): Use scm_i_read_bytes_unlocked.
(scm_c_read_bytes_unlocked): New function.
(scm_c_read_unlocked): Update comment, and always go through the
buffer.
(scm_c_read_bytes): New function.
(scm_flush_unlocked): Use scm_i_write_unlocked instead of the port's
write function.
(scm_i_write_bytes_unlocked): New function.
(scm_i_write_unlocked): Use scm_i_write_bytes_unlocked.
(scm_c_write_bytes_unlocked): New function.
(scm_c_write_unlocked): Always write through the buffer.
(scm_c_write_bytes): New function.
(scm_truncate_file): Remove unused variable.
(void_port_read, void_port_write): Adapt to read/write prototype
change.
* libguile/fports.c (fport_read, fport_write):
* libguile/r6rs-ports.c (bytevector_input_port_read)
(custom_binary_input_port_read, bytevector_output_port_write)
(custom_binary_output_port_write, transcoded_port_write)
(transcoded_port_read): Adapt to read/write prototype
change.
(scm_get_bytevector_n, scm_get_bytevector_n_x)
(scm_get_bytevector_all): Use scm_c_read_bytes.
(scm_put_bytevector): Use scm_c_write_bytes.
* libguile/strports.c (string_port_read, string_port_write):
* libguile/vports.c (soft_port_write, soft_port_read): Adapt to
read/write prototype change.
* test-suite/standalone/test-scm-c-read.c (custom_port_read): Fix for
read API change.
| Andy Wingo | 2016-04-11 | 1 | -99/+54 |
* | Generic port facility provides buffering uniformly...* libguile/ports.h (struct scm_t_port_buffer): New data type.
(struct scm_t_port): Refactor to use port buffers instead of
implementation-managed read and write pointers. Add "read_buffering"
member.
(SCM_INITIAL_PUTBACK_BUF_SIZE, SCM_READ_BUFFER_EMPTY_P): Remove.
(scm_t_ptob_descriptor): Rename "fill_input" function to "read", and
take a port buffer, returning void. Likewise "write" takes a port
buffer and returns void. Remove "end_input"; instead if there is
buffered input and rw_random is true, then there must be a seek
function, so just seek back if needed. Remove "flush"; instead all
calls to the "write" function implicitly include a "flush", since the
buffering happens in the generic port code now. Remove "setvbuf", but
add "get_natural_buffer_sizes"; instead the generic port code can
buffer any port.
(scm_make_port_type): Adapt to read and write prototype changes.
(scm_set_port_flush, scm_set_port_end_input, scm_set_port_setvbuf):
Remove.
(scm_slow_get_byte_or_eof_unlocked)
(scm_slow_get_peek_or_eof_unlocked): Remove; the slow path is to call
scm_fill_input.
(scm_set_port_get_natural_buffer_sizes): New function.
(scm_c_make_port_buffer): New internal function.
(scm_port_non_buffer): Remove. This was a function for
implementations that is no longer needed. Instead open with BUF0 or
use (setvbuf port 'none).
(scm_fill_input, scm_fill_input_unlocked): Return the filled port
buffer.
(scm_get_byte_or_eof_unlocked, scm_peek_byte_or_eof_unlocked): Adapt
to changes in buffering and EOF management.
* libguile/ports.c: Adapt to port interface changes.
(initialize_port_buffers): New function, using the port mode flags to
set up appropriate initial buffering for all ports.
(scm_c_make_port_with_encoding): Create port buffers here instead of
delegating to implementations.
(scm_close_port): Flush the port if needed instead of delegating to
the implementation.
* libguile/filesys.c (set_element): Adapt to buffering changes.
* libguile/fports.c (fport_get_natural_buffer_sizes): New function,
replacing scm_fport_buffer_add.
(fport_write, fport_read): Update to let the generic ports code do the
buffering.
(fport_flush, fport_end_input): Remove.
(fport_close): Don't flush in a dynwind; that's the core ports' job.
(scm_make_fptob): Adapt.
* libguile/ioext.c (scm_redirect_port): Adapt to buffering changes.
* libguile/poll.c (scm_primitive_poll): Adapt to buffering changes.
* libguile/ports-internal.h (struct scm_port_internal): Remove
pending_eof flag; this is now set on the read buffer.
* libguile/r6rs-ports.c (struct bytevector_input_port): New type. The
new buffering arrangement means that there's now an intermediate
buffer between the bytevector and the user of the port; this could
lead to a perf degradation, but on the other hand there are some other
speedups enabled by the buffering refactor, so probably the memcpy
cost is dwarfed by the cost of the other parts of the ports
machinery.
(make_bytevector_input_port, bytevector_input_port_read):
(bytevector_input_port_seek, initialize_bytevector_input_ports): Adapt
to new buffering arrangement.
(struct custom_binary_port): Remove read buffer, as Guile handles that
now.
(custom_binary_input_port_setvbuf): Remove; now handled by Guile.
(make_custom_binary_input_port, custom_binary_input_port_read)
(initialize_custom_binary_input_ports): Adapt.
(scm_get_bytevector_some): Adapt to new EOF management.
(scm_t_bytevector_output_port_buffer): Hold on to the underlying port,
so we can flush it if it's open.
(make_bytevector_output_port, bytevector_output_port_write):
(bytevector_output_port_seek): Adapt.
(bytevector_output_port_procedure): Flush the port as appropriate, so
that we get all the bytes.
(make_custom_binary_output_port, custom_binary_output_port_write):
Adapt.
(make_transcoded_port): Don't muck with buffering.
(transcoded_port_write): Simply forward the write to the underlying
port.
(transcoded_port_read): Likewise.
(transcoded_port_close): No need to flush.
(initialize_transcoded_ports): Adapt.
* libguile/read.c (scm_i_scan_for_encoding): Adapt to buffering
changes.
* libguile/rw.c (scm_write_string_partial): Adapt to buffering changes.
* libguile/strports.c: Adapt to the fact that we don't manage the
buffer. Probably room for speed improvements here...
* libguile/vports.c (soft_port_get_natural_buffer_sizes): New function.
Adapt the rest of the file for the new buffering regime.
* test-suite/tests/r6rs-ports.test ("8.2.10 Output ports"): Custom
binary output ports need to be flushed before you can rely on the
write! procedure having been called. Add necessary flush-port
invocations.
("8.2.6 Input and output ports"): Transcoded ports now have an
internal buffer by default. This test checks that the characters are
transcoded one at a time, so to do that, call setvbuf on the
transcoded port to remove the buffer.
* test-suite/tests/web-client.test (run-with-http-transcript): Fix for
different flushing regime on soft ports. (The vestigial flush
procedure is now called after each write, which is not what the test
was expecting.)
* test-suite/standalone/test-scm-c-read.c: Update for changes to the C
interface for defining port types.
* doc/ref/api-io.texi (Ports): Update to discuss buffering in a generic
way, and to remove a hand-wavey paragraph describing string ports as
"interesting and powerful".
(Reading, Writing): Remove placeholder comments. Document
`scm_lfwrite'.
(Buffering): New section.
(File Ports): Link to buffering.
(I/O Extensions): Join subnodes into parent and describe new API,
including buffering API.
* doc/ref/posix.texi (Ports and File Descriptors): Link to buffering.
Remove unread-char etc, as they are documented elsewhere.
(Pipes, Network Sockets and Communication): Link to buffering.
| Andy Wingo | 2016-04-06 | 1 | -350/+145 |
* | Port close functions return void...* libguile/ports.h (scm_t_ptob_descriptor): The port close function now
returns void.
(scm_set_port_close): Adapt prototype.
* libguile/ports.c (scm_close_port): Always return true if we managed to
call the close function. There's no other sensible result; exceptions
are handled, well, exceptionally.
* libguile/fports.c (fport_close)
* libguile/r6rs-ports.c (custom_binary_port_close, transcoded_port_close):
* libguile/vports.c (soft_port_close): Adapt.
* doc/ref/api-io.texi (Port Implementation): Update.
| Andy Wingo | 2016-04-05 | 1 | -5/+3 |
* | Refactor to rw_random / rw_active port flags...* libguile/fports.c (fport_flush, fport_end_input): Move rw_active
handling to ports.c.
* libguile/ioext.c (scm_redirect_port): Use scm_flush_unlocked instead
of calling the flush function directly.
* libguile/ports.c (scm_c_make_port_with_encoding): Ports default to
"rw_random" mode when they have a seek function.
(scm_c_read_unlocked, scm_i_unget_bytes_unlocked)
(scm_slow_get_byte_or_eof_unlocked)
(scm_slow_peek_byte_or_eof_unlocked): Flush write buffer and set
rw_active always in the same way, and only if rw_random is true.
(scm_end_input_unlocked, scm_flush_unlocked): Clear rw_active here
unconditionally.
(scm_c_write_unlocked): Flush read buffer and set rw_active always in
the same way, but only if rw_random is true.
(scm_c_write, scm_lfwrite): Whitespace fixes.
(scm_lfwrite_substr): Don't flush read buffer; lower-level code will
do this.
(scm_truncate_file): Use scm_flush_unlocked instead of calling the
flush function directly.
* libguile/r6rs-ports.c (transcoded_port_flush): Don't muck with
rw_active.
* libguile/read.c (scm_i_scan_for_encoding): Flush write buffer if
needed in same way as ports.c.
* libguile/strports.c (st_end_input): Don't muck with rw_active.
(scm_mkstrport): rw_random defaults to 1 now.
| Andy Wingo | 2016-04-04 | 1 | -1/+0 |
* | Custom binary port internals refactor...* libguile/r6rs-ports.c (struct custom_binary_port): Use a struct
instead of a vector as the state for a custom binary port. Adapt all
callers. Some whitespace fixes as well.
| Andy Wingo | 2016-04-04 | 1 | -72/+70 |
* | Cosmetic changes to r6rs-ports.c...* libguile/r6rs-ports.c: Expand out the acronyms "bip", "bop", "cbip",
"cbop", and "tp". They always confused me, especially that the "b" in
cbip/cbop wasn't the same as the one in bip/bop.
| Andy Wingo | 2016-04-04 | 1 | -118/+128 |
* | Remove port free functions; just close instead...* libguile/ports.h (scm_t_port_type_flags): Replace
SCM_PORT_TYPE_HAS_FLUSH with SCM_PORT_TYPE_NEEDS_CLOSE_ON_GC.
(scm_t_ptob_descriptor): Remove free function.
* libguile/ports.c (scm_set_port_needs_close_on_gc): New function.
(scm_set_port_flush): Don't set flags.
(scm_c_make_port_with_encoding, scm_close_port): Use the new flag to
determine when to add a finalizer and also when to include the port in
the weak set.
(scm_set_port_free): Remove.
(do_close, finalize_port): Close port instead of calling free
function.
* libguile/r6rs-ports.c (initialize_transcoded_ports):
* libguile/vports.c (scm_make_sfptob):
* libguile/fports.c (scm_make_fptob): Mark these ports as needing close
on GC.
* libguile/fports.c (fport_free): Remove.
* NEWS: Update.
* doc/ref/api-io.texi (Port Implementation): Update.
| Andy Wingo | 2016-04-04 | 1 | -0/+1 |
* | Use symbols instead of _IONBF values as args to setvbuf...* libguile/ports.c (scm_setvbuf): Use the symbols `none', `line', and
`block' instead of the values `_IONBF', `_IOLBF', and `_IOFBF'.
* NEWS: Update.
* doc/ref/posix.texi (Ports and File Descriptors): Update setvbuf
documentation.
* module/ice-9/deprecated.scm (define-deprecated): New helper.
(_IONBF, _IOLBF, _IOFBF): Define deprecated values.
* benchmark-suite/benchmarks/read.bm ("read"):
* benchmark-suite/benchmarks/uniform-vector-read.bm
("uniform-vector-read!"):
* libguile/r6rs-ports.c (cbip_fill_input):
* module/system/base/types.scm (%ffi-memory-backend):
* module/web/client.scm (open-socket-for-uri):
* module/web/server/http.scm (http-read):
* test-suite/tests/ports.test ("pipe, fdopen, and line buffering"):
("setvbuf"):
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports"): Update to use
non-deprecated interfaces.
| Andy Wingo | 2016-04-04 | 1 | -1/+1 |
* | Merge commit 'ed72201a795ac1c8d6c0288b6bb710f2bd0ebd9c'...Conflicts:
test-suite/tests/r6rs-ports.test
| Andy Wingo | 2015-01-22 | 1 | -7/+10 |
|\ |
|
| * | Fix buffer overrun with unbuffered custom binary input ports....Fixes <http://bugs.gnu.org/19621>.
Before that, in 'cbip_fill_input', BUFFERED would be set to 0 when
reading from 'scm_getc' et al, because 'shortbuf' was being used. Thus,
we could eventually execute this line:
/* Copy the data back to the internal buffer. */
memcpy ((char *) c_port->read_pos, SCM_BYTEVECTOR_CONTENTS (bv),
c_octets);
But 'read_pos' would quickly point to the fields beyond 'shortbuf',
thereby leading to a corruption of the 'scm_t_port' itself.
* libguile/r6rs-ports.c (cbip_setvbuf): When READ_SIZE is 0, keep using
BV as the 'read_buf'.
(cbip_fill_input): Adjust assertion to accept 'read_buf_size = 1'.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port unbuffered & 'get-string-all'", "custom binary input port
unbuffered UTF-8 & 'get-string-all'"]: New tests.
| Ludovic Courtès | 2015-01-18 | 1 | -7/+10 |
* | | Merge branch 'stable-2.0'...Conflicts:
GUILE-VERSION
NEWS
guile-readline/ice-9/readline.scm
libguile/async.c
libguile/backtrace.c
libguile/deprecated.h
libguile/gc-malloc.c
libguile/gdbint.c
libguile/init.c
libguile/ioext.c
libguile/mallocs.c
libguile/print.c
libguile/rw.c
libguile/scmsigs.c
libguile/script.c
libguile/simpos.c
libguile/snarf.h
libguile/strports.c
libguile/threads.c
libguile/vm-i-scheme.c
libguile/vm-i-system.c
module/srfi/srfi-18.scm
test-suite/Makefile.am
test-suite/standalone/test-num2integral.c
| Mark H Weaver | 2014-04-25 | 1 | -4/+1 |
|\| |
|
| * | Rely on Gnulib for <unistd.h>....* libguile/async.c:
* libguile/backtrace.c:
* libguile/error.c:
* libguile/filesys.c:
* libguile/fports.c:
* libguile/gc-malloc.c:
* libguile/gc.c:
* libguile/gdbint.c:
* libguile/init.c:
* libguile/ioext.c:
* libguile/load.c:
* libguile/mallocs.c:
* libguile/mkstemp.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/rw.c:
* libguile/scmsigs.c:
* libguile/script.c:
* libguile/simpos.c:
* libguile/socket.c:
* libguile/stime.c:
* libguile/strports.c:
* libguile/threads.c: Unconditionally include <unistd.h>.
| Mark H Weaver | 2014-02-27 | 1 | -4/+1 |
* | | Merge commit '45a28515c13348dfd18e53038ad63dd091a5a3c1' | Andy Wingo | 2014-02-07 | 1 | -3/+6 |
|\| |
|
| * | Buffered custom binary input ports correctly handle partial read requests....* libguile/r6rs-ports.c (cbip_fill_input): Always initialize 'read_pos'
when BUFFERED.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port buffered partial reads"]: New test.
| Ludovic Courtès | 2014-01-21 | 1 | -3/+6 |
* | | Merge commit '8ca97482b01cf1a6aa538cc5a2d1f71fb60f080c'...Conflicts:
libguile/r6rs-ports.c
| Andy Wingo | 2014-02-07 | 1 | -15/+75 |
|\| |
|
| * | Custom binary input ports support 'setvbuf'....* libguile/r6rs-ports.c (CBIP_BUFFER_SIZE): Adjust comment. Set to 8KiB.
(SCM_SET_CBIP_BYTEVECTOR): New macro.
(cbip_setvbuf): New function.
(make_cbip): Set PORT's 'setvbuf' internal field.
(cbip_fill_input): Check whether PORT is buffered. When unbuffered,
check whether BV can hold C_REQUESTED bytes, and allocate a new
bytevector if not; copy the data back from BV to c_port->read_pos.
Remove 'again' label, and don't loop there.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port unbuffered & 'port-position'", "custom binary input port
unbuffered & 'read!' calls", "custom binary input port, unbuffered
then buffered", "custom binary input port, buffered then unbuffered"]:
New tests.
* doc/ref/api-io.texi (R6RS Binary Input): Document the buffering of
custom binary input ports, and link to 'setvbuf'.
| Ludovic Courtès | 2014-01-18 | 1 | -16/+78 |
* | | Merge branch 'stable-2.0'...Conflicts:
libguile/read.c
test-suite/tests/web-response.test
| Mark H Weaver | 2014-01-21 | 1 | -3/+7 |
|\| |
|
| * | Custom binary input ports sanity-check the return value of 'read!'....* libguile/r6rs-ports.c (cbip_fill_input): Throw an exception when
C_OCTETS is greater than what was requested.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port 'read!' returns too much"]: New test.
| Ludovic Courtès | 2014-01-15 | 1 | -3/+7 |
* | | Merge branch 'stable-2.0'...Conflicts:
libguile/hash.c
module/ice-9/psyntax-pp.scm
module/ice-9/psyntax.scm
test-suite/tests/r6rs-ports.test
| Mark H Weaver | 2014-01-14 | 1 | -7/+10 |
|\| |
|
| * | 'port-position' works on CBIPs that do not support 'set-port-position!'....* libguile/r6rs-ports.c (cbp_seek)[WHENCE == SEEK_CUR]: Break out of the
switch statement when OFFSET is zero.
Pass 'scm_wrong_type_arg_msg' a phrase suitable for use after
"expecting".
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port supports `port-position', not `set-port-position!'"]: New
test.
| Ludovic Courtès | 2014-01-13 | 1 | -7/+10 |
* | | Declare r6rs-ports functions...* libguile/r6rs-ports.h:
* libguile/r6rs-ports.c: Declare scm_unget_bytevector and
scm_i_make_transcoded_port.
| Andy Wingo | 2013-11-27 | 1 | -0/+2 |
* | | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts:
GUILE-VERSION
libguile/array-map.c
libguile/fports.h
libguile/gc.h
libguile/inline.h
libguile/ports.c
libguile/ports.h
libguile/print.c
libguile/r6rs-ports.c
libguile/read.c
test-suite/tests/00-socket.test
| Mark H Weaver | 2013-04-14 | 1 | -55/+67 |
|\| |
|
| * | Implement efficient 'scm_unget_bytes' and 'unget-bytevector'....* libguile/ports.c (scm_i_unget_bytes): New static function.
(scm_unget_bytes): New API function.
(scm_unget_byte): Rewrite to simply call 'scm_i_unget_bytes'.
(scm_ungetc, scm_peek_char, looking_at_bytes): Use 'scm_i_unget_bytes'.
* libguile/ports.h: Add prototype for 'scm_unget_bytes'.
* libguile/fports.c (scm_setvbuf): Use 'scm_unget_bytes'.
* libguile/r6rs-ports.c (scm_unget_bytevector): New procedure.
* module/ice-9/binary-ports.scm (unget-bytevector): New export.
* doc/ref/api-io.texi (R6RS Binary Input): Add documentation.
(R6RS I/O Ports): Update brief description of (ice-9 binary-ports) to
reflect the new reality: it is no longer a subset of (rnrs io ports).
* test-suite/tests/ports.test ("unget-bytevector"): Add test.
| Mark H Weaver | 2013-04-07 | 1 | -0/+43 |
| * | Optimize 'get-bytevector-some'; it may now read less than possible....* libguile/r6rs-ports.c (scm_get_bytevector_some): Rewrite to
efficiently take the contents of the read/putback buffers. In the
docstring, clarify that it might not return all available bytes.
* doc/ref/api-io.texi (R6RS Binary Input): Clarify that
'get-bytevector-some' might not return all available bytes.
* test-suite/tests/r6rs-ports.test ("get-bytevector-some [only-some]"):
Remove bogus test, which requires more than the R6RS requires.
| Mark H Weaver | 2013-04-01 | 1 | -54/+24 |
* | | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts:
libguile/r6rs-ports.c
| Mark H Weaver | 2013-04-01 | 1 | -18/+9 |
|\| |
|
| * | Avoid unnecessary peeks for EOF in r6rs-ports....* libguile/r6rs-ports.c (scm_get_bytevector_n, scm_get_bytevector_n_x,
scm_get_bytevector_some, scm_get_bytevector_all): Avoid peeking for
EOF when we already know.
| Mark H Weaver | 2013-03-31 | 1 | -18/+9 |
* | | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts:
configure.ac
libguile/deprecated.c
libguile/deprecated.h
libguile/filesys.h
libguile/fluids.c
libguile/fports.c
libguile/gc.c
libguile/guile.c
libguile/numbers.c
libguile/objcodes.c
libguile/r6rs-ports.c
libguile/smob.c
libguile/socket.c
libguile/threads.h
module/language/scheme/decompile-tree-il.scm
module/language/tree-il/peval.scm
test-suite/tests/syncase.test
| Mark H Weaver | 2013-03-28 | 1 | -7/+9 |
|\| |
|
| * | Use byte-oriented functions in `get-bytevector*'....* libguile/r6rs-ports.c (scm_get_bytevector_some, scm_get_bytevector_n,
scm_get_bytevector_n_x, scm_get_bytevector_all): Use
`scm_get_byte_or_eof' and `scm_peek_byte_or_eof' instead of their
`char' counterparts.
Reported by Chris K. Jester-Young.
| Ludovic Courtès | 2013-03-18 | 1 | -7/+9 |
* | | locking for write, lfwrite...* libguile/ports.c (scm_c_write_unlocked, scm_c_write)
(scm_lfwrite_unlocked, scm_lfwrite): Add locking and _unlocked
variants. Change uses to _unlocked.
| Andy Wingo | 2011-11-08 | 1 | -3/+3 |
* | | locking for putc, puts...* libguile/ports.c (scm_putc, scm_puts):
* libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into
_unlocked and locked variants. Change all callers to use the
_unlocked versions.
| Andy Wingo | 2011-11-08 | 1 | -1/+1 |
* | | locking on port buffering operations...* libguile/ports.c (scm_fill_input_unlocked, scm_fill_input)
(scm_end_input, scm_end_input_unlocked, scm_flush)
(scm_flush_unlocked): Add locking and _unlocked variants.
* libguile/filesys.c:
* libguile/fports.c:
* libguile/gdbint.c:
* libguile/r6rs-ports.c:
* libguile/read.c:
* libguile/rw.c: Adapt callers to use _unlocked variants.
| Andy Wingo | 2011-11-08 | 1 | -1/+1 |
* | | locking on scm_c_read, scm_getc...* libguile/ports.c (scm_c_read_unlocked, scm_c_read, scm_getc_unlocked)
(scm_getc): Split getc and read operations into locked and unlocked
variants. Change most uses to use the _unlocked version.
| Andy Wingo | 2011-11-08 | 1 | -5/+5 |
* | | add scm_c_make_port; the port table is now a weak set...* libguile/ports.c (scm_c_make_port_with_encoding, scm_c_make_port): New
functions, to replace scm_new_port_table_entry. Use a weak set
instead of a weak table.
(scm_i_remove_port):
(scm_c_port_for_each, scm_port_for_each): Adapt to use weak set.
(scm_i_void_port): Use scm_c_make_port.
(scm_init_ports): Make a weak set.
* libguile/fports.c:
* libguile/ioext.c:
* libguile/r6rs-ports.c:
* libguile/strports.c:
* libguile/vports.c: Adapt to use the new scm_c_make_port API.
| Andy Wingo | 2011-10-23 | 1 | -63/+25 |
* | | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts:
libguile/bytevectors.c
libguile/bytevectors.h
libguile/objcodes.c
libguile/r6rs-ports.c
libguile/strings.c
libguile/vm.c
| Andy Wingo | 2011-08-31 | 1 | -7/+7 |
|\| |
|
| * | fix a couple of leaks...* libguile/bytevectors.h:
* libguile/bytevectors.c (scm_c_take_gc_bytevector): Rename this
internal function, from scm_c_take_bytevector. This indicates that
unlike the other scm_take_* functions, this one takes GC-managed
memory.
* libguile/objcodes.c (scm_objcode_to_bytecode):
* libguile/vm.c (really_make_boot_program): Use
scm_gc_malloc_pointerless, not scm_malloc. Thanks to Stefan
Israelsson Tampe!
* libguile/r6rs-ports.c:
* libguile/strings.c: Adapt to renames.
| Andy Wingo | 2011-08-18 | 1 | -5/+5 |