unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#31528: patch get-bytevector-n to read more than 4 GB
@ 2018-05-19 11:10 Jan Šmydke
  2018-06-18 12:05 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Šmydke @ 2018-05-19 11:10 UTC (permalink / raw)
  To: 31528


[-- Attachment #1.1: Type: text/plain, Size: 495 bytes --]

Hi,

I found

(use-modules (rnrs io ports))

(define v (call-with-input-file "EIVE01.DAT" (lambda (port)
>
  (get-bytevector-n port (* 5 1024 1024 1024)))))
>

fails due to 'out of range':

ERROR: In procedure get-bytevector-n:

ERROR: Value out of range 0 to 4294967295: 52434042880


 The "count" variable was of "unsigned" type (i.e. 32-bit) so I changed it
to "size_t" and the problem is solved.

Enclosed is the corresponding patch (using format-patch)

Jan Šmydke

[-- Attachment #1.2: Type: text/html, Size: 1329 bytes --]

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 1409 bytes --]

From 5b72b9d9c3cfa40884594eb1d403ec1d2f477d37 Mon Sep 17 00:00:00 2001
From: Jan Smydke <jan.smydke@gmail.com>
Date: Sat, 19 May 2018 12:48:01 +0200
Subject: [PATCH] get-bytevector-n and get-bytevector-n! can now read more than
 4 GB: var "count" changed from unsigned to size_t

---
 libguile/r6rs-ports.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index e944c7aab..00eea04a8 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -408,11 +408,11 @@ SCM_DEFINE (scm_get_bytevector_n, "get-bytevector-n", 2, 0, 0,
 #define FUNC_NAME s_scm_get_bytevector_n
 {
   SCM result;
-  unsigned c_count;
+  size_t c_count;
   size_t c_read;
 
   SCM_VALIDATE_BINARY_INPUT_PORT (1, port);
-  c_count = scm_to_uint (count);
+  c_count = scm_to_size_t (count);
 
   result = scm_c_make_bytevector (c_count);
 
@@ -444,13 +444,13 @@ SCM_DEFINE (scm_get_bytevector_n_x, "get-bytevector-n!", 4, 0, 0,
 #define FUNC_NAME s_scm_get_bytevector_n_x
 {
   SCM result;
-  unsigned c_start, c_count, c_len;
+  size_t c_start, c_count, c_len;
   size_t c_read;
 
   SCM_VALIDATE_BINARY_INPUT_PORT (1, port);
   SCM_VALIDATE_BYTEVECTOR (2, bv);
-  c_start = scm_to_uint (start);
-  c_count = scm_to_uint (count);
+  c_start = scm_to_size_t (start);
+  c_count = scm_to_size_t (count);
 
   c_len = SCM_BYTEVECTOR_LENGTH (bv);
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#31528: patch get-bytevector-n to read more than 4 GB
  2018-05-19 11:10 bug#31528: patch get-bytevector-n to read more than 4 GB Jan Šmydke
@ 2018-06-18 12:05 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2018-06-18 12:05 UTC (permalink / raw)
  To: Jan Šmydke; +Cc: 31528-done

Hello Jan,

Jan Šmydke <jan.smydke@gmail.com> skribis:

>  The "count" variable was of "unsigned" type (i.e. 32-bit) so I changed it
> to "size_t" and the problem is solved.
>
> Enclosed is the corresponding patch (using format-patch)
>
> Jan Šmydke
> From 5b72b9d9c3cfa40884594eb1d403ec1d2f477d37 Mon Sep 17 00:00:00 2001
> From: Jan Smydke <jan.smydke@gmail.com>
> Date: Sat, 19 May 2018 12:48:01 +0200
> Subject: [PATCH] get-bytevector-n and get-bytevector-n! can now read more than
>  4 GB: var "count" changed from unsigned to size_t
>
> ---
>  libguile/r6rs-ports.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Awesome.  I adjusted the commit log to match our conventions and
committed.

Thank you!

Ludo’.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-18 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-19 11:10 bug#31528: patch get-bytevector-n to read more than 4 GB Jan Šmydke
2018-06-18 12:05 ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).