summaryrefslogtreecommitdiff
blob: 8f5b02ee90847accc061b2bab60ce51a3cc85e39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
https://sourceforge.net/p/polyml/code/1875/
Required for sci-mathematics/isabelle-2013.2

------------------------------------------------------------------------
r1875 | dcjm | 2013-10-30 10:49:05 -0600 (Wed, 30 Oct 2013) | 1 line

Backport commit 1874 from trunk.  This fixes TextIO.inputN and StreamIO.inputN so they return immediately if the request is for zero characters.
Index: polyml/basis/BasicStreamIO.sml
===================================================================
--- polyml/basis/BasicStreamIO.sml	(revision 1851)
+++ polyml/basis/BasicStreamIO.sml	(working copy)
@@ -213,6 +213,8 @@
         fun inputN (f, n) =
         if n < 0
         then raise Size
+        else if n = 0 (* Defined to return the empty vector and f *)
+        then (emptyVec, f)
         else
         let
             val (vecs, f') = inputNList (f, n)
Index: polyml/basis/TextIO.sml
===================================================================
--- polyml/basis/TextIO.sml	(revision 1851)
+++ polyml/basis/TextIO.sml	(working copy)
@@ -597,6 +597,8 @@
         |   inputN' n (ref(Direct(strm as {buffer, bufp, buflimit, ...}))) =
             if n < 0 orelse n > CharVector.maxLen
             then raise Size
+            else if n = 0
+            then "" (* Return the empty string without blocking *)
             else if !buflimit = 0
             then (* Last read returned end-of-file.  Clear the EOF state once
                     we return this empty string. *)