[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 08/33: Merge from stable-2.2
From: |
Andy Wingo |
Subject: |
[Guile-commits] 08/33: Merge from stable-2.2 |
Date: |
Fri, 2 Aug 2019 09:38:26 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit c5526c4e40339e74462cc76ee246a60aceca1a63
Merge: 967f129 cc73c2a
Author: Andy Wingo <address@hidden>
Date: Fri Aug 2 15:02:11 2019 +0200
Merge from stable-2.2
doc/ref/api-io.texi | 10 ++++++++-
libguile/r6rs-ports.c | 50 ++++++++++++++++++++++++++++++++++++++-----
libguile/r6rs-ports.h | 7 ++++--
module/ice-9/binary-ports.scm | 1 +
4 files changed, 60 insertions(+), 8 deletions(-)
diff --cc libguile/r6rs-ports.c
index 255ba62,8403802..445ae54
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@@ -86,9 -79,9 +86,8 @@@ SCM_DEFINE (scm_eof_object, "eof-object
/* Input ports. */
--#ifndef MIN
--# define MIN(a,b) ((a) < (b) ? (a) : (b))
--#endif
++#define MAX(A, B) ((A) >= (B) ? (A) : (B))
++#define MIN(A, B) ((A) < (B) ? (A) : (B))
/* Bytevector input ports. */
static scm_t_port_type *bytevector_input_port_type = 0;
@@@ -521,6 -514,49 +520,49 @@@ SCM_DEFINE (scm_get_bytevector_some, "g
}
#undef FUNC_NAME
+ SCM_DEFINE (scm_get_bytevector_some_x, "get-bytevector-some!", 4, 0, 0,
+ (SCM port, SCM bv, SCM start, SCM count),
+ "Read up to @var{count} bytes from @var{port}, blocking "
+ "as necessary until at least one byte is available or an "
+ "end-of-file is reached. Store them in @var{bv} starting "
+ "at index @var{start}. Return the number of bytes actually "
+ "read, or an end-of-file object.")
+ #define FUNC_NAME s_scm_get_bytevector_some_x
+ {
+ SCM buf;
+ size_t c_start, c_count, c_len;
+ size_t cur, avail, transfer_size;
+
+ SCM_VALIDATE_BINARY_INPUT_PORT (1, port);
+ SCM_VALIDATE_BYTEVECTOR (2, bv);
+ c_start = scm_to_size_t (start);
+ c_count = scm_to_size_t (count);
+
+ c_len = SCM_BYTEVECTOR_LENGTH (bv);
+
+ if (SCM_UNLIKELY (c_len < c_start
+ || c_len - c_start < c_count))
+ scm_out_of_range (FUNC_NAME, count);
+
+ if (c_count == 0)
+ return SCM_INUM0;
+
+ buf = scm_fill_input (port, 0, &cur, &avail);
+ if (avail == 0)
+ {
+ scm_port_buffer_set_has_eof_p (buf, SCM_BOOL_F);
+ return SCM_EOF_VAL;
+ }
+
- transfer_size = min (avail, c_count);
++ transfer_size = MIN (avail, c_count);
+ scm_port_buffer_take (buf,
- (scm_t_uint8 *) SCM_BYTEVECTOR_CONTENTS (bv) +
c_start,
++ (uint8_t *) SCM_BYTEVECTOR_CONTENTS (bv) + c_start,
+ transfer_size, cur, avail);
+
+ return scm_from_size_t (transfer_size);
+ }
+ #undef FUNC_NAME
+
SCM_DEFINE (scm_get_bytevector_all, "get-bytevector-all", 1, 0, 0,
(SCM port),
"Read from @var{port}, blocking as necessary, until "
diff --cc libguile/r6rs-ports.h
index 780acf0,51dec41..56a535e
--- a/libguile/r6rs-ports.h
+++ b/libguile/r6rs-ports.h
@@@ -1,24 -1,23 +1,24 @@@
#ifndef SCM_R6RS_PORTS_H
#define SCM_R6RS_PORTS_H
- /* Copyright 2009-2011,2013,2018
-/* Copyright (C) 2009-2011, 2013, 2019 Free Software Foundation, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
++/* Copyright 2009-2011,2013,2018-2019
+ Free Software Foundation, Inc.
+
+ This file is part of Guile.
+
+ Guile is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Guile is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Guile. If not, see
+ <https://www.gnu.org/licenses/>. */
- [Guile-commits] branch master updated (cbacc77 -> 145ff63), Andy Wingo, 2019/08/02
- [Guile-commits] 01/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 02/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 03/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 06/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 07/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 09/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 04/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 08/33: Merge from stable-2.2,
Andy Wingo <=
- [Guile-commits] 10/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 12/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 05/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 13/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 15/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 14/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 19/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 16/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 20/33: Merge from stable-2.2, Andy Wingo, 2019/08/02
- [Guile-commits] 22/33: Merge from stable-2.2, Andy Wingo, 2019/08/02