euphoria
changeset 5051:90471def1f93
* fixes ticket 166
| author | Shawn Pringle <shawn.pringle@gmail.com> |
|---|---|
| date | Sat Jul 02 14:52:41 2011 -0300 (23 months ago) |
| parents | 8697fbaff8ab |
| children | 771228b27658 |
| files | docs/release/4.1.0.txt include/std/io.e |
line diff
1.1 --- a/docs/release/4.1.0.txt Fri Jul 01 10:33:53 2011 -0400 1.2 +++ b/docs/release/4.1.0.txt Sat Jul 02 14:52:41 2011 -0300 1.3 @@ -4,7 +4,6 @@ 1.4 1.5 * [[ticket:665]] Fixed to load socket routines from its DLL only when needed. 1.6 1.7 - 1.8 == Enhancements 1.9 1.10 * Euphoria can be built natively as a 64-bit programming language. 1.11 @@ -20,3 +19,5 @@ 1.12 * gcc builds now include -fPIC (position independent code) runtime libraries for translating 1.13 euphoria code into shared objects. 1.14 * -lib-pic switch for translator to specify the PIC runtime library to be used 1.15 +* [[ticket:166]] get_integer{16,32} will return -1 on EOF. 1.16 +
2.1 --- a/include/std/io.e Fri Jul 01 10:33:53 2011 -0400 2.2 +++ b/include/std/io.e Sat Jul 02 14:52:41 2011 -0300 2.3 @@ -480,11 +480,11 @@ 2.4 -- # ##fh## : an integer, the handle to an open file to read from. 2.5 -- 2.6 -- Returns: 2.7 --- An **atom**, made of the bytes that could be read from the file. 2.8 +-- An **atom**, between -1 and power(2,32)-1, made of the bytes that could be read from the file. 2.9 +-- When an end of file is encountered, it returns -1. 2.10 -- 2.11 -- Comments: 2.12 -- * This function is normally used with files opened in binary mode, "rb". 2.13 --- * Assumes that there at least four bytes available to be read. 2.14 -- 2.15 -- Example 1: 2.16 -- <eucode> 2.17 @@ -501,10 +501,18 @@ 2.18 2.19 public function get_integer32(integer fh) 2.20 -- read the 4 bytes as a single integer value at current position in file 2.21 - poke(mem0, getc(fh)) 2.22 - poke(mem1, getc(fh)) 2.23 - poke(mem2, getc(fh)) 2.24 - poke(mem3, getc(fh)) 2.25 + integer c -- a positive byte integer, 0 or -1 2.26 + c = getc(fh) 2.27 + poke(mem0, c) 2.28 + c = getc(fh) 2.29 + poke(mem1, c) 2.30 + c = getc(fh) 2.31 + poke(mem2, c) 2.32 + c = getc(fh) 2.33 + if c = -1 then 2.34 + return -1 2.35 + end if 2.36 + poke(mem3, c) 2.37 return peek4u(mem0) 2.38 end function 2.39 2.40 @@ -515,11 +523,11 @@ 2.41 -- # ##fh## : an integer, the handle to an open file to read from. 2.42 -- 2.43 -- Returns: 2.44 --- An **atom**, made of the bytes that could be read from the file. 2.45 +-- An **integer**, made of the bytes that could be read from the file. 2.46 +-- When an end of file is encountered, it returns -1. 2.47 -- 2.48 -- Comments: 2.49 -- * This function is normally used with files opened in binary mode, "rb". 2.50 --- * Assumes that there at least two bytes available to be read. 2.51 -- 2.52 -- Example 1: 2.53 -- <eucode> 2.54 @@ -536,8 +544,14 @@ 2.55 2.56 public function get_integer16(integer fh) 2.57 -- read the 2 bytes as a single integer value at current position in file 2.58 - poke(mem0, getc(fh)) 2.59 - poke(mem1, getc(fh)) 2.60 + integer c -- a positive byte integer from 0 to 255 or -1 2.61 + c = getc(fh) 2.62 + poke(mem0, c) 2.63 + c = getc(fh) 2.64 + if c = -1 then 2.65 + return -1 2.66 + end if 2.67 + poke(mem1, c) 2.68 return peek2u(mem0) 2.69 end function 2.70
