Fixed WGI_INPUT_STREAM read_to_string and append_to_string
This commit is contained in:
@@ -11,6 +11,9 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
WGI_INPUT_STREAM
|
WGI_INPUT_STREAM
|
||||||
|
|
||||||
|
inherit
|
||||||
|
STRING_HANDLER
|
||||||
|
|
||||||
feature -- Input
|
feature -- Input
|
||||||
|
|
||||||
read_character
|
read_character
|
||||||
@@ -48,7 +51,7 @@ feature -- Input
|
|||||||
a_string_not_void: a_string /= Void
|
a_string_not_void: a_string /= Void
|
||||||
valid_position: a_string.valid_index (pos)
|
valid_position: a_string.valid_index (pos)
|
||||||
nb_large_enough: nb > 0
|
nb_large_enough: nb > 0
|
||||||
nb_small_enough: nb <= a_string.count - pos + 1
|
nb_small_enough: nb <= a_string.capacity - pos + 1
|
||||||
local
|
local
|
||||||
i, end_pos: INTEGER
|
i, end_pos: INTEGER
|
||||||
do
|
do
|
||||||
@@ -59,16 +62,21 @@ feature -- Input
|
|||||||
i > end_pos
|
i > end_pos
|
||||||
loop
|
loop
|
||||||
read_character
|
read_character
|
||||||
if not end_of_input then
|
a_string.put (last_character, i)
|
||||||
a_string.put (last_character, i)
|
|
||||||
i := i + 1
|
if end_of_input then
|
||||||
else
|
Result := i
|
||||||
Result := i - pos - nb
|
|
||||||
-- Jump out of the loop.
|
-- Jump out of the loop.
|
||||||
i := end_pos + 1
|
i := end_pos + 1
|
||||||
|
else
|
||||||
|
i := i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Result := Result + i - pos
|
if not end_of_input then
|
||||||
|
Result := i
|
||||||
|
end
|
||||||
|
a_string.set_count (Result)
|
||||||
|
Result := Result - pos + 1
|
||||||
ensure
|
ensure
|
||||||
nb_char_read_large_enough: Result >= 0
|
nb_char_read_large_enough: Result >= 0
|
||||||
nb_char_read_small_enough: Result <= nb
|
nb_char_read_small_enough: Result <= nb
|
||||||
@@ -99,16 +107,16 @@ feature -- Input
|
|||||||
i > end_pos
|
i > end_pos
|
||||||
loop
|
loop
|
||||||
read_character
|
read_character
|
||||||
if not end_of_input then
|
a_string.extend (last_character)
|
||||||
a_string.extend (last_character)
|
l_count := l_count + 1
|
||||||
i := i + 1
|
if end_of_input then
|
||||||
else
|
|
||||||
l_count := i - nb
|
|
||||||
-- Jump out of the loop.
|
-- Jump out of the loop.
|
||||||
i := end_pos + 1
|
i := end_pos + 1
|
||||||
|
else
|
||||||
|
i := i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
last_appended_count := l_count + i
|
last_appended_count := l_count
|
||||||
ensure
|
ensure
|
||||||
nb_char_read_large_enough: last_appended_count >= 0
|
nb_char_read_large_enough: last_appended_count >= 0
|
||||||
nb_char_read_small_enough: last_appended_count <= nb
|
nb_char_read_small_enough: last_appended_count <= nb
|
||||||
|
|||||||
Reference in New Issue
Block a user