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
78fe65ae
Commit
78fe65ae
authored
Oct 20, 2015
by
Tomoyuki Sahara
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:iij/mruby-io
parents
5fa3c391
71197d27
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
2 deletions
+30
-2
mrblib/io.rb
mrblib/io.rb
+9
-0
run_test.rb
run_test.rb
+1
-0
src/io.c
src/io.c
+1
-2
test/io.rb
test/io.rb
+19
-0
No files found.
mrblib/io.rb
View file @
78fe65ae
...
@@ -108,6 +108,11 @@ class IO
...
@@ -108,6 +108,11 @@ class IO
raise
IOError
raise
IOError
end
end
def
<<
(
str
)
write
(
str
)
self
end
def
eof?
def
eof?
return
true
if
@buf
&&
@buf
.
size
>
0
return
true
if
@buf
&&
@buf
.
size
>
0
...
@@ -136,6 +141,10 @@ class IO
...
@@ -136,6 +141,10 @@ class IO
seek
(
i
,
SEEK_SET
)
seek
(
i
,
SEEK_SET
)
end
end
def
rewind
seek
(
0
,
SEEK_SET
)
end
def
seek
(
i
,
whence
=
SEEK_SET
)
def
seek
(
i
,
whence
=
SEEK_SET
)
raise
IOError
if
closed?
raise
IOError
if
closed?
@pos
=
sysseek
(
i
,
whence
)
@pos
=
sysseek
(
i
,
whence
)
...
...
run_test.rb
View file @
78fe65ae
...
@@ -20,6 +20,7 @@ MRuby::Build.new do |conf|
...
@@ -20,6 +20,7 @@ MRuby::Build.new do |conf|
conf
.
gembox
'default'
conf
.
gembox
'default'
conf
.
gem
:git
=>
'https://github.com/iij/mruby-env.git'
conf
.
gem
:git
=>
'https://github.com/iij/mruby-env.git'
conf
.
enable_test
conf
.
gem
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
conf
.
gem
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
end
end
src/io.c
View file @
78fe65ae
...
@@ -525,8 +525,7 @@ mrb_value
...
@@ -525,8 +525,7 @@ mrb_value
mrb_io_sysseek
(
mrb_state
*
mrb
,
mrb_value
io
)
mrb_io_sysseek
(
mrb_state
*
mrb
,
mrb_value
io
)
{
{
struct
mrb_io
*
fptr
;
struct
mrb_io
*
fptr
;
int
pos
;
mrb_int
pos
,
offset
,
whence
=
-
1
;
mrb_int
offset
,
whence
=
-
1
;
mrb_get_args
(
mrb
,
"i|i"
,
&
offset
,
&
whence
);
mrb_get_args
(
mrb
,
"i|i"
,
&
offset
,
&
whence
);
if
(
whence
<
0
)
{
if
(
whence
<
0
)
{
...
...
test/io.rb
View file @
78fe65ae
...
@@ -150,6 +150,14 @@ assert('IO#write', '15.2.20.5.20') do
...
@@ -150,6 +150,14 @@ assert('IO#write', '15.2.20.5.20') do
true
true
end
end
assert
(
'IO#<<'
)
do
io
=
IO
.
open
(
IO
.
sysopen
(
$mrbtest_io_wfname
))
io
<<
""
<<
""
assert_equal
0
,
io
.
pos
io
.
close
true
end
assert
(
'IO.for_fd'
)
do
assert
(
'IO.for_fd'
)
do
fd
=
IO
.
sysopen
(
$mrbtest_io_rfname
)
fd
=
IO
.
sysopen
(
$mrbtest_io_rfname
)
io
=
IO
.
for_fd
(
fd
)
io
=
IO
.
for_fd
(
fd
)
...
@@ -248,6 +256,17 @@ assert('IO#pos=, IO#seek') do
...
@@ -248,6 +256,17 @@ assert('IO#pos=, IO#seek') do
io
.
closed?
io
.
closed?
end
end
assert
(
'IO#rewind'
)
do
fd
=
IO
.
sysopen
$mrbtest_io_rfname
io
=
IO
.
new
fd
assert_equal
'm'
,
io
.
getc
assert_equal
1
,
io
.
pos
assert_equal
0
,
io
.
rewind
assert_equal
0
,
io
.
pos
io
.
close
io
.
closed?
end
assert
(
'IO#gets'
)
do
assert
(
'IO#gets'
)
do
fd
=
IO
.
sysopen
$mrbtest_io_rfname
fd
=
IO
.
sysopen
$mrbtest_io_rfname
io
=
IO
.
new
fd
io
=
IO
.
new
fd
...
...
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