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

17820 commits

Author SHA1 Message Date
Andy Wingo
58e508b569 Type inference: Use &u64-max instead of #xffff...
* module/language/cps/types.scm: Use &u64-max where possible.
2016-06-10 07:46:57 +02:00
Andy Wingo
1a2ab83bcf Types refactor for unboxed char ranges
* module/language/cps/types.scm (*max-codepoint*): Factor codepoint
  range restrictions to use this value.
2016-06-10 07:46:24 +02:00
Andy Wingo
6788faba7a Non-blocking accept/connect Scheme support
* module/ice-9/sports.scm (accept, connect): New Scheme functions.
2016-06-09 11:00:35 +02:00
Andy Wingo
69ea1fc45b Support `connect' on nonblocking sockets
* libguile/socket.c (scm_connect):
* doc/ref/posix.texi (Network Sockets and Communication): Support
  connect on nonblocking ports.
2016-06-09 10:59:08 +02:00
Andy Wingo
e6cc051f8c `accept' on nonblocking socket can return #f
* doc/ref/posix.texi (Network Sockets and Communication):
* libguile/socket.c (scm_accept): Return #f if the socket is nonblocking
  and no connection is ready.
2016-06-09 10:59:08 +02:00
Andy Wingo
d8067213dc put-char in Scheme
* libguile/ports.c (scm_port_encode_char): New function.
* module/ice-9/ports.scm (port-encode-char): Export port-encode-char to
  the internals module.
* module/ice-9/sports.scm (put-char): New function.
  (port-bindings): Add put-char and put-string.
2016-06-09 10:59:02 +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
a21f6467ac Big ports documentation update
* doc/ref/api-io.texi: Update to document ports more thoroughly.  Still
  some work needed.

* doc/ref/r6rs.texi: Move ports documentation back to r6rs.texi, now
  that Guile has a more thorough binary/textual I/O story, heavily based
  on R6RS.

* doc/ref/api-control.texi:
* doc/ref/api-data.texi:
* doc/ref/api-options.texi:
* doc/ref/misc-modules.texi:
* doc/ref/posix.texi:
* doc/ref/srfi-modules.texi: Update references.
2016-06-08 10:19:27 +02:00
Andy Wingo
6eee08874b Undocument (ice-9 rw)
* doc/ref/api-io.texi (Block Reading and Writing): Undocument (ice-9
  rw).  The R6RS routines do the same job and are not so clunky.
2016-06-08 08:38:49 +02:00
Andy Wingo
4ed9f6c29c Add (ice-9 textual-ports)
* module/ice-9/textual-ports.scm: New module.
* module/Makefile.am: Add new module.
2016-06-08 07:44:43 +02:00
Andy Wingo
4bceba876b put-char, put-string in (ice-9 ports internals)
* libguile/ports.h (scm_put_char):
* libguile/ports.c (scm_put_char): New function.
  (scm_put_string): Add docstrings, and expose to the internal ports
  module.
* module/ice-9/ports.scm (put-char, put-string): Expose these bindings
  only through the internals module.
2016-06-08 07:44:16 +02:00
Andy Wingo
d7f39a36b1 socket: TCP_CORK, TCP_NODELAY
* libguile/socket.c (scm_init_socket): Define TCP_NODELAY and TCP_CORK
  if they are available.
* doc/ref/posix.texi (Network Sockets and Communication): Add
  documentation.
* NEWS: Add entry.
2016-06-04 12:49:47 +02:00
Andy Wingo
9454068a54 put-string in Scheme
* module/ice-9/ports.scm: Export port-encode-chars and
  port-clear-stream-start-for-bom-write via the internals module.
* module/ice-9/sports.scm (put-string): New function.
2016-06-01 12:07:30 +02:00
Andy Wingo
5bec3261b4 Rework text encoding to be more Scheme-friendly
* libguile/ports.c (scm_port_clear_stream_start_for_bom_write): Instead
  of returning the BOM, take an optional buffer in which to write the
  BOM.  Return number of bytes written.
  (port_clear_stream_start_for_bom_write): Remove.
  (scm_i_write): Adapt scm_port_clear_stream_start_for_bom_write call.
  (try_encode_char_to_iconv_buf, encode_latin1_chars_to_latin1_buf):
  (encode_latin1_chars_to_utf8_buf, encode_latin1_chars_to_iconv_buf):
  (encode_latin1_chars, encode_utf32_chars_to_latin1_buf):
  (encode_utf32_chars_to_utf8_buf, encode_utf32_chars_to_iconv_buf):
  (encode_utf32_chars, port_encode_chars): New helpers.
  (scm_port_encode_chars): New procedure.
  (scm_c_put_latin1_chars, scm_c_put_utf32_chars): Rework to use new
  encoding helpers.
  (scm_lfwrite): Use scm_c_put_latin1_chars.
2016-06-01 12:07:20 +02:00
Andy Wingo
0e888cd00b Simplify string, symbol, char display/write impls
* libguile/print.h:
* libguile/print.c: Use the new routines from ports.[ch].
2016-05-30 18:49:25 +02:00
Andy Wingo
2affb9accf Add scm_c_put_escaped_char, scm_c_can_put_char
* libguile/ports.h:
* libguile/ports.c (scm_c_put_escaped_char, scm_c_can_put_char): New
  helpers.
2016-05-30 18:48:09 +02:00
Andy Wingo
934b6dc398 iprin1 uses scm_c_put_string
* libguile/print.c (iprin1): Use scm_c_put_string for strings.
* test-suite/test-suite/lib.scm (exception:encoding-error): Add an
  additional expected error string for `encoding-error'.
2016-05-30 15:07:23 +02:00
Andy Wingo
8f615cde45 print_normal_symbol uses new port functions
* libguile/print.c (print_normal_symbol): Use new port functions.
2016-05-30 15:07:20 +02:00
Andy Wingo
43b6feeb1a Beginnings of supporting encoding text in ports.c
* libguile/ports.h (scm_c_put_latin1_chars, scm_c_put_utf32_chars)
  (scm_c_put_char, scm_c_put_string, scm_print_string): New public
  functions.  The plan is to move encoding to ports.c and out of
  print.c.
* libguile/ports.c (UTF8_BUFFER_SIZE, ESCAPE_BUFFER_SIZE): New internal
  defines.
  (update_port_position): Take a position instead of a port.  Update
  callers.
  (utf8_to_codepoint): Allow lengths that are larger than necessary.
  (port_clear_stream_start_for_bom_write): Require that io_mode be
  BOM_IO_TEXT to write a BOM.
  (scm_fill_input): Add a related comment about BOM handling.
  (scm_i_write): use BOM_IO_TEXT, at least for now.
  (encode_escape_sequence, codepoint_to_utf8, utf8_to_codepoint)
  (put_utf8_chars_to_iconv_port, put_latin1_chars_to_utf8_port)
  (put_latin1_chars_to_iconv_port, put_utf32_chars_to_latin1_port)
  (put_utf32_chars_to_utf8_port, put_utf32_chars_to_iconv_port): New
  helpers.
  (scm_putc, scm_puts): Use scm_c_put_char and scm_put_latin1_chars.
2016-05-30 15:06:38 +02:00
Andy Wingo
1123002a9e Add port-line-buffered?
* libguile/ports.c (scm_port_line_buffered_p): New function.
* module/ice-9/ports.scm: Plump port-line-buffered? and
  port-auxiliary-write-buffer through to the internals module
2016-05-25 21:56:19 +02:00
Andy Wingo
2f836e2384 port_clear_stream_start_for_bom_write refactor
* libguile/ports.c (port_clear_stream_start_for_bom_write): Rework to be
  friendly to Scheme write implementations.
2016-05-25 21:56:16 +02:00
Andy Wingo
47918f38d9 Speed up scm_c_write / scm_lfwrite
* libguile/ports-internal.h (scm_t_port): Add write_buf_aux field.
* libguile/ports.h (scm_port_auxiliary_write_buffer): New internal
  decl.
* libguile/ports.c (AUXILIARY_WRITE_BUFFER_SIZE): New constant.
  (initialize_port_buffers): Init aux write buf.
  (scm_port_auxiliary_write_buffer): Lazily allocate an aux write
  buffer.
  (scm_c_write): Arrange to write through an aux buffer if the port is
  unbuffered.
2016-05-24 22:44:48 +02:00
Andy Wingo
48dbadd8e6 Speed golf on Scheme put-u8, put-bytevector
* module/ice-9/sports.scm (put-u8, put-bytevector): Speed hack.
2016-05-24 08:37:57 +02:00
Andy Wingo
7c8b80e076 Add put-u8 implementation in Scheme
* module/ice-9/sports.scm (put-u8): Add implementation.
  (port-bindings): Add put-u8.
2016-05-24 08:27:29 +02:00
Andy Wingo
ba91741063 `put-bytevector' in Scheme
* module/ice-9/sports.scm (flush-input): New helper.
  (put-bytevector): New function.
  (port-bindings): Add put-bytevector.
2016-05-24 08:06:04 +02:00
Andy Wingo
9686b04a26 Wire up non-blocking support in sport writes
* module/ice-9/sports.scm (write-bytes): Support non-blocking writes.
  (force-output, flush-output): Rearrange placement.
2016-05-24 07:21:30 +02:00
Andy Wingo
25381bdbc0 close-port implementation in sports
* module/ice-9/sports.scm (close-port): New function.
  (port-bindings): Add close-port.
2016-05-24 07:14:26 +02:00
Andy Wingo
690b856d59 Add force-output to sports
* module/ice-9/sports.scm (force-output): New implementation.
  (port-bindings): Add force-output.
2016-05-24 07:06:45 +02:00
Andy Wingo
6bf7ec0c9c Thread-safety fixes for iconv and ports
* libguile/ports-internal.h (scm_t_port): Rework to store iconv
  descriptors inline, so that the port finalizer doesn't race with the
  iconv descriptor finalizer.  Access is serialized through a lock.
  Fixes a bug whereby if the port finalizer and the descriptor finalizer
  run on different threads, the close-port run by the port finalizer
  could try to free the iconv descriptors at the same time as the
  descriptor finalizer.
* libguile/ports.c (iconv_lock): New static variable.
  (scm_c_make_port_with_encoding): Initialize iconv-related fields.
  (scm_close_port): Lock while frobbing iconv descriptors.
  (prepare_iconv_descriptors): Adapt.
  (scm_specialize_port_encoding_x, scm_i_set_port_encoding_x): Lock
  while preparing iconv descriptors.
  (scm_port_acquire_iconv_descriptors)
  (scm_port_release_iconv_descriptors): New functions, which replace
  scm_i_port_iconv_descriptors.
  (scm_port_decode_char): Lock around iconv operations.
  (port_clear_stream_start_for_bom_write): Acquire iconv descriptors
  before checking precise_encoding, to make sure precise_encoding is
  initialized.
* libguile/print.c (display_string_using_iconv): Adapt to use the new
  interface to get iconv descriptors from a port.
2016-05-23 16:37:23 +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
4e288ec2ff Fix range checking in new Scheme-to-C port code
* libguile/ports.c (trampoline_to_c_read, trampoline_to_c_write): Fix
  bugs checking ranges of start and count parameters.
2016-05-22 22:33:46 +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
Andy Wingo
2badbd06f6 Merge from stable-2.0
This cherry-picks changes from stable-2.0, starting from
acd2c8e36a and ending in
461b62efc9, inclusively.  I did not
cherry-pick patches that were already on master and did not cherry-pick
ones that don't make sense on master (for example because of the port
re-write).  I did pick all tests though.

I also did not cherry-pick the "Revert foreign objects" patch from
ff98cbb643; further discussion necessary.
2016-05-22 20:21:49 +02:00
Luribert
a7d0a0de2f doc: Fix typo in Web documentation.
* doc/ref/web.texi (Http Headers): Fixed typo.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2016-05-22 20:14:42 +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
Mark H Weaver
140496cc00 Bump user-visible copyright years to 2016.
* doc/ref/guile.texi: Add 2016 to user-visible copyright notice.
* module/ice-9/command-line.scm (version-etc): Bump 'copyright-year' to
  2016.
* module/system/repl/common.scm (*version*): Add 2016 to the range of
  copyright years.
2016-05-22 20:02:43 +02:00
Mark H Weaver
994b7d70e6 SRFI-19: Update the table of leap seconds.
* module/srfi/srfi-19.scm (leap-second-table): Update to include the
  most recent leap second.
2016-05-22 20:02:37 +02:00
Ludovic Courtès
66bc464542 http: Use 'read-header-line' instead of 'read-line*'.
* module/web/http.scm (read-line*): Remove.
(read-continuation-line, read-header, read-request-line): Use
'read-header-line' instead of 'read-line*'.
2016-05-22 20:02:37 +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
Mark H Weaver
95d146ff51 Bump user-visible copyright years to 2015.
* module/ice-9/command-line.scm (version-etc): Bump 'copyright-year' to
  2015.

* module/system/repl/common.scm (*version*): Add 2015 to the range of
  copyright years.
2016-05-22 19:52:45 +02:00
Mark H Weaver
7d7e4bc6c0 Fix getsockopt/setsockopt handling of SO_SNDBUF/SO_RCVBUF options.
Reported by Park SungMin <byulparan_eng@icloud.com>
in <https://lists.gnu.org/archive/html/guile-user/2015-11/msg00026.html>.

* libguile/socket.c (scm_getsockopt, scm_setsockopt): Remove code that
  incorrectly assumed that the argument for SO_SNDBUF and SO_RCVBUF
  options was of type 'size_t'.  Both the Linux and POSIX documentation
  indicates that the argument is of type 'int', as is the case for most
  options.
2016-05-22 19:52:36 +02:00
Ludovic Courtès
cfd4401a2c Regenerate SRFI-14 character set data.
Suggested by Mike Gran <spk121@yahoo.com>.

* libguile/srfi-14.i.c: Regenerate for Unicode 8.0.0,
  <ftp://unicode.org/Public/UNIDATA/UnicodeData.txt> with SHA256
  38b17e1118206489a7e0ab5d29d7932212d38838df7d3ec025ecb58e8798ec20.
2016-05-22 19:51:56 +02:00
Mark H Weaver
5de910ba28 build: Add SCM_T_OFF_MAX and SCM_T_OFF_MIN to scmconfig.h.
* libguile/gen-scmconfig.c (main): Add SCM_T_OFF_MAX and SCM_T_OFF_MIN
  to the generated 'scmconfig.h' file.
2016-05-22 19:50:57 +02:00
Ludovic Courtès
a88f94ff5e doc: Mention a known-good Flex version number.
Suggested by Jamil Egdemir <unclejamil@gmail.com>.

* HACKING: Mention a Flex version number.
2016-05-22 19:50:50 +02:00
Ludovic Courtès
34428bc5df Thank David and Kouhei. 2016-05-22 19:50:44 +02:00
Ludovic Courtès
7c36145075 build: Remove libguile/mkstemp.c, redundant with Gnulib.
Fixes <http://bugs.gnu.org/21425>.
Reported by Kouhei Sutou <kou@cozmixng.org>.

* configure.ac: Remove 'AC_REPLACE_FUNCS' for 'mkstemp'.
* libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  Remove mkstemp.c.
* libguile/mkstemp.c: Remove.
2016-05-22 19:50:35 +02:00
David Michael
41f28a9b0e Remove SIGEV constant definitions.
* libguile/Makefile.am (chknew-E chknew-SIG): Anchor the end of the
  signal/error name pattern to only match alphanumeric symbols.
* libguile/cpp-SIG.syms (SIGEV_MAX_SIZE, SIGEV_NONE): Remove.
  (SIGEV_PAD_SIZE, SIGEV_SIGNAL, SIGEV_THREAD): Likewise.
  (SIGEV_THREAD_ID): Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2016-05-22 19:50:27 +02:00
David Michael
befaad0c14 Add Hurd signal and error constants.
* libguile/cpp-E.syms (EAUTH, EBACKGROUND): New definitions.
  (EBADRPC, ED, EDIED, EFTYPE, EGRATUITOUS, EGREGIOUS): Likewise.
  (EIEIO, ENEEDAUTH, EPROCLIM, EPROCUNAVAIL): Likewise.
  (EPROGMISMATCH, EPROGUNAVAIL, ERPCMISMATCH): Likewise.
* libguile/cpp-SIG.syms (SIGEMT, SIGEV_MAX_SIZE): Likewise.
  (SIGEV_PAD_SIZE, SIGINFO, SIGLOST): Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2016-05-22 19:50:20 +02:00
David Michael
cdd0dc8213 Add new Linux errno constants.
* libguile/cpp-E.syms (EHWPOISON, ERFKILL): New definitions.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2016-05-22 19:50:13 +02:00