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

1802 commits

Author SHA1 Message Date
Daniel Llorens
f227a56991 Support typed arrays in some sort functions
* libguile/sort.c (sort!, sort, restricted-vector-sort!, sorted?):
  Support arrays of rank 1, whatever the type.

* libguile/quicksort.i.c: Fix accessors to handle typed arrays.

* test-suite/tests/sort.test: Test also with typed arrays.
2016-07-11 09:11:50 +02:00
Daniel Llorens
79bf245c7e Fix a corner case with empty arrays in (array-for-each-cell)
* libguile/array-map.c (scm_array_for_each_cell): Bail out early if any
  of the sizes is zero. Pack ais at the end of the fake stack.

* test-suite/tests/array-map.test: Add regression test.
2016-07-11 09:11:50 +02:00
Daniel Llorens
f6003e8881 Clean up (array-for-each-cell)
* libguile/array-map.c (array-for-each-cell,
  array-for-each-cell-in-order): Moved from libguile/arrays.c. Fix
  argument names. Complete docstring.

* libguile/array-map.h (array-for-each-cell,
  array-for-each-cell-in-order): Declarations moved from
  libguile/arrays.h.

* test-suite/tests/array-map.test: Renamed from
  test-suite/tests/ramap.test, fix module name.

  Add tests for (array-for-each-cell).

* test-suite/Makefile.am: Apply rename array-map.test -> ramap.test.

* doc/ref/api-compound.texi: Minor documentation fixes.
2016-07-11 09:11:50 +02:00
Daniel Llorens
c17799dda9 Speed up for multi-arg cases of scm_ramap functions
This patch results in a 20%-40% speedup in the > 1 argument cases of
the following microbenchmarks:

(define A (make-shared-array #0(1) (const '()) #e1e7))
; 1, 2, 3 arguments.
(define a 0) ,time (array-for-each (lambda (b) (set! a (+ a b))) A)
(define a 0) ,time (array-for-each (lambda (b c) (set! a (+ a b c))) A A)
(define a 0) ,time (array-for-each (lambda (b c d) (set! a (+ a b c d))) A A A)

(define A (make-shared-array (make-array 1) (const '()) #e1e7))
(define B (make-shared-array #0(1) (const '()) #e1e7))
; 1, 2, 3 arguments.
,time (array-map! A + B)
,time (array-map! A + B B)
,time (array-map! A + B B B)

* libguile/array-map.c (scm_ramap): note on cproc arguments.

  (rafill): assume that dst's lbnd is 0.

  (racp): assume that src's lbnd is 0.

  (ramap): assume that ra0's lbnd is 0. When there're more than two
  arguments, compute the array handles before the loop. Allocate the arg
  list once and reuse it in the loop.

  (rafe): like rafe, when there's more than one argument.

  (AREF, ASET): remove.
2016-07-11 09:11:50 +02:00
Daniel Llorens
fc0e75c50d Fix compilation of rank 0 typed array literals
* module/system/vm/assembler.scm (simple-uniform-vector?): array-length
  fails for rank 0 arrays; fix the shape condition.

* test-suite/tests/arrays.test: test reading of #0f64(x) in compilation
  context.
2016-07-11 09:11:50 +02:00
Daniel Llorens
3aafc2c857 Rename array-set-from!, scm_array_set_from_x to array-amend!, scm_array_amend_x 2016-07-11 09:11:50 +02:00
Daniel Llorens
ecb38d4268 Tests & doc for array-from, array-from*, array-set-from!
* test-suite/tests/arrays.test: tests for array-from, array-from*,
  array-set-from!

* doc/ref/api-compound.texi: document array-from, array-from*,
  array-set-from!.
2016-07-11 09:11:50 +02:00
Daniel Llorens
212c5b0f29 Unuse array 'contiguous' flag
SCM_I_ARRAY_FLAG_CONTIGUOUS (arrays.h) was set by all array-creating
functions (make-typed-array, transpose-array, make-shared-array) but it
was only used by array-contents, which needed to traverse the dimensions
anyway.

* libguile/arrays.c (scm_make_typed_array,
  scm_from_contiguous_typed_array): don't set the contiguous flag.

  (scm_transpose_array, scm_make_shared_array): don't call
  scm_i_ra_set_contp.

  (scm_array_contents): inline scm_i_ra_set_contp() here. Adopt uniform
  type check order. Remove redundant comments.

  (scm_i_ra_set_contp): remove.

* libguile/arrays.h: note.

* test-suite/tests/arrays.test: test array-contents with rank 0 array.
2016-07-11 09:11:50 +02:00
Daniel Llorens
655494c65b Avoid unneeded internal use of array handles
* libguile/arrays.c (scm_shared_array_root): adopt uniform check order.

  (scm_shared_array_offset, scm_shared_array_increments): use the array
  fields directly just as scm_shared_array_root does.

* test-suite/tests/arrays.test: tests for shared-array-offset,
  shared-array-increments.
2016-07-11 09:11:50 +02:00
Andy Wingo
229d062f83 Constant-folding eq? and eqv? uses deduplication
* test-suite/tests/peval.test ("partial evaluation"): Add tests.
* module/language/tree-il/peval.scm (peval): Constant-fold eq? and eqv?
  using equal?, anticipating deduplication.
2016-06-24 17:37:51 +02:00
Andy Wingo
bd65845497 Fix texinfo->html for @acronym, @itemize
* module/texinfo/html.scm (itemize, acronym, tag-replacements, rules):
  Fix HTML serialization of @itemize and @acronym.  Fixes #21772.
* test-suite/tests/texinfo.html.test: New file.
* test-suite/Makefile.am: Add new file.
2016-06-24 17:09:39 +02:00
Andy Wingo
1d72d46951 Don't serialize uninterned symbols
* module/system/vm/assembler.scm (intern-constant): Don't serialize
  uninterned symbols.
* test-suite/tests/rtl.test ("bad constants"): Add a test.
2016-06-23 15:45:53 +02:00
Andy Wingo
9a95167871 Fix relative file name canonicalization on paths with "."
* libguile/filesys.c (scm_i_relativize_path): Canonicalize the file
  names elements that we will be using as prefixes.  Fixes the case
  where a load path contains a relative file name: #19540.
* test-suite/tests/ports.test ("%file-port-name-canonicalization"): Add
  tests that elements of the load path are canonicalized.
2016-06-23 10:17:57 +02:00
Andy Wingo
0472af4c58 Fix (< 'foo) compilation
* module/language/tree-il/primitives.scm (expand-chained-comparisons):
  Fix (< 'foo) compilation.
* test-suite/tests/compiler.test ("regression tests"): Add test case.
2016-06-21 23:17:25 +02:00
Andy Wingo
2546849642 Fix srfi-64.test for #:select borkage. The irony...
* test-suite/tests/srfi-64.test: Fix for recent #:select borkage.
2016-06-21 22:46:03 +02:00
Andy Wingo
f1c0434403 `define!' instruction returns the variable
* doc/ref/vm.texi (Top-Level Environment Instructions): Update
  documentation.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, sadly.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* libguile/vm-engine.c (define!): Change to store variable in dst slot.
* module/language/tree-il/compile-cps.scm (convert):
* module/language/cps/compile-bytecode.scm (compile-function): Adapt to
  define! change.
* module/language/cps/effects-analysis.scm (current-module): Fix define!
  effects.  Incidentally here was the bug: in Guile 2.2 you can't have
  effects on different object kinds in one instruction, without
  reverting to &unknown-memory-kinds.
* test-suite/tests/compiler.test ("regression tests"): Add a test.
2016-06-21 22:40:31 +02:00
Andy Wingo
b8f5cdce15 Update and-let-star.test
* test-suite/tests/and-let-star.test ("and-let*"): Update test
  expectations.
2016-06-21 13:40:02 +02:00
Taylan Ulrich Bayırlı/Kammer
daf8d33036 Add SRFI-2 (and-let*) test suite.
* test-suite/tests/srfi-2.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add it.
2016-06-21 13:40:01 +02:00
Andy Wingo
4e27e3c054 Add R6RS bytevector->string, string->bytevector
* module/rnrs/io/ports.scm (string->bytevector):
  (bytevector->string): New procedures.
* module/rnrs.scm: Export new procedures.
* test-suite/tests/r6rs-ports.test: Add string->bytevector and
  bytevector->string tests.
2016-06-21 11:29:14 +02:00
Andy Wingo
5d9516637b Implement R6RS output-port-buffer-mode
* module/rnrs/io/ports.scm (r6rs-open): Set buffer-mode on new port.
  (output-port-buffer-mode): Implement and export.
* module/rnrs.scm (rnrs): Export output-port-buffer-mode
* test-suite/tests/r6rs-ports.test (test-output-file-opener): Add
  tests.
2016-06-21 11:06:25 +02:00
Taylan Ulrich Bayırlı/Kammer
d545e4551d (rnrs hashtables): Hash functions of eq? and eqv? hashtables
Also pinging this thread with a (very slightly) updated patch. :-)

[2. text/x-diff; 0001-Hashtable-hash-function-returns-f-on-eq-and-eqv-tabl.patch]

From 17599f6ce7ba0beb100e80455ff99af07333d871 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
Date: Tue, 21 Jun 2016 00:23:29 +0200
Subject: [PATCH] Hashtable-hash-function returns #f on eq and eqv tables.

* module/rnrs/hashtables.scm (r6rs:hashtable)[type]: New field.
(r6rs:hashtable-type): New procedure.
* test-suite/tests/r6rs-hashtables.test: Add related tests.
2016-06-21 09:48:36 +02:00
Taylan Ulrich Bayırlı/Kammer
c1abe68dbc (rnrs hashtables): Mutation of immutable hashtable ignored
Pinging this thread with a (very slightly) updated patch. :-)

[2. text/x-diff; 0001-Hashtable-set-errors-on-immutable-hashtable.patch]

From 7f35d515d711e255bba5a89a013d9d92034edf41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
Date: Tue, 21 Jun 2016 00:25:19 +0200
Subject: [PATCH] Hashtable-set! errors on immutable hashtable.

* module/rnrs/hashtables.scm (hashtable-set!): Raise an assertion
  violation error when the hashtable is immutable.
* test-suite/tests/r6rs-hashtables.test: Fix accordingly.
2016-06-21 09:47:07 +02:00
Andy Wingo
beea6302e0 Fix fixnum-range changes in R6RS fixnum bitops
* module/rnrs/arithmetic/fixnums.scm (fxcopy-bit, fxbit-field)
  (fxcopy-bit-field, fxarithmetic-shift)
  (fxarithmetic-shift-left, fx-arithmetic-shift-right)
  (fxrotate-bit-field, fxreverse-bit-field): Enforce range on amount by
  which to shift.  Fixes #14917.
* test-suite/tests/r6rs-arithmetic-fixnums.test ("fxarithmetic-shift-left"):
  Update test to not shift left by a negative amount.
2016-06-21 09:32:30 +02:00
Andy Wingo
845c873acf Add another code coverage test
* test-suite/tests/coverage.test ("line-execution-counts"): Add a test
  from Taylan Ulrich B, from bug #14849.
2016-06-21 09:07:26 +02:00
Andy Wingo
fff013215f Fix peval on (call-with-values foo (lambda (x) x))
* module/language/tree-il/peval.scm (peval): Don't
  inline (call-with-values foo (lambda (x) exp)) to (let ((x (foo)))
  exp).  The idea is that call-with-values sets up an explicit context
  in which we are requesting an explicit return arity, and that dropping
  extra values when there's not a rest argument is the wrong thing.
  Fixes #13966.
* test-suite/tests/peval.test ("partial evaluation"): Update test.
2016-06-20 22:04:45 +02:00
Andy Wingo
dc7bc06f69 Fix size measurement in bytevector_large_set
* libguile/bytevectors.c (bytevector_large_set): Fix computation of
  value size in words.
* test-suite/tests/bytevectors.test: Add test.

Thanks to Ben Rocer <fleabyte@mail.com> for the bug report and fix.
2016-06-20 17:15:21 +02:00
Andy Wingo
687d393e2c Fix uri-decode behavior for "+"
* module/web/uri.scm (uri-decode): Add #:decode-plus-to-space? keyword
  argument.
  (split-and-decode-uri-path): Don't decode plus to space.
* doc/ref/web.texi (URIs): Update documentation.
* test-suite/tests/web-uri.test ("decode"): Add tests.
* NEWS: Add entry.

Based on a patch by Brent <brent@tomski.co.za>.
2016-06-20 14:48:15 +02:00
Andy Wingo
c7c11f3af9 Update port documentation, rename sports to suspendable ports
* module/ice-9/suspendable-ports.scm: Rename from ice-9/sports.scm, and
  adapt module names.  Remove exports that are not related to the
  suspendable ports facility; we want people to continue using the port
  operations from their original locations.  Add put-string to the
  replacement list.
* module/Makefile.am: Adapt to rename.
* test-suite/tests/suspendable-ports.test: Rename from sports.test.
* test-suite/Makefile.am: Adapt to rename.
* module/ice-9/textual-ports.scm (unget-char, unget-string): New
  functions.
* doc/ref/api-io.texi (Textual I/O, Simple Output): Flesh out
  documentation.
  (Line/Delimited): Undocument write-line, read-string, and
  read-string!.  This is handled by (ice-9 textual-ports).
  (Bytevector Ports): Fix duplicated section.
  (String Ports): Move the note about encodings down to the end.
  (Custom Ports): Add explanatory text.  Remove mention of C functions;
  they should use the C port interface.
  (Venerable Port Interfaces): Add text, and make documentation refer to
  recommended interfaces.
  (Using Ports from C): Add documentation.
  (Non-Blocking I/O): Document more fully and adapt to suspendable-ports
  name change.
2016-06-09 10:50:32 +02:00
Andy Wingo
c95a19376b get-bytevector-n in Scheme.
* module/ice-9/sports.scm (fill-input): Add io-mode optional arg.
  (get-bytevector-n): New implementation.
  (port-bindings): Add get-bytevector-n.
* test-suite/tests/sports.test: Add r6rs-ports tests.
2016-05-22 23:03:16 +02:00
Andy Wingo
2c95a21027 More thorough ice-9 sports testing
* module/ice-9/sports.scm: Export read-line, %read-line, and
  read-delimited.  Add these latest three to install-sports!, and fix
  install-sports! if the current module isn't (ice-9 sports).

* test-suite/tests/sports.test: Use install-sports! instead of lexical
  bindings, to allow us to nicely frob bindings in rdelim.  Include
  rdelim tests.
2016-05-22 20:40:54 +02:00
Ludovic Courtès
b9f6e89a27 http: Accept date strings with a leading space for hours.
Fixes <http://bugs.gnu.org/23421>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* module/web/http.scm (parse-rfc-822-date): Add two clauses for hours
with a leading space.
* test-suite/tests/web-http.test ("general headers"): Add two tests.
2016-05-22 20:14:34 +02:00
Ludovic Courtès
f53145d41c http: Accept empty reason phrases.
Fixes <http://bugs.gnu.org/22273>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* module/web/http.scm (read-header-line): New procedure.
(read-response-line): Use it instead of 'read-line*'.
* test-suite/tests/web-http.test ("read-response-line"): Add test.
2016-05-22 20:02:37 +02:00
Ludovic Courtès
3829047ec7 http: Test that responses lacking CR/LF are rejected.
* test-suite/tests/web-http.test ("read-response-line")["missing
CR/LF"]: New test.
2016-05-22 20:02:36 +02:00
Ludovic Courtès
2e3f6c3c67 i18n: Add new collation test for posterity.
* test-suite/tests/i18n.test ("text collation (Czech)"): New test
  prefix.
2016-05-22 19:49:44 +02:00
Ludovic Courtès
0bcf5d78ec web: Gracefully handle premature EOF when reading chunk header.
* module/web/http.scm (read-chunk-header): Return 0 when 'read-line'
  returns EOF.
2016-05-22 19:49:33 +02:00
Ludovic Courtès
d52edc05d3 web: Fix 'close' method of delimited input ports.
* module/web/response.scm (make-delimited-input-port)[close]: Replace
  erroneous self-recursive call with a call to 'close-port'.
* test-suite/tests/web-response.test ("example-1")["response-body-port +
  close"]: New test.
2016-05-22 19:48:47 +02:00
Andreas Rottmann
d77247b90b Heed the reader settings implied by #!r6rs
When encountering the #!r6rs directive, apply the appropriate reader
settings to the port.

* libguile/read.scm (read-string-as-list): New helper procedure.
  (scm_read_shebang): Set reader options implied by the R6RS syntax
  upon encountering the #!r6rs directive.
* test-suite/tests/reader.test (per-port-read-options): Add tests for
  the #!r6rs directive.
2016-05-22 19:40:37 +02:00
Mark H Weaver
aa13da5189 Fix atan procedure when applied to complex numbers.
Fixes a regression introduced in commit
ad79736c68.

* libguile/numbers.c (scm_atan): Fix the complex case.
* test-suite/tests/numbers.test ("atan"): Add test.
2016-05-22 19:29:38 +02:00
Mark H Weaver
82357f7bd8 Add more R6RS port encoding tests
Originally applied to stable-2.0 as "Fix bytevector and custom binary
ports to actually use ISO-8859-1 encoding.", commit
d574d96f87.  Related to
http://bugs.gnu.org/20200, which was introduced in in stable-2.0 but
never existed on master.  Test modified by Andy Wingo to add a
`force-output' where needed.

* test-suite/tests/r6rs-ports.test: Add tests.
2016-05-22 19:29:09 +02:00
Ludovic Courtès
70d8ef786a tests: Gracefully handle ENOSYS return for 'setaffinity'.
Fixes <http://bugs.gnu.org/19646>.
Reported by John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>.

* test-suite/tests/posix.test ("affinity")["setaffinity"]: Wrap in
  'catch' and throw 'unresolved upon ENOSYS.
2016-05-22 19:09:33 +02:00
Mark H Weaver
e390e5760b Implement 'string-utf8-length' and 'scm_c_string_utf8_length'.
* libguile/strings.c (utf8_length, scm_c_string_utf8_length)
  (scm_string_utf8_length): New functions.
* libguile/strings.h (scm_c_string_utf8_length, scm_string_utf8_length):
  New prototypes.
* doc/ref/api-data.texi (Bytevectors as Strings): Add docs.
* doc/ref/guile.texi: Update manual copyright date to 2015.
* test-suite/tests/strings.test (string-utf8-length): Add tests.
2016-05-22 19:03:37 +02:00
Ludovic Courtès
751a55e355 http: Do not buffer HTTP chunks.
Fixes <http://bugs.gnu.org/19939>.

* module/web/http.scm (read-chunk, read-chunk-body): Remove.
  (make-chunked-input-port)[next-chunk, buffer-, buffer-size,
  buffer-pointer]: Remove.
  [chunk-size, remaining]: New variables.
  [read!]: Rewrite to write directly to BV.
* test-suite/tests/web-http.test ("chunked encoding")["reads chunks
  without buffering", "reads across chunk boundaries"]: New tests.
2016-05-22 18:43:28 +02:00
Ludovic Courtès
c6d88d1234 tests: Use 'pass-if-equal' in web-http chunked encoding tests.
* test-suite/tests/web-http.test ("chunked encoding"): Use
  'pass-if-equal' where appropriate.
2016-05-22 18:40:43 +02:00
Andy Wingo
534139e458 Support for non-blocking I/O
* doc/ref/api-io.texi (I/O Extensions): Document read_wait_fd /
  write_wait_fd members.
  (Non-Blocking I/O): New section.
* libguile/fports.c (fport_read, fport_write): Return -1 if the
  operation would block.
  (fport_wait_fd, scm_make_fptob): Add read/write wait-fd
  implementation.
* libguile/ports-internal.h (scm_t_port_type): Add read_wait_fd /
  write_wait_fd.
* libguile/ports.c (default_read_wait_fd, default_write_wait_fd): New
  functions.
  (scm_make_port_type): Initialize default read/write wait fd impls.
  (trampoline_to_c_read, trampoline_to_scm_read)
  (trampoline_to_c_write, trampoline_to_scm_write): To Scheme, a return
  of #f indicates EWOULDBLOCk.
  (scm_set_port_read_wait_fd, scm_set_port_write_wait_fd): New
  functions.
  (port_read_wait_fd, port_write_wait_fd, scm_port_read_wait_fd)
  (scm_port_write_wait_fd, port_poll, scm_port_poll): New functions.
  (scm_i_read_bytes, scm_i_write_bytes): Poll if the read or write would
  block.
* libguile/ports.h (scm_set_port_read_wait_fd)
  (scm_set_port_write_wait_fd): Add declarations.
* module/ice-9/ports.scm: Shunt port-poll and port-{read,write}-wait-fd
  to the internals module.
* module/ice-9/sports.scm (current-write-waiter):
  (current-read-waiter): Implement.
* test-suite/tests/ports.test: Adapt non-blocking test to new behavior.
* NEWS: Add entry.
2016-05-20 14:57:27 +02:00
Andy Wingo
8b6f4df3f4 Fix sports.test
* test-suite/tests/sports.test (include-tests): Fix encoding when
  reading ports.test.
2016-05-18 22:11:32 +02:00
Andy Wingo
e32dcf214e Test Scheme port implementation
* module/ice-9/ports.scm: Add port-decode-char to internals export
  list.
* test-suite/Makefile.am:
* test-suite/tests/sports.test: Add new test.
2016-05-16 14:04:54 +02:00
Andy Wingo
1e058add7b U+FFFD is the input substitution character
* libguile/ports.c (UNICODE_REPLACEMENT_CHARACTER):
* libguile/ports.c (peek_utf8_codepoint)
  (scm_port_decode_char, peek_iconv_codepoint):
* module/ice-9/sports.scm (peek-char-and-len/utf8):
  (peek-char-and-len/iconv): Return U+FFFD when we get a decoding error
  when reading, instead of '?', in accordance with Unicode
  recommendations.
* test-suite/tests/iconv.test:
* test-suite/tests/ports.test:
* test-suite/tests/rdelim.test: Update tests.
* NEWS: Update.
2016-05-16 10:48:35 +02:00
Andy Wingo
1953d29038 Decoding errors do not advance read pointer
* libguile/ports.c (scm_getc): If the port conversion strategy is
  'error, signal an error before advancing the read pointer.  This is a
  change from previous behavior; before, we advanced the read pointer
  under an understanding that that was what R6RS required.  But, that
  seems to be not the case.
* test-suite/tests/ports.test ("string ports"): Update decoding-error
  tests to assume that read-char with an error doesn't advance the read
  pointer.
* test-suite/tests/rdelim.test ("read-line"): Likewise.
2016-05-10 11:36:28 +02:00
Andy Wingo
5e470ea48f Fix R6RS imports of interfaces that use interfaces
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface): In Guile, a
  module's public interface is just another module, and that means that
  it can import other modules as well.  Allow for R6RS modules that
  import module whose interfaces import other modules to access all
  visible bindings.
* test-suite/tests/rnrs-libraries.test ("import features"): Update
  test.
2016-04-14 12:35:55 +02:00
Andy Wingo
8399e7af51 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.
2016-04-06 19:21:44 +02:00