Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
e5192377
Commit
e5192377
authored
Apr 28, 2020
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `IO#sysread` to update buffer string on `EOF`; ref #4982
parent
46857811
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
18 deletions
+10
-18
mrbgems/mruby-io/src/io.c
mrbgems/mruby-io/src/io.c
+10
-18
No files found.
mrbgems/mruby-io/src/io.c
View file @
e5192377
...
@@ -927,7 +927,8 @@ mrb_io_sysread_common(mrb_state *mrb,
...
@@ -927,7 +927,8 @@ mrb_io_sysread_common(mrb_state *mrb,
if
(
RSTRING_LEN
(
buf
)
!=
maxlen
)
{
if
(
RSTRING_LEN
(
buf
)
!=
maxlen
)
{
buf
=
mrb_str_resize
(
mrb
,
buf
,
maxlen
);
buf
=
mrb_str_resize
(
mrb
,
buf
,
maxlen
);
}
else
{
}
else
{
mrb_str_modify
(
mrb
,
RSTRING
(
buf
));
mrb_str_modify
(
mrb
,
RSTRING
(
buf
));
}
}
...
@@ -936,24 +937,15 @@ mrb_io_sysread_common(mrb_state *mrb,
...
@@ -936,24 +937,15 @@ mrb_io_sysread_common(mrb_state *mrb,
mrb_raise
(
mrb
,
E_IO_ERROR
,
"not opened for reading"
);
mrb_raise
(
mrb
,
E_IO_ERROR
,
"not opened for reading"
);
}
}
ret
=
readfunc
(
fptr
->
fd
,
RSTRING_PTR
(
buf
),
(
fsize_t
)
maxlen
,
offset
);
ret
=
readfunc
(
fptr
->
fd
,
RSTRING_PTR
(
buf
),
(
fsize_t
)
maxlen
,
offset
);
switch
(
ret
)
{
if
(
ret
<
0
)
{
case
0
:
/* EOF */
mrb_sys_fail
(
mrb
,
"sysread failed"
);
if
(
maxlen
==
0
)
{
}
buf
=
mrb_str_new_cstr
(
mrb
,
""
);
if
(
RSTRING_LEN
(
buf
)
!=
ret
)
{
}
else
{
buf
=
mrb_str_resize
(
mrb
,
buf
,
ret
);
mrb_raise
(
mrb
,
E_EOF_ERROR
,
"sysread failed: End of File"
);
}
}
if
(
ret
==
0
&&
maxlen
>
0
)
{
break
;
mrb_raise
(
mrb
,
E_EOF_ERROR
,
"sysread failed: End of File"
);
case
-
1
:
/* Error */
mrb_sys_fail
(
mrb
,
"sysread failed"
);
break
;
default:
if
(
RSTRING_LEN
(
buf
)
!=
ret
)
{
buf
=
mrb_str_resize
(
mrb
,
buf
,
ret
);
}
break
;
}
}
return
buf
;
return
buf
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment